use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class NodeSetFirstGroupStep method process.
@Override
protected void process(RelationshipGroupRecord[] batch, BatchSender sender) throws Throwable {
for (RelationshipGroupRecord group : batch) {
assert group.inUse();
long nodeId = group.getOwningNode();
if (cache.getByte(nodeId, 0) == 0) {
cache.setByte(nodeId, 0, (byte) 1);
nodeRecordCursor.next(nodeId);
NodeRecord node = nodeRecordCursor.get().clone();
node.setNextRel(group.getId());
current[cursor++] = node;
if (cursor == batchSize) {
sender.send(current);
newBatch();
}
}
}
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class StoreNodeRelationshipCursorTest method createNodeRelationships.
private void createNodeRelationships() {
RelationshipStore relationshipStore = neoStores.getRelationshipStore();
if (dense) {
RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore();
relationshipGroupStore.updateRecord(createRelationshipGroup(1, 1));
relationshipGroupStore.updateRecord(createRelationshipGroup(2, 2));
relationshipGroupStore.updateRecord(createRelationshipGroup(3, 3));
}
relationshipStore.updateRecord(createRelationship(1, NO_NEXT_RELATIONSHIP.intValue()));
relationshipStore.updateRecord(createRelationship(2, NO_NEXT_RELATIONSHIP.intValue()));
relationshipStore.updateRecord(createRelationship(3, NO_NEXT_RELATIONSHIP.intValue()));
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class StorageLayerRelTypesAndDegreeTest method markRelGroupNotInUse.
private void markRelGroupNotInUse(long nodeId, TestRelType... types) {
NodeRecord node = getNodeRecord(nodeId);
assertTrue(node.isDense());
Set<TestRelType> typesToRemove = asSet(types);
long relGroupId = node.getNextRel();
while (relGroupId != NO_NEXT_RELATIONSHIP.intValue()) {
RelationshipGroupRecord relGroup = getRelGroupRecord(relGroupId);
TestRelType type = relTypeForId(relGroup.getType());
if (typesToRemove.contains(type)) {
relGroup.setInUse(false);
update(relGroup);
}
relGroupId = relGroup.getNext();
}
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class TransactionRecordStateTest method assertDenseRelationshipCounts.
public static void assertDenseRelationshipCounts(RecordChangeSet recordChangeSet, long nodeId, int type, int outCount, int inCount) {
RelationshipGroupRecord group = getRelationshipGroup(recordChangeSet, recordChangeSet.getNodeRecords().getOrLoad(nodeId, null).forReadingData(), type).forReadingData();
assertNotNull(group);
RelationshipRecord rel;
long relId = group.getFirstOut();
if (relId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
rel = recordChangeSet.getRelRecords().getOrLoad(relId, null).forReadingData();
// count is stored in the back pointer of the first relationship in the chain
assertEquals("Stored relationship count for OUTGOING differs", outCount, rel.getFirstPrevRel());
assertEquals("Manually counted relationships for OUTGOING differs", outCount, manuallyCountRelationships(recordChangeSet, nodeId, relId));
}
relId = group.getFirstIn();
if (relId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
rel = recordChangeSet.getRelRecords().getOrLoad(relId, null).forReadingData();
assertEquals("Stored relationship count for INCOMING differs", inCount, rel.getSecondPrevRel());
assertEquals("Manually counted relationships for INCOMING differs", inCount, manuallyCountRelationships(recordChangeSet, nodeId, relId));
}
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class WriteTransactionCommandOrderingTest method injectAllPossibleCommands.
private TransactionRecordState injectAllPossibleCommands() {
RecordChangeSet recordChangeSet = mock(RecordChangeSet.class);
RecordChanges<Integer, LabelTokenRecord, Void> labelTokenChanges = mock(RecordChanges.class);
RecordChanges<Integer, RelationshipTypeTokenRecord, Void> relationshipTypeTokenChanges = mock(RecordChanges.class);
RecordChanges<Integer, PropertyKeyTokenRecord, Void> propertyKeyTokenChanges = mock(RecordChanges.class);
RecordChanges<Long, NodeRecord, Void> nodeRecordChanges = mock(RecordChanges.class);
RecordChanges<Long, RelationshipRecord, Void> relationshipRecordChanges = mock(RecordChanges.class);
RecordChanges<Long, PropertyRecord, PrimitiveRecord> propertyRecordChanges = mock(RecordChanges.class);
RecordChanges<Long, RelationshipGroupRecord, Integer> relationshipGroupChanges = mock(RecordChanges.class);
RecordChanges<Long, SchemaRecord, SchemaRule> schemaRuleChanges = mock(RecordChanges.class);
when(recordChangeSet.getLabelTokenChanges()).thenReturn(labelTokenChanges);
when(recordChangeSet.getRelationshipTypeTokenChanges()).thenReturn(relationshipTypeTokenChanges);
when(recordChangeSet.getPropertyKeyTokenChanges()).thenReturn(propertyKeyTokenChanges);
when(recordChangeSet.getNodeRecords()).thenReturn(nodeRecordChanges);
when(recordChangeSet.getRelRecords()).thenReturn(relationshipRecordChanges);
when(recordChangeSet.getPropertyRecords()).thenReturn(propertyRecordChanges);
when(recordChangeSet.getRelGroupRecords()).thenReturn(relationshipGroupChanges);
when(recordChangeSet.getSchemaRuleChanges()).thenReturn(schemaRuleChanges);
List<RecordProxy<Long, NodeRecord, Void>> nodeChanges = new LinkedList<>();
RecordChange<Long, NodeRecord, Void> deletedNode = mock(RecordChange.class);
when(deletedNode.getBefore()).thenReturn(inUseNode());
when(deletedNode.forReadingLinkage()).thenReturn(missingNode());
nodeChanges.add(deletedNode);
RecordChange<Long, NodeRecord, Void> createdNode = mock(RecordChange.class);
when(createdNode.getBefore()).thenReturn(missingNode());
when(createdNode.forReadingLinkage()).thenReturn(createdNode());
nodeChanges.add(createdNode);
RecordChange<Long, NodeRecord, Void> updatedNode = mock(RecordChange.class);
when(updatedNode.getBefore()).thenReturn(inUseNode());
when(updatedNode.forReadingLinkage()).thenReturn(inUseNode());
nodeChanges.add(updatedNode);
when(nodeRecordChanges.changes()).thenReturn(nodeChanges);
when(nodeRecordChanges.changeSize()).thenReturn(3);
when(recordChangeSet.changeSize()).thenReturn(3);
when(labelTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, LabelTokenRecord, Void>>emptyList());
when(relationshipTypeTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, RelationshipTypeTokenRecord, Void>>emptyList());
when(propertyKeyTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, PropertyKeyTokenRecord, Void>>emptyList());
when(relationshipRecordChanges.changes()).thenReturn(Collections.<RecordProxy<Long, RelationshipRecord, Void>>emptyList());
when(propertyRecordChanges.changes()).thenReturn(Collections.<RecordProxy<Long, PropertyRecord, PrimitiveRecord>>emptyList());
when(relationshipGroupChanges.changes()).thenReturn(Collections.<RecordProxy<Long, RelationshipGroupRecord, Integer>>emptyList());
when(schemaRuleChanges.changes()).thenReturn(Collections.<RecordProxy<Long, SchemaRecord, SchemaRule>>emptyList());
NeoStores neoStores = mock(NeoStores.class);
when(neoStores.getNodeStore()).thenReturn(mock(NodeStore.class));
when(neoStores.getRelationshipGroupStore()).thenReturn(mock(RelationshipGroupStore.class));
when(neoStores.getRelationshipStore()).thenReturn(mock(RelationshipStore.class));
return new TransactionRecordState(neoStores, mock(IntegrityValidator.class), recordChangeSet, 0, null, null, null, null, null);
}
Aggregations