messif.buckets.impl
Class MemoryStorageNoDupsBucket
java.lang.Object
messif.buckets.Bucket
messif.buckets.LocalBucket
messif.buckets.OrderedLocalBucket<LocalAbstractObject>
messif.buckets.impl.MemoryStorageNoDupsBucket
- All Implemented Interfaces:
- java.io.Serializable, ObjectProvider<LocalAbstractObject>
public class MemoryStorageNoDupsBucket
- extends OrderedLocalBucket<LocalAbstractObject>
- implements java.io.Serializable
A volatile implementation of LocalBucket
.
It stores all objects in a memory storage
.
Objects are indexed by their data
and
does not allow to store two objects with the same data. If an object that is
dataEquals
to
any object actually stored in the bucket, the addObject method will
throw DuplicateObjectException
.
This bucket has an efficient LocalBucket.deleteObject(messif.objects.LocalAbstractObject, int)
implementation
at the cost of additional memory overhead for maintaining the index.
If fast deleteObject
implementation is not required and
the iteration over all objects is used frequently, consider using
MemoryStorageBucket
.
- See Also:
BucketDispatcher
,
LocalBucket
,
Serialized Form
Constructor Summary |
MemoryStorageNoDupsBucket(long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes)
Constructs a new instance of MemoryStorageNoDupsBucket. |
Methods inherited from class messif.buckets.LocalBucket |
addObject, addObject, addObjectErrCode, deleteAllObjects, deleteObject, deleteObject, deleteObject, deregisterFilter, getAllObjects, getBucketID, getCapacity, getFilter, getLowOccupation, getObject, getObject, getObject, getObjectCount, getOccupation, getOccupationRatio, getSoftCapacity, isBucketStandalone, isSoftCapacityExceeded, registerFilter, setLowOccupation, setSoftCapacity, toString |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
objects
protected ModifiableOrderedIndex<LocalAbstractObject,LocalAbstractObject> objects
- Object storage with object-id index
MemoryStorageNoDupsBucket
public MemoryStorageNoDupsBucket(long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes)
- Constructs a new instance of MemoryStorageNoDupsBucket.
- Parameters:
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 objects
getModifiableIndex
protected ModifiableOrderedIndex<LocalAbstractObject,LocalAbstractObject> getModifiableIndex()
- Description copied from class:
LocalBucket
- Returns the index (including storage) for this bucket.
The index provides the access to the underlying storage of objects in this bucket.
- Specified by:
getModifiableIndex
in class OrderedLocalBucket<LocalAbstractObject>
- Returns:
- the index for this bucket
finalize
public void finalize()
throws java.lang.Throwable
- Description copied from class:
LocalBucket
- Finalize this bucket. All transient resources associated with this
bucket are released.
After this method is called, the bucket methods' behavior is unpredictable.
This method is called by the
BucketDispatcher
when it is finalized.
- Overrides:
finalize
in class LocalBucket
- Throws:
java.lang.Throwable
- if there was an error while cleaning
destroy
public void destroy()
throws java.lang.Throwable
- Description copied from class:
LocalBucket
- Destroy this bucket. This method releases all resources (transient and persistent)
associated with this bucket (e.g. the statistics and all objects are deleted).
After this method is called, the bucket methods' behavior is unpredictable.
This method is called by the
BucketDispatcher
when the bucket is removed
from the dispatcher.
- Overrides:
destroy
in class LocalBucket
- Throws:
java.lang.Throwable
- if there was an error while cleaning