Class DiskHashtable
- java.lang.Object
-
- org.apache.derby.iapi.store.access.DiskHashtable
-
public class DiskHashtable extends java.lang.Object
This class is used by BackingStoreHashtable when the BackingStoreHashtable must spill to disk. It implements the methods of a hash table: put, get, remove, elements, however it is not implemented as a hash table. In order to minimize the amount of unique code it is implemented using a Btree and a heap conglomerate. The Btree indexes the hash code of the row key. The actual key may be too long for our Btree implementation. Created: Fri Jan 28 13:58:03 2005- Version:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
DiskHashtable.ElementEnum
-
Field Summary
Fields Modifier and Type Field Description private ConglomerateController
btreeConglomerate
private long
btreeConglomerateId
private DataValueDescriptor[]
btreeRow
private boolean
keepAfterCommit
private boolean
keepStatistics
private int[]
key_column_numbers
private boolean
remove_duplicates
private DataValueDescriptor[]
row
private ConglomerateController
rowConglomerate
private long
rowConglomerateId
private DataValueDescriptor[]
scanKey
private int
size
private TransactionController
tc
-
Constructor Summary
Constructors Constructor Description DiskHashtable(TransactionController tc, DataValueDescriptor[] template, int[] collation_ids, int[] key_column_numbers, boolean remove_duplicates, boolean keepAfterCommit)
Creates a newDiskHashtable
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.util.Enumeration<java.lang.Object>
elements()
Return an Enumeration that can be used to scan entire table.java.lang.Object
get(java.lang.Object key)
Get a row from the overflow structure.private static Context
getContextOrNull(java.lang.String contextID)
Privileged lookup of a Context.private java.lang.Object
getRemove(java.lang.Object key, boolean remove, boolean existenceOnly)
boolean
put(java.lang.Object key, java.lang.Object[] row)
Put a new row in the overflow structure.java.lang.Object
remove(java.lang.Object key)
remove all rows with a given key from the hash table.private boolean
rowMatches(DataValueDescriptor[] row, java.lang.Object key)
int
size()
-
-
-
Field Detail
-
rowConglomerateId
private final long rowConglomerateId
-
rowConglomerate
private ConglomerateController rowConglomerate
-
btreeConglomerateId
private final long btreeConglomerateId
-
btreeConglomerate
private ConglomerateController btreeConglomerate
-
btreeRow
private final DataValueDescriptor[] btreeRow
-
key_column_numbers
private final int[] key_column_numbers
-
remove_duplicates
private final boolean remove_duplicates
-
tc
private final TransactionController tc
-
row
private final DataValueDescriptor[] row
-
scanKey
private final DataValueDescriptor[] scanKey
-
size
private int size
-
keepStatistics
private boolean keepStatistics
-
keepAfterCommit
private final boolean keepAfterCommit
-
-
Constructor Detail
-
DiskHashtable
public DiskHashtable(TransactionController tc, DataValueDescriptor[] template, int[] collation_ids, int[] key_column_numbers, boolean remove_duplicates, boolean keepAfterCommit) throws StandardException
Creates a newDiskHashtable
instance.- Parameters:
tc
-template
- An array of DataValueDescriptors that serves as a template for the rows.key_column_numbers
- The indexes of the key columns (0 based)remove_duplicates
- If true then rows with duplicate keys are removed.keepAfterCommit
- If true then the hash table is kept after a commit- Throws:
StandardException
-
-
Method Detail
-
close
public void close() throws StandardException
- Throws:
StandardException
-
put
public boolean put(java.lang.Object key, java.lang.Object[] row) throws StandardException
Put a new row in the overflow structure.- Parameters:
row
- The row to be inserted.- Returns:
- true if the row was added, false if it was not added (because it was a duplicate and we are eliminating duplicates).
- Throws:
StandardException
- standard error policy
-
get
public java.lang.Object get(java.lang.Object key) throws StandardException
Get a row from the overflow structure.- Parameters:
key
- If the rows only have one key column then the key value. If there is more than one key column then a KeyHasher- Returns:
- null if there is no corresponding row, the row (DataValueDescriptor[]) if there is exactly one row with the key, or a Vector of all the rows with the key if there is more than one.
- Throws:
StandardException
-
getRemove
private java.lang.Object getRemove(java.lang.Object key, boolean remove, boolean existenceOnly) throws StandardException
- Throws:
StandardException
-
rowMatches
private boolean rowMatches(DataValueDescriptor[] row, java.lang.Object key)
-
remove
public java.lang.Object remove(java.lang.Object key) throws StandardException
remove all rows with a given key from the hash table.- Parameters:
key
- The key of the rows to remove.- Returns:
- The removed row(s).
- Throws:
StandardException
- Standard exception policy.
-
size
public int size()
- Returns:
- The number of rows in the hash table
-
elements
public java.util.Enumeration<java.lang.Object> elements() throws StandardException
Return an Enumeration that can be used to scan entire table.RESOLVE - is it worth it to support this routine?
- Returns:
- The Enumeration.
- Throws:
StandardException
- Standard exception policy.
-
getContextOrNull
private static Context getContextOrNull(java.lang.String contextID)
Privileged lookup of a Context. Must be private so that user code can't call this entry point.
-
-