Search in sources :

Example 16 with BatchInserter

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));
}
Also used : BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) Set(java.util.Set) Iterators.asSet(org.neo4j.helpers.collection.Iterators.asSet) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 17 with BatchInserter

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));
}
Also used : BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) NeoStores(org.neo4j.kernel.impl.store.NeoStores) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 18 with BatchInserter

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"));
}
Also used : BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) Test(org.junit.Test)

Example 19 with BatchInserter

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();
}
Also used : BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) Test(org.junit.Test)

Example 20 with BatchInserter

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());
}
Also used : BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) MyRelTypes(org.neo4j.kernel.impl.MyRelTypes) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Test(org.junit.Test)

Aggregations

BatchInserter (org.neo4j.unsafe.batchinsert.BatchInserter)60 Test (org.junit.Test)58 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)9 File (java.io.File)8 ConstraintViolationException (org.neo4j.graphdb.ConstraintViolationException)8 Transaction (org.neo4j.graphdb.Transaction)8 Label (org.neo4j.graphdb.Label)5 HashMap (java.util.HashMap)4 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)4 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)4 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)4 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)4 BatchRelationship (org.neo4j.unsafe.batchinsert.BatchRelationship)4 HashSet (java.util.HashSet)3 Matchers.anyLong (org.mockito.Matchers.anyLong)3 Node (org.neo4j.graphdb.Node)3 PropertyAccessor (org.neo4j.kernel.api.index.PropertyAccessor)3 NeoStores (org.neo4j.kernel.impl.store.NeoStores)3 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)3 Set (java.util.Set)2