use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldCreateDeferredSchemaIndexesInEmptyDatabase.
@Test
public void shouldCreateDeferredSchemaIndexesInEmptyDatabase() throws Exception {
// GIVEN
BatchInserter inserter = newBatchInserter();
// WHEN
IndexDefinition definition = inserter.createDeferredSchemaIndex(label("Hacker")).on("handle").create();
// THEN
assertEquals("Hacker", definition.getLabel().name());
assertEquals(asCollection(iterator("handle")), Iterables.asCollection(definition.getPropertyKeys()));
inserter.shutdown();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class LegacyIndexTest method legacyIndexPopulationWithBunchOfFields.
@Test(timeout = TEST_TIMEOUT)
public void legacyIndexPopulationWithBunchOfFields() throws Exception {
BatchInserter batchNode = BatchInserters.inserter(directory.graphDbDir());
LuceneBatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(batchNode);
try {
BatchInserterIndex batchIndex = provider.nodeIndex("node_auto_index", stringMap(IndexManager.PROVIDER, "lucene", "type", "fulltext"));
Map<String, Object> properties = new HashMap<>();
for (int i = 0; i < 2000; i++) {
properties.put(Integer.toString(i), RandomStringUtils.randomAlphabetic(200));
}
long node = batchNode.createNode(properties, Label.label("NODE"));
batchIndex.add(node, properties);
} finally {
provider.shutdown();
batchNode.shutdown();
}
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class GeoDataGenerator method generate.
public void generate(File storeDir) throws IOException {
try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
BatchInserter inserter = BatchInserters.inserter(storeDir.getAbsoluteFile(), fileSystem);
Grid grid = new Grid();
try {
for (int i = 0; i < numberOfNodes; i++) {
grid.createNodeAtRandomLocation(random, inserter);
}
for (int i = 0; i < numberOfConnections; i++) {
grid.createConnection(random, inserter);
}
} finally {
inserter.shutdown();
}
}
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method testSimple.
@Test
public void testSimple() throws Exception {
BatchInserter graphDb = globalInserter;
long node1 = graphDb.createNode(null);
long node2 = graphDb.createNode(null);
long rel1 = graphDb.createRelationship(node1, node2, RelTypes.BATCH_TEST, null);
BatchRelationship rel = graphDb.getRelationshipById(rel1);
assertEquals(rel.getStartNode(), node1);
assertEquals(rel.getEndNode(), node2);
assertEquals(RelTypes.BATCH_TEST.name(), rel.getType().name());
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldGetNodeLabels.
@Test
public void shouldGetNodeLabels() throws Exception {
// GIVEN
BatchInserter inserter = globalInserter;
long node = inserter.createNode(map(), Labels.FIRST, Labels.THIRD);
// WHEN
Iterable<String> labelNames = asNames(inserter.getNodeLabels(node));
// THEN
assertEquals(asSet(Labels.FIRST.name(), Labels.THIRD.name()), Iterables.asSet(labelNames));
}
Aggregations