Top Description Inners Fields Constructors Methods
org.hsqldb.index

public Class IndexAVL

extends Object
implements Index
Class Inheritance
All Implemented Interfaces
org.hsqldb.index.Index, org.hsqldb.SchemaObject
Known Direct Subclasses
org.hsqldb.index.IndexAVLMemory
Imports
org.hsqldb.Constraint, .HsqlNameManager.HsqlName, .OpTypes, .RangeVariable.RangeVariableConditions, .Row, .RowAVL, .SchemaObject, .Session, .Table, .TableBase, .Tokens, .TransactionManager, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.ArrayUtil, .OrderedHashSet, org.hsqldb.navigator.RangeIterator, .RowIterator, org.hsqldb.persist.PersistentStore, org.hsqldb.rights.Grantee, org.hsqldb.types.DateTimeType, .TimestampData, .Type

Implementation of an AVL tree with parent pointers in nodes. Subclasses of Node implement the tree node objects for memory or disk storage. An Index has a root Node that is linked with other nodes using Java Object references or file pointers, depending on Node implementation.

An Index object also holds information on table columns (in the form of int indexes) that are covered by it.

New class derived from Hypersonic SQL code and enhanced in HSQLDB.

Authors
Thomas Mueller (Hypersonic SQL Group), Fred Toussi (fredt@users dot sourceforge.net)
Since
Hypersonic SQL
Version
2.7.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private Index.IndexUse[]
private final boolean[]
private final boolean[]
pack-priv final int[]
pack-priv final Type[]
private final int[]
private boolean
protected final boolean
private final boolean
protected final boolean
pack-priv final boolean
pack-priv final boolean
protected final boolean
protected final HsqlNameManager.HsqlName
pack-priv Object[]
private final boolean[]
private final long
pack-priv int
protected TableBase

Constructor Summary

AccessConstructor and Description
public
IndexAVL(HsqlNameManager.HsqlName
HsqlName of the index
name
,
long
persistnece id
id
,
TableBase
table of the index
table
,
int[]
array of column indexes
columns
,
boolean[]
boolean[]
descending
,
boolean[]
boolean[]
nullsLast
,
Type[]
array of column types
colTypes
,
boolean
if index is for a primary key
pk
,
boolean
is this a unique index
unique
,
boolean
does this index belonging to a constraint
constraint
,
boolean
is this an auto-index for an FK that refers to a table defined after this table
forward
)

Constructor declaration

Method Summary

Modifier and TypeMethod and Description
public Index.IndexUse[]
pack-priv void
balance(PersistentStore store, NodeAVL x, boolean isleft)

Balances part of the tree after an alteration to the index.

pack-priv int
compareObject(Session session, Object[] a, Object[] b, int[] rowColMap, int position, int opType)

public int
public void
compareRowForChange(Session session, Object[] a, Object[] b, double[] changes)

pack-priv int

Returns:

comparison result, -1,0,+1
compareRowForInsertOrDelete
(Session
Session
session
,
Row
data
newRow
,
Row
data
existingRow
,
boolean
boolean
useRowId
,
int
int
start
)

Compare two rows of the table for inserting rows into unique indexes Supports descending columns.

public int

Returns:

comparison result, -1,0,+1
compareRowNonUnique
(Session
Session
session
,
Object[]
row from another table
a
,
Object[]
a full row in this table
b
,
int[]
column indexes in the other table
rowColMap
)

Implements org.hsqldb.index.Index.compareRowNonUnique.

Compares two table rows based on the columns of this index.

public int
compareRowNonUnique(Session session, Object[] a, Object[] b, int[] rowColMap, int fieldCount)

Implements org.hsqldb.index.Index.compareRowNonUnique.

public int
compareRowNonUnique(Session session, Object[] a, Object[] b, int fieldCount)

Implements org.hsqldb.index.Index.compareRowNonUnique.

As above but use the index column data

public void
public boolean
existsParent(Session session, PersistentStore store, Object[] rowdata, int[] rowColMap)

Implements org.hsqldb.index.Index.existsParent.

pack-priv NodeAVL
findDistinctNode(Session session, PersistentStore store, NodeAVL node, int fieldCount, boolean reversed)

public RowIterator

Returns:

iterator
findFirstRow
(Session
session object
session
,
PersistentStore
store object
store
,
Object[]
array containing index column data
rowdata
,
int
count of columns to match
matchCount
,
int
int
distinctCount
,
int
int
compareType
,
boolean
boolean
reversed
,
boolean[]
boolean[]
map
)

