public class DummyIndexedStorageUtility<T extends Persistable> extends java.lang.Object implements IStorageUtilityIndexed<T>
Modifier and Type | Field and Description |
---|---|
(package private) int |
curCount |
private java.util.Hashtable<java.lang.Integer,T> |
data |
(package private) java.util.ArrayList<java.lang.String> |
dynamicIndices |
private java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.Object,java.util.ArrayList<java.lang.Integer>>> |
meta |
Constructor and Description |
---|
DummyIndexedStorageUtility() |
Modifier and Type | Method and Description |
---|---|
int |
add(T 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
|
T |
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
|
boolean |
isEmpty()
Return whether the store is empty
|
IStorageIterator<T> |
iterate()
Return an iterator to iterate through all records in this store
|
T |
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() |
private void |
syncMeta() |
void |
update(int id,
T e)
Update a record in the store.
|
void |
write(Persistable p)
Write an object to the store.
|
private java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.Object,java.util.ArrayList<java.lang.Integer>>> meta
private java.util.Hashtable<java.lang.Integer,T extends Persistable> data
int curCount
java.util.ArrayList<java.lang.String> dynamicIndices
public java.util.List<java.lang.Integer> getIDsForValue(java.lang.String fieldName, java.lang.Object value)
IStorageUtilityIndexed
getIDsForValue
in interface IStorageUtilityIndexed<T extends Persistable>
fieldName
- The name of a field which should be evaluatedvalue
- The value which should be contained by the field specifiedpublic T getRecordForValue(java.lang.String fieldName, java.lang.Object value) throws java.util.NoSuchElementException, InvalidIndexException
IStorageUtilityIndexed
getRecordForValue
in interface IStorageUtilityIndexed<T extends Persistable>
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.public int add(T e) throws StorageFullException
IStorageUtility
add
in interface IStorageUtility<T extends Persistable>
e
- object to addStorageFullException
- if not enough space availablepublic void close()
IStorageUtility
close
in interface IStorageUtility<T extends Persistable>
public void destroy()
IStorageUtility
destroy
in interface IStorageUtility<T extends Persistable>
public boolean exists(int id)
IStorageUtility
exists
in interface IStorageUtility<T extends Persistable>
id
- record IDpublic java.lang.Object getAccessLock()
IStorageUtility
getAccessLock
in interface IStorageUtility<T extends Persistable>
public int getNumRecords()
IStorageUtility
getNumRecords
in interface IStorageUtility<T extends Persistable>
public int getRecordSize(int id)
IStorageUtility
getRecordSize
in interface IStorageUtility<T extends Persistable>
id
- record IDpublic int getTotalSize()
IStorageUtility
getTotalSize
in interface IStorageUtility<T extends Persistable>
public boolean isEmpty()
IStorageUtility
isEmpty
in interface IStorageUtility<T extends Persistable>
public IStorageIterator<T> iterate()
IStorageUtility
iterate
in interface IStorageUtility<T extends Persistable>
public T read(int id)
IStorageUtility
read
in interface IStorageUtility<T extends Persistable>
id
- id of the objectpublic byte[] readBytes(int id)
IStorageUtility
readBytes
in interface IStorageUtility<T extends Persistable>
id
- id of the objectpublic void remove(int id)
IStorageUtility
remove
in interface IStorageUtility<T extends Persistable>
id
- ID of record to removepublic void remove(Persistable p)
IStorageUtility
remove
in interface IStorageUtility<T extends Persistable>
p
- object to removepublic void removeAll()
removeAll
in interface IStorageUtility<T extends Persistable>
public java.util.List<java.lang.Integer> removeAll(EntityFilter ef)
removeAll
in interface IStorageUtility<T extends Persistable>
public void repack()
IStorageUtility
repack
in interface IStorageUtility<T extends Persistable>
public void repair()
IStorageUtility
repair
in interface IStorageUtility<T extends Persistable>
public void update(int id, T e) throws StorageFullException
IStorageUtility
update
in interface IStorageUtility<T extends Persistable>
id
- ID of record to updatee
- updated objectStorageFullException
- if not enough space available to updatepublic void write(Persistable p) throws StorageFullException
IStorageUtility
write
in interface IStorageUtility<T extends Persistable>
p
- object to storeStorageFullException
- if there is not enough room to store the objectprivate void syncMeta()
public void setReadOnly()
setReadOnly
in interface IStorageUtility<T extends Persistable>
public void registerIndex(java.lang.String filterIndex)
IStorageUtilityIndexed
registerIndex
in interface IStorageUtilityIndexed<T extends Persistable>