use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldAddManyInitialLabelsAsDynamicRecords.
@Test
public void shouldAddManyInitialLabelsAsDynamicRecords() throws Exception {
// GIVEN
BatchInserter inserter = globalInserter;
Pair<Label[], Set<String>> labels = manyLabels(200);
long node = inserter.createNode(map(), labels.first());
forceFlush(inserter);
// WHEN
Iterable<String> labelNames = asNames(inserter.getNodeLabels(node));
// THEN
assertEquals(labels.other(), Iterables.asSet(labelNames));
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInserterImplTest method testHonorsPassedInParams.
@Test
public void testHonorsPassedInParams() throws Exception {
BatchInserter inserter = BatchInserters.inserter(testDirectory.graphDbDir(), fileSystemRule.get(), stringMap(GraphDatabaseSettings.pagecache_memory.name(), "280K"));
NeoStores neoStores = ReflectionUtil.getPrivateField(inserter, "neoStores", NeoStores.class);
PageCache pageCache = ReflectionUtil.getPrivateField(neoStores, "pageCache", PageCache.class);
inserter.shutdown();
int mappedMemoryTotalSize = pageCache.maxCachedPages() * pageCache.pageSize();
assertThat("memory mapped config is active", mappedMemoryTotalSize, is(280 * 1024));
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method propertiesCanBeReSetUsingBatchInserter2.
@Test
public void propertiesCanBeReSetUsingBatchInserter2() throws Exception {
// GIVEN
BatchInserter batchInserter = globalInserter;
long id = batchInserter.createNode(new HashMap<String, Object>());
// WHEN
batchInserter.setNodeProperty(id, "test", "looooooooooong test");
batchInserter.setNodeProperty(id, "test", "small test");
// THEN
assertEquals("small test", batchInserter.getNodeProperties(id).get("test"));
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method testSetAndKeepNodeProperty.
@Test
public void testSetAndKeepNodeProperty() throws Exception {
BatchInserter inserter = newBatchInserter();
long tehNode = inserter.createNode(MapUtil.map("foo", "bar"));
inserter.setNodeProperty(tehNode, "foo2", "bar2");
Map<String, Object> props = inserter.getNodeProperties(tehNode);
assertEquals(2, props.size());
assertEquals("bar", props.get("foo"));
assertEquals("bar2", props.get("foo2"));
inserter.shutdown();
inserter = newBatchInserter();
props = inserter.getNodeProperties(tehNode);
assertEquals(2, props.size());
assertEquals("bar", props.get("foo"));
assertEquals("bar2", props.get("foo2"));
inserter.setNodeProperty(tehNode, "foo", "bar3");
props = inserter.getNodeProperties(tehNode);
assertEquals("bar3", props.get("foo"));
assertEquals(2, props.size());
assertEquals("bar3", props.get("foo"));
assertEquals("bar2", props.get("foo2"));
inserter.shutdown();
inserter = newBatchInserter();
props = inserter.getNodeProperties(tehNode);
assertEquals("bar3", props.get("foo"));
assertEquals(2, props.size());
assertEquals("bar3", props.get("foo"));
assertEquals("bar2", props.get("foo2"));
inserter.shutdown();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method mustSplitUpRelationshipChainsWhenCreatingDenseNodes.
@Test
public void mustSplitUpRelationshipChainsWhenCreatingDenseNodes() throws Exception {
BatchInserter inserter = globalInserter;
long node1 = inserter.createNode(null);
long node2 = inserter.createNode(null);
for (int i = 0; i < 1000; i++) {
for (MyRelTypes relType : MyRelTypes.values()) {
inserter.createRelationship(node1, node2, relType, null);
}
}
NeoStores neoStores = getFlushedNeoStores(inserter);
NodeRecord record = getRecord(neoStores.getNodeStore(), node1);
assertTrue("Node " + record + " should have been dense", record.isDense());
}
Aggregations