public abstract class Bucket extends java.lang.Object implements ObjectProvider<LocalAbstractObject>
LocalBucket
,
RemoteBucket
Constructor and Description |
---|
Bucket() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addObject(LocalAbstractObject object)
Insert a new object into this bucket.
|
BucketErrorCode |
addObjectErrCode(LocalAbstractObject object)
Insert a new object into this bucket and returns error code instead of exception.
|
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.
|
abstract int |
deleteAllObjects()
Delete all objects from this bucket.
|
int |
deleteObject(LocalAbstractObject object)
Delete all objects from this bucket that are
data-equals to
the specified object. |
abstract int |
deleteObject(LocalAbstractObject object,
int deleteLimit)
Delete all objects from this bucket that are
data-equals to
the specified object. |
int |
deleteObject(java.lang.String locatorURI)
Delete all objects from this bucket that have the specified
locatorURI . |
abstract int |
deleteObject(java.lang.String locatorURI,
int deleteLimit)
Delete all objects from this bucket that have the specified
locatorURI . |
abstract AbstractObjectIterator<LocalAbstractObject> |
getAllObjects()
Returns iterator over all objects from this bucket.
|
abstract int |
getBucketID()
Returns the unique ID of this bucket.
|
abstract LocalAbstractObject |
getObject(AbstractObjectKey key)
Retrieve an object with the specified key from this bucket.
|
abstract LocalAbstractObject |
getObject(java.lang.String locator)
Retrieve an object with the specified locator from this bucket.
|
int |
processQuery(QueryOperation<?> query)
Process a query operation on objects from this bucket.
|
AbstractObjectIterator<LocalAbstractObject> |
provideObjects()
The iterator for provided objects for ObjectProvider interface.
|
int |
split(SplitPolicy policy,
java.util.List<Bucket> targetBuckets,
BucketDispatcher bucketCreator,
int whoStays)
Splits this bucket according to the specified policy.
|
public abstract int getBucketID()
public abstract void addObject(LocalAbstractObject object) throws BucketStorageException
object
- a new object to be insertedBucketStorageException
- if the object cannot be inserted into the bucketpublic BucketErrorCode addObjectErrCode(LocalAbstractObject object)
object
- the new object to be insertedpublic int addObjects(java.util.Collection<? extends LocalAbstractObject> objects) throws BucketStorageException
objects
- the collection of new objectsBucketStorageException
- if there was an object that cannot be inserted into the bucketpublic int addObjects(java.util.Iterator<? extends LocalAbstractObject> objects) throws BucketStorageException
objects
- iterator that provides the new objects to insertBucketStorageException
- if there was an object that cannot be inserted into the bucketpublic abstract int deleteObject(LocalAbstractObject object, int deleteLimit) throws BucketStorageException
data-equals
to
the specified object. If deleteLimit
is greater than zero, only the first deleteLimit
data-equal objects found are deleted.object
- the object to match againstdeleteLimit
- the maximal number of deleted objects (zero means unlimited)BucketStorageException
- if there was an object that cannot be deleted from the bucketpublic abstract int deleteObject(java.lang.String locatorURI, int deleteLimit) throws BucketStorageException
locatorURI
.
If deleteLimit
is greater than zero, only the first deleteLimit
objects with the given locator are deleted.locatorURI
- the object locator to matchdeleteLimit
- the maximal number of deleted objects (zero means unlimited)BucketStorageException
- if there was an object that cannot be deleted from the bucketpublic final int deleteObject(java.lang.String locatorURI) throws BucketStorageException
locatorURI
.locatorURI
- the object locator to matchBucketStorageException
- if there was an object that cannot be deleted from the bucketpublic final int deleteObject(LocalAbstractObject object) throws BucketStorageException
data-equals
to
the specified object.object
- the object to match againstBucketStorageException
- if the object cannot be deleted from the bucketpublic abstract int deleteAllObjects() throws BucketStorageException
BucketStorageException
- if there was an object that cannot be deleted from the bucketpublic int split(SplitPolicy policy, java.util.List<Bucket> targetBuckets, BucketDispatcher bucketCreator, int whoStays) throws java.lang.IllegalArgumentException, BucketStorageException
targetBuckets
parameters.
The position is the value returned by the policy's matcher method.
The parameter whoStays
denotes the partition that corresponds to this
bucket, i.e.,
the objects marked with this number (whoStays
) by the policy's matcher are left in this bucket
and not moved to any new bucket (unless whoStays
is smaller than zero).
As a result, the whoStays
index in targetBuckets
is null
(if this index existed in targetBuckets
, it is left untouched).
ATTENTION: if whoStays
is lower than zero, than no objects are to
stay in this bucket and, due to efficiency, the objects are not removed from this bucket!
The list targetBuckets
is extended to contain all getPartitionsCount()
items.
The items corresponding to indexes that have not been returned by matcher for any object are initialized to null
(or left
untouched if the index have already existed).
If targetBuckets
is not initialized with references to buckets, the bucketCreator
must be able to create additional buckets.
Remark: to partition all objects to new buckets pass an empty instance of list in targetBuckets
and set whoStays
to
a negative value since the matcher returns non-negative values only.policy
- the split policy used to split this buckettargetBuckets
- the list of target buckets to split the objects tobucketCreator
- the bucket dispatcher to use when creating target buckets; can be null if the targetBuckets
has enough bucketswhoStays
- identification of a partition whose objects stay in this bucket; if lower than zero, no objects are to
stay in this bucket and, due to efficiency, the objects are not removed from this bucket!java.lang.IllegalArgumentException
- if there are too few target bucketsBucketStorageException
- if there was a storage error during objects
between buckets (including capacity overflow or underflow) during object move;
warning: the split is interrupted and should be reinitializedpublic abstract LocalAbstractObject getObject(java.lang.String locator) throws java.util.NoSuchElementException
locator
- the locator URI of the object to retrievejava.util.NoSuchElementException
- This exception is thrown if there is no object with the specified locator in this bucketpublic abstract LocalAbstractObject getObject(AbstractObjectKey key) throws java.util.NoSuchElementException
key
- the key of the object to retrievejava.util.NoSuchElementException
- This exception is thrown if there is no object with the specified key in this bucketpublic abstract AbstractObjectIterator<LocalAbstractObject> getAllObjects()
public int processQuery(QueryOperation<?> query)
query
- query operation that is to be processed on this bucketpublic AbstractObjectIterator<LocalAbstractObject> provideObjects()
provideObjects
in interface ObjectProvider<LocalAbstractObject>