Last active
August 1, 2018 05:08
-
-
Save NhuanTDBK/8b907111770bc6c4749f192eee0fdfdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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