Search in sources :

Example 1 with MyRelTypes

use of org.neo4j.kernel.impl.MyRelTypes 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)

Example 2 with MyRelTypes

use of org.neo4j.kernel.impl.MyRelTypes in project neo4j by neo4j.

the class BatchInsertTest method mustSplitUpRelationshipChainsWhenCreatingDenseNodes.

@ParameterizedTest
@MethodSource("params")
void mustSplitUpRelationshipChainsWhenCreatingDenseNodes(int denseNodeThreshold) throws Exception {
    var inserter = newBatchInserter(denseNodeThreshold);
    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);
    NodeStore nodeStore = neoStores.getNodeStore();
    NodeRecord record = nodeStore.getRecord(node1, nodeStore.newRecord(), NORMAL, NULL);
    assertTrue(record.isDense(), "Node " + record + " should have been dense");
    inserter.shutdown();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) MyRelTypes(org.neo4j.kernel.impl.MyRelTypes) NeoStores(org.neo4j.kernel.impl.store.NeoStores) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with MyRelTypes

use of org.neo4j.kernel.impl.MyRelTypes in project neo4j by neo4j.

the class TestRelationshipCount method convertNodeToDense.

@ParameterizedTest(name = "denseNodeThreshold={0}")
@MethodSource("argumentsProvider")
public void convertNodeToDense(int denseNodeThreshold) {
    init(denseNodeThreshold);
    Node node = tx.createNode();
    EnumMap<MyRelTypes, Set<Relationship>> rels = new EnumMap<>(MyRelTypes.class);
    for (MyRelTypes type : MyRelTypes.values()) {
        rels.put(type, new HashSet<>());
    }
    int expectedRelCount = 0;
    for (int i = 0; i < 6; i++, expectedRelCount++) {
        MyRelTypes type = MyRelTypes.values()[i % MyRelTypes.values().length];
        Relationship rel = node.createRelationshipTo(tx.createNode(), type);
        rels.get(type).add(rel);
    }
    newTransaction();
    node = tx.getNodeById(node.getId());
    for (int i = 0; i < 1000; i++, expectedRelCount++) {
        node.createRelationshipTo(tx.createNode(), MyRelTypes.TEST);
    }
    assertEquals(expectedRelCount, node.getDegree());
    assertEquals(expectedRelCount, node.getDegree(Direction.BOTH));
    assertEquals(expectedRelCount, node.getDegree(Direction.OUTGOING));
    assertEquals(0, node.getDegree(Direction.INCOMING));
    assertEquals(rels.get(MyRelTypes.TEST2), Iterables.asSet(node.getRelationships(MyRelTypes.TEST2)));
    assertEquals(join(rels.get(MyRelTypes.TEST_TRAVERSAL), rels.get(MyRelTypes.TEST2)), Iterables.asSet(node.getRelationships(MyRelTypes.TEST_TRAVERSAL, MyRelTypes.TEST2)));
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) MyRelTypes(org.neo4j.kernel.impl.MyRelTypes) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) EnumMap(java.util.EnumMap) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with MyRelTypes

use of org.neo4j.kernel.impl.MyRelTypes in project neo4j by neo4j.

the class TestRelationshipCount method convertNodeToDense.

@Test
public void convertNodeToDense() throws Exception {
    Node node = getGraphDb().createNode();
    EnumMap<MyRelTypes, Set<Relationship>> rels = new EnumMap<>(MyRelTypes.class);
    for (MyRelTypes type : MyRelTypes.values()) {
        rels.put(type, new HashSet<Relationship>());
    }
    int expectedRelCount = 0;
    for (int i = 0; i < 6; i++, expectedRelCount++) {
        MyRelTypes type = MyRelTypes.values()[i % MyRelTypes.values().length];
        Relationship rel = node.createRelationshipTo(getGraphDb().createNode(), type);
        rels.get(type).add(rel);
    }
    newTransaction();
    for (int i = 0; i < 1000; i++, expectedRelCount++) {
        node.createRelationshipTo(getGraphDb().createNode(), MyRelTypes.TEST);
    }
    assertEquals(expectedRelCount, node.getDegree());
    assertEquals(expectedRelCount, node.getDegree(Direction.BOTH));
    assertEquals(expectedRelCount, node.getDegree(Direction.OUTGOING));
    assertEquals(0, node.getDegree(Direction.INCOMING));
    assertEquals(rels.get(MyRelTypes.TEST2), Iterables.asSet(node.getRelationships(MyRelTypes.TEST2)));
    assertEquals(join(rels.get(MyRelTypes.TEST_TRAVERSAL), rels.get(MyRelTypes.TEST2)), Iterables.asSet(node.getRelationships(MyRelTypes.TEST_TRAVERSAL, MyRelTypes.TEST2)));
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) MyRelTypes(org.neo4j.kernel.impl.MyRelTypes) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Aggregations

MyRelTypes (org.neo4j.kernel.impl.MyRelTypes)4 EnumMap (java.util.EnumMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Test (org.junit.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Node (org.neo4j.graphdb.Node)2 Relationship (org.neo4j.graphdb.Relationship)2 NeoStores (org.neo4j.kernel.impl.store.NeoStores)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)2 NodeStore (org.neo4j.kernel.impl.store.NodeStore)1 BatchInserter (org.neo4j.unsafe.batchinsert.BatchInserter)1