Top Description Fields Constructors Methods
org.apache.derby.iapi.sql.dictionary

public Class TableDescriptor

extends UniqueSQLObjectDescriptor
implements Provider, Dependent
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.depend.Dependent, org.apache.derby.catalog.Dependable, org.apache.derby.iapi.sql.depend.Provider
Imports
java.util.List, org.apache.derby.catalog.Dependable, .DependableFinder, .UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.Property, .SQLState, org.apache.derby.iapi.services.io.FormatableBitSet, .StoredFormatIds, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.context.Context, .ContextService, org.apache.derby.iapi.services.property.PropertyUtil, org.apache.derby.iapi.sql.StatementType, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.depend.DependencyManager, .Dependent, .Provider, org.apache.derby.iapi.sql.execute.ExecRow, org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.iapi.util.IdUtil

This class represents a table descriptor. The external interface to this class is:

  1. external interface
  2. public String getSchemaName();
  3. public String getQualifiedName();
  4. public int getTableType();
  5. public long getHeapConglomerateId() throws StandardException;
  6. public int getNumberOfColumns();
  7. public FormatableBitSet getReferencedColumnMap();
  8. public void setReferencedColumnMap(FormatableBitSet referencedColumnMap);
  9. public int getMaxColumnID() throws StandardException;
  10. public void setUUID(UUID uuid);
  11. public char getLockGranularity();
  12. public void setTableName(String newTableName);
  13. public void setLockGranularity(char lockGranularity);
  14. public ExecRow getEmptyExecRow( ContextManager cm) throws StandardException;
  15. public boolean tableNameEquals(String otherSchemaName, String otherTableName);
  16. public ReferencedKeyConstraintDescriptor getPrimaryKey() throws StandardException;
  17. public void removeConglomerateDescriptor(ConglomerateDescriptor cd) throws StandardException;
  18. public void removeConstraintDescriptor(ConstraintDescriptor cd) throws StandardException;
  19. public void getAffectedIndexes(...) throws StandardException;
  20. public void getAllRelevantTriggers(...) throws StandardException;
  21. public void getAllRelevantConstraints(...) throws StandardException
  22. public ColumnDescriptorList getColumnDescriptorList();
  23. public String[] getColumnNamesArray();
  24. public long[] getAutoincIncrementArray();
  25. public ColumnDescriptor getColumnDescriptor(String columnName);
  26. public ColumnDescriptor getColumnDescriptor(int columnNumber);
  27. public ConglomerateDescriptor[] getConglomerateDescriptors() throws StandardException;
  28. public ConglomerateDescriptor getConglomerateDescriptor(long conglomerateNumber) throws StandardException;
  29. public ConglomerateDescriptor getConglomerateDescriptor(UUID conglomerateUUID) throws StandardException;
  30. public IndexLister getIndexLister() throws StandardException;
  31. public ViewDescriptor getViewDescriptor();
  32. public boolean tableHasAutoincrement();
  33. public boolean statisticsExist(ConglomerateDescriptor cd) throws StandardException;
  34. public double selectivityForConglomerate(...)throws StandardException;

Field Summary

Modifier and TypeField and Description
public static final int
pack-priv ColumnDescriptorList
pack-priv ConglomerateDescriptorList
pack-priv ConstraintDescriptorList
public static final char
public static final int
private volatile long
heapConglomNumber

The id of the heap conglomerate for the table described by this instance.

private String
private boolean
public static final int
public static final int
public static final double
private char
pack-priv UUID
private boolean
private boolean
public static final char
pack-priv SchemaDescriptor
private List<StatisticsDescriptor>
statisticsDescriptorList

A list of statistics pertaining to this table--

public static final int
public static final int
public static final char
pack-priv String
pack-priv int
private TriggerDescriptorList
public static final int
pack-priv ViewDescriptor
public static final int

Constructor Summary

AccessConstructor and Description
public
TableDescriptor(DataDictionary
The data dictionary that this descriptor lives in
dataDictionary
,
String
The name of the temporary table
tableName
,
SchemaDescriptor
The schema descriptor for this table.
schema
,
int
An integer identifier for the type of the table : declared global temporary table
tableType
,
boolean
If true, on commit delete rows else on commit preserve rows of temporary table.
onCommitDeleteRows
,
boolean
If true, on rollback, delete rows from temp tables which were logically modified. true is the only supported value
onRollbackDeleteRows
)

Constructor for a TableDescriptor (this is for a temporary table).

