Search in sources :

Example 6 with StaticCompiledOpenConglomInfo

use of org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo in project derby by apache.

the class BaseJoinStrategy method fillInScanArgs1.

/**
 * Push the first set of common arguments for obtaining a scan ResultSet from
 * ResultSetFactory.
 * The first 11 arguments are common for these ResultSet getters
 * <UL>
 * <LI> ResultSetFactory.getBulkTableScanResultSet
 * <LI> ResultSetFactory.getHashScanResultSet
 * <LI> ResultSetFactory.getTableScanResultSet
 * <LI> ResultSetFactory.getRaDependentTableScanResultSet
 * </UL>
 * @param tc
 * @param mb
 * @param innerTable
 * @param predList
 * @param acbi
 * @throws StandardException
 */
void fillInScanArgs1(TransactionController tc, MethodBuilder mb, Optimizable innerTable, OptimizablePredicateList predList, ExpressionClassBuilderInterface acbi, int resultRowTemplate) throws StandardException {
    boolean sameStartStopPosition = predList.sameStartStopPosition();
    ExpressionClassBuilder acb = (ExpressionClassBuilder) acbi;
    long conglomNumber = innerTable.getTrulyTheBestAccessPath().getConglomerateDescriptor().getConglomerateNumber();
    StaticCompiledOpenConglomInfo scoci = tc.getStaticCompiledConglomInfo(conglomNumber);
    acb.pushThisAsActivation(mb);
    mb.push(conglomNumber);
    mb.push(acb.addItem(scoci));
    mb.push(resultRowTemplate);
    mb.push(innerTable.getResultSetNumber());
    predList.generateStartKey(acb, mb, innerTable);
    mb.push(predList.startOperator(innerTable));
    if (!sameStartStopPosition) {
        predList.generateStopKey(acb, mb, innerTable);
    } else {
        mb.pushNull(ClassName.GeneratedMethod);
    }
    mb.push(predList.stopOperator(innerTable));
    mb.push(sameStartStopPosition);
    predList.generateQualifiers(acb, mb, innerTable, true);
    mb.upCast(ClassName.Qualifier + "[][]");
}
Also used : StaticCompiledOpenConglomInfo(org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo)

Example 7 with StaticCompiledOpenConglomInfo

use of org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo in project derby by apache.

the class IndexToBaseRowNode method generate.

/**
 * Generation of an IndexToBaseRowNode creates an
 * IndexRowToBaseRowResultSet, which uses the RowLocation in the last
 * column of an index row to get the row from the base conglomerate (heap).
 *
 * @param acb	The ActivationClassBuilder for the class being built
 * @param mb the method  for the method to be built
 *
 * @exception StandardException		Thrown on error
 */
