use of org.neo4j.kernel.impl.batchinsert.BatchInserter in project graphdb by neo4j-attic.
the class TestLuceneBatchInsert method indexNumbers.
@Test
public void indexNumbers() throws Exception {
BatchInserter inserter = new BatchInserterImpl(new File(PATH, "8").getAbsolutePath());
BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(inserter);
BatchInserterIndex index = provider.nodeIndex("mine", EXACT_CONFIG);
long id = inserter.createNode(null);
Map<String, Object> props = new HashMap<String, Object>();
props.put("key", 123L);
index.add(id, props);
index.flush();
assertEquals(1, index.get("key", 123L).size());
assertEquals(1, index.get("key", "123").size());
provider.shutdown();
inserter.shutdown();
}
use of org.neo4j.kernel.impl.batchinsert.BatchInserter in project graphdb by neo4j-attic.
the class TestLuceneBatchInsert method testInsertionSpeed.
@Ignore
@Test
public void testInsertionSpeed() {
BatchInserter inserter = new BatchInserterImpl(new File(PATH, "3").getAbsolutePath());
BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(inserter);
BatchInserterIndex index = provider.nodeIndex("yeah", EXACT_CONFIG);
index.setCacheCapacity("key", 1000000);
long t = currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
Map<String, Object> properties = map("key", "value" + i);
long id = inserter.createNode(properties);
index.add(id, properties);
}
System.out.println("insert:" + (currentTimeMillis() - t));
index.flush();
t = currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
count((Iterator<Long>) index.get("key", "value" + i));
}
System.out.println("get:" + (currentTimeMillis() - t));
}
use of org.neo4j.kernel.impl.batchinsert.BatchInserter in project graphdb by neo4j-attic.
the class TestBatchInsert method testSimple.
@Test
public void testSimple() {
BatchInserter graphDb = newBatchInserter();
long node1 = graphDb.createNode(null);
long node2 = graphDb.createNode(null);
long rel1 = graphDb.createRelationship(node1, node2, RelTypes.BATCH_TEST, null);
SimpleRelationship rel = graphDb.getRelationshipById(rel1);
assertEquals(rel.getStartNode(), node1);
assertEquals(rel.getEndNode(), node2);
assertEquals(RelTypes.BATCH_TEST.name(), rel.getType().name());
graphDb.shutdown();
}
use of org.neo4j.kernel.impl.batchinsert.BatchInserter in project graphdb by neo4j-attic.
the class TestBatchInsert method testWithGraphDbService.
@Test
public void testWithGraphDbService() {
BatchInserter batchInserter = newBatchInserter();
GraphDatabaseService graphDb = batchInserter.getGraphDbService();
Node startNode = graphDb.createNode();
setProperties(startNode);
Node[] endNodes = new Node[25];
Set<Relationship> rels = new HashSet<Relationship>();
for (int i = 0; i < 25; i++) {
endNodes[i] = graphDb.createNode();
setProperties(endNodes[i]);
Relationship rel = startNode.createRelationshipTo(endNodes[i], relTypeArray[i % 5]);
rels.add(rel);
setProperties(rel);
}
for (Relationship rel : startNode.getRelationships()) {
assertTrue(rels.contains(rel));
assertEquals(rel.getStartNode(), startNode);
}
setProperties(startNode);
graphDb.shutdown();
}
use of org.neo4j.kernel.impl.batchinsert.BatchInserter in project graphdb by neo4j-attic.
the class ImdbExampleTest method batchInsert.
@Test
public void batchInsert() {
// START SNIPPET: batchInsert
BatchInserter inserter = new BatchInserterImpl("target/neo4jdb-batchinsert");
BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(inserter);
BatchInserterIndex actors = indexProvider.nodeIndex("actors", MapUtil.stringMap("type", "exact"));
actors.setCacheCapacity("name", 100000);
Map<String, Object> properties = MapUtil.map("name", "Keanu Reeves");
long node = inserter.createNode(properties);
actors.add(node, properties);
// Make sure to shut down the index provider
indexProvider.shutdown();
inserter.shutdown();
// END SNIPPET: batchInsert
}
Aggregations