use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class ReadGroupsFromCacheStepTest method groups.
protected static List<RelationshipGroupRecord> groups(Group... groups) {
List<RelationshipGroupRecord> records = new ArrayList<>();
for (Group group : groups) {
for (int i = 0; i < group.count; i++) {
RelationshipGroupRecord record = new RelationshipGroupRecord(NULL_REFERENCE.longValue());
record.setOwningNode(group.owningNode);
// count: how many come after it (importer does this)
record.setNext(group.count - i - 1);
records.add(record);
}
}
return records;
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class RelationshipGroupCacheTest method shouldSortOutOfOrderTypes.
@Test
public void shouldSortOutOfOrderTypes() throws Exception {
// GIVEN
int nodeCount = 100;
RelationshipGroupCache cache = new RelationshipGroupCache(HEAP, ByteUnit.kibiBytes(40), nodeCount);
int[] counts = new int[nodeCount];
int groupCount = 0;
for (int nodeId = 0; nodeId < counts.length; nodeId++) {
counts[nodeId] = random.nextInt(10);
setCount(cache, nodeId, counts[nodeId]);
groupCount += counts[nodeId];
}
assertEquals(nodeCount, cache.prepare(0));
boolean thereAreMoreGroups = true;
int cachedCount = 0;
int[] types = scrambledTypes(10);
for (int i = 0; thereAreMoreGroups; i++) {
int typeId = types[i];
thereAreMoreGroups = false;
for (int nodeId = 0; nodeId < nodeCount; nodeId++) {
if (counts[nodeId] > 0) {
thereAreMoreGroups = true;
if (cache.put(new RelationshipGroupRecord(nodeId).initialize(true, typeId, -1, -1, -1, nodeId, -1))) {
cachedCount++;
counts[nodeId]--;
}
}
}
}
assertEquals(groupCount, cachedCount);
// WHEN/THEN
long currentNodeId = -1;
int currentTypeId = -1;
int readCount = 0;
for (RelationshipGroupRecord group : cache) {
assertTrue(group.getOwningNode() >= currentNodeId);
if (group.getOwningNode() > currentNodeId) {
currentNodeId = group.getOwningNode();
currentTypeId = -1;
}
assertTrue(group.getType() > currentTypeId);
readCount++;
}
assertEquals(cachedCount, readCount);
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class EncodeGroupsStepTest method assertBatch.
private void assertBatch(RelationshipGroupRecord[] batch, long lastOwningNodeLastBatch) {
for (int i = 0; i < batch.length; i++) {
RelationshipGroupRecord record = batch[i];
assertTrue(record.getId() > Record.NULL_REFERENCE.longValue());
assertTrue(record.getOwningNode() > lastOwningNodeLastBatch);
// the mark our store mock sets when preparing
assertEquals(1, record.getFirstOut());
if (record.getNext() == Record.NULL_REFERENCE.longValue()) {
// This is the last in the chain, verify that this is either:
assertTrue(// - the last one in the batch, or
i == batch.length - 1 || // - the last one for this node
batch[i + 1].getOwningNode() > record.getOwningNode());
}
}
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class StorageLayerRelTypesAndDegreeTest method markRandomRelsInGroupNotInUse.
private void markRandomRelsInGroupNotInUse(long nodeId, TestRelType type) {
NodeRecord node = getNodeRecord(nodeId);
assertTrue(node.isDense());
long relGroupId = node.getNextRel();
while (relGroupId != NO_NEXT_RELATIONSHIP.intValue()) {
RelationshipGroupRecord relGroup = getRelGroupRecord(relGroupId);
if (type == relTypeForId(relGroup.getType())) {
markRandomRelsInChainNotInUse(relGroup.getFirstOut());
markRandomRelsInChainNotInUse(relGroup.getFirstIn());
markRandomRelsInChainNotInUse(relGroup.getFirstLoop());
return;
}
relGroupId = relGroup.getNext();
}
throw new IllegalStateException("No relationship group with type: " + type + " found");
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class StoreNodeRelationshipCursorTest method createRelationshipChain.
private void createRelationshipChain(int recordsInChain) {
RelationshipStore relationshipStore = neoStores.getRelationshipStore();
for (int i = 1; i < recordsInChain; i++) {
relationshipStore.updateRecord(createRelationship(i, i + 1));
}
relationshipStore.updateRecord(createRelationship(recordsInChain, NO_NEXT_RELATIONSHIP.intValue()));
if (dense) {
RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore();
for (int i = 1; i < recordsInChain; i++) {
relationshipGroupStore.updateRecord(createRelationshipGroup(i, i));
}
relationshipGroupStore.updateRecord(createRelationshipGroup(recordsInChain, NO_NEXT_RELATIONSHIP.intValue()));
}
}
Aggregations