public
TableDescriptor(DataDictionary
The data dictionary that this descriptor lives in
dataDictionary
,
String
The name of the table
tableName
,
SchemaDescriptor
The schema descriptor for this table.
schema
,
int
An integer identifier for the type of the table (base table, view, etc.)
tableType
,
char
The lock granularity.
lockGranularity
)

Constructor for a TableDescriptor.

Method Summary

Modifier and TypeMethod and Description
public void
emptyConstraintDescriptorList()

Empty the constraint descriptor list

public void
emptyTriggerDescriptorList()

Empty the trigger descriptor list

public void
getAllRelevantConstraints(int
As defined in StatementType.
statementType
,
int[]
If null, all columns being changed, otherwise array of 1-based column ids for columns being changed
changedColumnIds
,
boolean[]
IN/OUT. true if the statement already needs deferred processing. set while evaluating this routine if a trigger or constraint requires deferred processing
needsDeferredProcessing
,
ConstraintDescriptorList
IN/OUT. Empty list is passed in. We hang constraints on it as we go.
relevantConstraints
)

Gets all of the relevant constraints for a statement, given its statement type and its list of updated columns.

public void
getAllRelevantTriggers(int
defined in StatementType
statementType
,
int[]
array of changed columns
changedColumnIds
,
TriggerDescriptorList
IN/OUT. Passed in as an empty list. Filled in as we go.
relevantTriggers
)

Builds a list of all triggers which are relevant to a given statement type, given a list of updated columns.

public boolean

Returns:

true if the statistics are considered up-to-date, false if not.
getAndClearIndexStatsIsUpToDate
()

Tells if the index statistics for the indexes associated with this table are consideres up-to-date, and clears the state.

public long[]

Returns:

array containing the increment values of autoincrement columns.
getAutoincIncrementArray
()

gets an array of increment values for autoincrement columns in the target table.

public String

Returns:

String The provider's type.
getClassType
()

Implements org.apache.derby.catalog.Dependable.getClassType.

Get the provider's type.

public int[]
getColumnCollationIds()

Return an array of collation ids for this table.

public ColumnDescriptor

Returns:

A ColumnDescriptor describing the column
getColumnDescriptor
(String
A String containing the name of the column
columnName
)

Get the descriptor for a column in the table, either by the column name or by its ordinal position (column number).

public ColumnDescriptor

Returns:

A ColumnDescriptor describing the column
getColumnDescriptor
(int
The ordinal (1-based) position of the column in the table
columnNumber
)

public ColumnDescriptorList

Returns:

The column descriptor list for this table descriptor
getColumnDescriptorList
()

Gets the column descriptor list

public int[]
getColumnIDs(String[] names)

Turn an array of column names into the corresponding 1-based column positions.

public String[]

Returns:

An array, filled with the column names in the table.
getColumnNamesArray
()

Gets an array of column names.

public ConglomerateDescriptor

Returns:

A ConglomerateDescriptor describing the requested conglomerate. Returns NULL if no such conglomerate.
getConglomerateDescriptor
(long
The conglomerate number we're interested in
conglomerateNumber
)

Gets a conglomerate descriptor for the given table and conglomerate number.

public ConglomerateDescriptor

Returns:

A ConglomerateDescriptor describing the requested conglomerate. Returns NULL if no such conglomerate.
getConglomerateDescriptor
(UUID
The UUID for the conglomerate we're interested in
conglomerateUUID
)

Gets a conglomerate descriptor for the given table and conglomerate UUID String.

public ConglomerateDescriptorList

Returns:

The conglomerate descriptor list for this table descriptor
getConglomerateDescriptorList
()

Gets the conglomerate descriptor list

public ConglomerateDescriptor[]

Returns:

A ConglomerateDescriptor[] for looping through the table's conglomerates
getConglomerateDescriptors
()

Gets a ConglomerateDescriptor[] to loop through all the conglomerate descriptors for the table.

public ConglomerateDescriptor[]

Returns:

Array of ConglomerateDescriptors with the requested conglomerate number. Returns size 0 array if no such conglomerate.
getConglomerateDescriptors
(long
The conglomerate number we're interested in
conglomerateNumber
)

Gets array of conglomerate descriptors for the given table and conglomerate number.

public ConglomerateDescriptor[]

Returns:

Array of ConglomerateDescriptors with the requested conglomerate UUID. Returns size 0 array if no such conglomerate.
getConglomerateDescriptors
(UUID
The conglomerate UUID we're interested in
conglomerateUUID
)

Gets array of conglomerate descriptors for the given table and conglomerate UUID.

public ConstraintDescriptorList

