private int biggestPartition() {
    int res = -1;
    int maxSize = 0;

    // If a partition has been spilled to disk, its size will be 0, i.e. it won't be picked
    for (int i = 0; i < hashPartitions.length; i++) {
      int size;
      if (isOnDisk(i)) {
        continue;
      } else {
        size = hashPartitions[i].hashMap.getNumValues();
      }
      if (size > maxSize) {
        maxSize = size;
        res = i;
      }
    }

    // It can happen that although there are some partitions in memory, but their sizes are all 0.
    // In that case we just pick one and spill.
    if (res == -1) {
      for (int i = 0; i < hashPartitions.length; i++) {
        if (!isOnDisk(i)) {
          return i;
        }
      }
    }

    return res;
  }
Find the partition with biggest hashtable in memory at this moment
@return the biggest partition number
ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HybridHashTableContainer.java