OrientDB:如何加速从Blueprint Java API导入?

OrientDB:如何加速从Blueprint Java API导入?,orientdb,tinkerpop-blueprint,Orientdb,Tinkerpop Blueprint,通过使用Blueprint Java API,我在OrientDB中的数据接收速度非常慢。 具体地说,我使用plocal模式和OrientGraphNoTx类从几个CSV文件中加载~1M个节点和3M个边(不幸的是,我无法使用ETL,因为它不允许我读取包含现有节点之间边的文件)。 代码是用Scala编写的,运行大约一个半小时 数据库的模式包含5个顶点类、7个边类和6个索引。我用来创建边的属性通过使用unique\u hash\u indexes进行索引。 在现有节点之间创建边是最耗时的操作(可能是

通过使用Blueprint Java API,我在OrientDB中的数据接收速度非常慢。 具体地说,我使用
plocal
模式和
OrientGraphNoTx
类从几个CSV文件中加载~1M个节点和3M个边(不幸的是,我无法使用ETL,因为它不允许我读取包含现有节点之间边的文件)。 代码是用Scala编写的,运行大约一个半小时

数据库的模式包含5个顶点类、7个边类和6个索引。我用来创建边的属性通过使用
unique\u hash\u index
es进行索引。 在现有节点之间创建边是最耗时的操作(可能是因为有许多边),下面是我使用的代码。 有人知道如何优化它吗

/**
 * Adds edges to the graph.
 * Assumes edgesPath points to a CSV file with format (from, to)
 */
def addEdges(edgesPath: String,
             fromTable: String, fromAttribute: String,
             toTable: String, toAttribute: String,
             edgeType: String, graph: OrientGraphNoTx) {

  logger.info(s"Adding edges from '$edgesPath'...")
  val in = Files.newBufferedReader(Paths.get(edgesPath), Charset.forName("utf-8"))
  val records = CSVFormat.DEFAULT
    .withHeader("from", "to")
    .withSkipHeaderRecord(hasHeader)
    .parse(in)
  var errors = 0
  for (r <- records) {
    val (src, target) = (r.get("from"), r.get("to"))
    if (src != "" && target != "") {
      try {
        graph.command(new OCommandSQL(s"CREATE EDGE $edgeType FROM (" +
          s"SELECT FROM $fromTable WHERE $fromAttribute = '$src') " +
          s"TO (SELECT FROM $toTable WHERE $toAttribute ='$target')")).execute()
      } catch {
        case e: OCommandExecutionException => errors += 1
      }
    } //if
  } //for
  if(errors > 0)
    logger.warn(s"Couldn't create $errors edges due to missing sources/targets or internal errors")
  logger.info("done.")
} //addEdges
/**
*将边添加到图形中。
*假设EdgePath指向格式为(从、到)的CSV文件
*/
def addEdges(edgesPath:String,
fromTable:String,fromAttribute:String,
toTable:String,toAttribute:String,
edgeType:String,graph:OrientGraphNoTx){
logger.info(s“从“$EdgePath”…”添加边)
val in=Files.newBufferedErader(path.get(edgePath)、Charset.forName(“utf-8”))
val记录=CSVFormat.DEFAULT
.withHeader(“from”、“to”)
.withSkipHeaderRecord(HashHeader)
.parse(in)
var错误=0
对于(r错误+=1)
}
}//如果
}//为了
如果(错误>0)
logger.warn(s“由于缺少源/目标或内部错误,无法创建$errors边缘”)
logger.info(“完成”)
}//增补

如果您在plocal中工作,并且需要一次批量导入 尝试为您的进口商禁用WAL

OGlobalConfiguration.USE_WAL.setValue(false);

谢谢您的建议;它现在正在运行。我会让您知道的。不幸的是,执行时间几乎没有改进:(