[blazegraph] blazegraph 설치와 대용량 데이터 넣기

솜솜·2022년 11월 4일
0

Blazegraph

RDF, Turtle 등 트리플 형식의 데이터를 저장하고 탐색하는 오픈소스 데이터베이스이다.
데이터를 업로드하고, Endpoint를 사용해 SPARQL 쿼리로 데이터를 탐색할 수 있다.

blazegraph 공식 홈페이지

1. 설치

Release Blazegraph 2.1.6 Release Candidate · blazegraph/database

blazegraph 깃헙 페이지에서 다운로드 가능

  • bigdata.jar 또는 blazegraph.jar 다운로드 하여 커맨드를 통해 실행

2. 사용방법

Quick_Start · blazegraph/database Wiki

cd [blazegraph.jar가 존재하는 폴더]

java -server -Xmx16g -jar blazegraph.jar (or bigdata.jar)

-Xmx 옵션은 'set maximum Java heap size' (메모리) 힙사이즈의 최대를 결정해주는 옵션, 큰데이터를 올릴수록 크게 숫자설정이 필요함. 참고:https://sosal.kr/883

  • 다운받은 파일이 있는 경로에서 명령어 입력하면 로컬호스트:8888 로 blazegraph가 열리고, 주소를 복사해서 브라우저에 입력

2.1 업로드

UPDATE 탭에 직접 업로드하거나, 파일경로를 입력할 수 있음.

주의! 대략 100메가 이상의 데이터는 직접 업로드 불가

  • Bulkdata 업로드 방법

Bulk_Data_Load · blazegraph/database Wiki

→ 공식 홈페이지 안내 : 문제는 .properties를 처음 접함

Loading triples into Blazegraph using the bulk data loader

fastload.properties from the Blazegraph samples on GitHub, 에서 .properties 파일을 만들고 blazegraph.jar 파일이 있는 폴더에 저장함.

~~~.file = blazegraph.jnl 추가해주어야함.

.properties 파일이란? → https://docu94.tistory.com/130

fastload.properies 예시

# This configuration turns off incremental inference for load and retract, so
# you must explicitly force these operations if you want to compute the closure
# of the knowledge base.  Forcing the closure requires punching through the SAIL
# layer.  Of course, if you are not using inference then this configuration is
# just the ticket and is quite fast.

# set the initial and maximum extent of the journal
com.bigdata.journal.AbstractJournal.initialExtent=209715200
com.bigdata.journal.AbstractJournal.maximumExtent=209715200
com.bigdata.journal.AbstractJournal.file=blazegraph.jnl
# turn off automatic inference in the SAIL
com.bigdata.rdf.sail.truthMaintenance=false

# don't store justification chains, meaning retraction requires full manual 
# re-closure of the database
com.bigdata.rdf.store.AbstractTripleStore.justify=false

# turn off the statement identifiers feature for provenance
com.bigdata.rdf.store.AbstractTripleStore.statementIdentifiers=false

# turn off the free text index
com.bigdata.rdf.store.AbstractTripleStore.textIndex=false

# RWStore (scalable single machine backend)
com.bigdata.journal.AbstractJournal.bufferMode=DiskRW

fastload.properties에 있는 함수는 여기를 참고하면 더 다양한 기능을 사용할 수 있을 것으로 예상함.

fastload.properties

https://blazegraph.com/database/apidocs/index.html
https://blazegraph.com/database/apidocs/com/bigdata/journal/AbstractJournal.html

Error when loading a bulk .zip containing database · Issue #43 · blazegraph/database

→ 이분과 마찬가지로 .zip으로 넣으면 statement수가 나오지 않음. 즉 오류 발생.
→ .ttl을 직접 넣어주니 성공함.

벌크 데이터 최종 코드

❗❗ 주의: fastload.properties 실행 시, 반드시 blazegraph 끄고 실행할 것! ❗❗

java -cp blazegraph.jar com.bigdata.rdf.store.DataLoader -namespace [네임스페이스명] fastload.properties [파일경로 또는 폴더경로]
  • 네임스페이스는 저장하고자하는 네임스페이스를 입력.
  • .properties 파일은 blazegraph.jar가 있는 폴더에 저장.
  • blazegraph를 실행하면 blazegraph.jnl 파일이 생김.
    • jnl 파일이란? ...아래 페이지를 참고하면 되지만 여기서 이해하기론 코드를 통해서 올리는 파일과 네임스페이스 등등의 이력이 저장되는 것으로 생각함.

profile
매번 잊어버리는 것들을 기록합니다.

0개의 댓글