public class BlueCollectionOnDisk<T extends java.io.Serializable> extends java.lang.Object implements BlueCollection<T>, Rollupable
Constructor and Description |
---|
BlueCollectionOnDisk(BlueDbOnDisk db,
java.lang.String name,
java.lang.Class<? extends BlueKey> requestedKeyType,
java.lang.Class<T> valueType,
java.util.List<java.lang.Class<? extends java.io.Serializable>> additionalRegisteredClasses) |
BlueCollectionOnDisk(BlueDbOnDisk db,
java.lang.String name,
java.lang.Class<? extends BlueKey> requestedKeyType,
java.lang.Class<T> valueType,
java.util.List<java.lang.Class<? extends java.io.Serializable>> additionalRegisteredClasses,
SegmentSizeSetting segmentSize) |
Modifier and Type | Method and Description |
---|---|
void |
batchDelete(java.util.Collection<BlueKey> keys)
Deletes the values for the given keys.
|
void |
batchUpsert(java.util.Map<BlueKey,T> values)
Inserts or replaces the given key value pairs.
|
boolean |
contains(BlueKey key)
Returns true if the collection contains a value for the given key.
|
<I extends ValueKey> |
createIndex(java.lang.String name,
java.lang.Class<I> keyType,
KeyExtractor<I,T> keyExtractor)
|
void |
delete(BlueKey key)
Deletes the value for the given key
|
protected static java.lang.Class<? extends BlueKey> |
determineKeyType(CollectionMetaData metaData,
java.lang.Class<? extends BlueKey> providedKeyType) |
protected static SegmentSizeSetting |
determineSegmentSize(CollectionMetaData metaData,
java.lang.Class<? extends BlueKey> keyType,
SegmentSizeSetting requestedSegmentSize,
boolean isNewCollection) |
protected void |
ensureCorrectKeyType(BlueKey key) |
protected void |
ensureCorrectKeyTypes(java.util.Collection<BlueKey> keys) |
void |
executeTask(java.lang.Runnable task) |
java.util.List<BlueEntity<T>> |
findMatches(Range range,
java.util.List<Condition<T>> conditions,
boolean byStartTime) |
T |
get(BlueKey key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key
|
FileManager |
getFileManager() |
<I extends ValueKey> |
getIndex(java.lang.String indexName,
java.lang.Class<I> keyType)
Returns existing BlueIndex that maps objects of type keyType to values in the collection.
|
IndexManager<T> |
getIndexManager() |
java.lang.Class<? extends BlueKey> |
getKeyType() |
BlueKey |
getLastKey()
Returns the key with the highest grouping number that exists in this collection
|
CollectionMetaData |
getMetaData() |
java.nio.file.Path |
getPath() |
int |
getQueuedTaskCount() |
RecoveryManager<T> |
getRecoveryManager() |
RollupScheduler |
getRollupScheduler() |
SegmentManager<T> |
getSegmentManager() |
BlueSerializer |
getSerializer() |
BlueExecutor |
getSharedExecutor() |
java.lang.Class<T> |
getType() |
void |
insert(BlueKey key,
T value)
Inserts the given key value pair
|
BlueQuery<T> |
query()
Creates a
BlueQuery object which can be used to build and execute a query against this collection. |
void |
replace(BlueKey key,
Mapper<T> mapper)
Replaces the value for the given key by passing it to the given updater
|
void |
reportReads(java.util.List<RollupTarget> rollupTargets) |
void |
reportWrites(java.util.List<RollupTarget> rollupTargets) |
void |
rollup(Range timeRange) |
void |
rollupIndex(java.lang.String indexName,
Range range) |
void |
submitTask(java.lang.Runnable task) |
void |
update(BlueKey key,
Updater<T> updater)
Mutates the value for the given key by passing it to the given updater
|
public BlueCollectionOnDisk(BlueDbOnDisk db, java.lang.String name, java.lang.Class<? extends BlueKey> requestedKeyType, java.lang.Class<T> valueType, java.util.List<java.lang.Class<? extends java.io.Serializable>> additionalRegisteredClasses) throws BlueDbException
BlueDbException
public BlueCollectionOnDisk(BlueDbOnDisk db, java.lang.String name, java.lang.Class<? extends BlueKey> requestedKeyType, java.lang.Class<T> valueType, java.util.List<java.lang.Class<? extends java.io.Serializable>> additionalRegisteredClasses, SegmentSizeSetting segmentSize) throws BlueDbException
BlueDbException
public int getQueuedTaskCount()
public BlueQuery<T> query()
BlueCollection
BlueQuery
object which can be used to build and execute a query against this collection.query
in interface BlueCollection<T extends java.io.Serializable>
BlueQuery
object which can be used to build and execute a query against this collection.public boolean contains(BlueKey key) throws BlueDbException
BlueCollection
contains
in interface BlueCollection<T extends java.io.Serializable>
key
- the key that may or may not be in collectionBlueDbException
- if the type of key was not the type specified when the collection was createdpublic T get(BlueKey key) throws BlueDbException
BlueCollection
get
in interface BlueCollection<T extends java.io.Serializable>
key
- the key for the desired valueBlueDbException
- if the key is not the same type specified when the collection was createdpublic void insert(BlueKey key, T value) throws BlueDbException
BlueCollection
insert
in interface BlueCollection<T extends java.io.Serializable>
key
- key where value should be saved (must match the keyType specified when the collection was created)value
- value to be saved for the keyBlueDbException
- if the key type is not the type specified when the collection was createdpublic void batchUpsert(java.util.Map<BlueKey,T> values) throws BlueDbException
BlueCollection
batchUpsert
in interface BlueCollection<T extends java.io.Serializable>
values
- the key value pairs to insert. Key types must match the keyType specified when the collection was created.BlueDbException
- if the key types do not match the type specified when the collection was createdpublic void batchDelete(java.util.Collection<BlueKey> keys) throws BlueDbException
BlueCollection
batchDelete
in interface BlueCollection<T extends java.io.Serializable>
keys
- the keys for the values which will be deletedBlueDbException
- if type of key is not the type specified when the collection was createdpublic void replace(BlueKey key, Mapper<T> mapper) throws BlueDbException
BlueCollection
replace
in interface BlueCollection<T extends java.io.Serializable>
key
- the key for the value which will be replacedmapper
- a function that returns the value that should replace the value to which the specified key is mappedBlueDbException
- if type of key is not the type specified when the collection was created or if updater throws an exceptionpublic void update(BlueKey key, Updater<T> updater) throws BlueDbException
BlueCollection
update
in interface BlueCollection<T extends java.io.Serializable>
key
- The key for the value which will be updatedupdater
- a function that mutates the value to which the specified key is mappedBlueDbException
- if type of key is not the type specified when the collection was created or if updater throws an exceptionpublic void delete(BlueKey key) throws BlueDbException
BlueCollection
delete
in interface BlueCollection<T extends java.io.Serializable>
key
- the key for the value which will be deletedBlueDbException
- if type of key is not the type specified when the collection was createdpublic BlueKey getLastKey()
BlueCollection
getLastKey
in interface BlueCollection<T extends java.io.Serializable>
public java.util.List<BlueEntity<T>> findMatches(Range range, java.util.List<Condition<T>> conditions, boolean byStartTime) throws BlueDbException
BlueDbException
public BlueExecutor getSharedExecutor()
public void submitTask(java.lang.Runnable task)
public void executeTask(java.lang.Runnable task) throws BlueDbException
BlueDbException
public void rollup(Range timeRange) throws BlueDbException
BlueDbException
public SegmentManager<T> getSegmentManager()
public RecoveryManager<T> getRecoveryManager()
public java.nio.file.Path getPath()
public FileManager getFileManager()
public BlueSerializer getSerializer()
public CollectionMetaData getMetaData()
public java.lang.Class<T> getType()
public java.lang.Class<? extends BlueKey> getKeyType()
protected void ensureCorrectKeyType(BlueKey key) throws BlueDbException
BlueDbException
protected void ensureCorrectKeyTypes(java.util.Collection<BlueKey> keys) throws BlueDbException
BlueDbException
protected static SegmentSizeSetting determineSegmentSize(CollectionMetaData metaData, java.lang.Class<? extends BlueKey> keyType, SegmentSizeSetting requestedSegmentSize, boolean isNewCollection) throws BlueDbException
BlueDbException
protected static java.lang.Class<? extends BlueKey> determineKeyType(CollectionMetaData metaData, java.lang.Class<? extends BlueKey> providedKeyType) throws BlueDbException
BlueDbException
public <I extends ValueKey> BlueIndex<I,T> createIndex(java.lang.String name, java.lang.Class<I> keyType, KeyExtractor<I,T> keyExtractor) throws BlueDbException
BlueCollection
BlueIndex
that maps objects of type ValueKey
(UUIDKey
, StringKey
, IntegerKey
, LongKey
) to values in the collection.createIndex
in interface BlueCollection<T extends java.io.Serializable>
I
- the key type of the index or the type of data that the collection is being indexed on. It must be a concretion of
ValueKey
(UUIDKey
, StringKey
, LongKey
, or IntegerKey
).name
- index name (one index per name per each collection)keyType
- the type of each key which is used to lookup a value using the index (this must match the keyType of any existing index with the same name)keyExtractor
- a function that maps a value to the keys by which the value should be indexed. The appropriate subclass can be used and would be more
simple to implement. These include UUIDIndexKeyExtractor
, StringIndexKeyExtractor
, IntegerIndexKeyExtractor
, and LongIndexKeyExtractor
BlueIndex
object (existing index if it exists, otherwise a newly created index)BlueDbException
- if the index exists but is not compatible with these typespublic <I extends ValueKey> BlueIndex<I,T> getIndex(java.lang.String indexName, java.lang.Class<I> keyType) throws BlueDbException
BlueCollection
getIndex
in interface BlueCollection<T extends java.io.Serializable>
I
- the key type of the index or the type of data that the collection is being indexed on. It must be a concretion of
ValueKey
(UUIDKey
, StringKey
, LongKey
, or IntegerKey
).indexName
- index name (one index per name per each collection)keyType
- the type of each key which is used to lookup a value using the index (this must match the keyType of any existing index with the same name)BlueIndex
with the same name if it exists and has the same keyTypeBlueDbException
- if index doesn't exist or has a different keyTypepublic void rollupIndex(java.lang.String indexName, Range range) throws BlueDbException
BlueDbException
public IndexManager<T> getIndexManager()
public void reportReads(java.util.List<RollupTarget> rollupTargets)
reportReads
in interface Rollupable
public void reportWrites(java.util.List<RollupTarget> rollupTargets)
reportWrites
in interface Rollupable
public RollupScheduler getRollupScheduler()