Created
June 27, 2013 14:15
-
-
Save andrii0lomakin/5876770 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @Test | |
| public class TxTest { | |
| public void testTx() { | |
| OGlobalConfiguration.TX_COMMIT_SYNCH.setValue(true); | |
| int TOP_COUNTER = 0, BOTTOM_COUNTER = 0, LINK_COUNTER = 0; | |
| OGraphDatabase database = new OGraphDatabase("plocal:D:/Temp/my_db_orient").create(); | |
| long ts = System.currentTimeMillis(); | |
| ODocument firstLayerVertex, secondLayerVertex; | |
| for (int i = 0; i < 1000; i++) { | |
| database.begin(OTransaction.TXTYPE.OPTIMISTIC); | |
| firstLayerVertex = database.createVertex().field("name", "first" + TOP_COUNTER).field("weight", TOP_COUNTER++); | |
| firstLayerVertex.save(); | |
| for (int j = 0; j < 100; j++) { | |
| secondLayerVertex = database.createVertex().field("name", "second" + BOTTOM_COUNTER).field("weight", BOTTOM_COUNTER++); | |
| secondLayerVertex.save(); | |
| database.createEdge(firstLayerVertex, secondLayerVertex).field("name", "link" + LINK_COUNTER++).save(); | |
| } | |
| database.commit(); | |
| } | |
| System.out.println(System.currentTimeMillis() - ts); | |
| // final Iterable<ODocument> gwList = database.browseVertices(); | |
| // if (gwList != null) { | |
| // for (final ODocument gw : gwList) { | |
| // System.out.println(gw.toJSON()); | |
| // } | |
| // } | |
| database.close(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment