|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.buckets.Bucket
messif.buckets.LocalBucket
messif.buckets.impl.AlgorithmStorageBucket
public class AlgorithmStorageBucket
This is a LocalBucket that allows to create buckets backed by an Algorithm. The algorithm should be able to execute the following operations: InsertOperation DeleteOperation GetAllObjectsQueryOperation GetObjectQueryOperation All other query operations are first tried on the encapsulated algorithm and if they are not supported, they are evaluated by the standard mechanism.
Field Summary |
---|
Fields inherited from class messif.buckets.LocalBucket |
---|
counterBucketAddObject, counterBucketDelObject, counterBucketRead |
Constructor Summary | |
---|---|
AlgorithmStorageBucket(Algorithm algorithm,
long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes)
Creates a new instance of AlgorithmStorageBucket and setups all bucket limits. |
Method Summary | ||
---|---|---|
boolean |
add(LocalAbstractObject object)
Stores the specified object in the encapsulated algorithm, i.e. |
|
int |
addObjects(java.util.Collection<? extends LocalAbstractObject> objects)
Insert several new objects into this bucket. |
|
int |
addObjects(java.util.Iterator<? extends LocalAbstractObject> objects)
Insert several new objects to this bucket. |
|
protected static Algorithm |
createAlgorithmFromParams(java.lang.Class<? extends Algorithm> algClass,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Creates an algorithm of the specified class with map of parameters. |
|
protected static Algorithm |
createAlgorithmFromParams(java.lang.String algClassName,
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. |
|
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. |
|
|
search(IndexComparator<? super C,? super LocalAbstractObject> comparator,
C key)
Returns a search for objects in this index that have any of the specified keys. |
|
|
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. |
|
|
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. |
Methods inherited from class messif.buckets.LocalBucket |
---|
addObject, addObject, addObjectErrCode, deleteAllObjects, deleteObject, deleteObject, deregisterFilter, getAllObjects, getBucketID, getCapacity, getFilter, getIndex, getLowOccupation, getObject, getObject, getObject, getObjectCount, getOccupation, getOccupationRatio, getSoftCapacity, isBucketStandalone, isSoftCapacityExceeded, registerFilter, setLowOccupation, setSoftCapacity, toString |
Methods inherited from class messif.buckets.Bucket |
---|
deleteObject, deleteObjects, provideObjects |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AlgorithmStorageBucket(Algorithm algorithm, long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes)
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 objectsMethod Detail |
---|
public 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.lang.Class<? extends Algorithm> algClass, java.util.Map<java.lang.String,java.lang.Object> parameters) throws java.lang.IllegalArgumentException
algClass
- the class of the algorithm that is createdparameters
- the parameters for the algorithm constructor
java.lang.IllegalArgumentException
- if the parameter map contains invalid values or the instantiation of algorithm failsprotected static Algorithm createAlgorithmFromParams(java.lang.String algClassName, java.util.Map<java.lang.String,java.lang.Object> parameters) throws java.lang.IllegalArgumentException
algClassName
- the name of the class of the algorithm that is createdparameters
- the parameters for the algorithm constructor
java.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 inserted
BucketErrorCode
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.Collection<? extends LocalAbstractObject> objects) throws BucketStorageException
Bucket
addObjects
in class Bucket
objects
- the collection of new objects
BucketStorageException
- if there was an object that cannot be inserted into the bucketpublic int addObjects(java.util.Iterator<? extends LocalAbstractObject> objects) throws BucketStorageException
Bucket
addObjects
in class Bucket
objects
- iterator that provides the new objects to insert
BucketStorageException
- 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 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 for
java.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 returned
java.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 bucket
java.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.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 buckets
BucketStorageException
- if there was a storage error (capacity overflow/underflow or filter reject) during split
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |