Package org.apache.derby.iapi.util

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


    // 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

        continue;
      }

      int[] keyColumns = id.baseColumnPositions();
      int numBits = tableColMap[0].size();
      JBitSet keyMap = new JBitSet(numBits);
      JBitSet resMap = new JBitSet(numBits);

      int inner = 0;
      for ( ; inner < keyColumns.length; inner++)
      {
        keyMap.set(keyColumns[inner]);
      }
      int table = 0;
      for ( ; table < tableColMap.length; table++)
      {
        resMap.setTo(tableColMap[table]);
        resMap.and(keyMap);
        if (keyMap.equals(resMap))
        {
          tableColMap[table].set(0);
          return true;
        }
View Full Code Here

                          C_NodeTypes.PREDICATE_LIST,
                          getContextManager()));
    }

    /* Allocate a dummy referenced table map */
    referencedTableMap = new JBitSet(numTables);
    referencedTableMap.set(tableNumber);
    return this;
  }
View Full Code Here

         * up then the single next logic for an EXISTS join does not work
         * because that row may get disqualified at a higher level.)
         */
        else if ( (isIN() || isANY() || isEXISTS() || flattenableNotExists) &&
              ((leftOperand == null) ? true :
               leftOperand.categorize(new JBitSet(numTables), false)) &&
              select.getWherePredicates().allPushable() &&
              singleFromBaseTable(select.getFromList()))
        {
          return flattenToExistsJoin(numTables,
                       outerFromList, outerSubqueryList,
View Full Code Here

        int numTables)
      throws StandardException
  {
    AndNode            andNode;
    BinaryComparisonOperatorNode bcoNode = null;
    JBitSet            tableMap;
    Predicate          predicate;
    ResultColumn        firstRC;
    ResultColumnList      resultColumns;
    UnaryComparisonOperatorNode  ucoNode = null;
    ValueNode          oldWhereClause;
    ValueNode          rightOperand;

    /* We have to ensure that the resultSet immediately under us has
     * a PredicateList, otherwise we can't push the predicate down.
     */
    resultSet = resultSet.ensurePredicateList(numTables);

    /* RESOLVE - once we understand how correlated columns will work,
     * we probably want to mark leftOperand as a correlated column
     */
    resultColumns = resultSet.getResultColumns();

    /*
    ** Create a new PR node.  Put it over the original subquery.  resulSet
    ** is now the new PR.  We give the chance that things under the PR node
    ** can be materialized.  See beetle 4373.
    */
    ResultColumnList newRCL = resultColumns.copyListAndObjects();
    newRCL.genVirtualColumnNodes(resultSet, resultColumns);
    resultSet = (ResultSetNode) getNodeFactory().getNode(
                    C_NodeTypes.PROJECT_RESTRICT_NODE,
                    resultSet,  // child
                    newRCL,      // result columns
                    null,      // restriction
                    null,       // restriction list
                    null,      // project subqueries
                    null,      // restrict subqueries 
                    null,
                    getContextManager());
    resultColumns = newRCL;
 
    firstRC = (ResultColumn) resultColumns.elementAt(0);
    rightOperand = firstRC.getExpression();

    bcoNode = getNewJoinCondition(leftOperand, rightOperand);

    ValueNode andLeft = bcoNode;

    /* For NOT IN or ALL, and if either side of the comparison is nullable, and the
     * subquery can not be flattened (because of that), we need to add IS NULL node
     * on top of the nullables, such that the behavior is (beetle 5173):
     *
     *    (1) If we have nulls in right operand, no row is returned.
     *    (2) If subquery result is empty before applying join predicate, every
     *      left row (including NULLs) is returned.
     *    (3) Otherwise, return {all left row} - {NULLs}
     */
    if (isNOT_IN() || isALL())
    {
      boolean leftNullable = leftOperand.getTypeServices().isNullable();
      boolean rightNullable = rightOperand.getTypeServices().isNullable();
      if (leftNullable || rightNullable)
      {
        /* Create a normalized structure.
         */
        BooleanConstantNode falseNode = (BooleanConstantNode) getNodeFactory().getNode(
                        C_NodeTypes.BOOLEAN_CONSTANT_NODE,
                        Boolean.FALSE,
                        getContextManager());
        OrNode newOr = (OrNode) getNodeFactory().getNode(
                        C_NodeTypes.OR_NODE,
                        bcoNode,
                        falseNode,
                        getContextManager());
        newOr.postBindFixup();
        andLeft = newOr;

        if (leftNullable)
        {
          UnaryComparisonOperatorNode leftIsNull = (UnaryComparisonOperatorNode)
                  getNodeFactory().getNode(
                            C_NodeTypes.IS_NULL_NODE,
                            leftOperand,
                            getContextManager());
          leftIsNull.bindComparisonOperator();
          newOr = (OrNode) getNodeFactory().getNode(
                          C_NodeTypes.OR_NODE,
                          leftIsNull,
                          andLeft,
                          getContextManager());
          newOr.postBindFixup();
          andLeft = newOr;
        }
        if (rightNullable)
        {
          UnaryComparisonOperatorNode rightIsNull = (UnaryComparisonOperatorNode)
                  getNodeFactory().getNode(
                            C_NodeTypes.IS_NULL_NODE,
                            rightOperand,
                            getContextManager());
          rightIsNull.bindComparisonOperator();
          newOr = (OrNode) getNodeFactory().getNode(
                          C_NodeTypes.OR_NODE,
                          rightIsNull,
                          andLeft,
                          getContextManager());
          newOr.postBindFixup();
          andLeft = newOr;
        }
      }
    }

    /* Place an AndNode above the <BinaryComparisonOperator> */
    andNode = (AndNode) getNodeFactory().getNode(
                          C_NodeTypes.AND_NODE,
                          andLeft,
                          getTrueNode(),
                          getContextManager());

    /* Build the referenced table map for the new predicate */
    tableMap = new JBitSet(numTables);
    andNode.postBindFixup();

    /* Put the AndNode under a Predicate */
    predicate = (Predicate) getNodeFactory().getNode(
                    C_NodeTypes.PREDICATE,
View Full Code Here

    // always a safe option; further investigation required.

    BinaryRelationalOperatorNode opNode =
      (BinaryRelationalOperatorNode)getAndNode().getLeftOperand();

    JBitSet tNums = new JBitSet(getReferencedSet().size());
    BaseTableNumbersVisitor btnVis = new BaseTableNumbersVisitor(tNums);
    opNode.getLeftOperand().accept(btnVis);
    if (tNums.getFirstSetBit() == -1)
      return false;

    tNums.clearAll();
    opNode.getRightOperand().accept(btnVis);
    if (tNums.getFirstSetBit() == -1)
      return false;

    return true;
  }
View Full Code Here

    // Categorize the new AND node; among other things, this
    // call sets up the new operators's referenced table map,
    // which is important for correct pushing of the new
    // predicate.
    JBitSet tableMap = new JBitSet(
      childRSN.getReferencedTableMap().size());
    newAnd.categorize(tableMap, false);

    // Now put the pieces together to get a new predicate.
    Predicate newPred = (Predicate) getNodeFactory().getNode(
View Full Code Here

                 ValueNode searchClause)
        throws StandardException
  {
    AndNode    thisAnd;
    AndNode    topAnd;
    JBitSet    newJBitSet;
    Predicate  newPred;
    BooleanConstantNode  trueNode = null;

    if (searchClause != null)
    {
      topAnd = (AndNode) searchClause;
      searchClause = null;
      trueNode = (BooleanConstantNode) getNodeFactory().getNode(
                      C_NodeTypes.BOOLEAN_CONSTANT_NODE,
                      Boolean.TRUE,
                      getContextManager());
     
      while (topAnd.getRightOperand() instanceof AndNode)
      {
        /* Break out the next top AndNode */
        thisAnd = topAnd;
        topAnd = (AndNode) topAnd.getRightOperand();
        thisAnd.setRightOperand(null);

        /* Set the rightOperand to true */
        thisAnd.setRightOperand(trueNode);

        /* Add the top AndNode to the PredicateList */
        newJBitSet = new JBitSet(numTables);
        newPred = (Predicate) getNodeFactory().getNode(
                      C_NodeTypes.PREDICATE,
                      thisAnd,
                      newJBitSet,
                      getContextManager());
        addPredicate(newPred);
      }
     
      /* Add the last top AndNode to the PredicateList */
      newJBitSet = new JBitSet(numTables);
      newPred = (Predicate) getNodeFactory().getNode(
                      C_NodeTypes.PREDICATE,
                      topAnd,
                      newJBitSet,
                      getContextManager());
View Full Code Here

                          C_NodeTypes.AND_NODE,
                          leftOperand,
                          trueNode,
                          getContextManager());
        newAnd.postBindFixup();
        JBitSet tableMap = new JBitSet(select.referencedTableMap.size());

        // Use newly constructed predicate
        predicate = (Predicate) getNodeFactory().getNode(
                        C_NodeTypes.PREDICATE,
                        newAnd,
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.