Class IndexRowGenerator
- All Implemented Interfaces:
Externalizable
,Serializable
,IndexDescriptor
,Formatable
,TypedFormat
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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionZero-argument constructor for Formatable interfaceIndexRowGenerator
(String indexType, boolean isUnique, boolean isUniqueWithDuplicateNulls, boolean isUniqueDeferrable, boolean hasDeferrableChecking, int[] baseColumnPositions, boolean[] isAscending, int numberOfOrderedColumns) Constructor for an IndexRowGeneratorImplIndexRowGenerator
(IndexDescriptor indexDescriptor) Constructor for an IndexRowGeneratorImpl -
Method Summary
Modifier and TypeMethodDescriptionint[]
Returns an array of column positions in the base table.boolean
Test for value equalityint[]
getColumnCollationIds
(ColumnDescriptorList columnList) Return an array of collation ids for this table.private static Context
getContext
(String contextID) Privileged lookup of a Context.private ExecutionFactory
Get the IndexDescriptor that this IndexRowGenerator is based on.void
getIndexRow
(ExecRow baseRow, RowLocation rowLocation, ExecIndexRow indexRow, FormatableBitSet bitSet) Get an index row for this index given a row from the base table and the RowLocation of the base row.Get a template for the index row, to be used with getIndexRow.int
getKeyColumnPosition
(int heapColumnPosition) Returns the postion of a column.getNullIndexRow
(ColumnDescriptorList columnList, RowLocation rowLocation) Get a NULL Index Row for this index.int
Get a universally unique identifier for the type of this object.boolean
Returns true if the index is used to support a deferrable constraint.int
hashCode()
Returns the type of the index.boolean[]
Returns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method.boolean
isAscending
(Integer keyColumnPosition) Returns true if the specified column is ascending in the index (1-based).boolean
isDescending
(Integer keyColumnPosition) Returns true if the specified column is descending in the index (1-based).boolean
isUnique()
Returns true if the index is unique.boolean
The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.boolean
Returns true if the index is duplicate keys only for null key parts.int
Returns the number of ordered columns.void
void
setBaseColumnPositions
(int[] baseColumnPositions) set the baseColumnPositions field of the index descriptor.void
setIsAscending
(boolean[] isAscending) set the isAscending field of the index descriptor.void
setNumberOfOrderedColumns
(int numberOfOrderedColumns) set the numberOfOrderedColumns field of the index descriptor.toString()
void
-
Field Details
-
id
-
ef
-
-
Constructor Details
-
IndexRowGenerator
public IndexRowGenerator(String indexType, boolean isUnique, boolean isUniqueWithDuplicateNulls, boolean isUniqueDeferrable, boolean hasDeferrableChecking, int[] baseColumnPositions, boolean[] isAscending, int numberOfOrderedColumns) Constructor for an IndexRowGeneratorImpl- Parameters:
indexType
- The type of indexisUnique
- True means the index is uniqueisUniqueWithDuplicateNulls
- means the index is almost unique i.e. unique only for non null keysisUniqueDeferrable
- True means the index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.hasDeferrableChecking
- True if the index is used to back a deferrable constraintbaseColumnPositions
- 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.
-
IndexRowGenerator
Constructor for an IndexRowGeneratorImpl- Parameters:
indexDescriptor
- An IndexDescriptor to delegate calls to
-
IndexRowGenerator
public IndexRowGenerator()Zero-argument constructor for Formatable interface
-
-
Method Details
-
getIndexRowTemplate
Get a template for the index row, to be used with getIndexRow.- Returns:
- A row template for the index row.
-
getNullIndexRow
public ExecIndexRow getNullIndexRow(ColumnDescriptorList columnList, RowLocation rowLocation) throws StandardException Get a NULL Index Row for this index. This is useful to create objects that need to be passed to ScanController.- Parameters:
columnList
- ColumnDescriptors describing the base table.rowLocation
- empty row location.- Throws:
StandardException
- thrown on error.
-
getIndexRow
public void getIndexRow(ExecRow baseRow, RowLocation rowLocation, ExecIndexRow indexRow, FormatableBitSet bitSet) throws StandardException Get an index row for this index given a row from the base table and the RowLocation of the base row. This method can be used to get the new index row for inserts, and the old and new index rows for deletes and updates. For updates, the result row has all the old column values followed by all of the new column values, so you must form a row using the new column values to pass to this method to get the new index row.- Parameters:
baseRow
- A row in the base tablerowLocation
- The RowLocation of the row in the base tableindexRow
- A template for the index row. It must have the correct number of columns.bitSet
- If non-null, then baseRow is a partial row and the set bits in bitSet represents the column mapping for the partial row to the complete base row. WARNING: ONE based!!!- Throws:
StandardException
- Thrown on error
-
getColumnCollationIds
Return an array of collation ids for this table.Return an array of collation ids, one for each column in the columnDescriptorList. This is useful for passing collation id info down to store, for instance in createConglomerate() to create the index. This is only expected to get called during ddl, so object allocation is ok.
- Parameters:
columnList
- ColumnDescriptors describing the base table.- Throws:
StandardException
- Standard exception policy.
-
getIndexDescriptor
Get the IndexDescriptor that this IndexRowGenerator is based on. -
isUniqueWithDuplicateNulls
public boolean isUniqueWithDuplicateNulls()Description copied from interface:IndexDescriptor
Returns true if the index is duplicate keys only for null key parts. This is effective only if isUnique is false.- Specified by:
isUniqueWithDuplicateNulls
in interfaceIndexDescriptor
- See Also:
-
hasDeferrableChecking
public boolean hasDeferrableChecking()Description copied from interface:IndexDescriptor
Returns true if the index is used to support a deferrable constraint.- Specified by:
hasDeferrableChecking
in interfaceIndexDescriptor
-
isUniqueDeferrable
public boolean isUniqueDeferrable()Description copied from interface:IndexDescriptor
The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.true
impliesisUnique() == false
andisUniqueWithDuplicateNulls() == false
andhasDeferrableChecking() == true
.- Specified by:
isUniqueDeferrable
in interfaceIndexDescriptor
- Returns:
true
if the index represents such a constraint
-
isUnique
public boolean isUnique()Description copied from interface:IndexDescriptor
Returns true if the index is unique.- Specified by:
isUnique
in interfaceIndexDescriptor
- See Also:
-
baseColumnPositions
public int[] baseColumnPositions()Description copied from interface:IndexDescriptor
Returns 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:
baseColumnPositions
in interfaceIndexDescriptor
- See Also:
-
getKeyColumnPosition
public int getKeyColumnPosition(int heapColumnPosition) Description copied from interface:IndexDescriptor
Returns 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:
getKeyColumnPosition
in interfaceIndexDescriptor
- See Also:
-
numberOfOrderedColumns
public int numberOfOrderedColumns()Description copied from interface:IndexDescriptor
Returns 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:
numberOfOrderedColumns
in interfaceIndexDescriptor
- See Also:
-
indexType
Description copied from interface:IndexDescriptor
Returns the type of the index. For now, we only support B-Trees, so the value "BTREE" is returned.- Specified by:
indexType
in interfaceIndexDescriptor
- See Also:
-
toString
-
isAscending
Description copied from interface:IndexDescriptor
Returns true if the specified column is ascending in the index (1-based).- Specified by:
isAscending
in interfaceIndexDescriptor
- See Also:
-
isDescending
Description copied from interface:IndexDescriptor
Returns true if the specified column is descending in the index (1-based). In the current release, only ascending columns are supported.- Specified by:
isDescending
in interfaceIndexDescriptor
- See Also:
-
isAscending
public boolean[] isAscending()Description copied from interface:IndexDescriptor
Returns 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:
isAscending
in interfaceIndexDescriptor
- See Also:
-
setBaseColumnPositions
public void setBaseColumnPositions(int[] baseColumnPositions) Description copied from interface:IndexDescriptor
set 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:
setBaseColumnPositions
in interfaceIndexDescriptor
- See Also:
-
setIsAscending
public void setIsAscending(boolean[] isAscending) Description copied from interface:IndexDescriptor
set 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:
setIsAscending
in interfaceIndexDescriptor
- See Also:
-
setNumberOfOrderedColumns
public void setNumberOfOrderedColumns(int numberOfOrderedColumns) Description copied from interface:IndexDescriptor
set 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:
setNumberOfOrderedColumns
in interfaceIndexDescriptor
- See Also:
-
equals
Test for value equality -
hashCode
public int hashCode() -
getExecutionFactory
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
- Thrown on read errorClassNotFoundException
- Thrown on read error- See Also:
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
- Thrown on write error
-
getTypeFormatId
public int getTypeFormatId()Description copied from interface:TypedFormat
Get a universally unique identifier for the type of this object.- Specified by:
getTypeFormatId
in interfaceTypedFormat
- Returns:
- The identifier. (A UUID stuffed in an array of 16 bytes).
-
getContext
Privileged lookup of a Context. Must be private so that user code can't call this entry point.
-