@Override public long prev( RelationshipRecord relationship ) { return relationship.getSecondPrevRel(); }
@Override public long relOf( RelationshipRecord rel ) { return rel.getSecondPrevRel(); }
@Override public long valueFrom( RelationshipRecord relationship ) { return relationship.getSecondPrevRel(); }
@Override long get( RelationshipRecord rel ) { return rel.isFirstInSecondChain() ? Record.NO_NEXT_RELATIONSHIP.intValue() : rel.getSecondPrevRel(); }
static int relCount( long nodeId, RelationshipRecord rel ) { return (int) (nodeId == rel.getFirstNode() ? rel.getFirstPrevRel() : rel.getSecondPrevRel()); }
private int count( long reference ) { if ( reference == NO_ID ) { return 0; } if ( edgePage == null ) { edgePage = relationshipStore.openPageCursorForReading( reference ); } relationshipStore.getRecordByCursor( reference, edge, RecordLoad.FORCE, edgePage ); if ( edge.getFirstNode() == getOwningNode() ) { return (int) edge.getFirstPrevRel(); } else { return (int) edge.getSecondPrevRel(); } }
@Override protected void checkRelationship( RecordStore<RelationshipRecord> store, RelationshipRecord rel, RecordCheck<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport> checker ) { if ( stage != null && (stage == CheckStage.Stage6_RS_Forward || stage == CheckStage.Stage7_RS_Backward) ) { long id = rel.getId(); CacheAccess.Client client = cacheAccess.client(); countLinks( id, rel.getFirstNextRel(), client ); countLinks( id, rel.getFirstPrevRel(), client ); countLinks( id, rel.getSecondNextRel(), client ); countLinks( id, rel.getSecondPrevRel(), client ); } report.forRelationship( rel, checker ); }
@Override protected void assertRecordsEqual( RelationshipRecord actualRecord, RelationshipRecord expectedRecord ) { assertNotNull( "actualRecord", actualRecord ); assertNotNull( "expectedRecord", expectedRecord ); assertThat( "getFirstNextRel", actualRecord.getFirstNextRel(), is( expectedRecord.getFirstNextRel() ) ); assertThat( "getFirstNode", actualRecord.getFirstNode(), is( expectedRecord.getFirstNode() ) ); assertThat( "getFirstPrevRel", actualRecord.getFirstPrevRel(), is( expectedRecord.getFirstPrevRel() ) ); assertThat( "getSecondNextRel", actualRecord.getSecondNextRel(), is( expectedRecord.getSecondNextRel() ) ); assertThat( "getSecondNode", actualRecord.getSecondNode(), is( expectedRecord.getSecondNode() ) ); assertThat( "getSecondPrevRel", actualRecord.getSecondPrevRel(), is( expectedRecord.getSecondPrevRel() ) ); assertThat( "getType", actualRecord.getType(), is( expectedRecord.getType() ) ); assertThat( "isFirstInFirstChain", actualRecord.isFirstInFirstChain(), is( expectedRecord.isFirstInFirstChain() ) ); assertThat( "isFirstInSecondChain", actualRecord.isFirstInSecondChain(), is( expectedRecord.isFirstInSecondChain() ) ); assertThat( "getId", actualRecord.getId(), is( expectedRecord.getId() ) ); assertThat( "getLongId", actualRecord.getId(), is( expectedRecord.getId() ) ); assertThat( "getNextProp", actualRecord.getNextProp(), is( expectedRecord.getNextProp() ) ); assertThat( "inUse", actualRecord.inUse(), is( expectedRecord.inUse() ) ); }
private String diff( RelationshipRecord expected, RelationshipRecord actual ) { if ( actual.getId() == expected.getId() && actual.getFirstNode() == expected.getFirstNode() && actual.getSecondNode() == expected.getSecondNode() && actual.getType() == expected.getType() && actual.getFirstPrevRel() == expected.getFirstPrevRel() && actual.getFirstNextRel() == expected.getFirstNextRel() && actual.getSecondPrevRel() == expected.getSecondPrevRel() && actual.getSecondNextRel() == expected.getSecondNextRel() && actual.isFirstInFirstChain() == expected.isFirstInFirstChain() && actual.isFirstInSecondChain() == expected.isFirstInSecondChain() ) { return null; } return describeDiff( expected.toString(), actual.toString() ); }
newCount = firstRel.getSecondPrevRel() + 1; firstRel.setSecondPrevRel( rel.getId() ); firstRel.setFirstInSecondChain( false );
@Override public RecordKey<RelationshipRecord> relationship() { return ( written, read ) -> { assertEquals( written.getNextProp(), read.getNextProp() ); assertEquals( written.getFirstNode(), read.getFirstNode() ); assertEquals( written.getSecondNode(), read.getSecondNode() ); assertEquals( written.getType(), read.getType() ); assertEquals( written.getFirstPrevRel(), read.getFirstPrevRel() ); assertEquals( written.getFirstNextRel(), read.getFirstNextRel() ); assertEquals( written.getSecondPrevRel(), read.getSecondPrevRel() ); assertEquals( written.getSecondNextRel(), read.getSecondNextRel() ); assertEquals( written.isFirstInFirstChain(), read.isFirstInFirstChain() ); assertEquals( written.isFirstInSecondChain(), read.isFirstInSecondChain() ); }; }
long firstNextRelMod = firstNextRel == Record.NO_NEXT_RELATIONSHIP.intValue() ? 0 : (firstNextRel & 0x700000000L) >> 10; long secondPrevRel = record.getSecondPrevRel(); long secondPrevRelMod = secondPrevRel == Record.NO_NEXT_RELATIONSHIP.intValue() ? 0 : (secondPrevRel & 0x700000000L) >> 13;
private void writeRelationshipRecord( WritableChannel channel, RelationshipRecord record ) throws IOException { byte flags = bitFlags( bitFlag( record.inUse(), Record.IN_USE.byteValue() ), bitFlag( record.isCreated(), Record.CREATED_IN_TX ), bitFlag( record.requiresSecondaryUnit(), Record.REQUIRE_SECONDARY_UNIT ), bitFlag( record.hasSecondaryUnitId(), Record.HAS_SECONDARY_UNIT ), bitFlag( record.isUseFixedReferences(), Record.USES_FIXED_REFERENCE_FORMAT ) ); channel.put( flags ); if ( record.inUse() ) { channel.putLong( record.getFirstNode() ).putLong( record.getSecondNode() ).putInt( record.getType() ) .putLong( record.getFirstPrevRel() ).putLong( record.getFirstNextRel() ) .putLong( record.getSecondPrevRel() ).putLong( record.getSecondNextRel() ) .putLong( record.getNextProp() ) .put( (byte) ((record.isFirstInFirstChain() ? 1 : 0) | (record.isFirstInSecondChain() ? 2 : 0)) ); if ( record.hasSecondaryUnitId() ) { channel.putLong( record.getSecondaryUnitId() ); } } else { channel.putInt( record.getType() ); } } }
relationship.getId(), relationship.getSecondPrevRel(), 1 ); updateCacheCounts( cache2Free, cacheAccess );
private 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 ) ); } }
private long getSecondPrevReference( RelationshipRecord record, long recordId ) { return record.isFirstInSecondChain() ? record.getSecondPrevRel() : toRelative( record.getSecondPrevRel(), recordId ); }
private long getSecondPrevReference( RelationshipRecord record, long recordId ) { return record.isFirstInSecondChain() ? record.getSecondPrevRel() : toRelative( record.getSecondPrevRel(), recordId ); }
private long getSecondPrevReference( RelationshipRecord record, long recordId ) { return record.isFirstInSecondChain() ? record.getSecondPrevRel() : toRelative( record.getSecondPrevRel(), recordId ); }
@Override long get( RelationshipRecord rel ) { return rel.isFirstInSecondChain() ? Record.NO_NEXT_RELATIONSHIP.intValue() : rel.getSecondPrevRel(); }
@Override protected boolean canUseFixedReferences( RelationshipRecord record, int recordSize ) { return (isRecordBigEnoughForFixedReferences( recordSize ) && (record.getFirstNode() & ONE_BIT_OVERFLOW_BIT_MASK) == 0) && ((record.getSecondNode() & ONE_BIT_OVERFLOW_BIT_MASK) == 0) && ((record.getFirstPrevRel() == NULL) || ((record.getFirstPrevRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && ((record.getFirstNextRel() == NULL) || ((record.getFirstNextRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && ((record.getSecondPrevRel() == NULL) || ((record.getSecondPrevRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && ((record.getSecondNextRel() == NULL) || ((record.getSecondNextRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && ((record.getNextProp() == NULL) || ((record.getNextProp() & THREE_BITS_OVERFLOW_BIT_MASK) == 0)); }