Returns:

The constraint descriptor list for this table descriptor
getConstraintDescriptorList
()

Gets the constraint descriptor list

private static Context
getContextOrNull(final String contextID)

Must be private so that user code can't call this entry point.

public DependableFinder

Returns:

the stored form of this provider
getDependableFinder
()

Implements org.apache.derby.catalog.Dependable.getDependableFinder.

Get an object which can be written to disk and which, when read from disk, will find or reconstruct this in-memory Dependable.

public String
public String
getDescriptorType()

Overrides org.apache.derby.iapi.sql.dictionary.TupleDescriptor.getDescriptorType.

Each descriptor must identify itself with its type; i.e index, check constraint whatever.

public ExecRow

Returns:

the row.
getEmptyExecRow
()

Gets an ExecRow for rows stored in the table this describes.

public ColumnDescriptorList
getGeneratedColumns()

Gets the list of columns defined by generation clauses.

public long

Returns:

the id of the heap conglomerate for the table.
getHeapConglomerateId
()

Gets the id for the heap conglomerate of the table.

public IndexLister

Returns:

An object to list out the index row generators.
getIndexLister
()

Gets an object which lists out all the index row generators on a table together with their conglomerate ids.

public String

Returns:

A string describing the update criteria that were met.
getIndexStatsUpdateReason
()

Returns the update criteria telling why the statistics are considered stale.

public char

Returns:

A char representing the lock granularity for the table.
getLockGranularity
()

Gets the lock granularity for the table.

public int

Returns:

the highest column ID in the table
getMaxColumnID
()

Gets the highest column id in the table.

public String

Returns:

A String containing the name of the table.
getName
()

Implements abstract org.apache.derby.iapi.sql.dictionary.UniqueSQLObjectDescriptor.getName.

Gets the name of the table.

public int

Returns:

the number of columns in the table.
getNumberOfColumns
()

Gets the number of columns in the table.

public UUID

Returns:

String The provider's UUID
getObjectID
()

Implements org.apache.derby.catalog.Dependable.getObjectID.

Get the provider's UUID

public String

Returns:

String The name of this provider.
getObjectName
()

Implements org.apache.derby.catalog.Dependable.getObjectName.

Return the name of this Provider.

public ReferencedKeyConstraintDescriptor

Returns:

The priamry key or null
getPrimaryKey
()

Gets the primary key, may return null if no primary key

public String

Returns:

A String containing the name of the table.
getQualifiedName
()

Gets the full, qualified name of the table.

public int

Returns:

Number of matching indexes.
getQualifiedNumberOfIndexes
(int
the minimum number of ordered columns in the indexes we want to count
minColCount
,
boolean
if true a non-unique index will be included in the count even if it has less than minColCount ordered columns
nonUniqeTrumpsColCount
)

Returns the number of indexes matching the criteria.

public FormatableBitSet

Returns:

the referencedColumnMap of the table.
getReferencedColumnMap
()

Get the referenced column map of the table.

public SchemaDescriptor

Returns:

SchemaDescriptor The SchemaDescriptor.
getSchemaDescriptor
()

Implements abstract org.apache.derby.iapi.sql.dictionary.UniqueSQLObjectDescriptor.getSchemaDescriptor.

Gets the SchemaDescriptor for this TableDescriptor.

public String

Returns:

A String containing the name of the schema the table lives in.
getSchemaName
()

Gets the name of the schema the table lives in.

public synchronized List<StatisticsDescriptor>
getStatistics()

Returns a list of statistics for this table.

public int

Returns:

An identifier telling what type of table this is.
getTableType
()

Gets an identifier telling what type of table this is (base table, declared global temporary table, view, etc.)

public int

Returns:

the number of columns in the table.
getTotalNumberOfIndexes
()

Gets the number of indexes on the table, including the backing indexes.

public TriggerDescriptorList

Returns:

The trigger descriptor list for this table descriptor
getTriggerDescriptorList
()

Gets the trigger descriptor list

public UUID

Returns:

The UUID of the table.
getUUID
()

Implements abstract org.apache.derby.iapi.sql.dictionary.UniqueTupleDescriptor.getUUID.

Gets the UUID of the table.

public ViewDescriptor

Returns:

ViewDescriptor The ViewDescriptor, if any.
getViewDescriptor
()

Gets the view descriptor for this TableDescriptor.

public boolean

Returns:

A boolean representing the on commit behavior for the declared global temporary table.
isOnCommitDeleteRows
()

Gets the on commit behavior for the declared global temporary table.

public boolean

Returns:

