Package org.apache.derby.iapi.sql.dictionary

Examples of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor


  (
    ExpressionClassBuilder  acb,
    MethodBuilder mb
  ) throws StandardException
  {
    ConglomerateDescriptor cd = getTrulyTheBestAccessPath().getConglomerateDescriptor();
    CostEstimate costEstimate = getFinalCostEstimate();
    int colRefItem = (referencedCols == null) ?
            -1 :
            acb.addItem(referencedCols);
    boolean tableLockGranularity = tableDescriptor.getLockGranularity() == TableDescriptor.TABLE_LOCK_GRANULARITY;
 
    /*
    ** getLastIndexKeyResultSet
    ** (
    **    activation,     
    **    resultSetNumber,     
    **    resultRowAllocator,     
    **    conglomereNumber,     
    **    tableName,
    **    optimizeroverride     
    **    indexName,     
    **    colRefItem,     
    **    lockMode,     
    **    tableLocked,
    **    isolationLevel,
    **    optimizerEstimatedRowCount,
    **    optimizerEstimatedRowCost,
    **  );
    */

    acb.pushGetResultSetFactoryExpression(mb);

    acb.pushThisAsActivation(mb);
    mb.push(getResultSetNumber());
    resultColumns.generateHolder(acb, mb, referencedCols, (FormatableBitSet) null);
    mb.push(cd.getConglomerateNumber());
    mb.push(tableDescriptor.getName());
    //User may have supplied optimizer overrides in the sql
    //Pass them onto execute phase so it can be shown in
    //run time statistics.
    if (tableProperties != null)
View Full Code Here


  (
    ExpressionClassBuilder  acb,
    MethodBuilder mb
  ) throws StandardException
  {
    ConglomerateDescriptor cd = getTrulyTheBestAccessPath().getConglomerateDescriptor();
    CostEstimate costEstimate = getFinalCostEstimate();
    int colRefItem = (referencedCols == null) ?
            -1 :
            acb.addItem(referencedCols);
    boolean tableLockGranularity = tableDescriptor.getLockGranularity() == TableDescriptor.TABLE_LOCK_GRANULARITY;
 
    /*
    ** getDistinctScanResultSet
    ** (
    **    activation,     
    **    resultSetNumber,     
    **    resultRowAllocator,     
    **    conglomereNumber,     
    **    tableName,
    **    optimizeroverride     
    **    indexName,     
    **    colRefItem,     
    **    lockMode,     
    **    tableLocked,
    **    isolationLevel,
    **    optimizerEstimatedRowCount,
    **    optimizerEstimatedRowCost,
    **    closeCleanupMethod
    **  );
    */

    /* Get the hash key columns and wrap them in a formattable */
    int[] hashKeyColumns;

    hashKeyColumns = new int[resultColumns.size()];
    if (referencedCols == null)
    {
      for (int index = 0; index < hashKeyColumns.length; index++)
      {
        hashKeyColumns[index] = index;
      }
    }
    else
    {
      int index = 0;
      for (int colNum = referencedCols.anySetBit();
          colNum != -1;
          colNum = referencedCols.anySetBit(colNum))
      {
        hashKeyColumns[index++] = colNum;
      }
    }

    FormatableIntHolder[] fihArray =
        FormatableIntHolder.getFormatableIntHolders(hashKeyColumns);
    FormatableArrayHolder hashKeyHolder = new FormatableArrayHolder(fihArray);
    int hashKeyItem = acb.addItem(hashKeyHolder);
    long conglomNumber = cd.getConglomerateNumber();
    StaticCompiledOpenConglomInfo scoci = getLanguageConnectionContext().
                        getTransactionCompile().
                          getStaticCompiledConglomInfo(conglomNumber);

    acb.pushGetResultSetFactoryExpression(mb);

       acb.pushThisAsActivation(mb);
    mb.push(conglomNumber);
    mb.push(acb.addItem(scoci));
     resultColumns.generateHolder(acb, mb, referencedCols, (FormatableBitSet) null);
    mb.push(getResultSetNumber());
    mb.push(hashKeyItem);
    mb.push(tableDescriptor.getName());
    //User may have supplied optimizer overrides in the sql
    //Pass them onto execute phase so it can be shown in
    //run time statistics.
    if (tableProperties != null)
      mb.push(org.apache.derby.iapi.util.PropertyUtil.sortProperties(tableProperties));
    else
      mb.pushNull("java.lang.String");
    pushIndexName(cd, mb);
    mb.push(cd.isConstraint());
    mb.push(colRefItem);
    mb.push(getTrulyTheBestAccessPath().getLockMode());
    mb.push(tableLockGranularity);
    mb.push(getCompilerContext().getScanIsolationLevel());
    mb.push(costEstimate.singleScanRowCount());
View Full Code Here

    // beetle entry 3865: updateable cursor using index
    int indexColItem = -1;
    if (cursorTargetTable || getUpdateLocks)
    {
      ConglomerateDescriptor cd = getTrulyTheBestAccessPath().getConglomerateDescriptor();
      if (cd.isIndex())
      {
        int[] baseColPos = cd.getIndexDescriptor().baseColumnPositions();
        boolean[] isAscending = cd.getIndexDescriptor().isAscending();
        int[] indexCols = new int[baseColPos.length];
        for (int i = 0; i < indexCols.length; i++)
          indexCols[i] = isAscending[i] ? baseColPos[i] : -baseColPos[i];
        indexColItem = acb.addItem(indexCols);
      }
View Full Code Here

    ConglomerateDescriptor[] cds = tableDescriptor.getConglomerateDescriptors();

    /* Cycle through the ConglomerateDescriptors */
    for (int index = 0; index < cds.length; index++)
    {
      ConglomerateDescriptor cd = cds[index];

      if (! cd.isIndex())
      {
        continue;
      }
      IndexDescriptor id = cd.getIndexDescriptor();

      if (! id.isUnique())
      {
        continue;
      }
View Full Code Here

    ConglomerateDescriptor[] cds = tableDescriptor.getConglomerateDescriptors();

    /* Cycle through the ConglomerateDescriptors */
    for (int index = 0; index < cds.length; index++)
    {
      ConglomerateDescriptor cd = cds[index];

      if (! cd.isIndex())
      {
        continue;
      }
      IndexDescriptor id = cd.getIndexDescriptor();

      if (! id.isUnique())
      {
        continue;
      }
View Full Code Here

      {
        return false;
      }
    }
    // Verify access path is an index
    ConglomerateDescriptor cd = getTrulyTheBestAccessPath().getConglomerateDescriptor();
    if (! cd.isIndex())
    {
      return false;
    }

    // Now consider whether or not the CRs can be permuted
View Full Code Here

    td = getTableDescriptor();

    conglomerateNumber = td.getHeapConglomerateId();

    /* Get the base conglomerate descriptor */
    ConglomerateDescriptor cd = td.getConglomerateDescriptor(conglomerateNumber);

    /* Statement is dependent on the TableDescriptor and ConglomerateDescriptor */
    cc.createDependency(td);
    cc.createDependency(cd);

 
View Full Code Here

              )
          throws StandardException
  {
    int[] hashKeyColumns = null;

    ConglomerateDescriptor cd = null;

    /* If the innerTable is a VTI, then we
     * must check to see if there are any
     * join columns in the VTI's parameters.
     * If so, then hash join is not feasible.
View Full Code Here

        ** list).
    */
    originalRestrictionList.copyPredicatesToOtherList(
            requalificationRestrictionList);

    ConglomerateDescriptor cd =
      innerTable.getTrulyTheBestAccessPath().getConglomerateDescriptor();

    /* For the inner table of a hash join, then divide up the predicates:
         *
     *  o restrictionList  - predicates that get applied when creating
     *              the hash table (single table clauses)
         *
     *  o nonBaseTableRestrictionList
     *            - those that get applied when probing into the
     *              hash table (equijoin clauses on key columns,
     *              ordered by key column position first, followed
     *              by any other join predicates. (All predicates
         *              in this list are qualifiers which can be
         *              evaluated in the store).
         *
     *  o baseTableRL    - Only applicable if this is not a covering
         *                        index.  In that case, we will need to
         *                        requalify the data page.  Thus, this list
         *                        will include all predicates.
     */

    // Build the list to be applied when creating the hash table
    originalRestrictionList.transferPredicates(
                  storeRestrictionList,
                  innerTable.getReferencedTableMap(),
                  innerTable);

    /*
         * Eliminate any non-qualifiers that may have been pushed, but
         * are redundant and not useful for hash join.
         *
         * For instance "in" (or other non-qualifier) was pushed down for
         * start/stop key, * but for hash join, it may no longer be because
         * previous key column may have been disqualified (eg., correlation). 
         * We simply remove
         * such non-qualifier ("in") because we left it as residual predicate
         * anyway.  It's easier/safer to filter it out here than detect it
         * ealier (and not push it down). Beetle 4316.
         *
         * Can't filter out OR list, as it is not a residual predicate,
     */
    for (int i = storeRestrictionList.size() - 1; i >= 0; i--)
    {
      Predicate p1 = (Predicate) storeRestrictionList.getOptPredicate(i);

          
            if (!p1.isStoreQualifier() && !p1.isStartKey() && !p1.isStopKey())
            {
        storeRestrictionList.removeOptPredicate(i);
            }
    }

    for (int i = originalRestrictionList.size() - 1; i >= 0; i--)
    {
      Predicate p1 =
                (Predicate) originalRestrictionList.getOptPredicate(i);

            if (!p1.isStoreQualifier())
        originalRestrictionList.removeOptPredicate(i);
    }

    /* Copy the rest of the predicates to the non-store list */
    originalRestrictionList.copyPredicatesToOtherList(
                          nonStoreRestrictionList);

    /* If innerTable is ProjectRestrictNode, we need to use its child
     * to find hash key columns, this is because ProjectRestrictNode may
     * not have underlying node's every result column as result column,
     * and the predicate's column reference was bound to the underlying
     * node's column position.  Also we have to pass in the
      * ProjectRestrictNode rather than the underlying node to this method
     * because a predicate's referencedTableMap references the table number
     * of the ProjectRestrictiveNode.  And we need this info to see if
     * a predicate is in storeRestrictionList that can be pushed down.
     * Beetle 3458.
     */
    Optimizable hashTableFor = innerTable;
    if (innerTable instanceof ProjectRestrictNode)
    {
      ProjectRestrictNode prn = (ProjectRestrictNode) innerTable;
      if (prn.getChildResult() instanceof Optimizable)
        hashTableFor = (Optimizable) (prn.getChildResult());
    }
    int[] hashKeyColumns = findHashKeyColumns(hashTableFor,
                        cd,
                        nonStoreRestrictionList);
    if (hashKeyColumns != null)
    {
      innerTable.setHashKeyColumns(hashKeyColumns);
    }
    else
    {
      String name;
      if (cd != null && cd.isIndex())
      {
        name = cd.getConglomerateName();
      }
      else
      {
        name = innerTable.getBaseTableName();
      }

      throw StandardException.newException(SQLState.LANG_HASH_NO_EQUIJOIN_FOUND,
            name,
            innerTable.getBaseTableName());
    }

    // Mark all of the predicates in the probe list as qualifiers
    nonStoreRestrictionList.markAllPredicatesQualifiers();

    int[] conglomColumn = new int[hashKeyColumns.length];
    if (cd != null && cd.isIndex())
    {
      /*
      ** If the conglomerate is an index, get the column numbers of the
      ** hash keys in the base heap.
      */
      for (int index = 0; index < hashKeyColumns.length; index++)
      {
        conglomColumn[index] =
          cd.getIndexDescriptor().baseColumnPositions()[hashKeyColumns[index]];
      }
    }
    else
    {
      /*
 
View Full Code Here

    ** Updates are also deferred if they update a column in the index
    ** used to scan the table being updated.
    */
    if (! deferred )
    {
      ConglomerateDescriptor updateCD =
                    targetTable.
                      getTrulyTheBestAccessPath().
                        getConglomerateDescriptor();

      if (updateCD != null && updateCD.isIndex())
      {
        int [] baseColumns =
            updateCD.getIndexDescriptor().baseColumnPositions();

        if (resultSet.
            getResultColumns().
                    updateOverlaps(baseColumns))
        {
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.