@Override
  public int size() {
    if (cachedSize > -1){
      return cachedSize;
    }
    int count = 0;
    if (blocks.isEmpty()) {
      // Easy case, only buffered batches are present.
      count = countBufferedRows();
    } else {
      /*
       * We need to be aware that any of the blocks can be loaded into memory at the time of
       * counting. If we count the records of a spilled block, we should not count the in-memory
       * records again.
       */
      count += blocks.getRowSize(countBufferedRows());
    }
    cachedSize = count;
    return count;
  }
Overrides PTFPartition.size(), this is supposed to return the amount of records in the partition.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFGroupBatches.java