use of org.apache.derby.iapi.sql.dictionary.IndexRowGenerator in project derby by apache.
the class FromBaseTable method isOneRowResultSet.
/**
* Is this a one-row result set with the given conglomerate descriptor?
*/
private boolean isOneRowResultSet(ConglomerateDescriptor cd, OptimizablePredicateList predList) throws StandardException {
if (predList == null) {
return false;
}
if (SanityManager.DEBUG) {
if (!(predList instanceof PredicateList)) {
SanityManager.THROWASSERT("predList should be a PredicateList, but is a " + predList.getClass().getName());
}
}
PredicateList restrictList = (PredicateList) predList;
if (!cd.isIndex()) {
return false;
}
IndexRowGenerator irg = cd.getIndexDescriptor();
// is this a unique index
if (!irg.isUnique()) {
return false;
}
int[] baseColumnPositions = irg.baseColumnPositions();
// Do we have an exact match on the full key
for (int index = 0; index < baseColumnPositions.length; index++) {
// get the column number at this position
int curCol = baseColumnPositions[index];
/* Is there a pushable equality predicate on this key column?
* (IS NULL is also acceptable)
*/
if (!restrictList.hasOptimizableEqualityPredicate(this, curCol, true)) {
return false;
}
}
return true;
}
use of org.apache.derby.iapi.sql.dictionary.IndexRowGenerator in project derby by apache.
the class SYSCONGLOMERATESRowFactory method buildDescriptor.
// /////////////////////////////////////////////////////////////////////////
//
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
//
// /////////////////////////////////////////////////////////////////////////
/**
* @param row a SYSCOLUMNS row
* @param parentTupleDescriptor Null for this kind of descriptor.
* @param dd dataDictionary
*
* @return a conglomerate descriptor equivalent to a SYSCONGOMERATES row
*
* @exception StandardException thrown on failure
*/
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
if (SanityManager.DEBUG)
SanityManager.ASSERT(row.nColumns() == SYSCONGLOMERATES_COLUMN_COUNT, "Wrong number of columns for a SYSCONGLOMERATES row");
DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
long conglomerateNumber;
String name;
boolean isConstraint;
boolean isIndex;
IndexRowGenerator indexRowGenerator;
DataValueDescriptor col;
ConglomerateDescriptor conglomerateDesc;
String conglomUUIDString;
UUID conglomUUID;
String schemaUUIDString;
UUID schemaUUID;
String tableUUIDString;
UUID tableUUID;
/* 1st column is SCHEMAID (UUID - char(36)) */
col = row.getColumn(1);
schemaUUIDString = col.getString();
schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);
/* 2nd column is TABLEID (UUID - char(36)) */
col = row.getColumn(2);
tableUUIDString = col.getString();
tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);
/* 3nd column is CONGLOMERATENUMBER (long) */
col = row.getColumn(3);
conglomerateNumber = col.getLong();
/* 4rd column is CONGLOMERATENAME (varchar(128)) */
col = row.getColumn(4);
name = col.getString();
/* 5th column is ISINDEX (boolean) */
col = row.getColumn(5);
isIndex = col.getBoolean();
/* 6th column is DESCRIPTOR */
col = row.getColumn(6);
indexRowGenerator = new IndexRowGenerator((IndexDescriptor) col.getObject());
/* 7th column is ISCONSTRAINT (boolean) */
col = row.getColumn(7);
isConstraint = col.getBoolean();
/* 8th column is CONGLOMERATEID (UUID - char(36)) */
col = row.getColumn(8);
conglomUUIDString = col.getString();
conglomUUID = getUUIDFactory().recreateUUID(conglomUUIDString);
/* now build and return the descriptor */
conglomerateDesc = ddg.newConglomerateDescriptor(conglomerateNumber, name, isIndex, indexRowGenerator, isConstraint, conglomUUID, tableUUID, schemaUUID);
return conglomerateDesc;
}
use of org.apache.derby.iapi.sql.dictionary.IndexRowGenerator in project derby by apache.
the class SYSCONGLOMERATESRowFactory method makeRow.
/**
* Make a SYSCONGLOMERATES row
*
* @return Row suitable for inserting into SYSCONGLOMERATES.
*
* @exception StandardException thrown on failure
*/
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
ExecRow row;
DataValueDescriptor col;
String tabID = null;
Long conglomNumber = null;
String conglomName = null;
Boolean supportsIndex = null;
IndexRowGenerator indexRowGenerator = null;
Boolean supportsConstraint = null;
String conglomUUIDString = null;
String schemaID = null;
ConglomerateDescriptor conglomerate = (ConglomerateDescriptor) td;
if (td != null) {
/* Sometimes the SchemaDescriptor is non-null and sometimes it
* is null. (We can't just rely on getting the schema id from
* the ConglomerateDescriptor because it can be null when
* we are creating a new conglomerate.
*/
if (parent != null) {
SchemaDescriptor sd = (SchemaDescriptor) parent;
schemaID = sd.getUUID().toString();
} else {
schemaID = conglomerate.getSchemaID().toString();
}
tabID = conglomerate.getTableID().toString();
conglomNumber = conglomerate.getConglomerateNumber();
conglomName = conglomerate.getConglomerateName();
conglomUUIDString = conglomerate.getUUID().toString();
supportsIndex = conglomerate.isIndex();
indexRowGenerator = conglomerate.getIndexDescriptor();
supportsConstraint = conglomerate.isConstraint();
}
/* RESOLVE - It would be nice to require less knowledge about sysconglomerates
* and have this be more table driven.
*/
/* Build the row to insert */
row = getExecutionFactory().getValueRow(SYSCONGLOMERATES_COLUMN_COUNT);
/* 1st column is SCHEMAID (UUID - char(36)) */
row.setColumn(1, new SQLChar(schemaID));
/* 2nd column is TABLEID (UUID - char(36)) */
row.setColumn(2, new SQLChar(tabID));
/* 3rd column is CONGLOMERATENUMBER (long) */
row.setColumn(3, new SQLLongint(conglomNumber));
/* 4th column is CONGLOMERATENAME (varchar(128))
** If null, use the tableid so we always
** have a unique column
*/
row.setColumn(4, (conglomName == null) ? new SQLVarchar(tabID) : new SQLVarchar(conglomName));
/* 5th column is ISINDEX (boolean) */
row.setColumn(5, new SQLBoolean(supportsIndex));
/* 6th column is DESCRIPTOR
* (user type org.apache.derby.catalog.IndexDescriptor)
*/
row.setColumn(6, new UserType((indexRowGenerator == null ? (IndexDescriptor) null : indexRowGenerator.getIndexDescriptor())));
/* 7th column is ISCONSTRAINT (boolean) */
row.setColumn(7, new SQLBoolean(supportsConstraint));
/* 8th column is CONGLOMERATEID (UUID - char(36)) */
row.setColumn(8, new SQLChar(conglomUUIDString));
return row;
}
Aggregations