A boolean representing the on rollback behavior for the declared global temporary table.
isOnRollbackDeleteRows
()

Gets the on rollback behavior for the declared global temporary table.

public boolean

Returns:

boolean Whether or not this provider is persistent.
isPersistent
()

Overrides org.apache.derby.iapi.sql.dictionary.TupleDescriptor.isPersistent.

Implements org.apache.derby.catalog.Dependable.isPersistent.

Is this provider persistent?

public boolean

Returns:

boolean Whether or not this represents a synonym
isSynonymDescriptor
()

Is this descriptor represents a synonym?

public synchronized boolean

Returns:

true if the dependent is currently valid
isValid
()

Implements org.apache.derby.iapi.sql.depend.Dependent.isValid.

Check that all of the dependent's dependencies are valid.

public FormatableBitSet
makeColumnMap(ColumnDescriptorList
list of columns whose positions we want to record in the bit map
cdl
)

Given a list of columns in the table, construct a bit map of those columns' ids.

public void
makeInvalid(int
The action causing the invalidation
action
,
LanguageConnectionContext
The LanguageConnectionContext
lcc
)

Implements org.apache.derby.iapi.sql.depend.Dependent.makeInvalid.

Mark the dependent as invalid (due to at least one of its dependencies being invalid).

public static String
makeSequenceName(UUID tableID)

Make the name of an identity sequence generator from a table ID

public void
markForIndexStatsUpdate(long
row count estimate for this table
tableRowCountEstimate
)

Marks the cardinality statistics for the indexes associated with this table for update if they are considered stale, or for creation if they don't exist, and if it is considered useful to update/create them.

public void
prepareToInvalidate(Provider
the provider
p
,
int
The action causing the invalidation
action
,
LanguageConnectionContext
The LanguageConnectionContext
lcc
)

Implements org.apache.derby.iapi.sql.depend.Dependent.prepareToInvalidate.

Prepare to mark the dependent as invalid (due to at least one of its dependencies being invalid).

private FormatableBitSet
private void
referencedColumnMapPut(FormatableBitSet newReferencedColumnMap)

public void
removeConglomerateDescriptor(ConglomerateDescriptor
The conglomerate descriptor
cd
)

Remove this descriptor

public void
removeConstraintDescriptor(ConstraintDescriptor
constraint descriptor
cd
)

Remove this descriptor.

public void
resetHeapConglomNumber()

Sets the heapConglomNumber to -1 for temporary table since the table was dropped and recreated at the commit time and hence its conglomerate id has changed.

public double
selectivityForConglomerate(ConglomerateDescriptor
ConglomerateDescriptor (Index) whose cardinality we are interested in.
cd
,
int
Number of leading columns of the index for which cardinality is desired.
numKeys
)

For this conglomerate (index), return the selectivity of the first numKeys.

public void
setConstraintDescriptorList(ConstraintDescriptorList
The new constraint descriptor list for this table descriptor
newCDL
)

Sets the constraint descriptor list

public void
setLockGranularity(char
The new lockGranularity.
lockGranularity
)

Sets the lock granularity for the table to the specified value.

public void
setReferencedColumnMap(FormatableBitSet
FormatableBitSet of referenced columns.
referencedColumnMap
)

Set the referenced column map of the table.

public void
setTableName(String
The new table name.
newTableName
)

Sets the the table name in case of rename table.

public void
setTriggerDescriptorList(TriggerDescriptorList
The new trigger descriptor list for this table descriptor
newCDL
)

Sets the trigger descriptor list

public void
setUUID(UUID
The UUID of the table to be set in the descriptor
oid
)

Sets the UUID of the table

public void
setViewDescriptor(ViewDescriptor
The view descriptor to cache.
viewDescriptor
)

Set (cache) the view descriptor for this TableDescriptor

public boolean
statisticsExist(ConglomerateDescriptor
Conglomerate/Index for which we want to check if statistics exist. cd can be null in which case user wants to know if there are any statistics at all on the table.
cd
)

Are there statistics for this particular conglomerate.

public boolean

Returns:

TRUE if the table has at least one auto-increment column, false otherwise
tableHasAutoincrement
()

Does the table have an auto-increment column or not?

public boolean

Returns:

boolean Whether or not the 2 TableNames are equal.
tableNameEquals
(String
the other table name
otherTableName
,
String
the other schema name
otherSchemaName
)

Compare the tables descriptors based on the names.

public String

Returns:

The contents as a String
toString
()

Overrides java.lang.Object.toString.

Prints the contents of the TableDescriptor