class ThemisCpUtil {

  protected static List<KeyValue> getPutKvs(List<KeyValue> writeKvs) {
    if (ColumnUtil.isCommitToSameFamily()) {
      List<KeyValue> result = new ArrayList<KeyValue>();
      Column lastDataColumn = null;
      KeyValue lastKv = null;
      for (int i = 0; i < writeKvs.size(); ++i) {
        KeyValue kv = writeKvs.get(i);
        Column column = new Column(kv.getFamily(), kv.getQualifier());
        Column dataColumn = ColumnUtil.getDataColumn(column);
        if (lastDataColumn != null && lastDataColumn.equals(dataColumn)) {
          if (lastKv.getTimestamp() < kv.getTimestamp()) {
            lastKv = kv;
          }
        } else {
          if (lastKv != null && ColumnUtil.isPutColumn(lastKv.getFamily(), lastKv.getQualifier())) {
            result.add(lastKv);
          }
          lastDataColumn = dataColumn;
          lastKv = kv;
        }
      }
      if (lastKv != null && ColumnUtil.isPutColumn(lastKv.getFamily(), lastKv.getQualifier())) {
        result.add(lastKv);
      }
      return result;
    } else {
      return getPutKvsForCommitDifferentFamily(writeKvs);
    }
  }

}