Exemple #1
0
  int indexOf(final byte[] family, final byte[] qualifier) {
    KeyValue searchTerm = new KeyValue(getRowKey(), family, qualifier, HBaseClient.EMPTY_ARRAY);
    int pos = Collections.binarySearch(kvList, searchTerm, KV_COMPARATOR);
    // never will exact match
    if (pos < 0) {
      pos = (pos + 1) * -1;
      // pos is now insertion point
    }
    if (pos == kvList.size()) {
      return -1; // doesn't exist
    }

    KeyValue kv = kvList.get(pos);
    return (Bytes.equals(family, kv.family()) && Bytes.equals(qualifier, kv.qualifier()))
        ? pos
        : -1;
  }
Exemple #2
0
 /**
  * Extracts the qualifier of a cell containing a data point.
  *
  * @param kv The cell.
  * @return The qualifier, on a short, since it's expected to be on 2 bytes.
  */
 private short extractQualifier(final KeyValue kv) {
   if (!Bytes.equals(TSDB.FAMILY, kv.family())) {
     throw new AssertionError("unexpected KeyValue family: " + Bytes.pretty(kv.family()));
   }
   final byte[] qual = kv.qualifier();
   if (qual.length != 2) {
     throw new AssertionError("Invalid qualifier length: " + Bytes.pretty(qual));
   }
   return Bytes.getShort(qual);
 }