public class DiskBlockBucket extends LocalBucket 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.Modifier and Type | Field and Description |
---|---|
protected ModifiableIndex<LocalAbstractObject> |
objects
Object storage
|
counterBucketAddObject, counterBucketDelObject, counterBucketRead
Constructor and Description |
---|
DiskBlockBucket(long capacity,
long softCapacity,
long lowOccupation,
java.io.File file)
Constructs a new DiskBlockBucket instance with 16k direct-buffered input.
|
DiskBlockBucket(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 DiskBlockBucket |
getBucket(long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Creates a bucket.
|
protected ModifiableIndex<LocalAbstractObject> |
getModifiableIndex()
Returns the index (including storage) for this bucket.
|
addObject, addObject, addObjectErrCode, deleteAllObjects, deleteObject, deleteObject, deleteObject, deleteObjects, deregisterFilter, getAllObjects, getBucketID, getCapacity, getFilter, getIndex, getLowOccupation, getObject, getObject, getObjectCount, getOccupation, getOccupationRatio, getSoftCapacity, isBucketStandalone, isSoftCapacityExceeded, registerFilter, setLowOccupation, setSoftCapacity, toString
addObjects, addObjects, deleteObject, deleteObject, processQuery, provideObjects, split
protected final ModifiableIndex<LocalAbstractObject> objects
public DiskBlockBucket(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 DiskBlockBucket(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 DiskBlockBucket 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 ModifiableIndex<LocalAbstractObject> getModifiableIndex()
LocalBucket
getModifiableIndex
in class LocalBucket