Skip to content

Instantly share code, notes, and snippets.

@NhuanTDBK
Last active August 1, 2018 05:08
Show Gist options
  • Save NhuanTDBK/8b907111770bc6c4749f192eee0fdfdc to your computer and use it in GitHub Desktop.
Save NhuanTDBK/8b907111770bc6c4749f192eee0fdfdc to your computer and use it in GitHub Desktop.
val configJanus = new PropertiesConfiguration(configJanusPath)
val graph = JanusGraphFactory.open(configJanus)
// create schema
val tx = graph.buildTransaction().enableBatchLoading().start()
while (iter.hasNext) {
val item = iter.next()
val key = item.getString(0)
val value = item.getString(1)
val productVertex = tx.addVertex(T.label, NodeConstraint.PRODUCT_LABEL)
productVertex.property(NodeConstraint.NODE_TYPE, NodeConstraint.PRODUCT)
productVertex.property("shop_id", shopID)
productVertex.property("ref_id", refID)
}
try {
tx.commit()
logger.info("Add attributes")
}
catch {
case e: Exception =>
tx.rollback()
logger.error("Error to commit")
}
finally {
tx.close()
graph.close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment