Package org.apache.derby.iapi.util

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


    // Check to see if the child nodes reference any base tables; if either
    // child does not reference at least one base table, then we don't try
    // to push the predicate.
    boolean canPush = false;

    JBitSet tableNums = new JBitSet(getReferencedTableMap().size());
    BaseTableNumbersVisitor btnVis =
      new BaseTableNumbersVisitor(tableNums);

    // Check the left child.
    leftResultSet.accept(btnVis);
    canPush = (tableNums.getFirstSetBit() != -1);

    /* If we can't push it to _both_ children, then we don't push at all.
     * RESOLVE: We can add the ability to push a predicate to one side
     * only by putting a ProjectRestrictNode between the union node and
     * the child as a place to park the predicate. To make things simple,
     * we might want to always put ProjectRestrictNodes under both sides
     * of the union during preprocessing (i.e. after binding but before
     * optimization). In some cases the extra nodes won't be needed, but
     * PRNs (and the corresponding ProjectRestrictResultSets) are cheap.
     * Also, we could eliminate unnecessary ProjectRestrictNodes at the
     * end of optimization (possibly in modifyAccessPaths()).  Until all
     * of that is implemented, though, we only push if we can push to
     * both sides...
     */
    if (!canPush)
      return false;

    // Check the right child.
    tableNums.clearAll();
    rightResultSet.accept(btnVis);
    canPush = (tableNums.getFirstSetBit() != -1);
    if (!canPush)
      return false;

    // Get a list of all of the underlying base tables that this node
    // references.  We pass this down when scoping so that we can tell
    // if the operands are actually supposed to be scoped to _this_
    // node's children.  Note that in order for the predicate to
    // have been pushed this far, at least one of its operands must
    // apply to this node--we don't know which one it is, though,
    // so we use this tableNums info to figure that out.
    tableNums.clearAll();
    this.accept(btnVis);

    /* What we want to do here is push the predicate to the left/right
     * child.  That means that we need to find the equivalent column(s)
     * in each child.
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

    /* In order to tell if this is a legal join order, we
     * need to see if the assignedTableMap, ORed with the
     * outer tables that we are correlated with, contains
     * our dependency map.
     */
    JBitSet tempBitSet = (JBitSet) assignedTableMap;
    tempBitSet.or(correlationMap);

    /* Have all of our dependencies been satisified? */
    return tempBitSet.contains(dependencyMap);
  }
View Full Code Here

   */
  public boolean selfComparison(ColumnReference cr)
    throws StandardException
  {
    ValueNode  otherSide;
    JBitSet    tablesReferenced;

    /*
    ** Figure out which side the given ColumnReference is on,
    ** and look for the same table on the other side.
    */
    if (leftOperand == cr)
    {
      otherSide = rightOperand;
    }
    else if (rightOperand == cr)
    {
      otherSide = leftOperand;
    }
    else
    {
      otherSide = null;
      if (SanityManager.DEBUG)
      {
        SanityManager.THROWASSERT(
            "ColumnReference not found on either side of binary comparison.");
      }
    }

    tablesReferenced = otherSide.getTablesReferenced();

    /* Return true if the table we're looking for is in the bit map */
    return tablesReferenced.get(cr.getTableNumber());
  }
View Full Code Here

    if (inListProbeSource != null)
      return false;

    FromTable  ft;
    ValueNode  otherSide = null;
    JBitSet    tablesReferenced;
    ColumnReference  cr = null;
    boolean  found = false;
    boolean walkSubtree = true;

    ft = (FromTable) optTable;
View Full Code Here

  }

  public JBitSet LOJgetReferencedTables(int numTables)
        throws StandardException
  {
    JBitSet map = new JBitSet(numTables);
    fillInReferencedTableMap(map);
    return map;
  }
View Full Code Here

    // correlation column, to fill in eqOuterCols properly. We don't care
    // about eqOuterCols, so just create a zero-length array, pretending
    // that all columns are correlation columns.
    int[] tableNumbers = new int[0];
    JBitSet[] tableColMap = new JBitSet[1];
    tableColMap[0] = new JBitSet(numColumns + 1);

    pl.checkTopPredicatesForEqualsConditions(tableNumber,
                        null,
                        tableNumbers,
                        tableColMap,
View Full Code Here

                  GroupByList gbl,
                  FromList fromList)
                throws StandardException
  {
    /* Generate the referenced table map */
    referencedTableMap = new JBitSet(numTables);
    referencedTableMap.set(tableNumber);

    return genProjectRestrict(numTables);
  }
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

  {
    if (this instanceof FromTable)
    {
      if (((FromTable)this).tableNumber != -1)
      {
        JBitSet map = new JBitSet(numTables);
        map.set(((FromTable)this).tableNumber);
        return map;
      }
    }

    return null;
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.