org.hsqldb.index
Class IndexAVL
- java.lang.Object
-
- org.hsqldb.index.IndexAVL
-
- All Implemented Interfaces:
- Index, SchemaObject
- Direct Known Subclasses:
- IndexAVLMemory
public class IndexAVL extends java.lang.Object implements Index
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.
- Since:
- Hypersonic SQL
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classIndexAVL.IndexRowIterator-
Nested classes/interfaces inherited from interface org.hsqldb.index.Index
Index.IndexUse
-
Nested classes/interfaces inherited from interface org.hsqldb.SchemaObject
SchemaObject.ConstraintTypes, SchemaObject.Deferable, SchemaObject.Nullability, SchemaObject.ParameterModes, SchemaObject.ReferentialAction, SchemaObject.ViewCheckModes
-
-
Field Summary
-
Fields inherited from interface org.hsqldb.index.Index
cachedFactor, emptyArray, emptyUseArray, INDEX_NON_UNIQUE, INDEX_NONE, INDEX_UNIQUE, minimumSelectivity, probeDepth
-
Fields inherited from interface org.hsqldb.SchemaObject
ASSERTION, CATALOG, CHARSET, COLLATION, COLUMN, CONSTRAINT, CURSOR, DOMAIN, FUNCTION, GRANTEE, INDEX, LABEL, PARAMETER, PROCEDURE, ROUTINE, SCHEMA, SEARCH, SEQUENCE, SERVER, SPECIFIC_ROUTINE, SUBQUERY, TABLE, TRANSITION, TRIGGER, TYPE, VARIABLE, VIEW, WRAPPER
-
-
Constructor Summary
Constructors Constructor and Description IndexAVL(HsqlNameManager.HsqlName name, long id, TableBase table, int[] columns, boolean[] descending, boolean[] nullsLast, Type[] colTypes, boolean pk, boolean unique, boolean constraint, boolean forward)Constructor declaration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Index.IndexUse[]asArray()voidcheckIndex(PersistentStore store)intcompareRow(Session session, java.lang.Object[] a, java.lang.Object[] b)voidcompareRowForChange(Session session, java.lang.Object[] a, java.lang.Object[] b, double[] changes)intcompareRowNonUnique(Session session, java.lang.Object[] a, java.lang.Object[] b, int fieldCount)As above but use the index column dataintcompareRowNonUnique(Session session, java.lang.Object[] a, java.lang.Object[] b, int[] rowColMap)Compares two table rows based on the columns of this index.intcompareRowNonUnique(Session session, java.lang.Object[] a, java.lang.Object[] b, int[] rowColMap, int fieldCount)voidcompile(Session session, SchemaObject parentObject)voiddelete(Session session, PersistentStore store, Row row)RowIteratoremptyIterator()booleanexistsParent(Session session, PersistentStore store, java.lang.Object[] rowdata, int[] rowColMap)RowIteratorfindFirstRow(Session session, PersistentStore store, java.lang.Object[] rowdata)Return the first node equal to the rowdata object.RowIteratorfindFirstRow(Session session, PersistentStore store, java.lang.Object[] rowdata, int[] rowColMap)Return the first node equal to the rowdata object.RowIteratorfindFirstRow(Session session, PersistentStore store, java.lang.Object[] rowdata, int matchCount, int distinctCount, int compareType, boolean reversed, boolean[] map)Return the first node equal to the indexdata object.RowIteratorfindFirstRowNotNull(Session session, PersistentStore store)Finds the first node where the data is not null.RowIteratorfirstRow(PersistentStore store)RowIteratorfirstRow(Session session, PersistentStore store, int distinctCount)Returns the row for the first node of the indexHsqlNameManager.HsqlNamegetCatalogName()longgetChangeTimestamp()intgetColumnCount()Returns the count of visible columns usedboolean[]getColumnDesc()Returns the count of visible columns usedint[]getColumns()Returns the array containing column indexes for indexType[]getColumnTypes()Returns the array containing column indexes for indexOrderedHashSetgetComponents()int[]getDefaultColumnMap()Returns the array containing 0, 1, ..intgetIndexOrderValue()Returns a value indicating the order of different types of index in the list of indexes for a table.HsqlNameManager.HsqlNamegetName()longgetNodeCount(Session session, PersistentStore store)GranteegetOwner()longgetPersistenceId()intgetPosition()OrderedHashSetgetReferences()HsqlNameManager.HsqlNamegetSchemaName()java.lang.StringgetSQL()intgetType()voidinsert(Session session, PersistentStore store, Row row)Insert a node into the indexbooleanisClustered()booleanisConstraint()Does this index belong to a constraint?booleanisEmpty(PersistentStore store)booleanisForward()booleanisUnique()Is this a UNIQUE index?RowIteratorlastRow(Session session, PersistentStore store, int distinctCount)Returns the row for the last node of the indexdouble[]searchCost(Session session, PersistentStore store)voidsetClustered(boolean clustered)voidsetPosition(int position)voidsetTable(TableBase table)longsize(Session session, PersistentStore store)Returns the node count.longsizeUnique(PersistentStore store)voidunlinkNodes(NodeAVL primaryRoot)Removes all links between memory nodes
-
-
-
Constructor Detail
-
IndexAVL
public IndexAVL(HsqlNameManager.HsqlName name, long id, TableBase table, int[] columns, boolean[] descending, boolean[] nullsLast, Type[] colTypes, boolean pk, boolean unique, boolean constraint, boolean forward)
Constructor declaration- Parameters:
name- HsqlName of the indexid- persistnece idtable- table of the indexcolumns- array of column indexesdescending- boolean[]nullsLast- boolean[]colTypes- array of column typespk- if index is for a primary keyunique- is this a unique indexconstraint- does this index belonging to a constraintforward- is this an auto-index for an FK that refers to a table defined after this table
-
-
Method Detail
-
getType
public int getType()
- Specified by:
getTypein interfaceSchemaObject
-
getName
public HsqlNameManager.HsqlName getName()
- Specified by:
getNamein interfaceSchemaObject
-
getCatalogName
public HsqlNameManager.HsqlName getCatalogName()
- Specified by:
getCatalogNamein interfaceSchemaObject
-
getSchemaName
public HsqlNameManager.HsqlName getSchemaName()
- Specified by:
getSchemaNamein interfaceSchemaObject
-
getOwner
public Grantee getOwner()
- Specified by:
getOwnerin interfaceSchemaObject
-
getReferences
public OrderedHashSet getReferences()
- Specified by:
getReferencesin interfaceSchemaObject
-
getComponents
public OrderedHashSet getComponents()
- Specified by:
getComponentsin interfaceSchemaObject
-
compile
public void compile(Session session, SchemaObject parentObject)
- Specified by:
compilein interfaceSchemaObject
-
getSQL
public java.lang.String getSQL()
- Specified by:
getSQLin interfaceSchemaObject
-
getChangeTimestamp
public long getChangeTimestamp()
- Specified by:
getChangeTimestampin interfaceSchemaObject
-
asArray
public Index.IndexUse[] asArray()
-
emptyIterator
public RowIterator emptyIterator()
- Specified by:
emptyIteratorin interfaceIndex
-
getPosition
public int getPosition()
- Specified by:
getPositionin interfaceIndex
-
setPosition
public void setPosition(int position)
- Specified by:
setPositionin interfaceIndex
-
getPersistenceId
public long getPersistenceId()
- Specified by:
getPersistenceIdin interfaceIndex
-
getColumnCount
public int getColumnCount()
Returns the count of visible columns used- Specified by:
getColumnCountin interfaceIndex
-
isUnique
public boolean isUnique()
Is this a UNIQUE index?
-
isConstraint
public boolean isConstraint()
Does this index belong to a constraint?- Specified by:
isConstraintin interfaceIndex
-
getColumns
public int[] getColumns()
Returns the array containing column indexes for index- Specified by:
getColumnsin interfaceIndex
-
getColumnTypes
public Type[] getColumnTypes()
Returns the array containing column indexes for index- Specified by:
getColumnTypesin interfaceIndex
-
getColumnDesc
public boolean[] getColumnDesc()
Description copied from interface:IndexReturns the count of visible columns used- Specified by:
getColumnDescin interfaceIndex
-
getDefaultColumnMap
public int[] getDefaultColumnMap()
Description copied from interface:IndexReturns the array containing 0, 1, .. column indexes- Specified by:
getDefaultColumnMapin interfaceIndex
-
getIndexOrderValue
public int getIndexOrderValue()
Returns a value indicating the order of different types of index in the list of indexes for a table. The position of the groups of Indexes in the list in ascending order is as follows: primary key index unique constraint indexes autogenerated foreign key indexes for FK's that reference this table or tables created before this table user created indexes (CREATE INDEX) autogenerated foreign key indexes for FK's that reference tables created after this table Among a group of indexes, the order is based on the order of creation of the index.- Specified by:
getIndexOrderValuein interfaceIndex- Returns:
- ordinal value
-
setClustered
public void setClustered(boolean clustered)
- Specified by:
setClusteredin interfaceIndex
-
isClustered
public boolean isClustered()
- Specified by:
isClusteredin interfaceIndex
-
size
public long size(Session session, PersistentStore store)
Returns the node count.
-
sizeUnique
public long sizeUnique(PersistentStore store)
- Specified by:
sizeUniquein interfaceIndex
-
searchCost
public double[] searchCost(Session session, PersistentStore store)
- Specified by:
searchCostin interfaceIndex
-
getNodeCount
public long getNodeCount(Session session, PersistentStore store)
-
isEmpty
public boolean isEmpty(PersistentStore store)
-
unlinkNodes
public void unlinkNodes(NodeAVL primaryRoot)
Removes all links between memory nodes
-
checkIndex
public void checkIndex(PersistentStore store)
- Specified by:
checkIndexin interfaceIndex
-
compareRowNonUnique
public int compareRowNonUnique(Session session, java.lang.Object[] a, java.lang.Object[] b, int[] rowColMap)
Compares two table rows based on the columns of this index. The rowColMap parameter specifies which columns of the other table are to be compared with the colIndex columns of this index. The rowColMap can cover all or only some columns of this index.- Specified by:
compareRowNonUniquein interfaceIndex- Parameters:
session- Sessiona- row from another tablerowColMap- column indexes in the other tableb- a full row in this table- Returns:
- comparison result, -1,0,+1
-
compareRowNonUnique
public int compareRowNonUnique(Session session, java.lang.Object[] a, java.lang.Object[] b, int[] rowColMap, int fieldCount)
- Specified by:
compareRowNonUniquein interfaceIndex
-
compareRowNonUnique
public int compareRowNonUnique(Session session, java.lang.Object[] a, java.lang.Object[] b, int fieldCount)
As above but use the index column data- Specified by:
compareRowNonUniquein interfaceIndex
-
compareRowForChange
public void compareRowForChange(Session session, java.lang.Object[] a, java.lang.Object[] b, double[] changes)
-
compareRow
public int compareRow(Session session, java.lang.Object[] a, java.lang.Object[] b)
- Specified by:
compareRowin interfaceIndex
-
insert
public void insert(Session session, PersistentStore store, Row row)
Insert a node into the index
-
delete
public void delete(Session session, PersistentStore store, Row row)
-
existsParent
public boolean existsParent(Session session, PersistentStore store, java.lang.Object[] rowdata, int[] rowColMap)
- Specified by:
existsParentin interfaceIndex
-
findFirstRow
public RowIterator findFirstRow(Session session, PersistentStore store, java.lang.Object[] rowdata, int matchCount, int distinctCount, int compareType, boolean reversed, boolean[] map)
Return the first node equal to the indexdata object. The rowdata has the same column mapping as this index.- Specified by:
findFirstRowin interfaceIndex- Parameters:
session- session objectstore- store objectrowdata- array containing index column datamatchCount- count of columns to matchcompareType- intreversed- booleanmap- boolean[]- Returns:
- iterator
-
findFirstRow
public RowIterator findFirstRow(Session session, PersistentStore store, java.lang.Object[] rowdata)
Return the first node equal to the rowdata object. The rowdata has the same column mapping as this table.- Specified by:
findFirstRowin interfaceIndex- Parameters:
session- session objectstore- store objectrowdata- array containing table row data- Returns:
- iterator
-
findFirstRow
public RowIterator findFirstRow(Session session, PersistentStore store, java.lang.Object[] rowdata, int[] rowColMap)
Return the first node equal to the rowdata object. The rowdata has the column mapping provided in rowColMap.- Specified by:
findFirstRowin interfaceIndex- Parameters:
session- session objectstore- store objectrowdata- array containing table row datarowColMap- int[]- Returns:
- iterator
-
findFirstRowNotNull
public RowIterator findFirstRowNotNull(Session session, PersistentStore store)
Finds the first node where the data is not null.- Specified by:
findFirstRowNotNullin interfaceIndex- Returns:
- iterator
-
firstRow
public RowIterator firstRow(Session session, PersistentStore store, int distinctCount)
Returns the row for the first node of the index
-
firstRow
public RowIterator firstRow(PersistentStore store)
-
lastRow
public RowIterator lastRow(Session session, PersistentStore store, int distinctCount)
Returns the row for the last node of the index
-
-
DataMelt 3.0 © DataMelt by jWork.ORG