@Override public List<RECORD> getRecords( long firstId, RecordLoad mode ) { if ( Record.NULL_REFERENCE.is( firstId ) ) { return Collections.emptyList(); } List<RECORD> records = new ArrayList<>(); long id = firstId; try ( PageCursor cursor = openPageCursorForReading( firstId ) ) { RECORD record; do { record = newRecord(); getRecordByCursor( id, record, mode, cursor ); // Even unused records gets added and returned records.add( record ); id = getNextRecordReference( record ); } while ( !Record.NULL_REFERENCE.is( id ) ); } return records; }
private boolean visitPropertyRecordChain( long firstPropertyRecordId, Visitor<PropertyRecord,RuntimeException> visitor ) throws CircularPropertyRecordChainException { if ( Record.NO_NEXT_PROPERTY.is( firstPropertyRecordId ) ) { return false; } MutableLongSet visitedPropertyRecordIds = new LongHashSet( 8 ); visitedPropertyRecordIds.add( firstPropertyRecordId ); long nextProp = firstPropertyRecordId; while ( !Record.NO_NEXT_PROPERTY.is( nextProp ) ) { PropertyRecord propRecord = propertyStore.getRecord( nextProp, propertyStore.newRecord(), FORCE ); nextProp = propRecord.getNextProp(); if ( !Record.NO_NEXT_PROPERTY.is( nextProp ) && !visitedPropertyRecordIds.add( nextProp ) ) { throw new CircularPropertyRecordChainException( propRecord ); } if ( visitor.visit( propRecord ) ) { return true; } } return false; }
/** * Removes property with given {@code propertyKey} from property chain owner by the primitive found in * {@code primitiveProxy} if it exists. * * @param primitiveProxy access to the primitive record pointing to the start of the property chain. * @param propertyKey the property key token id to look for and remove. * @param propertyRecords access to records. * @return {@code true} if the property was found and removed, otherwise {@code false}. */ public <P extends PrimitiveRecord> boolean removePropertyIfExists( RecordProxy<P,Void> primitiveProxy, int propertyKey, RecordAccess<PropertyRecord,PrimitiveRecord> propertyRecords ) { PrimitiveRecord primitive = primitiveProxy.forReadingData(); long propertyId = // propertyData.getId(); traverser.findPropertyRecordContaining( primitive, propertyKey, propertyRecords, false ); if ( !Record.NO_NEXT_PROPERTY.is( propertyId ) ) { removeProperty( primitiveProxy, propertyKey, propertyRecords, primitive, propertyId ); return true; } return false; }
@Override public void checkConsistency( NodeRecord node, CheckerEngine<NodeRecord, NodeConsistencyReport> engine, RecordAccess records ) { if ( !Record.NO_NEXT_RELATIONSHIP.is( node.getNextRel() ) ) { engine.comparativeCheck( records.relationshipGroup( node.getNextRel() ), this ); } }
@Override protected PropertyRecord fetchNextOrNull() { if ( Record.NO_NEXT_PROPERTY.is( next ) ) { return null; } PropertyRecord record = referenceTo( access.getPropertyStore(), next ).record(); next = record.getNextProp(); return record; } };
@Override public void checkConsistency( NodeRecord node, CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> engine, RecordAccess records ) { if ( !Record.NO_NEXT_RELATIONSHIP.is( node.getNextRel() ) ) { engine.comparativeCheck( records.relationship( node.getNextRel() ), this ); } }
private static PropertyRecord[] extractPropertyRecords( RecordAccess<PropertyRecord,PrimitiveRecord> propertyRecordAccess, long nextProp ) { List<PropertyRecord> result = new ArrayList<>(); while ( !Record.NULL_REFERENCE.is( nextProp ) ) { PropertyRecord record = propertyRecordAccess.getIfLoaded( nextProp ).forReadingLinkage(); result.add( record ); nextProp = record.getNextProp(); } return result.toArray( new PropertyRecord[result.size()] ); }
@Override protected PropertyRecord fetchNextOrNull() { if ( Record.NO_NEXT_PROPERTY.is( next ) ) { return null; } PropertyRecord record = reference( properties, next, Version.LATEST ).record(); next = record.getNextProp(); return record; } };
@Override public void check( RECORD record, CheckerEngine<RECORD, REPORT> engine, RecordAccess records ) { if ( !record.inUse() ) { return; } if ( !Record.NO_NEXT_BLOCK.is( record.getNameId() ) ) { engine.comparativeCheck( name( records, record.getNameId() ), this ); } }
@Override @SuppressWarnings( "unchecked" ) public void check( RECORD record, CheckerEngine<RECORD, REPORT> engine, RecordAccess records ) { if ( record.inUse() ) { long prop = record.getNextProp(); if ( !Record.NO_NEXT_PROPERTY.is( prop ) ) { PropertyOwner previous = owners.put( prop, owner( record ) ); if ( previous != null ) { engine.comparativeCheck( previous.record( records ), checker.ownerCheck() ); } } } checker.check( record, engine, records ); }
public static long[] getListOfLabels( NodeRecord nodeRecord, RecordStore<DynamicRecord> labels ) { long field = nodeRecord.getLabelField(); if ( NodeLabelsField.fieldPointsToDynamicRecordOfLabels( field ) ) { List<DynamicRecord> recordList = new ArrayList<>(); final MutableLongSet alreadySeen = new LongHashSet(); long id = NodeLabelsField.firstDynamicLabelRecordId( field ); while ( !Record.NULL_REFERENCE.is( id ) ) { DynamicRecord record = labels.getRecord( id, labels.newRecord(), FORCE ); if ( !record.inUse() || !alreadySeen.add( id ) ) { return PrimitiveLongCollections.EMPTY_LONG_ARRAY; } recordList.add( record ); } return LabelChainWalker.labelIds( recordList ); } return InlineNodeLabels.get( nodeRecord ); }
@Override public void checkReference( RECORD record, PropertyRecord property, CheckerEngine<RECORD, REPORT> engine, RecordAccess records ) { for ( int key : keys( property ) ) { if ( !keys.add( key ) ) { engine.report().propertyKeyNotUniqueInChain(); } } if ( !Record.NO_NEXT_PROPERTY.is( property.getNextProp() ) ) { engine.comparativeCheck( records.property( property.getNextProp() ), this ); } }
@Override public void checkReference( RECORD record, PropertyRecord property, CheckerEngine<RECORD, REPORT> engine, RecordAccess records ) { if ( !property.inUse() ) { engine.report().propertyNotInUse( property ); } else { if ( !Record.NO_PREVIOUS_PROPERTY.is( property.getPrevProp() ) ) { engine.report().propertyNotFirstInChain( property ); } new ChainCheck<RECORD, REPORT>().checkReference( record, property, engine, records ); } } }
private static void assertDynamicRecordChain( DynamicRecord... records ) { if ( records.length > 0 ) { for ( int i = 1; i < records.length; i++ ) { assertEquals( records[i].getId(), records[i - 1].getNextBlock() ); } assertTrue( Record.NO_NEXT_BLOCK.is( records[records.length - 1].getNextBlock() ) ); } }
if ( Record.NO_NEXT_BLOCK.is( nextBlock ) )
private void assertChain( ExpectedRecord... expectedRecords ) { long nextProp = primitive.forReadingLinkage().getNextProp(); int expectedRecordCursor = 0; while ( !Record.NO_NEXT_PROPERTY.is( nextProp ) ) { PropertyRecord record = records.getIfLoaded( nextProp ).forReadingData(); assertRecord( record, expectedRecords[expectedRecordCursor++] ); nextProp = record.getNextProp(); } }
@Override public void checkConsistency( PropertyRecord record, CheckerEngine<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> engine, RecordAccess records ) { if ( !NONE.is( valueFrom( record ) ) ) { PropertyRecord prop = records.cacheAccess().client().getPropertyFromCache( valueFrom( record ) ); if ( prop == null ) { engine.comparativeCheck( records.property( valueFrom( record ) ), this ); } else { engine.comparativeCheck( new DirectRecordReference<>( prop, records ), this ); } } }
@Override public void checkReference( PropertyRecord record, PropertyRecord property, CheckerEngine<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> engine, RecordAccess records ) { if ( record.getId() != property.getId() ) { if ( !property.inUse() || Record.NO_NEXT_PROPERTY.is( property.getNextProp() ) ) { wrongOwner( engine.report() ); } else if ( property.getNextProp() != record.getId() ) { engine.comparativeCheck( property( records, property.getNextProp() ), this ); } } }
while ( !Record.NULL_REFERENCE.is( nextProp ) )