Package com.nt.udc.util
Class FileHashtable
java.lang.Object
com.nt.udc.util.FileHashtable
This class handles the key -> disk based Object mappings, where
the disk-based Object is handled with an ObjectStorageFile class.
For the most part, use this class as you would a Hashtable
class, except note that your Object will be saved to disk
immediately. Therefore, it may be slower than an memory-based
Hashtable, but the data will be saved.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected ArrayListprotected Factoryprotected ObjectStorageFileprotected HashMapprotected HashMap -
Constructor Summary
ConstructorsConstructorDescriptionFileHashtable(ObjectStorageFile storage, Factory keyFact) Create a new file-based table.FileHashtable(ArrayList storageFileList, Factory keyFact) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPartition(ObjectStorageFile newStorage, int index) voidclear()This method is not supported.voidclose()Closes the file table.voidCompresses the ObjectStorageFile's file, and resets the offset table.booleancontainsKey(Object key) Returns whether this table contains the given key.booleancontainsValue(Object value) Returns whether this table contains the given value.entrySet()Returns the entries in Map.Entry form.booleanReturns whether this table is equal to the given Object.Retrieve an Object with the given key.inthashCode()Returns the hash code for this table.booleanisEmpty()Returns whether the table is empty.keys()Returns the keys of the table.keySet()Returns the keys of this table as a Set interface.voidopen()Opens the file table.voidPause the table compression.Puts an Object value in the table using the Object key.voidPuts all of the elements of the given Map into this table.Removes an Object from the table.protected voidThis method is for exclusive use by MTAggrDispatcher ONLY, because this method must return NAR instead of an arbitrary Object.voidCompresses the ObjectStorageFile's file, and resets the offset table.intsize()Returns the number of Objects in the table.toString()Returns the table, in displayable format.values()Returns all the values in the table as a Collection interface.
-
Field Details
-
offsetTable
-
objStorage
-
objStorageList
-
deadPartitionList
-
keyFactory
-
allowCompress
protected boolean allowCompress
-
-
Constructor Details
-
FileHashtable
Create a new file-based table.- Parameters:
storage- Handles the actual Object storage to disk.keyFact- Factory class, used to build Object keys when using a previously created table.- Throws:
IOException
-
FileHashtable
- Throws:
IOException
-
-
Method Details
-
addPartition
- Throws:
IOException
-
get
Retrieve an Object with the given key.- Parameters:
key- Object key to retrieve the value with.- Returns:
- Object value that was stored in the table.
- Throws:
IOException
-
put
- Throws:
IOException
-
put
Puts an Object value in the table using the Object key.- Parameters:
key- Key to index into the table.value- Value to put in the table.- Returns:
- Value that was placed in the table.
- Throws:
IOException
-
pauseTableCompression
public void pauseTableCompression()Pause the table compression. -
remove
Removes an Object from the table.- Parameters:
key- Object key, used to find the Object in the table.- Returns:
- Object value at the key.
- Throws:
IOException
-
removeDelayedNARParsing
This method is for exclusive use by MTAggrDispatcher ONLY, because this method must return NAR instead of an arbitrary Object. A clone of remove(), but this one calls ObjectStorageFile.getDelayedParsing() instead. and manually- Parameters:
key-- Returns:
- THE TYPE IS IMPORTANT!!! It's either type com.nt.common.util.ByteArray (which then needs parsing from ObjectStorageFile.objectFromBytes()), or type whatever it was originally. (There's gotta be a better way, but I can't figure out how to bypass the "useMemHash" thing.
- Throws:
IOException
-
removeDeadPartitions
- Throws:
IOException
-
resumeTableCompression
Compresses the ObjectStorageFile's file, and resets the offset table.- Throws:
IOException
-
compressTable
Compresses the ObjectStorageFile's file, and resets the offset table.- Throws:
NullPointerExceptionIOException
-
close
Closes the file table.- Throws:
IOException
-
open
Opens the file table.- Throws:
IOException
-
clear
This method is not supported.- Throws:
UnsupportedOperationException
-
containsKey
Returns whether this table contains the given key.- Parameters:
key- Key to find.- Returns:
- true, if this table contains the key
-
containsValue
Returns whether this table contains the given value.- Parameters:
value- Value to find.- Returns:
- true, if this table contains the value
- Throws:
IOException
-
keySet
Returns the keys of this table as a Set interface. !! Currently UNSUPPORTED !!- Returns:
- Keys of the table, as a Set interface.
- Throws:
UnsupportedOperationException
-
size
public int size()Returns the number of Objects in the table.- Returns:
- Number of Objects in the table.
-
isEmpty
public boolean isEmpty()Returns whether the table is empty.- Returns:
- true, if the table is empty
-
toString
Returns the table, in displayable format. -
entrySet
Returns the entries in Map.Entry form. !! Currently UNSUPPORTED !!- Returns:
- set of Map.Entry objects
- Throws:
UnsupportedOperationException
-
equals
Returns whether this table is equal to the given Object. -
hashCode
Returns the hash code for this table. !! Currently UNSUPPORTED !!- Overrides:
hashCodein classObject- Returns:
- hash code value for this table
- Throws:
UnsupportedOperationException
-
putAll
Puts all of the elements of the given Map into this table. !! Currently UNSUPPORTED !!- Parameters:
t- holds elements to enter into this table- Throws:
UnsupportedOperationException
-
values
Returns all the values in the table as a Collection interface. !! Currently UNSUPPORTED !!- Returns:
- Values, in a Collection interface.
- Throws:
UnsupportedOperationException
-
keys
Returns the keys of the table.- Returns:
- keys, as an Enumeration
-