Top Description Inners Fields Constructors Methods
org.apache.derby.iapi.store.access

public Class DiskHashtable

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Enumeration, .List, .NoSuchElementException, .Properties, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.types.DataValueDescriptor, .SQLInteger, .RowLocation, .StringDataValue, org.apache.derby.iapi.services.context.Context, .ContextService, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.conn.LanguageConnectionContext

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 and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private ConglomerateController
private final long
private final DataValueDescriptor[]
private final boolean
private boolean
private final int[]
private final boolean
private final DataValueDescriptor[]
private ConglomerateController
private final long
private final DataValueDescriptor[]
private int
private final TransactionController

Constructor Summary

AccessConstructor and Description
public
DiskHashtable(TransactionController tc, DataValueDescriptor[]
An array of DataValueDescriptors that serves as a template for the rows.
template
,
int[] collation_ids, int[]
The indexes of the key columns (0 based)
key_column_numbers
,
boolean
If true then rows with duplicate keys are removed.
remove_duplicates
,
boolean
If true then the hash table is kept after a commit
keepAfterCommit
)

Creates a new DiskHashtable instance.

Method Summary

Modifier and TypeMethod and Description
public void
public Enumeration<Object>

Returns:

The Enumeration.
elements
()

Return an Enumeration that can be used to scan entire table.

public Object

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.
get
(Object
If the rows only have one key column then the key value. If there is more than one key column then a KeyHasher
key
)

Get a row from the overflow structure.

private static Context
getContextOrNull(final String contextID)

Must be private so that user code can't call this entry point.

private Object
getRemove(Object key, boolean remove, boolean existenceOnly)

public boolean

Returns:

true if the row was added, false if it was not added (because it was a duplicate and we are eliminating duplicates).
put
(Object key, Object[]
The row to be inserted.
row
)

Put a new row in the overflow structure.

public Object

Returns:

The removed row(s).
remove
(Object
The key of the rows to remove.
key
)

remove all rows with a given key from the hash table.

private boolean
public int

Returns:

The number of rows in the hash table
size
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

btreeConglomerateback to summary
private ConglomerateController btreeConglomerate
btreeConglomerateIdback to summary
private final long btreeConglomerateId
btreeRowback to summary
private final DataValueDescriptor[] btreeRow
keepAfterCommitback to summary
private final boolean keepAfterCommit
keepStatisticsback to summary
private boolean keepStatistics
key_column_numbersback to summary
private final int[] key_column_numbers
remove_duplicatesback to summary
private final boolean remove_duplicates
rowback to summary
private final DataValueDescriptor[] row
rowConglomerateback to summary
private ConglomerateController rowConglomerate
rowConglomerateIdback to summary
private final long rowConglomerateId
scanKeyback to summary
private final DataValueDescriptor[] scanKey
sizeback to summary
private int size
tcback to summary
private final TransactionController tc

Constructor Detail

DiskHashtableback to summary
public DiskHashtable(TransactionController tc, DataValueDescriptor[] template, int[] collation_ids, int[] key_column_numbers, boolean remove_duplicates, boolean keepAfterCommit) throws StandardException

Creates a new DiskHashtable instance.

Parameters
template:DataValueDescriptor[]

An array of DataValueDescriptors that serves as a template for the rows.

key_column_numbers:int[]

The indexes of the key columns (0 based)

remove_duplicates:boolean

If true then rows with duplicate keys are removed.

keepAfterCommit:boolean

If true then the hash table is kept after a commit

Method Detail

closeback to summary
public void close() throws StandardException
elementsback to summary
public Enumeration<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:Enumeration<Object>

The Enumeration.

Exceptions
StandardException:
Standard exception policy.
getback to summary
public Object get(Object key) throws StandardException

Get a row from the overflow structure.

Parameters
key:Object

If the rows only have one key column then the key value. If there is more than one key column then a KeyHasher

Returns:Object

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.

getContextOrNullback to summary
private static Context getContextOrNull(final String contextID)

Must be private so that user code can't call this entry point.

getRemoveback to summary
private Object getRemove(Object key, boolean remove, boolean existenceOnly) throws StandardException
putback to summary
public boolean put(Object key, Object[] row) throws StandardException

Put a new row in the overflow structure.

Parameters
row:Object[]

The row to be inserted.

Returns:boolean

true if the row was added, false if it was not added (because it was a duplicate and we are eliminating duplicates).

Exceptions
StandardException:
standard error policy
removeback to summary
public Object remove(Object key) throws StandardException

remove all rows with a given key from the hash table.

Parameters
key:Object

The key of the rows to remove.

Returns:Object

The removed row(s).

Exceptions
StandardException:
Standard exception policy.
rowMatchesback to summary
private boolean rowMatches(DataValueDescriptor[] row, Object key)
sizeback to summary
public int size()
Returns:int

The number of rows in the hash table

org.apache.derby.iapi.store.access back to summary

private Class DiskHashtable.ElementEnum

extends Object
implements Enumeration<Object>
Class Inheritance
All Implemented Interfaces
java.util.Enumeration

Field Summary

Modifier and TypeField and Description
private boolean
private RowLocation
private ScanController

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

public Object
nextElement()

Implements java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hasMoreback to summary
private boolean hasMore
rowlocback to summary
private RowLocation rowloc
scanback to summary
private ScanController scan

Constructor Detail

ElementEnumback to summary
pack-priv ElementEnum()

Method Detail

hasMoreElementsback to summary
public boolean hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Doc from java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

Returns:boolean

true if and only if this enumeration object contains at least one more element to provide; false otherwise.

nextElementback to summary
public Object nextElement()

Implements java.util.Enumeration.nextElement.

Doc from java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Returns:Object

the next element of this enumeration.