public class DiskBlockObjectKeyMemoryBucket extends OrderedLocalBucket<AbstractObjectKey> implements java.io.Serializable
LocalBucket
.
It stores all objects in a specified blocks of a file.
The storage is persistent, even if the process using this bucket
quits, the bucket can be opened afterwards.
Note that this bucket only saves the name of the file when serialized,
thus the file must exist when the bucket is deserialized.BucketDispatcher
,
LocalBucket
,
DiskBlockBucket
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected static java.lang.String |
FILENAME_PREFIX
The prefix for auto-generated filenames
|
protected static java.lang.String |
FILENAME_SUFFIX
The suffix for auto-generated filenames
|
protected ModifiableOrderedIndex<AbstractObjectKey,LocalAbstractObject> |
objects
Object storage
|
counterBucketAddObject, counterBucketDelObject, counterBucketRead
Constructor and Description |
---|
DiskBlockObjectKeyMemoryBucket(long capacity,
long softCapacity,
long lowOccupation,
java.io.File file)
Constructs a new DiskBlockBucket instance with 16k direct-buffered input.
|
DiskBlockObjectKeyMemoryBucket(long capacity,
long softCapacity,
long lowOccupation,
java.io.File file,
int bufferSize,
boolean directBuffers,
int asyncThreads,
BinarySerializator serializator)
Constructs a new DiskBlockBucket instance.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy this bucket.
|
void |
finalize()
Finalize this bucket.
|
static DiskBlockObjectKeyMemoryBucket |
getBucket(long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Creates a bucket.
|
protected ModifiableOrderedIndex<AbstractObjectKey,LocalAbstractObject> |
getModifiableIndex()
Returns the index (including storage) for this bucket.
|
getIndex
addObject, addObject, addObjectErrCode, deleteAllObjects, deleteObject, deleteObject, deleteObject, deleteObjects, deregisterFilter, getAllObjects, getBucketID, getCapacity, getFilter, getLowOccupation, getObject, getObject, getObjectCount, getOccupation, getOccupationRatio, getSoftCapacity, isBucketStandalone, isSoftCapacityExceeded, registerFilter, setLowOccupation, setSoftCapacity, toString
addObjects, addObjects, deleteObject, deleteObject, processQuery, provideObjects, split
protected static final java.lang.String FILENAME_PREFIX
protected static final java.lang.String FILENAME_SUFFIX
protected final ModifiableOrderedIndex<AbstractObjectKey,LocalAbstractObject> objects
public DiskBlockObjectKeyMemoryBucket(long capacity, long softCapacity, long lowOccupation, java.io.File file) throws java.io.IOException
MultiClassSerializator
is used to serialize objects and
the occupation is counted in bytes.capacity
- maximal capacity of the bucket - cannot be exceededsoftCapacity
- maximal soft capacity of the bucketlowOccupation
- a minimal occupation for deleting objects - cannot be loweredfile
- the file where the bucket will be storedjava.io.IOException
- if there was a problem opening or creating the bucket filepublic DiskBlockObjectKeyMemoryBucket(long capacity, long softCapacity, long lowOccupation, java.io.File file, int bufferSize, boolean directBuffers, int asyncThreads, BinarySerializator serializator) throws java.io.IOException
capacity
- maximal capacity of the bucket - cannot be exceededsoftCapacity
- maximal soft capacity of the bucketlowOccupation
- a minimal occupation for deleting objects - cannot be loweredfile
- the file where the bucket will be storedbufferSize
- the size of the buffer used for I/O operationsdirectBuffers
- flag whether to use the direct buffers
asyncThreads
- the maximal number of threads to use (for asynchronous reading)serializator
- the binary serializator
used to store objectsjava.io.IOException
- if there was a problem opening or creating the bucket filepublic void finalize() throws java.lang.Throwable
LocalBucket
BucketDispatcher
when it is finalized.finalize
in class LocalBucket
java.lang.Throwable
- if there was an error while cleaningpublic void destroy() throws java.lang.Throwable
LocalBucket
BucketDispatcher
when the bucket is removed
from the dispatcher.destroy
in class LocalBucket
java.lang.Throwable
- if there was an error while cleaningpublic static DiskBlockObjectKeyMemoryBucket getBucket(long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes, java.util.Map<java.lang.String,java.lang.Object> parameters) throws java.io.IOException, java.lang.InstantiationException, java.lang.ClassNotFoundException
DiskStorage.create(java.lang.Class<T>, java.util.Map<java.lang.String, java.lang.Object>)
.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 (see above)java.io.IOException
- if something goes wrong when working with the filesystemjava.lang.InstantiationException
- if the parameters specified are invalid (non existent directory, null values, etc.)java.lang.ClassNotFoundException
- if the parameter class could not be resolved or is not a descendant of LocalAbstractObjectprotected ModifiableOrderedIndex<AbstractObjectKey,LocalAbstractObject> getModifiableIndex()
LocalBucket
getModifiableIndex
in class OrderedLocalBucket<AbstractObjectKey>