我正在使用Tinkerpop Blueprints为具有16GB内存,64位Ubuntu,64位jvm的笔记本电脑上的数百万个节点和100M边缘的数据集创建OrientDB图。
以下是我们的基准测试结果 - 顶点得到了很好的添加,但每个边缘添加都需要几秒钟。
你能否建议我们对边缘创建做得不对,以及如何让它改进到更合理的延迟?
这里是与上表相关的代码:
package orientdbtest
import com.orientechnologies.orient.core.metadata.schema.OType
import com.tinkerpop.blueprints.{Direction, Edge, Vertex}
import com.tinkerpop.blueprints.impls.orient._
import com.orientechnologies.orient.core.intent.OIntentMassiveInsert
object Example {
def addRandomVertex(graph: OrientGraphNoTx, uuid: String) : Vertex = graph.addVertex("class:Random", "uuid", uuid)
def addRandomEdge(source: Vertex, target: Vertex, id: String) = graph.addEdge(null, source, target, id)
def createRandomNetworkDatabase(graph: OrientGraphNoTx, numNodes: Int, numEdges: Int, useLightWeightEdges: Boolean):(Long, Long) = {
if (graph.getVertexType("Random") == null) {
println("Creating random type")
val random_vertex_type: OrientVertexType = graph.createVertexType("Random")
random_vertex_type.createProperty("id", OType.STRING)
} else {
println("Random type exists")
}
val timeStartNodeCreation = System.currentTimeMillis()
val nodeList: List[Vertex] = Range(0,numNodes).toList.map(x => addRandomVertex(graph, x.toString()))
val timeEndNodeCreation = System.currentTimeMillis()
println("Time to create " + numNodes + " is " + (timeEndNodeCreation-timeStartNodeCreation))
val nodeListFirstHalf = nodeList.slice(0,nodeList.length/2)
val nodeListSecondHalf = nodeList.slice(nodeList.length/2+1,nodeList.length)
var edgeID = 1
if(useLightWeightEdges) graph.setUseLightweightEdges(true)
val timeStartEdgeCreation = System.currentTimeMillis()
// createEdges from first half to the second half
nodeListFirstHalf.foreach(sourceVertex => {
nodeListSecondHalf.foreach(targetVertex => {
while(edgeID < numEdges)
{
addRandomEdge(sourceVertex, targetVertex, edgeID.toString())
edgeID = edgeID +1
graph.commit()
}
})
})
val timeEndEdgeCreation = System.currentTimeMillis()
println("Time to create " + edgeID + " is " + (timeEndEdgeCreation-timeStartEdgeCreation))
(0L, 0L)
}
def main(args: Array[String]): Unit = {
val numNodes = 10
val numEdges = 25
val useLightWeightEdges = false
val uri: String = "plocal:target/database/random_sample_" + numNodes + "_" + numEdges + useLightWeightEdges.toString()
val graph: OrientGraphNoTx = new OrientGraphNoTx(uri)
graph.setKeepInMemoryReferences(false);
graph.getRawGraph().getLocalCache().setEnable(false)
graph.declareIntent(new OIntentMassiveInsert())
try {
createRandomNetworkDatabase(graph, numNodes, numEdges, useLightWeightEdges)
graph.declareIntent(null)
} finally {
graph.shutdown()
}
println("Adios")
}
}