public OwningNodeRelationshipChain( RelationshipChainExplorer relationshipChainExplorer, RecordStore<NodeRecord> nodeStore ) { this.relationshipChainExplorer = relationshipChainExplorer; this.nodeStore = nodeStore; this.nodeRecord = nodeStore.newRecord(); }
@Override public R newRecord() { return actual.newRecord(); }
/** * Utility methods for reading records. These are not on the interface itself since it should be * an explicit choice when to create the record instances passed into it. * Also for mocking purposes it's less confusing and error prone having only a single method. */ static <R extends AbstractBaseRecord> R getRecord( RecordStore<R> store, long id, RecordLoad mode ) { R record = store.newRecord(); store.getRecord( id, record, mode ); return record; }
@Override public NodeRecord load( long key, Void additionalData ) { return store.getRecord( key, store.newRecord(), NORMAL ); }
@Override public RelationshipRecord load( long key, Void additionalData ) { return store.getRecord( key, store.newRecord(), NORMAL ); }
@Override public RelationshipGroupRecord load( long key, Integer type ) { return store.getRecord( key, store.newRecord(), NORMAL ); }
@Override public PropertyKeyTokenRecord load( long key, Void additionalData ) { return store.getRecord( key, store.newRecord(), NORMAL ); }
@Override public LabelTokenRecord load( long key, Void additionalData ) { return store.getRecord( key, store.newRecord(), NORMAL ); }
@Override public RelationshipTypeTokenRecord load( long key, Void additionalData ) { return store.getRecord( key, store.newRecord(), NORMAL ); }
private static <T extends AbstractBaseRecord> T[] readAllRecords( Class<T> type, RecordStore<T> store ) { @SuppressWarnings( "unchecked" ) T[] records = (T[]) Array.newInstance( type, (int) store.getHighId() ); for ( int i = 0; i < records.length; i++ ) { records[i] = store.getRecord( i, store.newRecord(), FORCE ); } return records; } }
private static Set<Long> labelsFor( RecordStore<NodeRecord> nodeStore, CheckerEngine<? extends AbstractBaseRecord,? extends ConsistencyReport> engine, RecordAccess recordAccess, long nodeId ) { return getListOfLabels( nodeStore.getRecord( nodeId, nodeStore.newRecord(), FORCE ), recordAccess, engine ); } }
Scan( RecordStore<R> store, boolean forward, final Predicate<? super R>... filters ) { this.filters = filters; this.ids = new StoreIdIterator( store, forward ); this.store = store; this.cursor = store.openPageCursorForReading( 0 ); this.record = store.newRecord(); }
protected RecordSet<RelationshipRecord> followChainFromNode( long nodeId, long relationshipId ) { return expandChain( recordStore.getRecord( relationshipId, recordStore.newRecord(), NORMAL ), nodeId, NEXT ); }
<RECORD extends AbstractBaseRecord> DirectRecordReference<RECORD> referenceTo( RecordStore<RECORD> store, long id ) { return new DirectRecordReference<>( store.getRecord( id, store.newRecord(), FORCE ), this ); }
protected R getForce( S store, int id ) { return store.getRecord( id, store.newRecord(), RecordLoad.FORCE ); }
public void warmUpCache() { int recordsPerPage = store.getRecordsPerPage(); long id = 0; long half = store.getHighId() / 2; RECORD record = store.newRecord(); while ( id < half ) { store.getRecord( id, record, FORCE ); id += recordsPerPage - 1; } } }
protected R getHeavy( S store, int id ) { R record = store.getRecord( id, store.newRecord(), NORMAL ); store.ensureHeavy( record ); return record; }
private static void breakTheChain( RecordStore<RelationshipRecord> relationshipStore ) { RelationshipRecord record = relationshipStore.getRecord( 10, relationshipStore.newRecord(), NORMAL ); long relationshipTowardsEndOfChain = record.getFirstNode(); while ( record.inUse() && !record.isFirstInFirstChain() ) { record = relationshipStore.getRecord( relationshipTowardsEndOfChain, relationshipStore.newRecord(), FORCE ); relationshipTowardsEndOfChain = record.getFirstPrevRel(); } relationshipStore.updateRecord( new RelationshipRecord( relationshipTowardsEndOfChain, 0, 0, 0 ) ); }
public static <RECORD extends AbstractBaseRecord> int numberOfRecordsInUse( RecordStore<RECORD> store ) { int inUse = 0; for ( long id = store.getNumberOfReservedLowIds(); id < store.getHighId(); id++ ) { RECORD record = store.getRecord( id, store.newRecord(), RecordLoad.FORCE ); if ( record.inUse() ) { inUse++; } } return inUse; }
@Test public void shouldLoadAllConnectedRelationshipRecordsAndTheirFullChainsOfRelationshipRecords() { // given RecordStore<RelationshipRecord> relationshipStore = store.getRelationshipStore(); // when int relationshipIdInMiddleOfChain = 10; RecordSet<RelationshipRecord> records = new RelationshipChainExplorer( relationshipStore ) .exploreRelationshipRecordChainsToDepthTwo( relationshipStore.getRecord( relationshipIdInMiddleOfChain, relationshipStore.newRecord(), NORMAL ) ); // then assertEquals( degreeTwoNodes * 2, records.size() ); }