콘텐츠로 이동
Graph 문서0.5

bluetape4k-graph-core

최신 안정판 Graph 0.5.1 릴리스 기준

실행 방식: 메모리에서 바로 실행한다. bluetape4k-graph-tinkerpop은 실행 가능한 GraphOperations를 제공한다. core API만 쓰는 모듈은 배포 환경에 맞는 실제 그래프 모듈을 선택해야 한다.

core는 GraphVertex, GraphEdge, GraphPath, 동기·virtual thread·coroutine 저장소, merge, schema DSL, 트랜잭션 scope, 공통 알고리즘을 정의한다. 공통 API로 애플리케이션을 작성하거나 새 그래프 구현을 만들 때 선택한다. 저장 엔진이 필요하면 core만 넣지 말고 실제 그래프 모듈을 고른다.

근거 API는 GraphOperations.ktGraphTraversalRepository.kt다.

dependencies {
implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<ecosystem-version>"))
implementation("io.github.bluetape4k:bluetape4k-graph-core")
implementation("io.github.bluetape4k:bluetape4k-graph-tinkerpop") // executable implementation
}

실행 가능한 최소 예제에는 TinkerGraph 구현을 함께 쓴다.

import io.bluetape4k.graph.model.NeighborOptions
import io.bluetape4k.graph.tinkerpop.TinkerGraphOperations
TinkerGraphOperations().use { ops ->
val alice = ops.createVertex("Person", mapOf("email" to "a@example.com"))
val bob = ops.mergeVertex("Person", mapOf("email" to "b@example.com"), mapOf("name" to "Bob"))
ops.createEdge(alice.id, bob.id, "KNOWS")
check(ops.neighbors(alice.id, NeighborOptions(edgeLabel = "KNOWS")).single().id == bob.id)
}

예상 결과는 정점 2개, 방향 간선 1개, Alice의 이웃 1개다.

공통 진입점은 session, vertex, edge, traversal 저장소를 묶는다. transaction { }은 구현체가 GraphTransactionalOperations를 제공할 때만 동작한다. 지원하지 않는 기능을 원자적인 것처럼 흉내 내지 않는다. GraphElementId는 불투명 값이므로 숫자나 문자열 구조를 해석하지 않는다.

core는 서버 자원을 소유하지 않는다. 연산 객체, Driver, DataSource의 종료 책임은 실제 구현과 연동 계층 설정이 정한다.

  • GraphElementId를 불투명 값으로 다룬다.
  • 테스트 결과에 실제 그래프 구현을 함께 기록한다.
  • 선택 기능 전에 트랜잭션과 schema 지원 여부를 확인한다.
  • 탐색 깊이와 batch 크기에 상한을 둔다.

증상: 확장 함수가 지원하지 않는 기능이라는 예외를 던진다. 필요한 interface를 제공하는 구현을 선택하거나 호출을 제거하고, 성공처럼 처리하지 않는다.

Terminal window
./gradlew :bluetape4k-graph-core:test --tests '*GraphMergeOperationsTest' --tests '*GraphTransactionExtensionsTest'

예상 결과는 merge helper와 트랜잭션 capability 검사가 통과하는 것이다. 특정 그래프 모듈만 실패하면 그 구현의 query 변환과 트랜잭션 경계를 확인한다. traversal 비용과 native 알고리즘 지원 여부도 구현마다 다르다.

고정된 TinkerGraphOperationsTest가 실제로 실행되는 release 근거다. 다음 명령으로 확인한다.

Terminal window
./gradlew :bluetape4k-graph-tinkerpop:test --tests '*TinkerGraphOperationsTest'

예상 결과는 위 자원 소유권과 기능 경계를 검증하면서 release 테스트 또는 build가 끝나는 것이다.

core model, 짝을 이루는 API, schema와 트랜잭션을 참고한다. core는 모든 그래프 제품의 기능을 하나로 합치거나 데이터베이스를 설치하지 않는다.

아래 그림은 0.5.1 배포본의 README 자산을 해당 배포 커밋에서 직접 불러옵니다. 이후 SNAPSHOT이 아니라 이 매뉴얼 버전의 구조와 실행 흐름을 보여 줍니다. 미리보기를 누르면 같은 배포 커밋의 SVG 원본이 열립니다.

Bluetape4k Graph core 아키텍처

배포본 README: graph/graph-core/README.ko.md

GraphPath 다이어그램

배포본 README: graph/graph-core/README.ko.md

GraphOperations 다이어그램

배포본 README: graph/graph-core/README.ko.md

DSL 다이어그램

배포본 README: graph/graph-core/README.ko.md

CRUD 다이어그램

배포본 README: graph/graph-core/README.ko.md

Bluetape4k Graph core 아키텍처 14 다이어그램

섹션 제목: “Bluetape4k Graph core 아키텍처 14 다이어그램”

Bluetape4k Graph core 아키텍처 14 다이어그램

배포본 README: graph/graph-core/README.ko.md

: GraphElementId, GraphVertex, GraphEdge 다이어그램

섹션 제목: “: GraphElementId, GraphVertex, GraphEdge 다이어그램”

: GraphElementId, GraphVertex, GraphEdge 다이어그램

배포본 README: graph/graph-core/README.ko.md

PathStep GraphPath 다이어그램

배포본 README: graph/graph-core/README.ko.md

Repository 다이어그램

배포본 README: graph/graph-core/README.ko.md

DSL 다이어그램

배포본 README: graph/graph-core/README.ko.md

createVertex 다이어그램

배포본 README: graph/graph-core/README.ko.md

shortestPath 다이어그램

배포본 README: graph/graph-core/README.ko.md

neighbors 다이어그램

배포본 README: graph/graph-core/README.ko.md

createEdge 다이어그램

배포본 README: graph/graph-core/README.ko.md