use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method setSingleProperty.
@Test
public void setSingleProperty() throws Exception {
BatchInserter inserter = newBatchInserter();
long node = inserter.createNode(null);
String value = "Something";
String key = "name";
inserter.setNodeProperty(node, key, value);
GraphDatabaseService db = switchToEmbeddedGraphDatabaseService(inserter);
assertThat(getNodeInTx(node, db), inTx(db, hasProperty(key).withValue(value)));
db.shutdown();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method testMore.
@Test
public void testMore() throws Exception {
BatchInserter graphDb = globalInserter;
long startNode = graphDb.createNode(properties);
long[] endNodes = new long[25];
Set<Long> rels = new HashSet<>();
for (int i = 0; i < 25; i++) {
endNodes[i] = graphDb.createNode(properties);
rels.add(graphDb.createRelationship(startNode, endNodes[i], relTypeArray[i % 5], properties));
}
for (BatchRelationship rel : graphDb.getRelationships(startNode)) {
assertTrue(rels.contains(rel.getId()));
assertEquals(rel.getStartNode(), startNode);
}
graphDb.setNodeProperties(startNode, properties);
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldPopulateLabelScanStoreOnShutdown.
@Test
public void shouldPopulateLabelScanStoreOnShutdown() throws Exception {
// GIVEN
// -- a database and a mocked label scan store
UpdateTrackingLabelScanStore labelScanStore = new UpdateTrackingLabelScanStore();
BatchInserter inserter = newBatchInserterWithLabelScanStore(new ControlledLabelScanStore(labelScanStore));
// -- and some data that we insert
long node1 = inserter.createNode(null, Labels.FIRST);
long node2 = inserter.createNode(null, Labels.SECOND);
long node3 = inserter.createNode(null, Labels.THIRD);
long node4 = inserter.createNode(null, Labels.FIRST, Labels.SECOND);
long node5 = inserter.createNode(null, Labels.FIRST, Labels.THIRD);
// WHEN we shut down the batch inserter
inserter.shutdown();
// THEN the label scan store should receive all the updates.
// of course, we don't know the label ids at this point, but we're assuming 0..2 (bad boy)
labelScanStore.assertRecivedUpdate(node1, 0);
labelScanStore.assertRecivedUpdate(node2, 1);
labelScanStore.assertRecivedUpdate(node3, 2);
labelScanStore.assertRecivedUpdate(node4, 0, 1);
labelScanStore.assertRecivedUpdate(node5, 0, 2);
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldReplaceExistingDynamicLabelsWithInlined.
@Test
public void shouldReplaceExistingDynamicLabelsWithInlined() throws Exception {
// GIVEN
BatchInserter inserter = globalInserter;
long node = inserter.createNode(map(), manyLabels(150).first());
// WHEN
inserter.setNodeLabels(node, Labels.FIRST);
// THEN
Iterable<String> labelNames = asNames(inserter.getNodeLabels(node));
assertEquals(asSet(Labels.FIRST.name()), Iterables.asSet(labelNames));
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldChangePropertiesInCurrentBatch.
@Test
public void shouldChangePropertiesInCurrentBatch() throws Exception {
// GIVEN
BatchInserter inserter = globalInserter;
Map<String, Object> properties = map("key1", "value1");
long node = inserter.createNode(properties);
// WHEN
properties.put("additionalKey", "Additional value");
inserter.setNodeProperties(node, properties);
// THEN
assertEquals(properties, inserter.getNodeProperties(node));
}
Aggregations