@Override public RelationshipGroupRecord newUnused( long key, Integer type ) { RelationshipGroupRecord record = new RelationshipGroupRecord( key ); record.setType( type ); return andMarkAsCreated( record ); }
public static RecordChangeSet newChangeSet( AbstractBaseRecord... records ) { return new RecordChangeSet( new Loader( filterType( records, NodeRecord.class ).collect( Collectors.toList() ), (BiFunction<Long,Object,NodeRecord>) ( key, extra ) -> new NodeRecord( key ) ), null, new Loader( filterType( records, RelationshipRecord.class ).collect( Collectors.toList() ), (BiFunction<Long,Object,RelationshipRecord>) ( key, extra ) -> new RelationshipRecord( key ) ), new Loader( filterType( records, RelationshipGroupRecord.class ).collect( Collectors.toList() ), (BiFunction<Long,Integer,RelationshipGroupRecord>) ( key, extra ) -> { RelationshipGroupRecord group = new RelationshipGroupRecord( key ); group.setType( extra ); return group; } ), null, null, null, null ); }
@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 RelationshipGroupRecord newUnused( long key, Integer type ) { RelationshipGroupRecord record = new RelationshipGroupRecord( key ); record.setType( type ); return andMarkAsCreated( record ); }