@Override
  public long split(long count, LongBitSet rightTree, PointWriter left, PointWriter right, boolean doClearBits) throws IOException {

    if (left instanceof OfflinePointWriter == false ||
        right instanceof OfflinePointWriter == false) {
      return super.split(count, rightTree, left, right, doClearBits);
    }

    // We specialize the offline -> offline split since the default impl
    // is somewhat wasteful otherwise (e.g. decoding docID when we don't
    // need to)

    int packedBytesLength = packedValue.length;

    int bytesPerDoc = packedBytesLength + Integer.BYTES;
    if (singleValuePerDoc == false) {
      if (longOrds) {
        bytesPerDoc += Long.BYTES;
      } else {
        bytesPerDoc += Integer.BYTES;
      }
    }

    long rightCount = 0;

    IndexOutput rightOut = ((OfflinePointWriter) right).out;
    IndexOutput leftOut = ((OfflinePointWriter) left).out;

    assert count <= countLeft: "count=" + count + " countLeft=" + countLeft;

    countLeft -= count;

    long countStart = count;

    byte[] buffer = new byte[bytesPerDoc];
    while (count > 0) {
      in.readBytes(buffer, 0, buffer.length);

      long ord;
      if (longOrds) {
        // A long ord, after the docID:
        ord = readLong(buffer, packedBytesLength+Integer.BYTES);
      } else if (singleValuePerDoc) {
        // docID is the ord:
        ord = readInt(buffer, packedBytesLength);
      } else {
        // An int ord, after the docID:
        ord = readInt(buffer, packedBytesLength+Integer.BYTES);
      }

      if (rightTree.get(ord)) {
        rightOut.writeBytes(buffer, 0, bytesPerDoc);
        if (doClearBits) {
          rightTree.clear(ord);
        }
        rightCount++;
      } else {
        leftOut.writeBytes(buffer, 0, bytesPerDoc);
      }

      count--;
    }

    ((OfflinePointWriter) right).count = rightCount;
    ((OfflinePointWriter) left).count = countStart-rightCount;

    return rightCount;
  }