Implements org.hsqldb.index.Index.findFirstRow.

Return the first node equal to the indexdata object.

public RowIterator

Returns:

iterator
findFirstRow
(Session
session object
session
,
PersistentStore
store object
store
,
Object[]
array containing table row data
rowdata
)

Implements org.hsqldb.index.Index.findFirstRow.

Return the first node equal to the rowdata object.

public RowIterator

Returns:

iterator
findFirstRow
(Session
session object
session
,
PersistentStore
store object
store
,
Object[]
array containing table row data
rowdata
,
int[]
int[]
rowColMap
)

Implements org.hsqldb.index.Index.findFirstRow.

Return the first node equal to the rowdata object.

public RowIterator

Returns:

iterator
findFirstRowNotNull
(Session
Session
session
,
PersistentStore
PersistentStore
store
)

Implements org.hsqldb.index.Index.findFirstRowNotNull.

Finds the first node where the data is not null.

pack-priv NodeAVL

Returns:

matching node or null
findNode
(Session
Session
session
,
PersistentStore
PersistentStore
store
,
Object[]
array containing data for the index columns
rowdata
,
int[]
map of the data to columns
rowColMap
,
int
int
fieldCount
,
int
int
compareType
,
int
int
readMode
,
boolean
boolean
reversed
)

Finds a match with a row from a different table

public RowIterator

Returns:

Iterator for first row
firstRow
(Session session, PersistentStore store, RangeVariable.RangeVariableConditions[] conditions, int distinctCount, boolean[] map)

Implements org.hsqldb.index.Index.firstRow.

Returns the row for the first node of the index

public RowIterator
pack-priv NodeAVL
public HsqlNameManager.HsqlName
public long
public int
getColumnCount()

Implements org.hsqldb.index.Index.getColumnCount.

Returns the count of visible columns used

public boolean[]
getColumnDesc()

Implements org.hsqldb.index.Index.getColumnDesc.

Returns the array containing desc column flags

public int[]
getColumns()

Implements org.hsqldb.index.Index.getColumns.

Returns the array containing column indexes for index

public Type[]
getColumnTypes()

Implements org.hsqldb.index.Index.getColumnTypes.

Returns the array containing column indexes for index

public int[]
getDefaultColumnMap()

Implements org.hsqldb.index.Index.getDefaultColumnMap.

Returns the array containing 0, 1, ...

public int

Returns:

ordinal value
getIndexOrderValue
()

Implements org.hsqldb.index.Index.getIndexOrderValue.

Returns a value indicating the order of different types of index in the list of indexes for a table.

pack-priv RowIterator
getIterator(Session session, PersistentStore store, NodeAVL x, boolean single, boolean reversed)

public HsqlNameManager.HsqlName
public Grantee
public long
public int
public HsqlNameManager.HsqlName
public String
public TableBase
public int
pack-priv boolean
hasNulls(Session session, Object[] rowData)

public void
insert(Session session, PersistentStore store, Row row)

Implements org.hsqldb.index.Index.insert.

Insert a node into the index

public boolean
public boolean
isConstraint()

Implements org.hsqldb.index.Index.isConstraint.

Does this index belong to a constraint?

public boolean
pack-priv boolean
public boolean
public boolean
isPrimaryKey()

Implements org.hsqldb.index.Index.isPrimaryKey.

Is this a PRIMARY_KEY index?

public boolean
isUnique()

Implements org.hsqldb.index.Index.isUnique.

Is this a UNIQUE index?

pack-priv NodeAVL
last(Session session, PersistentStore store, NodeAVL x, int distinctCount)

pack-priv NodeAVL
public RowIterator

Returns:

last row
lastRow
(Session session, PersistentStore store, int distinctCount, boolean[] map)

Implements org.hsqldb.index.Index.lastRow.

Returns the row for the last node of the index

pack-priv NodeAVL
next(Session session, PersistentStore store, NodeAVL x, int distinctCount)

Returns the node after the given one

pack-priv NodeAVL
pack-priv NodeAVL
next(PersistentStore store, NodeAVL x, int depth, int maxDepth, int[] depths)

pack-priv int
probeFactor(Session session, PersistentStore store, double[] changes, boolean left)

public double[]
public void
setClustered(boolean clustered)

Implements org.hsqldb.index.Index.setClustered.

public void
public void
public long
size(Session session, PersistentStore store)

Implements org.hsqldb.index.Index.size.

Returns the node count.

public long
public void
unlinkNodes(PersistentStore store, NodeAVL primaryRoot)

Removes all links between memory nodes

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait