protected byte[] buildKey(
      HashBytes partition, HashBytes first, HashBytes second, HashBytes third) {
    ByteBuffer buff = ByteBuffer.allocate(Schema.TRIPLE_KEY_LENGTH);

    if (partition != null) buff.put(partition.getBytes());

    buff.put(first.getBytes());
    buff.put(second.getBytes());
    buff.put(third.getBytes());

    if (partition == null) buff.put(Bytes.toBytes(0L));

    return buff.array();
  }
  protected byte[] buildEndKey(
      HashBytes partition, HashBytes first, HashBytes second, HashBytes third) {
    HashBytes endFirst = new HashBytes();
    HashBytes endSecond = new HashBytes();
    HashBytes endThird = new HashBytes();

    if (!second.isEmpty() && !third.isEmpty()) {
      endFirst.setBytes(first);
      endSecond.setBytes(second);
      endThird.setBytes(third.plusOne());
    } else if (!second.isEmpty()) {
      endFirst.setBytes(first);
      endSecond.setBytes(second.plusOne());
    } else {
      endFirst.setBytes(first.plusOne());
    }

    return buildKey(partition, endFirst, endSecond, endThird);
  }