public class AlgorithmStorageBucket extends LocalBucket implements ModifiableIndex<LocalAbstractObject>
counterBucketAddObject, counterBucketDelObject, counterBucketRead
Constructor and Description |
---|
AlgorithmStorageBucket(Algorithm algorithm,
long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes)
Creates a new instance of AlgorithmStorageBucket and setups all bucket limits.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(LocalAbstractObject object)
Stores the specified object in the encapsulated algorithm, i.e.
|
int |
addObjects(java.util.Iterator<? extends LocalAbstractObject> objects)
Insert several new objects to this bucket.
|
protected static Algorithm |
createAlgorithmFromParams(java.util.Map<java.lang.String,java.lang.Object> parameters)
Creates an algorithm of the specified class with map of parameters.
|
int |
deleteObject(LocalAbstractObject object,
int deleteLimit)
Removes the given object by calling
DeleteOperation on the
encapsulated algorithm. |
int |
deleteObject(java.lang.String locatorURI,
int deleteLimit)
Removes the given object by calling
DeleteByLocatorOperation on the
encapsulated algorithm. |
void |
destroy()
Destroy this bucket.
|
void |
finalize()
Clean up bucket internals before deletion.
|
Algorithm |
getAlgorithm()
Return the instance of the algorithm encapsulated by this bucket
|
static AlgorithmStorageBucket |
getBucket(long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Creates a new algorithm bucket.
|
protected ModifiableIndex<LocalAbstractObject> |
getModifiableIndex()
Returns the index (including storage) for this bucket.
|
int |
processQuery(QueryOperation<?> query)
Process a query operation on objects from this bucket.
|
ModifiableSearch<LocalAbstractObject> |
search()
Returns a search for all objects in this index.
|
<C> ModifiableSearch<LocalAbstractObject> |
search(IndexComparator<? super C,? super LocalAbstractObject> comparator,
C key)
Returns a search for objects in this index that have any of the specified keys.
|
<C> ModifiableSearch<LocalAbstractObject> |
search(IndexComparator<? super C,? super LocalAbstractObject> comparator,
C from,
C to)
Returns a search for objects in this index that are within the specified key-range.
|
<C> ModifiableSearch<LocalAbstractObject> |
search(IndexComparator<? super C,? super LocalAbstractObject> comparator,
java.util.Collection<? extends C> keys)
Returns a search for objects in this index that have any of the specified keys.
|
int |
size()
Returns current number of objects in this index.
|
int |
split(SplitPolicy policy,
java.util.List<Bucket> targetBuckets,
BucketDispatcher bucketCreator,
int whoStays)
Splits this bucket according to the specified policy.
|
addObject, addObject, addObjectErrCode, deleteAllObjects, deleteObject, deleteObjects, deregisterFilter, getAllObjects, getBucketID, getCapacity, getFilter, getIndex, getLowOccupation, getObject, getObject, getObjectCount, getOccupation, getOccupationRatio, getSoftCapacity, isBucketStandalone, isSoftCapacityExceeded, registerFilter, setLowOccupation, setSoftCapacity, toString
addObjects, deleteObject, deleteObject, provideObjects
public AlgorithmStorageBucket(Algorithm algorithm, long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes) throws AlgorithmMethodException
algorithm
- encapsulated algorithm that will actually do the jobcapacity
- maximal capacity of the bucket - cannot be exceededsoftCapacity
- maximal soft capacity of the bucketlowOccupation
- a minimal occupation for deleting objects - cannot be loweredoccupationAsBytes
- flag whether the occupation (and thus all the limits) are in bytes or number of objectsAlgorithmMethodException
- if there was a problem executing an operation on the algorithmpublic void finalize() throws java.lang.Throwable
finalize
in interface ModifiableIndex<LocalAbstractObject>
finalize
in class LocalBucket
java.lang.Throwable
- if there was an error during releasing resourcespublic void destroy() throws java.lang.Throwable
LocalBucket
BucketDispatcher
when the bucket is removed
from the dispatcher.destroy
in interface ModifiableIndex<LocalAbstractObject>
destroy
in class LocalBucket
java.lang.Throwable
- if there was an error while cleaningpublic static AlgorithmStorageBucket getBucket(long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes, java.util.Map<java.lang.String,java.lang.Object> parameters) throws java.lang.IllegalArgumentException
capacity
- maximal capacity of the bucket - cannot be exceededsoftCapacity
- maximal soft capacity of the bucketlowOccupation
- a minimal occupation for deleting objects - cannot be loweredoccupationAsBytes
- flag whether the occupation (and thus all the limits) are in bytes or number of objectsparameters
- list of named parameters - this bucket supports "file" and "path" (see above)java.lang.IllegalArgumentException
- if the parameters from the parameters
map are invalid and the
backing algorithm stub cannot be createdprotected static Algorithm createAlgorithmFromParams(java.util.Map<java.lang.String,java.lang.Object> parameters) throws java.lang.IllegalArgumentException
parameters
- the parameters for the algorithm constructorjava.lang.IllegalArgumentException
- if the parameter map contains invalid values or the instantiation of algorithm failsprotected ModifiableIndex<LocalAbstractObject> getModifiableIndex()
LocalBucket
getModifiableIndex
in class LocalBucket
public int size()
Index
size
in interface Index<LocalAbstractObject>
public Algorithm getAlgorithm()
public boolean add(LocalAbstractObject object) throws BucketStorageException
add
in interface Addible<LocalAbstractObject>
object
- The new object to be insertedBucketErrorCode
BucketStorageException
- if there was an error storing the object to the encapsulated algorithm,
e.g. the encapsulated algorithm does not support InsertOperationpublic int addObjects(java.util.Iterator<? extends LocalAbstractObject> objects) throws BucketStorageException
Bucket
addObjects
in class Bucket
objects
- iterator that provides the new objects to insertBucketStorageException
- if there was an object that cannot be inserted into the bucketpublic int deleteObject(LocalAbstractObject object, int deleteLimit) throws BucketStorageException
DeleteOperation
on the
encapsulated algorithm.deleteObject
in class LocalBucket
object
- the object to deletedeleteLimit
- the maximal number of deleted objects (zero means unlimited)BucketStorageException
- if the algorithm does not support delete operation or there was an error deleting the objectpublic int deleteObject(java.lang.String locatorURI, int deleteLimit) throws BucketStorageException
DeleteByLocatorOperation
on the
encapsulated algorithm.deleteObject
in class LocalBucket
locatorURI
- the object locator to matchdeleteLimit
- the maximal number of deleted objects (zero means unlimited)BucketStorageException
- if the algorithm does not support delete operation or there was an error deleting the objectpublic ModifiableSearch<LocalAbstractObject> search() throws java.lang.IllegalStateException
Index
search
in interface Index<LocalAbstractObject>
search
in interface ModifiableIndex<LocalAbstractObject>
java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic <C> ModifiableSearch<LocalAbstractObject> search(IndexComparator<? super C,? super LocalAbstractObject> comparator, C key) throws java.lang.IllegalStateException
Index
key
need not necessarily be of the same class as the objects stored
in this index and also consistency with equals
is not required.
Note that objects are not necessarily returned in the order defined by the comparator
search
in interface Index<LocalAbstractObject>
search
in interface ModifiableIndex<LocalAbstractObject>
C
- the type of the key used by the searchcomparator
- compares the key
with the stored objectskey
- the key to search forjava.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic <C> ModifiableSearch<LocalAbstractObject> search(IndexComparator<? super C,? super LocalAbstractObject> comparator, java.util.Collection<? extends C> keys) throws java.lang.IllegalStateException
Index
key
need not necessarily be of the same class as the objects stored
in this index and also consistency with equals
is not required.
Note that objects are not necessarily returned in the order defined by the comparator
search
in interface Index<LocalAbstractObject>
search
in interface ModifiableIndex<LocalAbstractObject>
C
- the type of the keys used by the searchcomparator
- compares the keys
with the stored objectskeys
- the keys to search for (at least one key must be given)java.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic <C> ModifiableSearch<LocalAbstractObject> search(IndexComparator<? super C,? super LocalAbstractObject> comparator, C from, C to) throws java.lang.IllegalStateException
Index
[from, to]
need not necessarily be of the same
class as the objects stored in this index, however, the comparator must be
able to compare the boundaries and the internal objects.
Note that objects are not returned in the order defined by the comparator
search
in interface Index<LocalAbstractObject>
search
in interface ModifiableIndex<LocalAbstractObject>
C
- the type the boundaries used by the searchcomparator
- compares the boundaries [from, to]
with the stored objectsfrom
- the lower bound on the searched objects, i.e. objects greater or equal are returnedto
- the upper bound on the searched objects, i.e. objects smaller or equal are returnedjava.lang.IllegalStateException
- if there was an error initializing the search on this indexpublic int processQuery(QueryOperation<?> query) throws java.lang.UnsupportedOperationException
processQuery
in class Bucket
query
- query operation that is to be processed on this bucketjava.lang.UnsupportedOperationException
- if the specified query is not supported by the encapsulated algorithmpublic int split(SplitPolicy policy, java.util.List<Bucket> targetBuckets, BucketDispatcher bucketCreator, int whoStays) throws java.lang.IllegalArgumentException, BucketStorageException
SplittableAlgorithm
interface and the bucketCreator is provided,
the split method of the algorithm will be called to perform the split. Otherwise, the standard Bucket's Bucket.split(messif.buckets.split.SplitPolicy, java.util.List<messif.buckets.Bucket>, messif.buckets.BucketDispatcher, int)
is executed.split
in class Bucket
policy
- the split policy used to split this buckettargetBuckets
- the list of target buckets that will receive the list of created bucketsbucketCreator
- the bucket dispatcher to use when creating target bucketswhoStays
- identification of a partition whose objects stay in this bucket.java.lang.IllegalArgumentException
- if there are too few target bucketsBucketStorageException
- if there was a storage error (capacity overflow/underflow or filter reject) during split