private boolean sortSameIndexOperandsForGroupJunction(CompiledValue[] cv, List operandsList,
      Map sameIndexOperands, ExecutionContext context)
      throws TypeMismatchException, NameResolutionException,
      FunctionDomainException, QueryInvocationTargetException {
    int size = operandsList.size();
    CompiledValue tempOp = null;
    boolean needsCompacting = false;
    for (int i = 0; i < size; ++i) {
      tempOp = (CompiledValue) operandsList.get(i);
      IndexInfo[] indx = null;
      Object listOrPosition = null;
      boolean evalAsFilter = tempOp.getPlanInfo(context).evalAsFilter;
      // TODO:Do not club Like predicate in an existing range
      if (evalAsFilter) {
        indx = ((Indexable) tempOp).getIndexInfo(context);
        // We are now sorting these for joins, therefore we need to weed out the join indexes
        if (!IndexManager.JOIN_OPTIMIZATION || indx.length == 1) {
          Assert.assertTrue(indx.length == 1,
              "There should have been just one index for the condition");
          listOrPosition = sameIndexOperands.get(indx[0]._index);
        }
      }

      if (listOrPosition != null) {
        if (listOrPosition instanceof Integer) {
          int position = (Integer) listOrPosition;
          List operands = new ArrayList(size);
          operands.add(cv[position]);
          operands.add(tempOp);
          cv[position] = null;
          sameIndexOperands.put(indx[0]._index, operands);
          needsCompacting = true;
        } else if (listOrPosition instanceof List) {
          List operands = (List) listOrPosition;
          operands.add(tempOp);
        } else {
          // a join was present here, let's now occupy that spot and remove the placeholder
          listOrPosition = null;
        }
      }
      if (listOrPosition == null) {
        cv[i] = tempOp;
        if (indx != null && indx.length == 1) {
          // TODO: Enable only for AND junction for now
          if (evalAsFilter && _operator == OQLLexerTokenTypes.LITERAL_and) {
            sameIndexOperands.put(indx[0]._index, i);
          }
        } else if (indx != null && indx.length == 2) {
          if (evalAsFilter && _operator == OQLLexerTokenTypes.LITERAL_and) {
            if (!sameIndexOperands.containsKey(indx[0]._index)) {
              sameIndexOperands.put(indx[0]._index, PLACEHOLDER_FOR_JOIN);
            }
            if (!sameIndexOperands.containsKey(indx[1]._index)) {
              sameIndexOperands.put(indx[1]._index, PLACEHOLDER_FOR_JOIN);
            }
          }
        }
      }
    }
    return needsCompacting;
  }
Creates a GroupJunction or a RangeJunction based on the operands passed. The operands are
either Filter Operands belonging to single independent RuntimeIterator or are iter evaluable on
the RuntimeIterator[] passed as parameter. If all the filter evaluable operands use a single
Index , than a RangeJunction is created with iter operand as part of RangeJunction. If there
exists operands using multiple indexes, then a GroupJunction is created. In that case , the
operands using the same index are grouped in a RangeJunction & that Range Junction becomes part
of the GroupJunction. A GroupJunction may contain one or more RangeJunction

@param needsCompacting boolean indicating if there is a possibility of RangeJunction or not. If
       needsCompacting is false , then a GroupJunction will be formed, without any
       RangeJunction
@param grpIndpndntItr Array of RuntimeIterator which represents the independent iterator for
       the Group. for all cases , except a CompositeGroupJunction containing a single
       GroupJunction , will have a single RuntimeIterator in this array.
@param completeExpnsn boolean indicating whether the Group or Range Junction needs to be
       expanded to the query from clause level or the group level
@param cv Array of CompiledValue containing operands belonging to a group
@param sameIndexOperands Map object containing Index as the key & as a value an Integer object
       or a List. If it contains an Integer as value against Index, it implies that there is
       only one operand which uses that type of index & hence cannot form a RangeJunction. If
       it contains a List then the Lis contains the operands which use same index & thus can
       form a RangeJunction
@return Object of GroupJunction or RangeJunction as the case may be
geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledJunction.java