Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.sql.dictionary
Class IndexRowGenerator  view IndexRowGenerator download IndexRowGenerator.java

java.lang.Object
  extended byorg.apache.derby.iapi.sql.dictionary.IndexRowGenerator
All Implemented Interfaces:
java.io.Externalizable, org.apache.derby.iapi.services.io.Formatable, org.apache.derby.catalog.IndexDescriptor, java.io.Serializable, org.apache.derby.iapi.services.io.TypedFormat

public class IndexRowGenerator
extends java.lang.Object
implements org.apache.derby.catalog.IndexDescriptor, org.apache.derby.iapi.services.io.Formatable

This class extends IndexDescriptor for internal use by the DataDictionary.


Field Summary
private  org.apache.derby.iapi.sql.execute.ExecutionFactory ef
           
(package private)  org.apache.derby.catalog.IndexDescriptor id
           
 
Constructor Summary
IndexRowGenerator()
          Zero-argument constructor for Formatable interface
IndexRowGenerator(org.apache.derby.catalog.IndexDescriptor indexDescriptor)
          Constructor for an IndexRowGeneratorImpl
IndexRowGenerator(java.lang.String indexType, boolean isUnique, int[] baseColumnPositions, boolean[] isAscending, int numberOfOrderedColumns)
          Constructor for an IndexRowGeneratorImpl
 
Method Summary
 int[] baseColumnPositions()
          Returns an array of column positions in the base table.
 boolean equals(java.lang.Object other)
          Test for value equality
private  org.apache.derby.iapi.sql.execute.ExecutionFactory getExecutionFactory()
           
 org.apache.derby.catalog.IndexDescriptor getIndexDescriptor()
          Get the IndexDescriptor that this IndexRowGenerator is based on.
 void getIndexRow(org.apache.derby.iapi.sql.execute.ExecRow baseRow, org.apache.derby.iapi.types.RowLocation rowLocation, org.apache.derby.iapi.sql.execute.ExecIndexRow indexRow, org.apache.derby.iapi.services.io.FormatableBitSet bitSet)
          Get an index row for this index given a row from the base table and the RowLocation of the base row.
 org.apache.derby.iapi.sql.execute.ExecIndexRow getIndexRowTemplate()
          Get a template for the index row, to be used with getIndexRow.
 int getKeyColumnPosition(int heapColumnPosition)
          Returns the postion of a column.
 java.lang.Integer getKeyColumnPosition(java.lang.Integer heapColumnPosition)
          Returns the postion of a column.
 org.apache.derby.iapi.sql.execute.ExecIndexRow getNullIndexRow(ColumnDescriptorList columnList, org.apache.derby.iapi.types.RowLocation rowLocation)
          Get a NULL Index Row for this index.
 int getTypeFormatId()
          Get a universally unique identifier for the type of this object.
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
 boolean indexChanged(int[] changedColumnIds)
          Return true iff a change to a set of columns changes the index for this IndexRowGenerator.
 java.lang.String indexType()
          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.
 boolean isAscending(java.lang.Integer keyColumnPosition)
          Returns true if the specified column is ascending in the index (1-based).
 boolean isDescending(java.lang.Integer keyColumnPosition)
          Returns true if the specified column is descending in the index (1-based).
 boolean isUnique()
          Returns true if the index is unique.
 int numberOfOrderedColumns()
          Returns the number of ordered columns.
 void readExternal(java.io.ObjectInput in)
          This method restores an object's state by reading in the instance data for the object from the passed in stream.
 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.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void writeExternal(java.io.ObjectOutput out)
          This method is responsible for writing the instance data of an object to the passed in stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

org.apache.derby.catalog.IndexDescriptor id

ef

private org.apache.derby.iapi.sql.execute.ExecutionFactory ef
Constructor Detail

IndexRowGenerator

public IndexRowGenerator(java.lang.String indexType,
                         boolean isUnique,
                         int[] baseColumnPositions,
                         boolean[] isAscending,
                         int numberOfOrderedColumns)
Constructor for an IndexRowGeneratorImpl


IndexRowGenerator

public IndexRowGenerator(org.apache.derby.catalog.IndexDescriptor indexDescriptor)
Constructor for an IndexRowGeneratorImpl


IndexRowGenerator

public IndexRowGenerator()
Zero-argument constructor for Formatable interface

Method Detail

getIndexRowTemplate

public org.apache.derby.iapi.sql.execute.ExecIndexRow getIndexRowTemplate()
Get a template for the index row, to be used with getIndexRow.


getIndexRow

public void getIndexRow(org.apache.derby.iapi.sql.execute.ExecRow baseRow,
                        org.apache.derby.iapi.types.RowLocation rowLocation,
                        org.apache.derby.iapi.sql.execute.ExecIndexRow indexRow,
                        org.apache.derby.iapi.services.io.FormatableBitSet bitSet)
                 throws org.apache.derby.iapi.error.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.


