/* Copyright (c) 2001-2010, The HSQL Development Group * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the HSQL Development Group nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.hsqldb.index; import org.hsqldb.Row; import org.hsqldb.SchemaObject; import org.hsqldb.Session; import org.hsqldb.TableBase; import org.hsqldb.navigator.RowIterator; import org.hsqldb.persist.PersistentStore; import org.hsqldb.types.Type; /** * * @author Fred Toussi (fredt@users dot sourceforge.net) * @version 1.9.0 * @since 1.9.0 */ public interface Index extends SchemaObject { Index[] emptyArray = new Index[]{}; RowIterator emptyIterator(); public int getPosition(); public void setPosition(int position); public long getPersistenceId(); /** * Returns the count of visible columns used */ public int getVisibleColumns(); public int getColumnCount(); /** * Is this a UNIQUE index? */ public boolean isUnique(); /** * Does this index belong to a constraint? */ public boolean isConstraint(); /** * Returns the array containing column indexes for index */ public int[] getColumns(); /** * Returns the array containing column indexes for index */ public Type[] getColumnTypes(); /** * Returns the count of visible columns used */ public boolean[] getColumnDesc(); /** * Returns the array containing 0, 1, .. column indexes */ public int[] getDefaultColumnMap(); /** * 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. * * @return ordinal value */ public int getIndexOrderValue(); public boolean isForward(); public void setTable(TableBase table); /** * Returns the node count. */ public int size(Session session, PersistentStore store); public int sizeUnique(PersistentStore store); public boolean isEmpty(PersistentStore store); public void checkIndex(PersistentStore store); /** * Insert a node into the index */ public void insert(Session session, PersistentStore store, Row row); public void delete(Session session, PersistentStore store, Row row); public boolean existsParent(Session session, PersistentStore store, Object[] rowdata, int[] rowColMap); /** * Return the first node equal to the indexdata object. The rowdata has * the same column mapping as this index. * * @param session session object * @param store store object * @param coldata array containing index column data * @param match count of columns to match * @return iterator */ public RowIterator findFirstRow(Session session, PersistentStore store, Object[] rowdata, int matchCount, int compareType, boolean reversed, boolean[] map); /** * Return the first node equal to the rowdata object. * The rowdata has the same column mapping as this table. * * @param session session object * @param store store object * @param rowdata array containing table row data * @return iterator */ public RowIterator findFirstRow(Session session, PersistentStore store, Object[] rowdata); /** * Return the first node equal to the rowdata object. * The rowdata has the column mapping privided in rowColMap. * * @param session session object * @param store store object * @param rowdata array containing table row data * @return iterator */ public RowIterator findFirstRow(Session session, PersistentStore store, Object[] rowdata, int[] rowColMap); /** * Finds the first node where the data is not null. * * @return iterator */ public RowIterator findFirstRowNotNull(Session session, PersistentStore store); public RowIterator firstRow(PersistentStore store); /** * Returns the row for the first node of the index * * @return Iterator for first row */ public RowIterator firstRow(Session session, PersistentStore store); /** * Returns the row for the last node of the index * * @return last row */ public RowIterator lastRow(Session session, PersistentStore store); /** * 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. * * @param a row from another table * @param rowColMap column indexes in the other table * @param b a full row in this table * * @return comparison result, -1,0,+1 */ public int compareRowNonUnique(Session session, Object[] a, Object[] b, int[] rowColMap); public int compareRowNonUnique(Session session, Object[] a, Object[] b, int[] rowColMap, int fieldCount); /** * As above but use the index column data */ public int compareRowNonUnique(Session session, Object[] a, Object[] b, int fieldcount); public int compareRow(Session session, Object[] a, Object[] b); }