@Override public IdGenerator get( IdType idType ) { return generators[idType.ordinal()]; } }
IdCapacityExceededException( IdType idType, long id, long maxId ) { super( format( "Maximum id limit for %s has been reached. Generated id %d is out of permitted range [0, %d].", idType.name(), id, maxId ) ); } }
IdAllocationState() { this( new long[IdType.values().length], -1L ); }
@Override public int hashCode() { int result = owner.hashCode(); result = 31 * result + idType.hashCode(); result = 31 * result + (int) (idRangeStart ^ (idRangeStart >>> 32)); result = 31 * result + idRangeLength; return result; }
IdAllocationState() { this( new long[IdType.values().length], -1L ); }
@Override public int hashCode() { int result = owner.hashCode(); result = 31 * result + idType.hashCode(); result = 31 * result + (int) (idRangeStart ^ (idRangeStart >>> 32)); result = 31 * result + idRangeLength; return result; }
@Override public IdGenerator get( IdType idType ) { IdGenerator generator = overriddenIdGenerators[idType.ordinal()]; return generator != null ? generator : delegate.get( idType ); }
private Map<IdType,Integer> getIdTypeAllocationSizeFromConfig( Config config ) { Map<IdType,Integer> allocationSizes = new HashMap<>( IdType.values().length ); allocationSizes.put( IdType.NODE, config.get( node_id_allocation_size ) ); allocationSizes.put( IdType.RELATIONSHIP, config.get( relationship_id_allocation_size ) ); allocationSizes.put( IdType.PROPERTY, config.get( property_id_allocation_size ) ); allocationSizes.put( IdType.STRING_BLOCK, config.get( string_block_id_allocation_size ) ); allocationSizes.put( IdType.ARRAY_BLOCK, config.get( array_block_id_allocation_size ) ); allocationSizes.put( IdType.PROPERTY_KEY_TOKEN, config.get( property_key_token_id_allocation_size ) ); allocationSizes.put( IdType.PROPERTY_KEY_TOKEN_NAME, config.get( property_key_token_name_id_allocation_size ) ); allocationSizes.put( IdType.RELATIONSHIP_TYPE_TOKEN, config.get( relationship_type_token_id_allocation_size ) ); allocationSizes.put( IdType.RELATIONSHIP_TYPE_TOKEN_NAME, config.get( relationship_type_token_name_id_allocation_size ) ); allocationSizes.put( IdType.LABEL_TOKEN, config.get( label_token_id_allocation_size ) ); allocationSizes.put( IdType.LABEL_TOKEN_NAME, config.get( label_token_name_id_allocation_size ) ); allocationSizes.put( IdType.NEOSTORE_BLOCK, config.get( neostore_block_id_allocation_size ) ); allocationSizes.put( IdType.SCHEMA, config.get( schema_id_allocation_size ) ); allocationSizes.put( IdType.NODE_LABELS, config.get( node_labels_id_allocation_size ) ); allocationSizes.put( IdType.RELATIONSHIP_GROUP, config.get( relationship_group_id_allocation_size ) ); return allocationSizes; }
IdCapacityExceededException( IdType idType, long id, long maxId ) { super( format( "Maximum id limit for %s has been reached. Generated id %d is out of permitted range [0, %d].", idType.name(), id, maxId ) ); } }
@Override public IdGenerator open( File filename, int grabSize, IdType idType, LongSupplier highId, long maxId ) { return generators[idType.ordinal()] = mock( IdGenerator.class ); }
private Map<IdType,Integer> getIdTypeAllocationSizeFromConfig( Config config ) { Map<IdType,Integer> allocationSizes = new HashMap<>( IdType.values().length ); allocationSizes.put( IdType.NODE, config.get( node_id_allocation_size ) ); allocationSizes.put( IdType.RELATIONSHIP, config.get( relationship_id_allocation_size ) ); allocationSizes.put( IdType.PROPERTY, config.get( property_id_allocation_size ) ); allocationSizes.put( IdType.STRING_BLOCK, config.get( string_block_id_allocation_size ) ); allocationSizes.put( IdType.ARRAY_BLOCK, config.get( array_block_id_allocation_size ) ); allocationSizes.put( IdType.PROPERTY_KEY_TOKEN, config.get( property_key_token_id_allocation_size ) ); allocationSizes.put( IdType.PROPERTY_KEY_TOKEN_NAME, config.get( property_key_token_name_id_allocation_size ) ); allocationSizes.put( IdType.RELATIONSHIP_TYPE_TOKEN, config.get( relationship_type_token_id_allocation_size ) ); allocationSizes.put( IdType.RELATIONSHIP_TYPE_TOKEN_NAME, config.get( relationship_type_token_name_id_allocation_size ) ); allocationSizes.put( IdType.LABEL_TOKEN, config.get( label_token_id_allocation_size ) ); allocationSizes.put( IdType.LABEL_TOKEN_NAME, config.get( label_token_name_id_allocation_size ) ); allocationSizes.put( IdType.NEOSTORE_BLOCK, config.get( neostore_block_id_allocation_size ) ); allocationSizes.put( IdType.SCHEMA, config.get( schema_id_allocation_size ) ); allocationSizes.put( IdType.NODE_LABELS, config.get( node_labels_id_allocation_size ) ); allocationSizes.put( IdType.RELATIONSHIP_GROUP, config.get( relationship_group_id_allocation_size ) ); return allocationSizes; }
@Override public IdGenerator open( File filename, int grabSize, IdType idType, LongSupplier highId, long maxId ) { assert boundaries != null : "Factory needs to be initialized before usage"; IdGenerator generator = delegate.open( filename, grabSize, idType, highId, maxId ); IdTypeConfiguration typeConfiguration = getIdTypeConfiguration(idType); if ( typeConfiguration.allowAggressiveReuse() ) { BufferingIdGenerator bufferingGenerator = new BufferingIdGenerator( generator ); bufferingGenerator.initialize( boundaries, safeThreshold ); overriddenIdGenerators[idType.ordinal()] = bufferingGenerator; generator = bufferingGenerator; } return generator; }
public static ReplicatedIdAllocationRequest unmarshal( ReadableChannel channel ) throws IOException, EndOfStreamException { MemberId owner = new MemberId.Marshal().unmarshal( channel ); IdType idType = IdType.values()[ channel.getInt() ]; long idRangeStart = channel.getLong(); int idRangeLength = channel.getInt(); return new ReplicatedIdAllocationRequest( owner, idType, idRangeStart, idRangeLength ); } }
/** * @param idType the type of graph object whose ID is under allocation * @return the first unallocated entry for idType */ @Override public long firstUnallocated( IdType idType ) { return firstUnallocated[idType.ordinal()]; }
public static ReplicatedIdAllocationRequest unmarshal( ReadableChannel channel ) throws IOException, EndOfStreamException { MemberId owner = new MemberId.Marshal().unmarshal( channel ); IdType idType = IdType.values()[ channel.getInt() ]; long idRangeStart = channel.getLong(); int idRangeLength = channel.getInt(); return new ReplicatedIdAllocationRequest( owner, idType, idRangeStart, idRangeLength ); } }
/** * @param idType the type of graph object whose ID is under allocation * @return the first unallocated entry for idType */ @Override public long firstUnallocated( IdType idType ) { return firstUnallocated[idType.ordinal()]; }
/** * @param idType the type of graph object whose ID is under allocation * @param idRangeEnd the first unallocated entry for idType */ void firstUnallocated( IdType idType, long idRangeEnd ) { firstUnallocated[idType.ordinal()] = idRangeEnd; }
/** * @param idType the type of graph object whose ID is under allocation * @param idRangeEnd the first unallocated entry for idType */ void firstUnallocated( IdType idType, long idRangeEnd ) { firstUnallocated[idType.ordinal()] = idRangeEnd; }
@Override public IdGenerator get( IdType idType ) { IdGenerator generator = overriddenIdGenerators[idType.ordinal()]; return generator != null ? generator : delegate.get( idType ); }
@Override public IdGenerator open( File filename, int grabSize, IdType idType, LongSupplier highId, long maxId ) { assert boundaries != null : "Factory needs to be initialized before usage"; IdGenerator generator = delegate.open( filename, grabSize, idType, highId, maxId ); IdTypeConfiguration typeConfiguration = getIdTypeConfiguration(idType); if ( typeConfiguration.allowAggressiveReuse() ) { BufferingIdGenerator bufferingGenerator = new BufferingIdGenerator( generator ); bufferingGenerator.initialize( boundaries, safeThreshold ); overriddenIdGenerators[idType.ordinal()] = bufferingGenerator; generator = bufferingGenerator; } return generator; }