public static List<TKeyValue> compress(List<? extends KeyValue> param) {
List<TKeyValue> tkvl = Arrays.asList(new TKeyValue[param.size()]);
if (param.size() > 0)
tkvl.set(0, new TKeyValue(param.get(0).key.toThrift(), ByteBuffer.wrap(param.get(0).value)));
for (int i = param.size() - 1; i > 0; i--) {
Key prevKey = param.get(i - 1).key;
KeyValue kv = param.get(i);
Key key = kv.key;
TKey newKey = null;
if (isEqual(prevKey.row, key.row)) {
newKey = key.toThrift();
newKey.row = null;
}
if (isEqual(prevKey.colFamily, key.colFamily)) {
if (newKey == null)
newKey = key.toThrift();
newKey.colFamily = null;
}
if (isEqual(prevKey.colQualifier, key.colQualifier)) {
if (newKey == null)
newKey = key.toThrift();
newKey.colQualifier = null;
}
if (isEqual(prevKey.colVisibility, key.colVisibility)) {
if (newKey == null)
newKey = key.toThrift();
newKey.colVisibility = null;
}
if (newKey == null)
newKey = key.toThrift();
tkvl.set(i, new TKeyValue(newKey, ByteBuffer.wrap(kv.value)));
}
return tkvl;
}