@Override long get( RelationshipRecord rel ) { return rel.getSecondNextRel(); }
@Override public long relOf( RelationshipRecord rel ) { return rel.getSecondNextRel(); }
@Override public long valueFrom( RelationshipRecord relationship ) { return relationship.getSecondNextRel(); }
@Override public long next( RelationshipRecord relationship ) { return relationship.getSecondNextRel(); }
@Override public boolean endOfChain( RelationshipRecord rel ) { return rel.getSecondNextRel() == Record.NO_NEXT_RELATIONSHIP.intValue(); } },
private void assertRelationshipChain( RelationshipStore relationshipStore, Node node, long firstId, long... chainedIds ) { long nodeId = node.getId(); RelationshipRecord record = relationshipStore.getRecord( firstId, relationshipStore.newRecord(), NORMAL ); Set<Long> readChain = new HashSet<>(); readChain.add( firstId ); while ( true ) { long nextId = record.getFirstNode() == nodeId ? record.getFirstNextRel() : record.getSecondNextRel(); if ( nextId == -1 ) { break; } readChain.add( nextId ); relationshipStore.getRecord( nextId, record, NORMAL ); } Set<Long> expectedChain = new HashSet<>( asList( firstId ) ); for ( long id : chainedIds ) { expectedChain.add( id ); } assertEquals( expectedChain, readChain ); } }
@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 ); }
private void markRandomRelsInChainNotInUse( long relId ) { if ( relId != NO_NEXT_RELATIONSHIP.intValue() ) { RelationshipRecord record = getRelRecord( relId ); boolean shouldBeMarked = random.nextBoolean(); if ( shouldBeMarked ) { record.setInUse( false ); update( record ); } markRandomRelsInChainNotInUse( record.getFirstNextRel() ); boolean isLoopRelationship = record.getFirstNextRel() == record.getSecondNextRel(); if ( !isLoopRelationship ) { markRandomRelsInChainNotInUse( record.getSecondNextRel() ); } } }
private static int manuallyCountRelationships( RecordChangeSet recordChangeSet, long nodeId, long firstRelId ) { int count = 0; long relId = firstRelId; while ( relId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { count++; RelationshipRecord record = recordChangeSet.getRelRecords().getOrLoad( relId, null ).forReadingData(); relId = record.getFirstNode() == nodeId ? record.getFirstNextRel() : record.getSecondNextRel(); } return count; }
@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() ) ); }
relationshipReference = edge.getSecondNextRel();
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() ); }
@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 secondPrevRelMod = secondPrevRel == Record.NO_NEXT_RELATIONSHIP.intValue() ? 0 : (secondPrevRel & 0x700000000L) >> 13; long secondNextRel = record.getSecondNextRel(); long secondNextRelMod = secondNextRel == Record.NO_NEXT_RELATIONSHIP.intValue() ? 0 : (secondNextRel & 0x700000000L) >> 16;
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.getSecondNextRel() , 1 ); updateCacheCounts( cache2Free, cacheAccess );
endNode.setNextRel( rel.getSecondNextRel() ); dir.setNextRel( group, rel.getSecondNextRel() ); if ( groupIsEmpty( group ) )
@Override long get( RelationshipRecord rel ) { return rel.getSecondNextRel(); }
@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)); }
@Override protected byte headerBits( RelationshipRecord record ) { byte header = 0; header = set( header, FIRST_IN_FIRST_CHAIN_BIT, record.isFirstInFirstChain() ); header = set( header, FIRST_IN_SECOND_CHAIN_BIT, record.isFirstInSecondChain() ); header = set( header, HAS_PROPERTY_BIT, record.getNextProp(), NULL ); header = set( header, HAS_FIRST_CHAIN_NEXT_BIT, record.getFirstNextRel(), NULL ); header = set( header, HAS_SECOND_CHAIN_NEXT_BIT, record.getSecondNextRel(), NULL ); return header; }