Package org.apache.derby.catalog.types
Class IndexDescriptorImpl
- java.lang.Object
-
- org.apache.derby.catalog.types.IndexDescriptorImpl
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,IndexDescriptor,Formatable,TypedFormat
public class IndexDescriptorImpl extends java.lang.Object implements IndexDescriptor, Formatable
See alsoIndexRowGenerator.For a description of how deferrable and non-deferrable constraints are backed differently, including the meaning of the boolean attributes used here, see
IndexDescriptor.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private int[]baseColumnPositionsprivate booleanhasDeferrableCheckingThe index represents a constraint which is deferrable.private java.lang.StringindexTypeprivate boolean[]isAscendingprivate booleanisUniqueThis class implements Formatable.private booleanisUniqueDeferrableThe index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.private booleanisUniqueWithDuplicateNullsprivate intnumberOfOrderedColumns
-
Constructor Summary
Constructors Constructor Description IndexDescriptorImpl()Zero-argument constructor for Formatable interfaceIndexDescriptorImpl(java.lang.String indexType, boolean isUnique, boolean isUniqueWithDuplicateNulls, boolean isUniqueDeferrable, boolean hasDeferrableChecking, int[] baseColumnPositions, boolean[] isAscending, int numberOfOrderedColumns)Constructor for an IndexDescriptorImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]baseColumnPositions()Returns an array of column positions in the base table.booleanequals(java.lang.Object other)Test for value equalityintgetKeyColumnPosition(int heapColumnPosition)Returns the postion of a column.intgetTypeFormatId()Get a universally unique identifier for the type of this object.booleanhasDeferrableChecking()Returns true if the index is used to support a deferrable constraint.inthashCode()java.lang.StringindexType()Returns the type of the index.boolean[]isAscending()Returns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method.booleanisAscending(java.lang.Integer keyColumnPosition)Returns true if the specified column is ascending in the index (1-based).booleanisDescending(java.lang.Integer keyColumnPosition)Returns true if the specified column is descending in the index (1-based).booleanisUnique()Returns true if the index is unique.booleanisUniqueDeferrable()The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.booleanisUniqueWithDuplicateNulls()Returns true if the index is duplicate keys only for null key parts.intnumberOfOrderedColumns()Returns the number of ordered columns.voidreadExternal(java.io.ObjectInput in)voidsetBaseColumnPositions(int[] baseColumnPositions)set the baseColumnPositions field of the index descriptor.voidsetIsAscending(boolean[] isAscending)set the isAscending field of the index descriptor.voidsetNumberOfOrderedColumns(int numberOfOrderedColumns)set the numberOfOrderedColumns field of the index descriptor.java.lang.StringtoString()voidwriteExternal(java.io.ObjectOutput out)
-
-
-
Field Detail
-
isUnique
private boolean isUnique
This class implements Formatable. That means that it can write itself to and from a formatted stream. If you add more fields to this class, make sure that you also write/read them with the writeExternal()/readExternal() methods. If, in between releases, you add more fields to this class, then you should bump the version number emitted by the getTypeFormatId() method.
-
baseColumnPositions
private int[] baseColumnPositions
-
isAscending
private boolean[] isAscending
-
numberOfOrderedColumns
private int numberOfOrderedColumns
-
indexType
private java.lang.String indexType
-
isUniqueWithDuplicateNulls
private boolean isUniqueWithDuplicateNulls
-
isUniqueDeferrable
private boolean isUniqueDeferrable
The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.trueimpliesisUnique == falseandisUniqueWithDuplicateNulls == falseandhasDeferrableChecking == true.
-
hasDeferrableChecking
private boolean hasDeferrableChecking
The index represents a constraint which is deferrable.
-
-
Constructor Detail
-
IndexDescriptorImpl
public IndexDescriptorImpl(java.lang.String indexType, boolean isUnique, boolean isUniqueWithDuplicateNulls, boolean isUniqueDeferrable, boolean hasDeferrableChecking, int[] baseColumnPositions, boolean[] isAscending, int numberOfOrderedColumns)Constructor for an IndexDescriptorImpl- Parameters:
indexType- The type of indexisUnique- True means the index is uniqueisUniqueWithDuplicateNulls- True means the index will be unique for non null values but duplicate nulls will be allowed. This parameter has no effect if the isUnique is true. If isUnique is false and isUniqueWithDuplicateNulls is set to true the index will allow duplicate nulls but for non null keys will act like a unique index.isUniqueDeferrable- True means the index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.hasDeferrableChecking- True if this index supports a deferrable constraint.baseColumnPositions- An array of column positions in the base table. Each index column corresponds to a column position in the base table.isAscending- An array of booleans telling asc/desc on each column.numberOfOrderedColumns- In the future, it will be possible to store non-ordered columns in an index. These will be useful for covered queries.
-
IndexDescriptorImpl
public IndexDescriptorImpl()
Zero-argument constructor for Formatable interface
-
-
Method Detail
-
isUniqueWithDuplicateNulls
public boolean isUniqueWithDuplicateNulls()
Description copied from interface:IndexDescriptorReturns true if the index is duplicate keys only for null key parts. This is effective only if isUnique is false.- Specified by:
isUniqueWithDuplicateNullsin interfaceIndexDescriptor- See Also:
IndexDescriptor.isUniqueWithDuplicateNulls()
-
hasDeferrableChecking
public boolean hasDeferrableChecking()
Description copied from interface:IndexDescriptorReturns true if the index is used to support a deferrable constraint.- Specified by:
hasDeferrableCheckingin interfaceIndexDescriptor- Returns:
trueis the index supports a deferrable constraint
-
isUniqueDeferrable
public boolean isUniqueDeferrable()
The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.trueimplies#isUnique() == falseand#isUniqueWithDuplicateNulls() == falseand#hasDeferrableChecking() == true.- Specified by:
isUniqueDeferrablein interfaceIndexDescriptor- Returns:
trueis the index supports such a constraint
-
isUnique
public boolean isUnique()
Description copied from interface:IndexDescriptorReturns true if the index is unique.- Specified by:
isUniquein interfaceIndexDescriptor- See Also:
IndexDescriptor.isUnique()
-
baseColumnPositions
public int[] baseColumnPositions()
Description copied from interface:IndexDescriptorReturns an array of column positions in the base table. Each index column corresponds to a column position in the base table, except the column representing the location of the row in the base table. The returned array holds the column positions in the base table, so, if entry 2 is the number 4, the second column in the index is the fourth column in the table.- Specified by:
baseColumnPositionsin interfaceIndexDescriptor- See Also:
IndexDescriptor.baseColumnPositions()
-
getKeyColumnPosition
public int getKeyColumnPosition(int heapColumnPosition)
Description copied from interface:IndexDescriptorReturns the postion of a column.Returns the position of a column within the key (1-based). 0 means that the column is not in the key. Same as the above method, but it uses int instead of Integer.
- Specified by:
getKeyColumnPositionin interfaceIndexDescriptor- See Also:
IndexDescriptor.getKeyColumnPosition(int)
-
numberOfOrderedColumns
public int numberOfOrderedColumns()
Description copied from interface:IndexDescriptorReturns the number of ordered columns.In the future, it will be possible to store non-ordered columns in an index. These will be useful for covered queries. The ordered columns will be at the beginning of the index row, and they will be followed by the non-ordered columns. For now, all columns in an index must be ordered.
- Specified by:
numberOfOrderedColumnsin interfaceIndexDescriptor- See Also:
IndexDescriptor.numberOfOrderedColumns()
-
indexType
public java.lang.String indexType()
Description copied from interface:IndexDescriptorReturns the type of the index. For now, we only support B-Trees, so the value "BTREE" is returned.- Specified by:
indexTypein interfaceIndexDescriptor- See Also:
IndexDescriptor.indexType()
-
isAscending
public boolean isAscending(java.lang.Integer keyColumnPosition)
Description copied from interface:IndexDescriptorReturns true if the specified column is ascending in the index (1-based).- Specified by:
isAscendingin interfaceIndexDescriptor- See Also:
IndexDescriptor.isAscending()
-
isDescending
public boolean isDescending(java.lang.Integer keyColumnPosition)
Description copied from interface:IndexDescriptorReturns true if the specified column is descending in the index (1-based). In the current release, only ascending columns are supported.- Specified by:
isDescendingin interfaceIndexDescriptor- See Also:
IndexDescriptor.isDescending(java.lang.Integer)
-
isAscending
public boolean[] isAscending()
Description copied from interface:IndexDescriptorReturns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method. Both methods return an array with subscript starting from 0.- Specified by:
isAscendingin interfaceIndexDescriptor- See Also:
IndexDescriptor.isAscending()
-
setBaseColumnPositions
public void setBaseColumnPositions(int[] baseColumnPositions)
Description copied from interface:IndexDescriptorset the baseColumnPositions field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where baseColumnPositions is changed.- Specified by:
setBaseColumnPositionsin interfaceIndexDescriptor- See Also:
IndexDescriptor.setBaseColumnPositions(int[])
-
setIsAscending
public void setIsAscending(boolean[] isAscending)
Description copied from interface:IndexDescriptorset the isAscending field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where isAscending is changed.- Specified by:
setIsAscendingin interfaceIndexDescriptor- See Also:
IndexDescriptor.setIsAscending(boolean[])
-
setNumberOfOrderedColumns
public void setNumberOfOrderedColumns(int numberOfOrderedColumns)
Description copied from interface:IndexDescriptorset the numberOfOrderedColumns field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where numberOfOrderedColumns is changed.- Specified by:
setNumberOfOrderedColumnsin interfaceIndexDescriptor- See Also:
IndexDescriptor.setNumberOfOrderedColumns(int)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException- Thrown on read errorjava.lang.ClassNotFoundException- See Also:
Externalizable.readExternal(java.io.ObjectInput)
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException- Thrown on write error- See Also:
Externalizable.writeExternal(java.io.ObjectOutput)
-
getTypeFormatId
public int getTypeFormatId()
Description copied from interface:TypedFormatGet a universally unique identifier for the type of this object.- Specified by:
getTypeFormatIdin interfaceTypedFormat- Returns:
- The identifier. (A UUID stuffed in an array of 16 bytes).
-
equals
public boolean equals(java.lang.Object other)
Test for value equality- Overrides:
equalsin classjava.lang.Object- Parameters:
other- The other indexrowgenerator to compare this one with- Returns:
- true if this indexrowgenerator has the same value as other
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
-