private void fillCacheUntilEndOrFull(int rowIdx, PTFPartition p) throws HiveException {
    BoundaryCache cache = p.getBoundaryCache();
    if (cache == null || p.size() <= 0) {
      return;
    }

    Object rowVal = null;

    //If we continue building cache
    Map.Entry<Integer, Object> ceilingEntry = cache.getMaxEntry();
    if (ceilingEntry != null) {
      rowIdx = ceilingEntry.getKey();
      rowVal = ceilingEntry.getValue();
      ++rowIdx;
    }

    Object lastRowVal = rowVal;

    while (rowIdx < p.size() && !cache.isFull()) {
      rowVal = computeValue(p.getAt(rowIdx));
      if (!isEqual(rowVal, lastRowVal)){
        cache.put(rowIdx, rowVal);
      }
      lastRowVal = rowVal;
      ++rowIdx;

    }
    //Signaling end of all rows in a partition
    if (cache.putIfNotFull(rowIdx, null)) {
      cache.setComplete(true);
    }
  }
Inserts values into cache starting from rowIdx in the current partition p. Stops if cache
reaches its maximum size or we get out of rows in p.
@param rowIdx
@param p
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/ValueBoundaryScanner.java