class ThemisCpUtil {

  public static Result removeNotRequiredLockColumns(Map<byte[], NavigableSet<byte[]>> familyMap,
      Result result) {
    if (!result.isEmpty()) {
      List<KeyValue> kvs = new ArrayList<KeyValue>();
      for (KeyValue kv : result.list()) {
        if (Bytes.equals(ColumnUtil.LOCK_FAMILY_NAME, kv.getFamily())
            || ColumnUtil.isCommitFamily(kv.getFamily())) {
          Column dataColumn = ColumnUtil.getDataColumnFromConstructedQualifier(new Column(kv.getFamily(), kv
              .getQualifier()));
          if (familyMap.containsKey(dataColumn.getFamily())) {
            Set<byte[]> qualifiers= familyMap.get(dataColumn.getFamily());
            // for scan, after serialization, the null qualifiers will be set to empty set
            if (qualifiers == null || qualifiers.size() == 0
                || qualifiers.contains(dataColumn.getQualifier())) {
              kvs.add(kv);
            }
          }
        } else {
          kvs.add(kv);
        }
      }
      if (kvs.size() != result.size()) {
        return new Result(kvs);
      }
    }
    return result;
  }

}