Package org.apache.derby.iapi.util

Examples of org.apache.derby.iapi.util.JBitSet


      if (! predicate.getPushable())
      {
        continue;
      }

      JBitSet curBitSet = predicate.getReferencedSet();
     
      /* Do we have a match? */
      if (referencedTableMap.contains(curBitSet))
      {
        /* Add the matching predicate to the push list */
 
View Full Code Here


                            newEquals,
                            trueNode,
                            getContextManager());
          newAnd.postBindFixup();
          // Add a new predicate to both the equijoin clauses and this list
          JBitSet tableMap = new JBitSet(numTables);
          newAnd.categorize(tableMap, false);
          Predicate newPred = (Predicate) getNodeFactory().getNode(
                          C_NodeTypes.PREDICATE,
                          newAnd,
                          tableMap,
View Full Code Here

                            roClone,
                            trueNode,
                            getContextManager());
          newAnd.postBindFixup();
          // Add a new predicate to both the search clauses and this list
          JBitSet tableMap = new JBitSet(numTables);
          newAnd.categorize(tableMap, false);
          Predicate newPred = (Predicate) getNodeFactory().getNode(
                            C_NodeTypes.PREDICATE,
                            newAnd,
                            tableMap,
View Full Code Here

  }

  /** @see OptimizableList#legalJoinOrder */
  public boolean legalJoinOrder(int numTablesInQuery)
  {
    JBitSet      assignedTableMap = new JBitSet(numTablesInQuery);

    int size = size();
    for (int index = 0; index < size; index++)
    {
      FromTable ft = (FromTable) elementAt(index);
      assignedTableMap.or(ft.getReferencedTableMap());
      if ( ! ft.legalJoinOrder(assignedTableMap))
      {
        return false;
      }
    }
View Full Code Here

              RelationalOperator.EQUALS_RELOP))
            {
              continue;
            }

            JBitSet referencedTables = and.getLeftOperand().getTablesReferenced();
            if (referencedTables.get(existsTableNumber))
            {
              predicatesTemp.removeElementAt(predicatesTempIndex);
              break;
            }
          }
        }
      }
    }

    /* Build an array of tableNumbers from this query block.
     * We will use that array to find out if we have at least
     * one table with a uniqueness condition based only on
     * constants, parameters and correlation columns.
     */
    tableNumbers = getTableNumbers();
    JBitSet[][] tableColMap = new JBitSet[size][size];
    boolean[] oneRow = new boolean[size];
    boolean oneRowResult = false;

    /* See if each table has a uniqueness condition */
    for (int index = 0; index < size; index++)
    {
      ProjectRestrictNode prn = (ProjectRestrictNode) elementAt(index);
      FromBaseTable fbt = (FromBaseTable) prn.getChildResult();

      // Skip over EXISTS FBT since they cannot introduce duplicates
      if (fbt.getExistsBaseTable())
      {
        oneRow[index] = true;
        continue;
      }

      int numColumns = fbt.getTableDescriptor().getNumberOfColumns();
      boolean[] eqOuterCols = new boolean[numColumns + 1];
      int tableNumber = fbt.getTableNumber();
      boolean resultColTable = false;
      for (int i = 0; i < size; i++)
        tableColMap[index][i] = new JBitSet(numColumns + 1);

      if (additionalCR != null &&
        additionalCR.getTableNumber() == tableNumber)
      {
        rcl.recordColumnReferences(eqOuterCols, tableColMap[index], index);
View Full Code Here

   */
  void genExistsBaseTables(JBitSet referencedTableMap, FromList outerFromList,
               boolean isNotExists)
    throws StandardException
  {
    JBitSet      dependencyMap = (JBitSet) referencedTableMap.clone();

    // We currently only flatten single table from lists
    if (SanityManager.DEBUG)
    {
      if (size() != 1)
      {
        SanityManager.THROWASSERT(
          "size() expected to be 1, not " + size());
      }
    }

    /* Create the dependency map */
    int size = size();
    for (int index = 0; index < size; index++)
    {
      ResultSetNode ft = ((ProjectRestrictNode) elementAt(index)).getChildResult();
      if (ft instanceof FromTable)
      {
        dependencyMap.clear(((FromTable) ft).getTableNumber());
      }
    }

    /* Degenerate case - If flattening a non-correlated EXISTS subquery
     * then we need to make the table that is getting flattened dependendent on
     * all of the tables in the outer query block.  Gross but true.  Otherwise
     * that table can get chosen as an outer table and introduce duplicates.
     * The reason that duplicates can be introduced is that we do special processing
     * in the join to make sure only one qualified row from the right side is
     * returned.  If the exists table is on the left, we can return all the
     * qualified rows.
     */
    if (dependencyMap.getFirstSetBit() == -1)
    {
      int outerSize = outerFromList.size();
      for (int outer = 0; outer < outerSize; outer++)
        dependencyMap.or(((FromTable) outerFromList.elementAt(outer)).getReferencedTableMap());
    }

    /* Do the marking */
    for (int index = 0; index < size; index++)
    {
      FromTable fromTable = (FromTable) elementAt(index);
      if (fromTable instanceof ProjectRestrictNode)
      {
        ProjectRestrictNode prn = (ProjectRestrictNode) fromTable;
        if (prn.getChildResult() instanceof FromBaseTable)
        {
          FromBaseTable fbt = (FromBaseTable) prn.getChildResult();
          fbt.setExistsBaseTable(true, (JBitSet) dependencyMap.clone(), isNotExists);
        }
      }
    }
  }
View Full Code Here

     * is not a ColumnReference or a VirtualColumnNode.
     */
    fromList.pushPredicates(wherePredicates);

    /* Set up the referenced table map */
    referencedTableMap = new JBitSet(numTables);
    int flSize = fromList.size();
    for (int index = 0; index < flSize; index++)
    {
      referencedTableMap.or(((FromTable) fromList.elementAt(index)).
                          getReferencedTableMap());
View Full Code Here

     * implement full outer join.
     */
    // Walk joinPredicates backwards due to possible deletes
    for (int index = joinPredicates.size() - 1; index >= 0; index --)
    {
      JBitSet    curBitSet;
      Predicate predicate;

      predicate = (Predicate) joinPredicates.elementAt(index);
      if (! predicate.getPushable())
      {
View Full Code Here

  protected void pushExpressionsToLeft(PredicateList outerPredicateList)
    throws StandardException
  {
    FromTable    leftFromTable = (FromTable) leftResultSet;

    JBitSet    leftReferencedTableMap = leftFromTable.getReferencedTableMap();

    /* Build a list of the single table predicates on left result set
     * that we can push down
     */
    // Walk outerPredicateList backwards due to possible deletes
    for (int index = outerPredicateList.size() - 1; index >= 0; index --)
    {
      JBitSet    curBitSet;
      Predicate predicate;

      predicate = (Predicate) outerPredicateList.elementAt(index);
      if (! predicate.getPushable())
      {
View Full Code Here

  private void pushExpressionsToRight(PredicateList outerPredicateList)
    throws StandardException
  {
    FromTable    rightFromTable = (FromTable) rightResultSet;

    JBitSet    rightReferencedTableMap = rightFromTable.getReferencedTableMap();

    /* Build a list of the single table predicates on right result set
     * that we can push down
     */
    // Walk outerPredicateList backwards due to possible deletes
    for (int index = outerPredicateList.size() - 1; index >= 0; index --)
    {
      JBitSet    curBitSet;
      Predicate predicate;

      predicate = (Predicate) outerPredicateList.elementAt(index);
      if (! predicate.getPushable())
      {
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.util.JBitSet

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.