use of org.apache.derby.iapi.sql.dictionary.UniqueTupleDescriptor in project derby by apache.
the class XMLOptTrace method formatPlanSummary.
/**
* <p>
* Produce a string representation of the plan being considered now.
* The string has the following grammar:
* </p>
*
* <pre>
* join :== factor OP factor
*
* OP :== "*" | "#"
*
* factor :== factor | conglomerateName
* </pre>
*/
private String formatPlanSummary(int[] planOrder, int planType) {
try {
OptimizerPlan plan = null;
StringBuilder buffer = new StringBuilder();
boolean avoidSort = (planType == Optimizer.SORT_AVOIDANCE_PLAN);
// a negative optimizable number indicates the end of the plan
int planLength = 0;
for (; planLength < planOrder.length; planLength++) {
if (planOrder[planLength] < 0) {
break;
}
}
for (int i = 0; i < planLength; i++) {
int listIndex = planOrder[i];
if (listIndex >= _currentQueryBlock.optimizableList.size()) {
// should never happen!
buffer.append("{ UNKNOWN LIST INDEX " + listIndex + " } ");
continue;
}
Optimizable optimizable = _currentQueryBlock.optimizableList.getOptimizable(listIndex);
AccessPath ap = avoidSort ? optimizable.getBestSortAvoidancePath() : optimizable.getBestAccessPath();
JoinStrategy js = ap.getJoinStrategy();
UniqueTupleDescriptor utd = OptimizerImpl.isTableFunction(optimizable) ? ((StaticMethodCallNode) ((FromVTI) ((ProjectRestrictNode) optimizable).getChildResult()).getMethodCall()).ad : ap.getConglomerateDescriptor();
OptimizerPlan current = (utd == null) ? new OptimizerPlan.DeadEnd(getOptimizableName(optimizable).toString()) : OptimizerPlan.makeRowSource(utd, _lcc.getDataDictionary());
if (plan != null) {
current = new OptimizerPlan.Join(js, plan, current);
}
plan = current;
}
return plan.toString();
} catch (Exception e) {
return e.getMessage();
}
}
use of org.apache.derby.iapi.sql.dictionary.UniqueTupleDescriptor in project derby by apache.
the class SYSCOLUMNSRowFactory method buildDescriptor.
// /////////////////////////////////////////////////////////////////////////
//
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
//
// /////////////////////////////////////////////////////////////////////////
/**
* Make a ColumnDescriptor out of a SYSCOLUMNS row
*
* @param row a SYSCOLUMNS row
* @param parentTupleDescriptor The UniqueTupleDescriptor for the object that is tied
* to this column
* @param dd dataDictionary
*
* @return a column descriptor equivalent to a SYSCOLUMNS row
*
* @exception StandardException thrown on failure
*/
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
if (SanityManager.DEBUG) {
int expectedCols = dd.checkVersion(DataDictionary.DD_VERSION_DERBY_10_14, null) ? SYSCOLUMNS_COLUMN_COUNT : (SYSCOLUMNS_COLUMN_COUNT - 1);
SanityManager.ASSERT(row.nColumns() == expectedCols, "Wrong number of columns for a SYSCOLUMNS row");
}
int columnNumber;
String columnName;
String defaultID;
DefaultInfoImpl defaultInfo = null;
ColumnDescriptor colDesc;
DataValueDescriptor defaultValue = null;
UUID defaultUUID = null;
UUID uuid = null;
UUIDFactory uuidFactory = getUUIDFactory();
long autoincStart, autoincInc, autoincValue;
boolean autoincCycle = false;
DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
/*
** We're going to be getting the UUID for this sucka
** so make sure it is a UniqueTupleDescriptor.
*/
if (parentTupleDescriptor != null) {
if (SanityManager.DEBUG) {
if (!(parentTupleDescriptor instanceof UniqueTupleDescriptor)) {
SanityManager.THROWASSERT(parentTupleDescriptor.getClass().getName() + " not instanceof UniqueTupleDescriptor");
}
}
uuid = ((UniqueTupleDescriptor) parentTupleDescriptor).getUUID();
} else {
/* 1st column is REFERENCEID (char(36)) */
uuid = uuidFactory.recreateUUID(row.getColumn(SYSCOLUMNS_REFERENCEID).getString());
}
/* NOTE: We get columns 5 and 6 next in order to work around
* a 1.3.0 HotSpot bug. (#4361550)
*/
// 5th column is COLUMNDEFAULT (serialiazable)
Object object = row.getColumn(SYSCOLUMNS_COLUMNDEFAULT).getObject();
if (object instanceof DataValueDescriptor) {
defaultValue = (DataValueDescriptor) object;
} else if (object instanceof DefaultInfoImpl) {
defaultInfo = (DefaultInfoImpl) object;
defaultValue = defaultInfo.getDefaultValue();
}
/* 6th column is DEFAULTID (char(36)) */
defaultID = row.getColumn(SYSCOLUMNS_COLUMNDEFAULTID).getString();
if (defaultID != null) {
defaultUUID = uuidFactory.recreateUUID(defaultID);
}
/* 2nd column is COLUMNNAME (varchar(128)) */
columnName = row.getColumn(SYSCOLUMNS_COLUMNNAME).getString();
/* 3rd column is COLUMNNUMBER (int) */
columnNumber = row.getColumn(SYSCOLUMNS_COLUMNNUMBER).getInt();
/* 4th column is COLUMNDATATYPE */
/*
** What is stored in the column is a TypeDescriptorImpl, which
** points to a BaseTypeIdImpl. These are simple types that are
** intended to be movable to the client, so they don't have
** the entire implementation. We need to wrap them in DataTypeServices
** and TypeId objects that contain the full implementations for
** language processing.
*/
TypeDescriptor catalogType = (TypeDescriptor) row.getColumn(SYSCOLUMNS_COLUMNDATATYPE).getObject();
DataTypeDescriptor dataTypeServices = DataTypeDescriptor.getType(catalogType);
/* 7th column is AUTOINCREMENTVALUE (long) */
autoincValue = row.getColumn(SYSCOLUMNS_AUTOINCREMENTVALUE).getLong();
/* 8th column is AUTOINCREMENTSTART (long) */
autoincStart = row.getColumn(SYSCOLUMNS_AUTOINCREMENTSTART).getLong();
/* 9th column is AUTOINCREMENTINC (long) */
autoincInc = row.getColumn(SYSCOLUMNS_AUTOINCREMENTINC).getLong();
if (row.nColumns() >= 10) {
DataValueDescriptor col = row.getColumn(SYSCOLUMNS_AUTOINCREMENTINCCYCLE);
autoincCycle = col.getBoolean();
}
DataValueDescriptor col = row.getColumn(SYSCOLUMNS_AUTOINCREMENTSTART);
autoincStart = col.getLong();
col = row.getColumn(SYSCOLUMNS_AUTOINCREMENTINC);
autoincInc = col.getLong();
// Hard upgraded tables <=10.13 come with a false autoincCyle before they are first
// explicitly set with cycle or no cycle command.
colDesc = new ColumnDescriptor(columnName, columnNumber, dataTypeServices, defaultValue, defaultInfo, uuid, defaultUUID, autoincStart, autoincInc, autoincValue, autoincCycle);
return colDesc;
}
Aggregations