@Override public void setNextRel( RelationshipGroupRecord group, long firstNextRel ) { group.setFirstOut( firstNextRel ); } },
public static Consumer<RelationshipGroupRecord> firstOut( long id ) { return g -> g.setFirstOut( id ); }
protected static RelationshipGroupRecord withRelationships( RelationshipGroupRecord group, long out, long in, long loop ) { group.setFirstOut( out ); group.setFirstIn( in ); group.setFirstLoop( loop ); return group; }
protected static RelationshipGroupRecord withRelationship( RelationshipGroupRecord group, Direction direction, long rel ) { switch ( direction ) { case OUTGOING: group.setFirstOut( rel ); break; case INCOMING: group.setFirstIn( rel ); break; case BOTH: group.setFirstLoop( rel ); break; default: throw new IllegalArgumentException( direction.name() ); } return group; }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
invocation.<RelationshipGroupRecord>getArgument( 0 ).setFirstOut( 1 ); return null; } ).when( store ).prepareForCommit( any( RelationshipGroupRecord.class ) );
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }
@Test public void shouldHandleGroupCountBeyondSignedShortRange() { // GIVEN long nodeId = 0; int limit = Short.MAX_VALUE + 10; RelationshipGroupCache cache = new RelationshipGroupCache( HEAP, ByteUnit.kibiBytes( 100 ), nodeId + 1 ); // WHEN first counting all groups per node for ( int type = 0; type < limit; type++ ) { cache.incrementGroupCount( nodeId ); } // and WHEN later putting group records into the cache RelationshipGroupRecord group = new RelationshipGroupRecord( -1 ); group.setOwningNode( nodeId ); for ( int type = 0; type < limit; type++ ) { group.setId( type ); group.setFirstOut( type ); // just some relationship group.setType( type ); cache.put( group ); } long prepared = cache.prepare( nodeId ); // THEN that should work, because it used to fail inside prepare, but we can also ask // the groupCount method to be sure assertEquals( nodeId, prepared ); assertEquals( limit, cache.groupCount( nodeId ) ); }
@Override public void setNextRel( RelationshipGroupRecord group, long firstNextRel ) { group.setFirstOut( firstNextRel ); } },
protected static RelationshipGroupRecord withRelationships( RelationshipGroupRecord group, long out, long in, long loop ) { group.setFirstOut( out ); group.setFirstIn( in ); group.setFirstLoop( loop ); return group; }
protected static RelationshipGroupRecord withRelationship( RelationshipGroupRecord group, Direction direction, long rel ) { switch ( direction ) { case OUTGOING: group.setFirstOut( rel ); break; case INCOMING: group.setFirstIn( rel ); break; case BOTH: group.setFirstLoop( rel ); break; default: throw new IllegalArgumentException( direction.name() ); } return group; }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }