use of org.neo4j.storageengine.api.StorageRelationshipTraversalCursor in project neo4j by neo4j.
the class DefaultRelationshipTraversalCursorTest method emptyStoreAllOfType.
@Test
void emptyStoreAllOfType() {
// given
StorageRelationshipTraversalCursor storeCursor = emptyStoreCursor();
DefaultRelationshipTraversalCursor cursor = new DefaultRelationshipTraversalCursor(pool::accept, storeCursor, mock(DefaultNodeCursor.class));
Read read = txState(rel(3, node, 50, type), rel(2, node, node, type), rel(5, 50, node, type2), rel(6, node, node, type), rel(7, 56, node, type), rel(8, node, 52, type));
// when
cursor.init(node, relationship, selection(type, Direction.BOTH), read);
// then
assertRelationships(cursor, 3, 8, 7, 2, 6);
}
use of org.neo4j.storageengine.api.StorageRelationshipTraversalCursor in project neo4j by neo4j.
the class NeoStoresTest method allocateRelationshipTraversalCursor.
private StorageRelationshipTraversalCursor allocateRelationshipTraversalCursor(StorageNodeCursor node) {
StorageRelationshipTraversalCursor relationships = storageReader.allocateRelationshipTraversalCursor(NULL);
node.relationships(relationships, ALL_RELATIONSHIPS);
return relationships;
}
use of org.neo4j.storageengine.api.StorageRelationshipTraversalCursor in project neo4j by neo4j.
the class DegreesRebuildFromStore method rebuild.
@Override
public void rebuild(RelationshipGroupDegreesStore.Updater updater, CursorContext cursorContext, MemoryTracker memoryTracker) {
// === sketch of a more performant version
// - Read all groups and for every group make a mark in a memory-structure like so:
// (node) -> (type,active directions,out,in,loop)
// - Read all relationships and for every matching node go into the memory-structure
// if it's there then look up the type
// if it's there then see if the direction matches any active direction
// if it does then increment the counter in the correct slot
// - Go though the memory-structure and write to the updater
//
// If not all data can fit in memory then do multiple passes (node id range)
RelationshipGroupStore groupStore = neoStores.getRelationshipGroupStore();
try (RecordStorageReader storageReader = new RecordStorageReader(neoStores);
StorageRelationshipTraversalCursor traversalCursor = storageReader.allocateRelationshipTraversalCursor(cursorContext);
PageCursor groupCursor = groupStore.openPageCursorForReadingWithPrefetching(0, cursorContext)) {
RelationshipGroupRecord groupRecord = groupStore.newRecord();
long highGroupId = groupStore.getHighId();
for (long id = groupStore.getNumberOfReservedLowIds(); id < highGroupId; id++) {
groupStore.getRecordByCursor(id, groupRecord, RecordLoad.LENIENT_CHECK, groupCursor);
if (groupRecord.inUse() && (groupRecord.hasExternalDegreesOut() || groupRecord.hasExternalDegreesIn() || groupRecord.hasExternalDegreesLoop())) {
updateDegree(groupRecord.hasExternalDegreesOut(), groupRecord.getFirstOut(), groupRecord, OUTGOING, traversalCursor, updater);
updateDegree(groupRecord.hasExternalDegreesIn(), groupRecord.getFirstIn(), groupRecord, INCOMING, traversalCursor, updater);
updateDegree(groupRecord.hasExternalDegreesLoop(), groupRecord.getFirstLoop(), groupRecord, LOOP, traversalCursor, updater);
}
}
}
}
Aggregations