messif.buckets.impl
Class MemoryStorageNoDupsBucket

java.lang.Object
  extended by messif.buckets.Bucket
      extended by messif.buckets.LocalBucket
          extended by messif.buckets.OrderedLocalBucket<LocalAbstractObject>
              extended by 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

Field Summary
protected  ModifiableOrderedIndex<LocalAbstractObject,LocalAbstractObject> objects
          Object storage with object-id index
 
Fields inherited from class messif.buckets.LocalBucket
counterBucketAddObject, counterBucketDelObject, counterBucketRead
 
Constructor Summary
MemoryStorageNoDupsBucket(long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes)
          Constructs a new instance of MemoryStorageNoDupsBucket.
 
Method Summary
 void destroy()
          Destroy this bucket.
 void finalize()
          Finalize this bucket.
protected  ModifiableOrderedIndex<LocalAbstractObject,LocalAbstractObject> getModifiableIndex()
          Returns the index (including storage) for this bucket.
 
Methods inherited from class messif.buckets.OrderedLocalBucket
getIndex
 
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 messif.buckets.Bucket
addObjects, addObjects, deleteObject, deleteObjects, processQuery, provideObjects, split
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

objects

protected ModifiableOrderedIndex<LocalAbstractObject,LocalAbstractObject> objects
Object storage with object-id index

Constructor Detail

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 exceeded
softCapacity - maximal soft capacity of the bucket
lowOccupation - a minimal occupation for deleting objects - cannot be lowered
occupationAsBytes - flag whether the occupation (and thus all the limits) are in bytes or number of objects
Method Detail

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