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