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());
}
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();
}
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)));
}
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)));
}
Aggregations