private boolean isMemoryFull() {
    int numPartitionsInMem = 0;

    for (HashPartition hp : hashPartitions) {
      if (!hp.isHashMapOnDisk()) {
        numPartitionsInMem++;
      }
    }

    return refreshMemoryUsed() + this.memoryCheckFrequency * getTableRowSize() +
        writeBufferSize * numPartitionsInMem >= memoryThreshold;
  }
Check if the memory threshold is about to be reached.
Since all the write buffer will be lazily allocated in BytesBytesMultiHashMap, we need to
consider those as well.
We also need to count in the next 1024 rows to be loaded.
@return true if memory is full, false if not
ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HybridHashTableContainer.java