private int binarySearch(final Cell[] kvs, final byte[] family, final int foffset,
    final int flength, final byte[] qualifier, final int qoffset, final int qlength) {

    double keyValueSize =
      (double) KeyValue.getKeyValueDataStructureSize(kvs[0].getRowLength(), flength, qlength, 0);

    byte[] buffer = localBuffer.get();
    if (buffer == null || keyValueSize > buffer.length) {
      // pad to the smallest multiple of the pad width
      buffer = new byte[(int) Math.ceil(keyValueSize / PAD_WIDTH) * PAD_WIDTH];
      localBuffer.set(buffer);
    }

    Cell searchTerm =
      KeyValueUtil.createFirstOnRow(buffer, 0, kvs[0].getRowArray(), kvs[0].getRowOffset(),
        kvs[0].getRowLength(), family, foffset, flength, qualifier, qoffset, qlength);

    // pos === ( -(insertion point) - 1)
    int pos = Arrays.binarySearch(kvs, searchTerm, CellComparator.getInstance());
    // never will exact match
    if (pos < 0) {
      pos = (pos + 1) * -1;
      // pos is now insertion point
    }
    if (pos == kvs.length) {
      return -1; // doesn't exist
    }
    return pos;
  }
Searches for the latest value for the specified column.
@param kvs       the array to search
@param family    family name
@param foffset   family offset
@param flength   family length
@param qualifier column qualifier
@param qoffset   qualifier offset
@param qlength   qualifier length
@return the index where the value was found, or -1 otherwise
hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java