@Override
void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException {
    ValueNode restriction = null;
    /*
		** Get the next ResultSet #, so that we can number this ResultSetNode,
		** its ResultColumnList and ResultSet.
		*/
    assignResultSetNumber();
    // Get the CostEstimate info for the underlying scan
    setCostEstimate(getFinalCostEstimate());
    /* Put the predicates back into the tree */
    if (restrictionList != null) {
        restriction = restrictionList.restorePredicates();
        /* Allow the restrictionList to get garbage collected now
			 * that we're done with it.
			 */
        restrictionList = null;
    }
    // for the restriction, we generate an exprFun
    // that evaluates the expression of the clause
    // against the current row of the child's result.
    // if the restriction is empty, simply pass null
    // to optimize for run time performance.
    // generate the function and initializer:
    // Note: Boolean lets us return nulls (boolean would not)
    // private Boolean exprN()
    // {
    // return <<restriction.generate(ps)>>;
    // }
    // static Method exprN = method pointer to exprN;
    int heapColRefItem = -1;
    if (heapReferencedCols != null) {
        heapColRefItem = acb.addItem(heapReferencedCols);
    }
    int allColRefItem = -1;
    if (allReferencedCols != null) {
        allColRefItem = acb.addItem(allReferencedCols);
    }
    int heapOnlyColRefItem = -1;
    if (heapOnlyReferencedCols != null) {
        heapOnlyColRefItem = acb.addItem(heapOnlyReferencedCols);
    }
    /* Create the ReferencedColumnsDescriptorImpl which tells which columns
		 * come from the index.
		 */
    int indexColMapItem = acb.addItem(new ReferencedColumnsDescriptorImpl(getIndexColMapping()));
    long heapConglomNumber = baseCD.getConglomerateNumber();
    StaticCompiledOpenConglomInfo scoci = getLanguageConnectionContext().getTransactionCompile().getStaticCompiledConglomInfo(heapConglomNumber);
    acb.pushGetResultSetFactoryExpression(mb);
    mb.push(heapConglomNumber);
    mb.push(acb.addItem(scoci));
    source.generate(acb, mb);
    mb.upCast(ClassName.NoPutResultSet);
    // Skip over the index columns that are propagated from the source
    // result set, if there are such columns. We won't pass the SQL NULL
    // wrappers down to store for those columns anyways, so no need to
    // generate them in the row template.
    // NOTE: We have to check for the case where indexReferencedCols is
    // not null, but no bits are set. This can happen when we need to get
    // all of the columns from the heap due to a check constraint.
    boolean skipPropagatedCols = indexReferencedCols != null && indexReferencedCols.getNumBitsSet() != 0;
    mb.push(acb.addItem(getResultColumns().buildRowTemplate(heapReferencedCols, skipPropagatedCols)));
    mb.push(getResultSetNumber());
    mb.push(source.getBaseTableName());
    mb.push(heapColRefItem);
    mb.push(allColRefItem);
    mb.push(heapOnlyColRefItem);
    mb.push(indexColMapItem);
    // if there is no restriction, we just want to pass null.
    if (restriction == null) {
        mb.pushNull(ClassName.GeneratedMethod);
    } else {
        // this sets up the method and the static field.
        // generates:
        // Object userExprFun { }
        MethodBuilder userExprFun = acb.newUserExprFun();
        // restriction knows it is returning its value;
        /* generates:
			 *    return <restriction.generate(acb)>;
			 * and adds it to userExprFun
			 * NOTE: The explicit cast to DataValueDescriptor is required
			 * since the restriction may simply be a boolean column or subquery
			 * which returns a boolean.  For example:
			 *		where booleanColumn
			 */
        restriction.generate(acb, userExprFun);
        userExprFun.methodReturn();
        // we are done modifying userExprFun, complete it.
        userExprFun.complete();
        // restriction is used in the final result set as an access of the new static
        // field holding a reference to this new method.
        // generates:
        // ActivationClass.userExprFun
        // which is the static field that "points" to the userExprFun
        // that evaluates the where clause.
        acb.pushMethodReference(mb, userExprFun);
    }
    mb.push(forUpdate);
    mb.push(getCostEstimate().rowCount());
    mb.push(getCostEstimate().getEstimatedCost());
    mb.push(source.getTableDescriptor().getNumberOfColumns());
    mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getIndexRowToBaseRowResultSet", ClassName.NoPutResultSet, 15);
    /*
		** Remember if this result set is the cursor target table, so we
		** can know which table to use when doing positioned update and delete.
		*/
    if (cursorTargetTable) {
        acb.rememberCursorTarget(mb);
    }
}
Also used : ReferencedColumnsDescriptorImpl(org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl) StaticCompiledOpenConglomInfo(org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo) MethodBuilder(org.apache.derby.iapi.services.compiler.MethodBuilder)

Aggregations

StaticCompiledOpenConglomInfo (org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo)7 TransactionController (org.apache.derby.iapi.store.access.TransactionController)3 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)2 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)2 ReferencedColumnsDescriptorImpl (org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl)1 MethodBuilder (org.apache.derby.iapi.services.compiler.MethodBuilder)1 FormatableArrayHolder (org.apache.derby.iapi.services.io.FormatableArrayHolder)1 FormatableIntHolder (org.apache.derby.iapi.services.io.FormatableIntHolder)1 Activation (org.apache.derby.iapi.sql.Activation)1 ResultDescription (org.apache.derby.iapi.sql.ResultDescription)1 CostEstimate (org.apache.derby.iapi.sql.compile.CostEstimate)1 IndexRowGenerator (org.apache.derby.iapi.sql.dictionary.IndexRowGenerator)1 RowChanger (org.apache.derby.iapi.sql.execute.RowChanger)1 DynamicCompiledOpenConglomInfo (org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo)1