code: int moveToNextRecordAndGetItsBucketId() throws IOException {
      while (numRecordsReadInBucket >= numRecordsInBucket) {
        if (currentBucket + 1>= numBuckets) {
          // We've finished all the records.
          return -1;
        } else {
          numRecordsInBucket = in.readInt();
          currentBucket++;
          numRecordsReadInBucket = 0;
        }
      }
      return currentBucket;
    }
docs: Find the bucket ID for the next record. If current bucket hasn't yet been
  finished, then the current bucket ID will be returned. Otherwise, it will
  keep reading the input file until it finds the next non-empty bucket and
  return this bucket's ID.
  
  After the call, the position of the input stream will be just before the
  next record.
  
  @return bucket ID for next record. -1 if no more record left.
  @throws IOException