HBASE-9142 Mutation#getFamilyMap() return type change between HBase 94 and 96 breaks downstream apps

For 0.95/0.96, we need to preserve the getFamilyMap signature through a deprecation cycle.  The new
method needs to be present alongside the old in 0.95, so we rename the method with the new signature
to getFamilyCellMap() in both trunk and 0.95, and restore a deprecated version of the old in 0.95.



git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1512103 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Hsieh 2013-08-08 23:50:28 +00:00
parent 3bc9e2c95c
commit f528e81766
19 changed files with 48 additions and 48 deletions

View File

@ -137,7 +137,7 @@ public class Delete extends Mutation implements Comparable<Row> {
public Delete(final Delete d) {
this.row = d.getRow();
this.ts = d.getTimeStamp();
this.familyMap.putAll(d.getFamilyMap());
this.familyMap.putAll(d.getFamilyCellMap());
this.durability = d.durability;
}

View File

@ -1328,7 +1328,7 @@ public class HTable implements HTableInterface {
throw new IllegalArgumentException("No columns to insert");
}
if (maxKeyValueSize > 0) {
for (List<? extends Cell> list : put.getFamilyMap().values()) {
for (List<? extends Cell> list : put.getFamilyCellMap().values()) {
for (Cell cell : list) {
// KeyValue v1 expectation. Cast for now.
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);

View File

@ -174,7 +174,7 @@ public class Increment extends Mutation implements Comparable<Row> {
* @since 0.95.0
*/
public Map<byte[], NavigableMap<byte [], Long>> getFamilyMapOfLongs() {
NavigableMap<byte[], List<? extends Cell>> map = super.getFamilyMap();
NavigableMap<byte[], List<? extends Cell>> map = super.getFamilyCellMap();
Map<byte [], NavigableMap<byte[], Long>> results =
new TreeMap<byte[], NavigableMap<byte [], Long>>(Bytes.BYTES_COMPARATOR);
for (Map.Entry<byte [], List<? extends Cell>> entry: map.entrySet()) {

View File

@ -70,7 +70,7 @@ public abstract class Mutation extends OperationWithAttributes implements Row, C
@Override
public CellScanner cellScanner() {
return CellUtil.createCellScanner(getFamilyMap());
return CellUtil.createCellScanner(getFamilyCellMap());
}
/**
@ -182,7 +182,7 @@ public abstract class Mutation extends OperationWithAttributes implements Row, C
* Method for retrieving the put's familyMap
* @return familyMap
*/
public NavigableMap<byte [], List<? extends Cell>> getFamilyMap() {
public NavigableMap<byte [], List<? extends Cell>> getFamilyCellMap() {
return this.familyMap;
}

View File

@ -93,7 +93,7 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
public Put(Put putToCopy) {
this(putToCopy.getRow(), putToCopy.ts);
this.familyMap = new TreeMap<byte [], List<? extends Cell>>(Bytes.BYTES_COMPARATOR);
for(Map.Entry<byte [], List<? extends Cell>> entry: putToCopy.getFamilyMap().entrySet()) {
for(Map.Entry<byte [], List<? extends Cell>> entry: putToCopy.getFamilyCellMap().entrySet()) {
this.familyMap.put(entry.getKey(), entry.getValue());
}
this.durability = putToCopy.durability;

View File

@ -927,7 +927,7 @@ public final class ProtobufUtil {
}
ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
for (Map.Entry<byte[], List<? extends Cell>> family: increment.getFamilyMap().entrySet()) {
for (Map.Entry<byte[], List<? extends Cell>> family: increment.getFamilyCellMap().entrySet()) {
columnBuilder.setFamily(ByteString.copyFrom(family.getKey()));
columnBuilder.clearQualifierValue();
List<? extends Cell> values = family.getValue();
@ -957,7 +957,7 @@ public final class ProtobufUtil {
MutationProto.Builder builder = getMutationBuilderAndSetCommonFields(type, mutation);
ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
for (Map.Entry<byte[],List<? extends Cell>> family: mutation.getFamilyMap().entrySet()) {
for (Map.Entry<byte[],List<? extends Cell>> family: mutation.getFamilyCellMap().entrySet()) {
columnBuilder.setFamily(ByteString.copyFrom(family.getKey()));
columnBuilder.clearQualifierValue();
for (Cell cell: family.getValue()) {

View File

@ -61,9 +61,9 @@ public class PutCombiner<K> extends Reducer<K, Put, K, Put> {
cnt++;
if (put == null) {
put = p;
familyMap = put.getFamilyMap();
familyMap = put.getFamilyCellMap();
} else {
for (Entry<byte[], List<? extends Cell>> entry : p.getFamilyMap()
for (Entry<byte[], List<? extends Cell>> entry : p.getFamilyCellMap()
.entrySet()) {
List<? extends Cell> cells = familyMap.get(entry.getKey());
List<KeyValue> kvs = (cells != null) ? (List<KeyValue>) cells : null;

View File

@ -63,7 +63,7 @@ public class PutSortReducer extends
// stop at the end or the RAM threshold
while (iter.hasNext() && curSize < threshold) {
Put p = iter.next();
for (List<? extends Cell> cells: p.getFamilyMap().values()) {
for (List<? extends Cell> cells: p.getFamilyCellMap().values()) {
for (Cell cell: cells) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
map.add(kv);

View File

@ -1734,13 +1734,13 @@ public class HRegion implements HeapSize { // , Writable{
*/
void prepareDelete(Delete delete) throws IOException {
// Check to see if this is a deleteRow insert
if(delete.getFamilyMap().isEmpty()){
if(delete.getFamilyCellMap().isEmpty()){
for(byte [] family : this.htableDescriptor.getFamiliesKeys()){
// Don't eat the timestamp
delete.deleteFamily(family, delete.getTimeStamp());
}
} else {
for(byte [] family : delete.getFamilyMap().keySet()) {
for(byte [] family : delete.getFamilyCellMap().keySet()) {
if(family == null) {
throw new NoSuchColumnFamilyException("Empty family is invalid");
}
@ -2026,7 +2026,7 @@ public class HRegion implements HeapSize { // , Writable{
Mutation mutation = batchOp.operations[lastIndexExclusive];
boolean isPutMutation = mutation instanceof Put;
Map<byte[], List<? extends Cell>> familyMap = mutation.getFamilyMap();
Map<byte[], List<? extends Cell>> familyMap = mutation.getFamilyCellMap();
// store the family map reference to allow for mutations
familyMaps[lastIndexExclusive] = familyMap;
@ -2045,7 +2045,7 @@ public class HRegion implements HeapSize { // , Writable{
} else {
checkFamilies(familyMap.keySet());
}
checkTimestamps(mutation.getFamilyMap(), now);
checkTimestamps(mutation.getFamilyCellMap(), now);
} else {
prepareDelete((Delete) mutation);
}
@ -2089,17 +2089,17 @@ public class HRegion implements HeapSize { // , Writable{
// individual puts then metrics can be reported as a mutliput across
// column families in the first put.
if (putsCfSet == null) {
putsCfSet = mutation.getFamilyMap().keySet();
putsCfSet = mutation.getFamilyCellMap().keySet();
} else {
putsCfSetConsistent = putsCfSetConsistent
&& mutation.getFamilyMap().keySet().equals(putsCfSet);
&& mutation.getFamilyCellMap().keySet().equals(putsCfSet);
}
} else {
if (deletesCfSet == null) {
deletesCfSet = mutation.getFamilyMap().keySet();
deletesCfSet = mutation.getFamilyCellMap().keySet();
} else {
deletesCfSetConsistent = deletesCfSetConsistent
&& mutation.getFamilyMap().keySet().equals(deletesCfSet);
&& mutation.getFamilyCellMap().keySet().equals(deletesCfSet);
}
}
}
@ -2185,7 +2185,7 @@ public class HRegion implements HeapSize { // , Writable{
durability = tmpDur;
}
if (tmpDur == Durability.SKIP_WAL) {
recordMutationWithoutWal(m.getFamilyMap());
recordMutationWithoutWal(m.getFamilyCellMap());
continue;
}
@ -4669,7 +4669,7 @@ public class HRegion implements HeapSize { // , Writable{
try {
long now = EnvironmentEdgeManager.currentTimeMillis();
// Process each family
for (Map.Entry<byte[], List<? extends Cell>> family : append.getFamilyMap().entrySet()) {
for (Map.Entry<byte[], List<? extends Cell>> family : append.getFamilyCellMap().entrySet()) {
Store store = stores.get(family.getKey());
List<KeyValue> kvs = new ArrayList<KeyValue>(family.getValue().size());
@ -4755,7 +4755,7 @@ public class HRegion implements HeapSize { // , Writable{
walEdits, HConstants.DEFAULT_CLUSTER_ID, EnvironmentEdgeManager.currentTimeMillis(),
this.htableDescriptor);
} else {
recordMutationWithoutWal(append.getFamilyMap());
recordMutationWithoutWal(append.getFamilyCellMap());
}
//Actually write to Memstore now
@ -4844,7 +4844,7 @@ public class HRegion implements HeapSize { // , Writable{
long now = EnvironmentEdgeManager.currentTimeMillis();
// Process each family
for (Map.Entry<byte [], List<? extends Cell>> family:
increment.getFamilyMap().entrySet()) {
increment.getFamilyCellMap().entrySet()) {
Store store = stores.get(family.getKey());
List<KeyValue> kvs = new ArrayList<KeyValue>(family.getValue().size());
@ -4905,7 +4905,7 @@ public class HRegion implements HeapSize { // , Writable{
walEdits, HConstants.DEFAULT_CLUSTER_ID, EnvironmentEdgeManager.currentTimeMillis(),
this.htableDescriptor);
} else {
recordMutationWithoutWal(increment.getFamilyMap());
recordMutationWithoutWal(increment.getFamilyCellMap());
}
//Actually write to Memstore now
for (Map.Entry<Store, List<KeyValue>> entry : tempMemstore.entrySet()) {

View File

@ -73,20 +73,20 @@ MultiRowMutationProcessorResponse> {
// Check mutations and apply edits to a single WALEdit
for (Mutation m : mutations) {
if (m instanceof Put) {
Map<byte[], List<? extends Cell>> familyMap = m.getFamilyMap();
Map<byte[], List<? extends Cell>> familyMap = m.getFamilyCellMap();
region.checkFamilies(familyMap.keySet());
region.checkTimestamps(familyMap, now);
region.updateKVTimestamps(familyMap.values(), byteNow);
} else if (m instanceof Delete) {
Delete d = (Delete) m;
region.prepareDelete(d);
region.prepareDeleteTimestamps(d.getFamilyMap(), byteNow);
region.prepareDeleteTimestamps(d.getFamilyCellMap(), byteNow);
} else {
throw new DoNotRetryIOException(
"Action must be Put or Delete. But was: "
+ m.getClass().getName());
}
for (List<? extends Cell> cells: m.getFamilyMap().values()) {
for (List<? extends Cell> cells: m.getFamilyCellMap().values()) {
boolean writeToWAL = m.getDurability() != Durability.SKIP_WAL;
for (Cell cell : cells) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);

View File

@ -184,7 +184,7 @@ public class RemoteHTable implements HTableInterface {
protected CellSetModel buildModelFromPut(Put put) {
RowModel row = new RowModel(put.getRow());
long ts = put.getTimeStamp();
for (List<? extends Cell> cells: put.getFamilyMap().values()) {
for (List<? extends Cell> cells: put.getFamilyCellMap().values()) {
for (Cell cell: cells) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
row.addCell(new CellModel(kv.getFamily(), kv.getQualifier(),
@ -404,7 +404,7 @@ public class RemoteHTable implements HTableInterface {
cells = new ArrayList<Cell>();
map.put(row, cells);
}
for (List<? extends Cell> l: put.getFamilyMap().values()) {
for (List<? extends Cell> l: put.getFamilyCellMap().values()) {
cells.addAll(l);
}
}
@ -445,7 +445,7 @@ public class RemoteHTable implements HTableInterface {
}
public void delete(Delete delete) throws IOException {
String spec = buildRowSpec(delete.getRow(), delete.getFamilyMap(),
String spec = buildRowSpec(delete.getRow(), delete.getFamilyCellMap(),
delete.getTimeStamp(), delete.getTimeStamp(), 1);
for (int i = 0; i < maxRetries; i++) {
Response response = client.delete(spec);

View File

@ -938,14 +938,14 @@ public class AccessController extends BaseRegionObserver
final Put put, final WALEdit edit, final Durability durability)
throws IOException {
requirePermission("put", Permission.Action.WRITE, c.getEnvironment(),
put.getFamilyMap());
put.getFamilyCellMap());
}
@Override
public void postPut(final ObserverContext<RegionCoprocessorEnvironment> c,
final Put put, final WALEdit edit, final Durability durability) {
if (aclRegion) {
updateACL(c.getEnvironment(), put.getFamilyMap());
updateACL(c.getEnvironment(), put.getFamilyCellMap());
}
}
@ -954,7 +954,7 @@ public class AccessController extends BaseRegionObserver
final Delete delete, final WALEdit edit, final Durability durability)
throws IOException {
requirePermission("delete", Permission.Action.WRITE, c.getEnvironment(),
delete.getFamilyMap());
delete.getFamilyCellMap());
}
@Override
@ -962,7 +962,7 @@ public class AccessController extends BaseRegionObserver
final Delete delete, final WALEdit edit, final Durability durability)
throws IOException {
if (aclRegion) {
updateACL(c.getEnvironment(), delete.getFamilyMap());
updateACL(c.getEnvironment(), delete.getFamilyCellMap());
}
}
@ -1003,7 +1003,7 @@ public class AccessController extends BaseRegionObserver
@Override
public Result preAppend(ObserverContext<RegionCoprocessorEnvironment> c, Append append)
throws IOException {
requirePermission("append", Permission.Action.WRITE, c.getEnvironment(), append.getFamilyMap());
requirePermission("append", Permission.Action.WRITE, c.getEnvironment(), append.getFamilyCellMap());
return null;
}
@ -1013,7 +1013,7 @@ public class AccessController extends BaseRegionObserver
throws IOException {
// Create a map of family to qualifiers.
Map<byte[], Set<byte[]>> familyMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
for (Map.Entry<byte [], List<? extends Cell>> entry: increment.getFamilyMap().entrySet()) {
for (Map.Entry<byte [], List<? extends Cell>> entry: increment.getFamilyCellMap().entrySet()) {
Set<byte[]> qualifiers = Sets.newTreeSet(Bytes.BYTES_COMPARATOR);
for (Cell cell: entry.getValue()) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);

View File

@ -288,7 +288,7 @@ public class ThriftUtilities {
// Map<family, List<KeyValue>>
for (Map.Entry<byte[], List<? extends org.apache.hadoop.hbase.Cell>> familyEntry:
in.getFamilyMap().entrySet()) {
in.getFamilyCellMap().entrySet()) {
TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
for (org.apache.hadoop.hbase.Cell cell: familyEntry.getValue()) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);

View File

@ -3796,10 +3796,10 @@ public class TestFromClientSide {
put.add(CONTENTS_FAMILY, null, value);
assertEquals(put.size(), 1);
assertEquals(put.getFamilyMap().get(CONTENTS_FAMILY).size(), 1);
assertEquals(put.getFamilyCellMap().get(CONTENTS_FAMILY).size(), 1);
// KeyValue v1 expectation. Cast for now until we go all Cell all the time. TODO
KeyValue kv = (KeyValue)put.getFamilyMap().get(CONTENTS_FAMILY).get(0);
KeyValue kv = (KeyValue)put.getFamilyCellMap().get(CONTENTS_FAMILY).get(0);
assertTrue(Bytes.equals(kv.getFamily(), CONTENTS_FAMILY));
// will it return null or an empty byte array?

View File

@ -315,7 +315,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
final Put put, final WALEdit edit,
final Durability durability) throws IOException {
Map<byte[], List<? extends Cell>> familyMap = put.getFamilyMap();
Map<byte[], List<? extends Cell>> familyMap = put.getFamilyCellMap();
RegionCoprocessorEnvironment e = c.getEnvironment();
assertNotNull(e);
assertNotNull(e.getRegion());
@ -348,7 +348,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
public void postPut(final ObserverContext<RegionCoprocessorEnvironment> c,
final Put put, final WALEdit edit,
final Durability durability) throws IOException {
Map<byte[], List<? extends Cell>> familyMap = put.getFamilyMap();
Map<byte[], List<? extends Cell>> familyMap = put.getFamilyCellMap();
RegionCoprocessorEnvironment e = c.getEnvironment();
assertNotNull(e);
assertNotNull(e.getRegion());
@ -381,7 +381,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
final Delete delete, final WALEdit edit,
final Durability durability) throws IOException {
Map<byte[], List<? extends Cell>> familyMap = delete.getFamilyMap();
Map<byte[], List<? extends Cell>> familyMap = delete.getFamilyCellMap();
RegionCoprocessorEnvironment e = c.getEnvironment();
assertNotNull(e);
assertNotNull(e.getRegion());
@ -395,7 +395,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
public void postDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
final Delete delete, final WALEdit edit,
final Durability durability) throws IOException {
Map<byte[], List<? extends Cell>> familyMap = delete.getFamilyMap();
Map<byte[], List<? extends Cell>> familyMap = delete.getFamilyCellMap();
RegionCoprocessorEnvironment e = c.getEnvironment();
assertNotNull(e);
assertNotNull(e.getRegion());

View File

@ -208,7 +208,7 @@ public class TestRegionObserverBypass {
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> e,
final Put put, final WALEdit edit, final Durability durability)
throws IOException {
Map<byte[], List<? extends Cell>> familyMap = put.getFamilyMap();
Map<byte[], List<? extends Cell>> familyMap = put.getFamilyCellMap();
if (familyMap.containsKey(test)) {
e.bypass();
}

View File

@ -157,7 +157,7 @@ public class TestWALObserver {
// Use a Put to create familyMap.
Put p = creatPutWith2Families(TEST_ROW);
Map<byte[], List<? extends Cell>> familyMap = p.getFamilyMap();
Map<byte[], List<? extends Cell>> familyMap = p.getFamilyCellMap();
WALEdit edit = new WALEdit();
addFamilyMapToWALEdit(familyMap, edit);

View File

@ -99,7 +99,7 @@ public final class HLogPerformanceEvaluation extends Configured implements Tool
Put put = setupPut(rand, key, value, numFamilies);
long now = System.currentTimeMillis();
WALEdit walEdit = new WALEdit();
addFamilyMapToWALEdit(put.getFamilyMap(), walEdit);
addFamilyMapToWALEdit(put.getFamilyCellMap(), walEdit);
HRegionInfo hri = region.getRegionInfo();
if (this.noSync) {
hlog.appendNoSync(hri, hri.getTableName(), walEdit,

View File

@ -222,12 +222,12 @@ public class TestCoprocessorScanPolicy {
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c, final Put put,
final WALEdit edit, final Durability durability) throws IOException {
if (put.getAttribute("ttl") != null) {
Cell cell = put.getFamilyMap().values().iterator().next().get(0);
Cell cell = put.getFamilyCellMap().values().iterator().next().get(0);
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
ttls.put(TableName.valueOf(kv.getQualifier()), Bytes.toLong(kv.getValue()));
c.bypass();
} else if (put.getAttribute("versions") != null) {
Cell cell = put.getFamilyMap().values().iterator().next().get(0);
Cell cell = put.getFamilyCellMap().values().iterator().next().get(0);
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
versions.put(TableName.valueOf(kv.getQualifier()), Bytes.toInt(kv.getValue()));
c.bypass();