그래프 데이터베이스 (Titan)와 잘 작동하는 응용 프로그램을 개발하고 있습니다 (단, 많은 가장자리의 정점에 문제가있는 경우는 제외) (예 : supernodes).Titan의 "Supernodes"
위의 슈퍼 노드 링크는 Titan 작성자의 블로그 게시물을 가리키며 문제를 해결하는 방법을 설명합니다. 해결책은 모서리를 필터링하여 정점 수를 줄이는 것 같습니다.
불행히도 groupCount
가장자리 또는 정점의 속성을 원합니다. 예를 들어 나는 1 백만 명의 사용자를 보유하고 있으며 각 사용자는 한 국가에 속해 있습니다. groupCount
을 빨리 수행하여 각 국가의 사용자 수를 산출 할 수 있습니까?
지금까지이 정교한 그루비 스크립트에 표시 할 수 있습니다 해봤 무엇 : 많은 연결, (타이탄에 "모든"노드 조회를 가지고 있지를 위해)
g = TitanFactory.open('titan.properties') // Cassandra
r = new Random(100)
people = 1e6
def newKey(g, name, type) {
return g
.makeType()
.name(name)
.simple()
.functional()
.indexed()
.dataType(type)
.makePropertyKey()
}
def newLabel(g, name, key) {
return g
.makeType()
.name(name)
.primaryKey(key)
.makeEdgeLabel()
}
country = newKey(g, 'country', String.class)
newLabel(g, 'lives', country)
g.stopTransaction(SUCCESS)
root = g.addVertex()
countries = ['AU', 'US', 'CN', 'NZ', 'UK', 'PL', 'RU', 'NL', 'FR', 'SP', 'IT']
(1..people).each {
country = countries[(r.nextFloat() * countries.size()).toInteger()]
g.startTransaction()
person = g.addVertex([name: 'John the #' + it])
g.addEdge(g.getVertex(root.id), person, 'lives', [country: country])
g.stopTransaction(SUCCESS)
}
t0 = new Date().time
m = [:]
root = g.getVertex(root.id)
root.outE('lives').country.groupCount(m).iterate()
t1 = new Date().time
println "groupCount seconds: " + ((t1 - t0)/1000)
기본적으로 하나 개의 루트 노드 country
속성을 가진 가장자리를 통해 person
. 1 백만 개의 꼭지점에서 groupCount()를 실행하면 1 분 이상 소요됩니다.
타이탄은 아마도 각 가장자리를 반복하고 카운트를 수집하고 있음을 알고 있습니다. 그러나 타이탄이나 다른 그래프 데이터베이스에서 타이탄을 더 빨리 실행할 수있는 방법이 있습니까? 트래버스 할 필요가 없도록 인덱스 자체를 계산할 수 있습니까? 내 색인이 맞습니까?