private AbstractGroupOrRangeJunction createGroupJunctionOrRangeJunction(boolean needsCompacting,
      RuntimeIterator[] grpIndpndntItr, boolean completeExpnsn, CompiledValue[] cv,
      Map sameIndexOperands) {
    AbstractGroupOrRangeJunction junction;
    if (needsCompacting) {
      Iterator itr = sameIndexOperands.values().iterator();
      if (sameIndexOperands.size() == 1) {
        // This means that there exists only one type of Index for the whole
        // Group. Thus overall we should just create a RangeJunction. It also
        // means that the rest of the operands are the Iter Operands ( they may
        // contain those operands which are not index evaluable but evaluate to
        // true/false ( not dependent on current scope)
        List sameIndexOps = (List) itr.next();
        Iterator sameIndexOpsItr = sameIndexOps.iterator();
        for (int i = 0; i < cv.length; ++i) {
          if (cv[i] == null) {
            cv[i] = (CompiledValue) sameIndexOpsItr.next();
          }
        }
        junction = new RangeJunction(_operator, grpIndpndntItr, completeExpnsn, cv);
      } else {
        int numRangeJunctions = 0;
        CompiledValue[] rangeJunctions = new CompiledValue[sameIndexOperands.size()];
        int nullifiedFields = 0;
        while (itr.hasNext()) {
          Object listOrPosition = itr.next();
          if (listOrPosition instanceof List) {
            List ops = (List) listOrPosition;
            nullifiedFields += ops.size();
            CompiledValue[] operands = (CompiledValue[]) ops.toArray(new CompiledValue[0]);
            rangeJunctions[numRangeJunctions++] =
                new RangeJunction(_operator, grpIndpndntItr, completeExpnsn, operands);
          }
        }
        int totalOperands = cv.length - nullifiedFields + numRangeJunctions;
        CompiledValue[] allOperands = new CompiledValue[totalOperands];
        // Fill the Non RangeJunction operands first
        int k = 0;
        for (CompiledValue tempCV : cv) {
          if (tempCV != null) {
            allOperands[k++] = tempCV;
          }
        }
        for (int i = 0; i < numRangeJunctions; ++i) {
          allOperands[k++] = rangeJunctions[i];
        }
        junction = new GroupJunction(_operator, grpIndpndntItr, completeExpnsn, allOperands);
      }
    } else {
      junction = new GroupJunction(_operator, grpIndpndntItr, completeExpnsn, cv);
    }
    return junction;
  }
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