diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java index 6df3626..83a5d31 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java @@ -19,9 +19,12 @@ package org.apache.hadoop.hbase.client; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.NavigableMap; +import java.util.TreeMap; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -133,6 +136,29 @@ public class Increment extends Mutation implements Comparable { } /** + * Before 0.95, when you called {@link Increment#getFamilyMap()}}, you got back + * a map of families to a list of Longs. Now, {@link #getFamilyMap()} returns + * families by list of Cells. This method has been added so you can have the + * old behavior. This is an + * @return Map of families to a list of Long increments. + * @since 0.95.0 + */ + public NavigableMap> getFamilyMapOfLongs() { + NavigableMap> map = super.getFamilyMap(); + NavigableMap> results = + new TreeMap>(Bytes.BYTES_COMPARATOR); + for (Map.Entry> entry: map.entrySet()) { + List longs = new ArrayList(entry.getValue().size()); + for (Cell cell: entry.getValue()) { + longs.add(new Long(Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), + cell.getValueLength()))); + } + results.put(entry.getKey(), longs); + } + return results; + } + + /** * @return String */ @Override