getNullIndexRow

public org.apache.derby.iapi.sql.execute.ExecIndexRow getNullIndexRow(ColumnDescriptorList columnList,
                                                                      org.apache.derby.iapi.types.RowLocation rowLocation)
                                                               throws org.apache.derby.iapi.error.StandardException
Get a NULL Index Row for this index. This is useful to create objects that need to be passed to ScanController.


indexChanged

public boolean indexChanged(int[] changedColumnIds)
Return true iff a change to a set of columns changes the index for this IndexRowGenerator.


getIndexDescriptor

public org.apache.derby.catalog.IndexDescriptor getIndexDescriptor()
Get the IndexDescriptor that this IndexRowGenerator is based on.


isUnique

public boolean isUnique()
Description copied from interface: org.apache.derby.catalog.IndexDescriptor
Returns true if the index is unique.

Specified by:
isUnique in interface org.apache.derby.catalog.IndexDescriptor

baseColumnPositions

public int[] baseColumnPositions()
Description copied from interface: org.apache.derby.catalog.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 interface org.apache.derby.catalog.IndexDescriptor

getKeyColumnPosition

public java.lang.Integer getKeyColumnPosition(java.lang.Integer heapColumnPosition)
Description copied from interface: org.apache.derby.catalog.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.

Specified by:
getKeyColumnPosition in interface org.apache.derby.catalog.IndexDescriptor

getKeyColumnPosition

public int getKeyColumnPosition(int heapColumnPosition)
Description copied from interface: org.apache.derby.catalog.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 interface org.apache.derby.catalog.IndexDescriptor

numberOfOrderedColumns

public int numberOfOrderedColumns()
Description copied from interface: org.apache.derby.catalog.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 interface org.apache.derby.catalog.IndexDescriptor

indexType

public java.lang.String indexType()
Description copied from interface: org.apache.derby.catalog.IndexDescriptor
Returns the type of the index. For now, we only support B-Trees, so the value "BTREE" is returned.

Specified by:
indexType in interface org.apache.derby.catalog.IndexDescriptor

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


isAscending

public boolean isAscending(java.lang.Integer keyColumnPosition)
Description copied from interface: org.apache.derby.catalog.IndexDescriptor
Returns true if the specified column is ascending in the index (1-based).

Specified by:
isAscending in interface org.apache.derby.catalog.IndexDescriptor

isDescending

public boolean isDescending(java.lang.Integer keyColumnPosition)
Description copied from interface: org.apache.derby.catalog.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 interface org.apache.derby.catalog.IndexDescriptor

isAscending

public boolean[] isAscending()
Description copied from interface: org.apache.derby.catalog.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 interface org.apache.derby.catalog.IndexDescriptor

setBaseColumnPositions

public void setBaseColumnPositions(int[] baseColumnPositions)
Description copied from interface: org.apache.derby.catalog.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 interface org.apache.derby.catalog.IndexDescriptor

setIsAscending

public void setIsAscending(boolean[] isAscending)
Description copied from interface: org.apache.derby.catalog.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 interface org.apache.derby.catalog.IndexDescriptor

setNumberOfOrderedColumns

public void setNumberOfOrderedColumns(int numberOfOrderedColumns)
Description copied from interface: org.apache.derby.catalog.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 interface org.apache.derby.catalog.IndexDescriptor

equals

public boolean equals(java.lang.Object other)
Test for value equality


hashCode

public int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)


getExecutionFactory

private org.apache.derby.iapi.sql.execute.ExecutionFactory getExecutionFactory()

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Description copied from interface: java.io.Externalizable
This method restores an object's state by reading in the instance data for the object from the passed in stream. Note that this stream is not a subclass of InputStream, but rather is a class that implements the ObjectInput interface. That interface provides a mechanism for reading in Java data types from a stream.

Note that this method must be compatible with writeExternal. It must read back the exact same types that were written by that method in the exact order they were written.

If this method needs to read back an object instance, then the class for that object must be found and loaded. If that operation fails, then this method throws a ClassNotFoundException

Specified by:
readExternal in interface java.io.Externalizable

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Description copied from interface: java.io.Externalizable
This method is responsible for writing the instance data of an object to the passed in stream. Note that this stream is not a subclass of OutputStream, but rather is a class that implements the ObjectOutput interface. That interface provides a number of methods for writing Java data values to a stream.

Not that the implementation of this method must be coordinated with the implementation of readExternal.

Specified by:
writeExternal in interface java.io.Externalizable

getTypeFormatId

public int getTypeFormatId()
Description copied from interface: org.apache.derby.iapi.services.io.TypedFormat
Get a universally unique identifier for the type of this object.

Specified by:
getTypeFormatId in interface org.apache.derby.iapi.services.io.TypedFormat