public class WrappingStorageUtility extends java.lang.Object implements IStorageUtilityIndexed
Modifier and Type | Class and Description |
---|---|
static interface |
WrappingStorageUtility.SerializationWrapper
Defines an alternate serialization scheme.
|
Modifier and Type | Field and Description |
---|---|
(package private) IStorageUtility |
storage |
(package private) WrappingStorageUtility.SerializationWrapper |
wrapper |
Constructor and Description |
---|
WrappingStorageUtility(java.lang.String name,
WrappingStorageUtility.SerializationWrapper wrapper,
IStorageFactory storageFactory)
Create a new wrapping StorageUtility
|
Modifier and Type | Method and Description |
---|---|
int |
add(Externalizable e)
Add a new record to the store.
|
void |
close()
Close all resources associated with this StorageUtility.
|
void |
destroy()
Delete the storage utility itself, along with all stored records and meta-data
|
boolean |
exists(int id)
Return whether a record exists in the store
|
java.lang.Object |
getAccessLock()
Fetch the object that acts as the synchronization lock for this StorageUtility
|
java.util.List<java.lang.Integer> |
getIDsForValue(java.lang.String fieldName,
java.lang.Object value)
Retrieves a List of IDs of Externalizable objects in storage for which the field
specified contains the value specified.
|
int |
getNumRecords()
Return the number of records in the store
|
Externalizable |
getRecordForValue(java.lang.String fieldName,
java.lang.Object value)
Retrieves a Externalizable object from the storage which is reference by the unique index fieldName.
|
int |
getRecordSize(int id)
Get the size of a record
|
int |
getTotalSize()
Return total size of device storage consumed by this StorageUtility
|
private IStorageUtilityIndexed |
indexedStorage() |
boolean |
isEmpty()
Return whether the store is empty
|
IStorageIterator |
iterate()
Return an iterator to iterate through all records in this store
|
Externalizable |
read(int id)
Read and return the record corresponding to 'id'.
|
byte[] |
readBytes(int id)
Read and return the raw bytes for the record corresponding to 'id'.
|
void |
registerIndex(java.lang.String filterIndex)
Optional.
|
void |
remove(int id)
Remove record with the given ID from the store.
|
void |
remove(Persistable p)
Remove object from the store
|
void |
removeAll() |
java.util.List<java.lang.Integer> |
removeAll(EntityFilter ef) |
void |
repack()
Perform any clean-up/consolidation of the StorageUtility's underlying datastructures that is too expensive to do during
normal usage (e.g., if all the records are scattered among 10 half-empty RMSes, repack them into 5 full RMSes)
|
void |
repair()
If the StorageUtility has been left in a corrupt/inconsistent state, restore it to a non-corrupt state, even if it results
in data loss.
|
void |
setReadOnly() |
void |
update(int id,
Externalizable e)
Update a record in the store.
|
void |
write(Persistable p)
Write an object to the store.
|
IStorageUtility storage
WrappingStorageUtility.SerializationWrapper wrapper
public WrappingStorageUtility(java.lang.String name, WrappingStorageUtility.SerializationWrapper wrapper, IStorageFactory storageFactory)
name
- unique name for underlying StorageUtilitywrapper
- serialization wrapperstorageFactory
- factory to create underlying StorageUtilitypublic Externalizable read(int id)
IStorageUtility
read
in interface IStorageUtility
id
- id of the objectpublic void write(Persistable p) throws StorageFullException
IStorageUtility
write
in interface IStorageUtility
p
- object to storeStorageFullException
- if there is not enough room to store the objectpublic int add(Externalizable e) throws StorageFullException
IStorageUtility
add
in interface IStorageUtility
e
- object to addStorageFullException
- if not enough space availablepublic void update(int id, Externalizable e) throws StorageFullException
IStorageUtility
update
in interface IStorageUtility
id
- ID of record to updatee
- updated objectStorageFullException
- if not enough space available to updatepublic IStorageIterator iterate()
IStorageUtility
iterate
in interface IStorageUtility
public byte[] readBytes(int id)
IStorageUtility
readBytes
in interface IStorageUtility
id
- id of the objectpublic void remove(int id)
IStorageUtility
remove
in interface IStorageUtility
id
- ID of record to removepublic void remove(Persistable p)
IStorageUtility
remove
in interface IStorageUtility
p
- object to removepublic void removeAll()
removeAll
in interface IStorageUtility
public java.util.List<java.lang.Integer> removeAll(EntityFilter ef)
removeAll
in interface IStorageUtility
public boolean exists(int id)
IStorageUtility
exists
in interface IStorageUtility
id
- record IDpublic boolean isEmpty()
IStorageUtility
isEmpty
in interface IStorageUtility
public int getNumRecords()
IStorageUtility
getNumRecords
in interface IStorageUtility
public int getRecordSize(int id)
IStorageUtility
getRecordSize
in interface IStorageUtility
id
- record IDpublic int getTotalSize()
IStorageUtility
getTotalSize
in interface IStorageUtility
public void close()
IStorageUtility
close
in interface IStorageUtility
public void destroy()
IStorageUtility
destroy
in interface IStorageUtility
public void repack()
IStorageUtility
repack
in interface IStorageUtility
public void repair()
IStorageUtility
repair
in interface IStorageUtility
public java.lang.Object getAccessLock()
IStorageUtility
getAccessLock
in interface IStorageUtility
public java.util.List<java.lang.Integer> getIDsForValue(java.lang.String fieldName, java.lang.Object value)
IStorageUtilityIndexed
getIDsForValue
in interface IStorageUtilityIndexed
fieldName
- The name of a field which should be evaluatedvalue
- The value which should be contained by the field specifiedpublic Externalizable getRecordForValue(java.lang.String fieldName, java.lang.Object value) throws java.util.NoSuchElementException, InvalidIndexException
IStorageUtilityIndexed
getRecordForValue
in interface IStorageUtilityIndexed
fieldName
- The name of the index field which will be evaluatedvalue
- The value which should be set in the index specified by fieldName for the returned
object.java.util.NoSuchElementException
- If no objects reside in storage for which the return condition
can be successful.InvalidIndexException
- If the field used is an invalid index, because more than one field in the Storage
contains the value of the index requested.private IStorageUtilityIndexed indexedStorage()
public void setReadOnly()
setReadOnly
in interface IStorageUtility
public void registerIndex(java.lang.String filterIndex)
IStorageUtilityIndexed
registerIndex
in interface IStorageUtilityIndexed