protected static RelationshipGroupRecord withOwner( RelationshipGroupRecord record, long owner ) { record.setOwningNode( owner ); return record; }
public static Consumer<RelationshipGroupRecord> owningNode( long id ) { return g -> g.setOwningNode( id ); }
protected static List<RelationshipGroupRecord> groups( Group... groups ) { List<RelationshipGroupRecord> records = new ArrayList<>(); for ( Group group : groups ) { for ( int i = 0; i < group.count; i++ ) { RelationshipGroupRecord record = new RelationshipGroupRecord( NULL_REFERENCE.longValue() ); record.setOwningNode( group.owningNode ); record.setNext( group.count - i - 1 ); // count: how many come after it (importer does this) records.add( record ); } } return records; }
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; }
record.setInUse( true ); record.setCreated(); record.setOwningNode( node.getId() );
@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 ) ); }
protected static RelationshipGroupRecord withOwner( RelationshipGroupRecord record, long owner ) { record.setOwningNode( owner ); return 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 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; }
record.setInUse( true ); record.setCreated(); record.setOwningNode( node.getId() );