HBASE-9496 make sure HBase APIs are compatible between 0.94 and 0.96
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1523825 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5a0016d1af
commit
ed90c565ef
|
@ -39,6 +39,7 @@ import org.apache.hadoop.hbase.io.HeapSize;
|
|||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.ClassSize;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
@ -195,12 +196,25 @@ public abstract class Mutation extends OperationWithAttributes implements Row, C
|
|||
/**
|
||||
* Method for setting the put's familyMap
|
||||
*/
|
||||
public void setFamilyMap(NavigableMap<byte [], List<Cell>> map) {
|
||||
public void setFamilyCellMap(NavigableMap<byte [], List<Cell>> map) {
|
||||
// TODO: Shut this down or move it up to be a Constructor. Get new object rather than change
|
||||
// this internal data member.
|
||||
this.familyMap = map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for setting the put's familyMap that is deprecated and inefficient.
|
||||
* @deprecated use {@link #setFamilyCellMap(NavigableMap)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setFamilyMap(NavigableMap<byte [], List<KeyValue>> map) {
|
||||
TreeMap<byte[], List<Cell>> fm = new TreeMap<byte[], List<Cell>>(Bytes.BYTES_COMPARATOR);
|
||||
for (Map.Entry<byte[], List<KeyValue>> e : map.entrySet()) {
|
||||
fm.put(e.getKey(), Lists.<Cell>newArrayList(e.getValue()));
|
||||
}
|
||||
this.familyMap = fm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if the familyMap is empty
|
||||
* @return true if empty, false otherwise
|
||||
|
|
|
@ -29,6 +29,8 @@ import java.util.Map;
|
|||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
|
@ -95,26 +97,45 @@ public class Result implements CellScannable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Result with the specified array of KeyValues.
|
||||
* <br><strong>Note:</strong> You must ensure that the keyvalues
|
||||
* are already sorted
|
||||
* @param cells array of KeyValues
|
||||
* @deprecated Use {@link #create(List)} instead.
|
||||
*/
|
||||
public Result(Cell [] cells) {
|
||||
@Deprecated
|
||||
public Result(KeyValue [] cells) {
|
||||
this.cells = cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Result with the specified List of KeyValues.
|
||||
* <br><strong>Note:</strong> You must ensure that the keyvalues
|
||||
* are already sorted
|
||||
* @param kvs List of KeyValues
|
||||
* @deprecated Use {@link #create(List)} instead.
|
||||
*/
|
||||
public Result(List<Cell> kvs) {
|
||||
@Deprecated
|
||||
public Result(List<KeyValue> kvs) {
|
||||
// TODO: Here we presume the passed in Cells are KVs. One day this won't always be so.
|
||||
this(kvs.toArray(new Cell[kvs.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Result with the specified List of KeyValues.
|
||||
* <br><strong>Note:</strong> You must ensure that the keyvalues are already sorted.
|
||||
* @param cells List of cells
|
||||
*/
|
||||
public static Result create(List<Cell> cells) {
|
||||
return new Result(cells.toArray(new Cell[cells.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Result with the specified array of KeyValues.
|
||||
* <br><strong>Note:</strong> You must ensure that the keyvalues are already sorted.
|
||||
* @param cells array of cells
|
||||
*/
|
||||
public static Result create(Cell[] cells) {
|
||||
return new Result(cells);
|
||||
}
|
||||
|
||||
/** Private ctor. Use {@link #create(Cell[])}. */
|
||||
private Result(Cell[] cells) {
|
||||
this.cells = cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for retrieving the row key that corresponds to
|
||||
* the row from which this Result was created.
|
||||
|
@ -196,6 +217,13 @@ public class Result implements CellScannable {
|
|||
return isEmpty() ? null : Arrays.asList(raw());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getColumnCells(byte[], byte[])} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<KeyValue> getColumn(byte [] family, byte [] qualifier) {
|
||||
return KeyValueUtil.ensureKeyValues(getColumnCells(family, qualifier));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Cells for the specific column. The Cells are sorted in
|
||||
|
@ -212,7 +240,7 @@ public class Result implements CellScannable {
|
|||
* @return a list of Cells for this column or empty list if the column
|
||||
* did not exist in the result set
|
||||
*/
|
||||
public List<Cell> getColumn(byte [] family, byte [] qualifier) {
|
||||
public List<Cell> getColumnCells(byte [] family, byte [] qualifier) {
|
||||
List<Cell> result = new ArrayList<Cell>();
|
||||
|
||||
Cell [] kvs = rawCells();
|
||||
|
@ -300,6 +328,14 @@ public class Result implements CellScannable {
|
|||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getColumnLatestCell(byte[], byte[])} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public KeyValue getColumnLatest(byte [] family, byte [] qualifier) {
|
||||
return KeyValueUtil.ensureKeyValue(getColumnLatestCell(family, qualifier));
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cell for the most recent timestamp for a given column.
|
||||
*
|
||||
|
@ -309,7 +345,7 @@ public class Result implements CellScannable {
|
|||
* @return the Cell for the column, or null if no value exists in the row or none have been
|
||||
* selected in the query (Get/Scan)
|
||||
*/
|
||||
public Cell getColumnLatest(byte [] family, byte [] qualifier) {
|
||||
public Cell getColumnLatestCell(byte [] family, byte [] qualifier) {
|
||||
Cell [] kvs = rawCells(); // side effect possibly.
|
||||
if (kvs == null || kvs.length == 0) {
|
||||
return null;
|
||||
|
@ -325,6 +361,16 @@ public class Result implements CellScannable {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getColumnLatestCell(byte[], int, int, byte[], int, int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public KeyValue getColumnLatest(byte [] family, int foffset, int flength,
|
||||
byte [] qualifier, int qoffset, int qlength) {
|
||||
return KeyValueUtil.ensureKeyValue(
|
||||
getColumnLatestCell(family, foffset, flength, qualifier, qoffset, qlength));
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cell for the most recent timestamp for a given column.
|
||||
*
|
||||
|
@ -338,7 +384,7 @@ public class Result implements CellScannable {
|
|||
* @return the Cell for the column, or null if no value exists in the row or none have been
|
||||
* selected in the query (Get/Scan)
|
||||
*/
|
||||
public Cell getColumnLatest(byte [] family, int foffset, int flength,
|
||||
public Cell getColumnLatestCell(byte [] family, int foffset, int flength,
|
||||
byte [] qualifier, int qoffset, int qlength) {
|
||||
|
||||
Cell [] kvs = rawCells(); // side effect possibly.
|
||||
|
@ -363,7 +409,7 @@ public class Result implements CellScannable {
|
|||
* @return value of latest version of column, null if none found
|
||||
*/
|
||||
public byte[] getValue(byte [] family, byte [] qualifier) {
|
||||
Cell kv = getColumnLatest(family, qualifier);
|
||||
Cell kv = getColumnLatestCell(family, qualifier);
|
||||
if (kv == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -380,7 +426,7 @@ public class Result implements CellScannable {
|
|||
*/
|
||||
public ByteBuffer getValueAsByteBuffer(byte [] family, byte [] qualifier) {
|
||||
|
||||
Cell kv = getColumnLatest(family, 0, family.length, qualifier, 0, qualifier.length);
|
||||
Cell kv = getColumnLatestCell(family, 0, family.length, qualifier, 0, qualifier.length);
|
||||
|
||||
if (kv == null) {
|
||||
return null;
|
||||
|
@ -403,7 +449,7 @@ public class Result implements CellScannable {
|
|||
public ByteBuffer getValueAsByteBuffer(byte [] family, int foffset, int flength,
|
||||
byte [] qualifier, int qoffset, int qlength) {
|
||||
|
||||
Cell kv = getColumnLatest(family, foffset, flength, qualifier, qoffset, qlength);
|
||||
Cell kv = getColumnLatestCell(family, foffset, flength, qualifier, qoffset, qlength);
|
||||
|
||||
if (kv == null) {
|
||||
return null;
|
||||
|
@ -449,7 +495,7 @@ public class Result implements CellScannable {
|
|||
public boolean loadValue(byte [] family, int foffset, int flength,
|
||||
byte [] qualifier, int qoffset, int qlength, ByteBuffer dst)
|
||||
throws BufferOverflowException {
|
||||
Cell kv = getColumnLatest(family, foffset, flength, qualifier, qoffset, qlength);
|
||||
Cell kv = getColumnLatestCell(family, foffset, flength, qualifier, qoffset, qlength);
|
||||
|
||||
if (kv == null) {
|
||||
return false;
|
||||
|
@ -486,7 +532,7 @@ public class Result implements CellScannable {
|
|||
public boolean containsNonEmptyColumn(byte [] family, int foffset, int flength,
|
||||
byte [] qualifier, int qoffset, int qlength) {
|
||||
|
||||
Cell kv = getColumnLatest(family, foffset, flength, qualifier, qoffset, qlength);
|
||||
Cell kv = getColumnLatestCell(family, foffset, flength, qualifier, qoffset, qlength);
|
||||
|
||||
return (kv != null) && (kv.getValueLength() > 0);
|
||||
}
|
||||
|
@ -518,7 +564,7 @@ public class Result implements CellScannable {
|
|||
*/
|
||||
public boolean containsEmptyColumn(byte [] family, int foffset, int flength,
|
||||
byte [] qualifier, int qoffset, int qlength) {
|
||||
Cell kv = getColumnLatest(family, foffset, flength, qualifier, qoffset, qlength);
|
||||
Cell kv = getColumnLatestCell(family, foffset, flength, qualifier, qoffset, qlength);
|
||||
|
||||
return (kv != null) && (kv.getValueLength() == 0);
|
||||
}
|
||||
|
@ -532,7 +578,7 @@ public class Result implements CellScannable {
|
|||
* @return true if at least one value exists in the result, false if not
|
||||
*/
|
||||
public boolean containsColumn(byte [] family, byte [] qualifier) {
|
||||
Cell kv = getColumnLatest(family, qualifier);
|
||||
Cell kv = getColumnLatestCell(family, qualifier);
|
||||
return kv != null;
|
||||
}
|
||||
|
||||
|
@ -551,7 +597,7 @@ public class Result implements CellScannable {
|
|||
public boolean containsColumn(byte [] family, int foffset, int flength,
|
||||
byte [] qualifier, int qoffset, int qlength) {
|
||||
|
||||
return getColumnLatest(family, foffset, flength, qualifier, qoffset, qlength) != null;
|
||||
return getColumnLatestCell(family, foffset, flength, qualifier, qoffset, qlength) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1060,7 +1060,7 @@ public final class ProtobufUtil {
|
|||
for (CellProtos.Cell c: values) {
|
||||
cells.add(toCell(c));
|
||||
}
|
||||
return new Result(cells);
|
||||
return Result.create(cells);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1088,7 +1088,7 @@ public final class ProtobufUtil {
|
|||
for (CellProtos.Cell c: values) {
|
||||
cells.add(toCell(c));
|
||||
}
|
||||
return new Result(cells);
|
||||
return Result.create(cells);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -309,7 +309,7 @@ public final class ResponseConverter {
|
|||
}
|
||||
cells.add(cellScanner.current());
|
||||
}
|
||||
results[i] = new Result(cells);
|
||||
results[i] = Result.create(cells);
|
||||
} else {
|
||||
// Result is pure pb.
|
||||
results[i] = ProtobufUtil.toResult(response.getResults(i));
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
package org.apache.hadoop.hbase;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.util.ByteBufferUtils;
|
||||
|
@ -27,6 +29,9 @@ import org.apache.hadoop.hbase.util.Bytes;
|
|||
import org.apache.hadoop.hbase.util.IterableUtils;
|
||||
import org.apache.hadoop.io.WritableUtils;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* static convenience methods for dealing with KeyValues and collections of KeyValues
|
||||
*/
|
||||
|
@ -203,4 +208,13 @@ public class KeyValueUtil {
|
|||
if (cell == null) return null;
|
||||
return cell instanceof KeyValue? (KeyValue)cell: copyToNewKeyValue(cell);
|
||||
}
|
||||
|
||||
public static List<KeyValue> ensureKeyValues(List<Cell> cells) {
|
||||
List<KeyValue> lazyList = Lists.transform(cells, new Function<Cell, KeyValue>() {
|
||||
public KeyValue apply(Cell arg0) {
|
||||
return KeyValueUtil.ensureKeyValue(arg0);
|
||||
}
|
||||
});
|
||||
return new ArrayList<KeyValue>(lazyList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,9 +202,9 @@ public class TestBulkDeleteProtocol {
|
|||
int rows = 0;
|
||||
for (Result result : ht.getScanner(new Scan())) {
|
||||
assertEquals(2, result.getFamilyMap(FAMILY1).size());
|
||||
assertTrue(result.getColumn(FAMILY1, QUALIFIER2).isEmpty());
|
||||
assertEquals(1, result.getColumn(FAMILY1, QUALIFIER1).size());
|
||||
assertEquals(1, result.getColumn(FAMILY1, QUALIFIER3).size());
|
||||
assertTrue(result.getColumnCells(FAMILY1, QUALIFIER2).isEmpty());
|
||||
assertEquals(1, result.getColumnCells(FAMILY1, QUALIFIER1).size());
|
||||
assertEquals(1, result.getColumnCells(FAMILY1, QUALIFIER3).size());
|
||||
rows++;
|
||||
}
|
||||
assertEquals(100, rows);
|
||||
|
@ -235,7 +235,7 @@ public class TestBulkDeleteProtocol {
|
|||
int rows = 0;
|
||||
for (Result result : ht.getScanner(new Scan())) {
|
||||
assertTrue(result.getFamilyMap(FAMILY1).isEmpty());
|
||||
assertEquals(1, result.getColumn(FAMILY2, QUALIFIER2).size());
|
||||
assertEquals(1, result.getColumnCells(FAMILY2, QUALIFIER2).size());
|
||||
rows++;
|
||||
}
|
||||
assertEquals(100, rows);
|
||||
|
@ -273,15 +273,15 @@ public class TestBulkDeleteProtocol {
|
|||
scan.setMaxVersions();
|
||||
for (Result result : ht.getScanner(scan)) {
|
||||
assertEquals(3, result.getFamilyMap(FAMILY1).size());
|
||||
List<Cell> column = result.getColumn(FAMILY1, QUALIFIER1);
|
||||
List<Cell> column = result.getColumnCells(FAMILY1, QUALIFIER1);
|
||||
assertEquals(1, column.size());
|
||||
assertTrue(CellUtil.matchingValue(column.get(0), "v1".getBytes()));
|
||||
|
||||
column = result.getColumn(FAMILY1, QUALIFIER2);
|
||||
column = result.getColumnCells(FAMILY1, QUALIFIER2);
|
||||
assertEquals(1, column.size());
|
||||
assertTrue(CellUtil.matchingValue(column.get(0), "v1".getBytes()));
|
||||
|
||||
column = result.getColumn(FAMILY1, QUALIFIER3);
|
||||
column = result.getColumnCells(FAMILY1, QUALIFIER3);
|
||||
assertEquals(1, column.size());
|
||||
assertTrue(CellUtil.matchingValue(column.get(0), "v1".getBytes()));
|
||||
rows++;
|
||||
|
@ -325,9 +325,9 @@ public class TestBulkDeleteProtocol {
|
|||
scan.setMaxVersions();
|
||||
for (Result result : ht.getScanner(scan)) {
|
||||
assertEquals(3, result.getFamilyMap(FAMILY1).size());
|
||||
assertEquals(3, result.getColumn(FAMILY1, QUALIFIER1).size());
|
||||
assertEquals(3, result.getColumn(FAMILY1, QUALIFIER2).size());
|
||||
List<Cell> column = result.getColumn(FAMILY1, QUALIFIER3);
|
||||
assertEquals(3, result.getColumnCells(FAMILY1, QUALIFIER1).size());
|
||||
assertEquals(3, result.getColumnCells(FAMILY1, QUALIFIER2).size());
|
||||
List<Cell> column = result.getColumnCells(FAMILY1, QUALIFIER3);
|
||||
assertEquals(2, column.size());
|
||||
assertTrue(CellUtil.matchingValue(column.get(0), "v3".getBytes()));
|
||||
assertTrue(CellUtil.matchingValue(column.get(1), "v1".getBytes()));
|
||||
|
@ -407,15 +407,15 @@ public class TestBulkDeleteProtocol {
|
|||
scan1.setMaxVersions();
|
||||
for (Result res : ht.getScanner(scan1)) {
|
||||
assertEquals(3, res.getFamilyMap(FAMILY1).size());
|
||||
List<Cell> column = res.getColumn(FAMILY1, QUALIFIER1);
|
||||
List<Cell> column = res.getColumnCells(FAMILY1, QUALIFIER1);
|
||||
assertEquals(2, column.size());
|
||||
assertTrue(CellUtil.matchingValue(column.get(0), "v4".getBytes()));
|
||||
assertTrue(CellUtil.matchingValue(column.get(1), "v3".getBytes()));
|
||||
column = res.getColumn(FAMILY1, QUALIFIER2);
|
||||
column = res.getColumnCells(FAMILY1, QUALIFIER2);
|
||||
assertEquals(2, column.size());
|
||||
assertTrue(CellUtil.matchingValue(column.get(0), "v4".getBytes()));
|
||||
assertTrue(CellUtil.matchingValue(column.get(1), "v3".getBytes()));
|
||||
assertEquals(4, res.getColumn(FAMILY1, QUALIFIER3).size());
|
||||
assertEquals(4, res.getColumnCells(FAMILY1, QUALIFIER3).size());
|
||||
rows++;
|
||||
}
|
||||
assertEquals(100, rows);
|
||||
|
|
|
@ -470,7 +470,7 @@ public class IntegrationTestBulkLoad extends IntegrationTestBase {
|
|||
for (Map.Entry<byte[], byte[]> entry : value.getFamilyMap(CHAIN_FAM).entrySet()) {
|
||||
long chainId = Bytes.toLong(entry.getKey());
|
||||
long next = Bytes.toLong(entry.getValue());
|
||||
Cell c = value.getColumn(SORT_FAM, entry.getKey()).get(0);
|
||||
Cell c = value.getColumnCells(SORT_FAM, entry.getKey()).get(0);
|
||||
long order = Bytes.toLong(CellUtil.cloneValue(c));
|
||||
context.write(new LinkKey(chainId, order), new LinkChain(longRk, next));
|
||||
}
|
||||
|
|
|
@ -170,8 +170,8 @@ public class TableNamespaceManager {
|
|||
if (res.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
byte[] val = CellUtil.cloneValue(res.getColumnLatest(HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES,
|
||||
HTableDescriptor.NAMESPACE_COL_DESC_BYTES));
|
||||
byte[] val = CellUtil.cloneValue(res.getColumnLatestCell(
|
||||
HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES, HTableDescriptor.NAMESPACE_COL_DESC_BYTES));
|
||||
return
|
||||
ProtobufUtil.toNamespaceDescriptor(
|
||||
HBaseProtos.NamespaceDescriptor.parseFrom(val));
|
||||
|
@ -241,7 +241,8 @@ public class TableNamespaceManager {
|
|||
ResultScanner scanner = getNamespaceTable().getScanner(HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES);
|
||||
try {
|
||||
for(Result r : scanner) {
|
||||
byte[] val = CellUtil.cloneValue(r.getColumnLatest(HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES,
|
||||
byte[] val = CellUtil.cloneValue(r.getColumnLatestCell(
|
||||
HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES,
|
||||
HTableDescriptor.NAMESPACE_COL_DESC_BYTES));
|
||||
ret.add(ProtobufUtil.toNamespaceDescriptor(
|
||||
HBaseProtos.NamespaceDescriptor.parseFrom(val)));
|
||||
|
|
|
@ -1787,7 +1787,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
void delete(NavigableMap<byte[], List<Cell>> familyMap,
|
||||
Durability durability) throws IOException {
|
||||
Delete delete = new Delete(FOR_UNIT_TESTS_ONLY);
|
||||
delete.setFamilyMap(familyMap);
|
||||
delete.setFamilyCellMap(familyMap);
|
||||
delete.setDurability(durability);
|
||||
doBatchMutate(delete);
|
||||
}
|
||||
|
@ -2598,7 +2598,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
|
||||
familyMap.put(family, edits);
|
||||
Put p = new Put(row);
|
||||
p.setFamilyMap(familyMap);
|
||||
p.setFamilyCellMap(familyMap);
|
||||
doBatchMutate(p);
|
||||
}
|
||||
|
||||
|
@ -4372,7 +4372,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
}
|
||||
}
|
||||
List<Cell> results = get(get, true);
|
||||
return new Result(results);
|
||||
return Result.create(results);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4810,7 +4810,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
}
|
||||
|
||||
|
||||
return append.isReturnResults() ? new Result(allKVs) : null;
|
||||
return append.isReturnResults() ? Result.create(allKVs) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4955,7 +4955,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
requestFlush();
|
||||
}
|
||||
|
||||
return new Result(allKVs);
|
||||
return Result.create(allKVs);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -3136,7 +3136,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
|||
currentScanResultSize += KeyValueUtil.ensureKeyValue(kv).heapSize();
|
||||
}
|
||||
}
|
||||
results.add(new Result(values));
|
||||
results.add(Result.create(values));
|
||||
}
|
||||
if (!moreRows) {
|
||||
break;
|
||||
|
|
|
@ -176,7 +176,7 @@ public class RemoteHTable implements HTableInterface {
|
|||
kvs.add(new KeyValue(row.getKey(), column, qualifier,
|
||||
cell.getTimestamp(), cell.getValue()));
|
||||
}
|
||||
results.add(new Result(kvs));
|
||||
results.add(Result.create(kvs));
|
||||
}
|
||||
return results.toArray(new Result[results.size()]);
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ public class TestSerialization {
|
|||
* TODO
|
||||
@Test public void testResultEmpty() throws Exception {
|
||||
List<KeyValue> keys = new ArrayList<KeyValue>();
|
||||
Result r = new Result(keys);
|
||||
Result r = Result.newResult(keys);
|
||||
assertTrue(r.isEmpty());
|
||||
byte [] rb = Writables.getBytes(r);
|
||||
Result deserializedR = (Result)Writables.getWritable(rb, new Result());
|
||||
|
@ -367,7 +367,7 @@ public class TestSerialization {
|
|||
KeyValue kvA = new KeyValue(rowA, famA, qfA, valueA);
|
||||
KeyValue kvB = new KeyValue(rowB, famB, qfB, valueB);
|
||||
|
||||
Result result = new Result(new KeyValue[]{kvA, kvB});
|
||||
Result result = Result.newResult(new KeyValue[]{kvA, kvB});
|
||||
|
||||
byte [] rb = Writables.getBytes(result);
|
||||
Result deResult = (Result)Writables.getWritable(rb, new Result());
|
||||
|
@ -399,7 +399,7 @@ public class TestSerialization {
|
|||
KeyValue kvA = new KeyValue(rowA, famA, qfA, valueA);
|
||||
KeyValue kvB = new KeyValue(rowB, famB, qfB, valueB);
|
||||
|
||||
Result result = new Result(new KeyValue[]{kvA, kvB});
|
||||
Result result = Result.newResult(new KeyValue[]{kvA, kvB});
|
||||
|
||||
byte [] rb = Writables.getBytes(result);
|
||||
|
||||
|
@ -441,9 +441,9 @@ public class TestSerialization {
|
|||
KeyValue kvB = new KeyValue(rowB, famB, qfB, valueB);
|
||||
|
||||
|
||||
Result result1 = new Result(new KeyValue[]{kvA, kvB});
|
||||
Result result2 = new Result(new KeyValue[]{kvB});
|
||||
Result result3 = new Result(new KeyValue[]{kvB});
|
||||
Result result1 = Result.newResult(new KeyValue[]{kvA, kvB});
|
||||
Result result2 = Result.newResult(new KeyValue[]{kvB});
|
||||
Result result3 = Result.newResult(new KeyValue[]{kvB});
|
||||
|
||||
Result [] results = new Result [] {result1, result2, result3};
|
||||
|
||||
|
@ -477,7 +477,7 @@ public class TestSerialization {
|
|||
|
||||
@Test public void testResultArrayEmpty() throws Exception {
|
||||
List<KeyValue> keys = new ArrayList<KeyValue>();
|
||||
Result r = new Result(keys);
|
||||
Result r = Result.newResult(keys);
|
||||
Result [] results = new Result [] {r};
|
||||
|
||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||
|
|
|
@ -107,7 +107,7 @@ public class MetaMockingUtil {
|
|||
//important: sort the kvs so that binary search work
|
||||
Collections.sort(kvs, KeyValue.META_COMPARATOR);
|
||||
|
||||
return new Result(kvs);
|
||||
return Result.create(kvs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -99,26 +99,26 @@ public class TestMetaReaderEditorNoCluster {
|
|||
assertNull(HRegionInfo.getHRegionInfo(new Result()));
|
||||
|
||||
List<Cell> kvs = new ArrayList<Cell>();
|
||||
Result r = new Result(kvs);
|
||||
Result r = Result.create(kvs);
|
||||
assertNull(HRegionInfo.getHRegionInfo(r));
|
||||
|
||||
byte [] f = HConstants.CATALOG_FAMILY;
|
||||
// Make a key value that doesn't have the expected qualifier.
|
||||
kvs.add(new KeyValue(HConstants.EMPTY_BYTE_ARRAY, f,
|
||||
HConstants.SERVER_QUALIFIER, f));
|
||||
r = new Result(kvs);
|
||||
r = Result.create(kvs);
|
||||
assertNull(HRegionInfo.getHRegionInfo(r));
|
||||
// Make a key that does not have a regioninfo value.
|
||||
kvs.add(new KeyValue(HConstants.EMPTY_BYTE_ARRAY, f,
|
||||
HConstants.REGIONINFO_QUALIFIER, f));
|
||||
HRegionInfo hri = HRegionInfo.getHRegionInfo(new Result(kvs));
|
||||
HRegionInfo hri = HRegionInfo.getHRegionInfo(Result.create(kvs));
|
||||
assertTrue(hri == null);
|
||||
// OK, give it what it expects
|
||||
kvs.clear();
|
||||
kvs.add(new KeyValue(HConstants.EMPTY_BYTE_ARRAY, f,
|
||||
HConstants.REGIONINFO_QUALIFIER,
|
||||
HRegionInfo.FIRST_META_REGIONINFO.toByteArray()));
|
||||
hri = HRegionInfo.getHRegionInfo(new Result(kvs));
|
||||
hri = HRegionInfo.getHRegionInfo(Result.create(kvs));
|
||||
assertNotNull(hri);
|
||||
assertTrue(hri.equals(HRegionInfo.FIRST_META_REGIONINFO));
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class TestMetaReaderEditorNoCluster {
|
|||
HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
|
||||
Bytes.toBytes(sn.getStartcode())));
|
||||
final List<CellScannable> cellScannables = new ArrayList<CellScannable>(1);
|
||||
cellScannables.add(new Result(kvs));
|
||||
cellScannables.add(Result.create(kvs));
|
||||
final ScanResponse.Builder builder = ScanResponse.newBuilder();
|
||||
for (CellScannable result : cellScannables) {
|
||||
builder.addCellsPerResult(((Result)result).size());
|
||||
|
|
|
@ -96,7 +96,7 @@ public class TestIntraRowPagination {
|
|||
kvListScan.addAll(results);
|
||||
results.clear();
|
||||
}
|
||||
result = new Result(kvListScan);
|
||||
result = Result.create(kvListScan);
|
||||
TestScannersFromClientSide.verifyResult(result, kvListExp, toLog,
|
||||
"Testing scan with storeOffset and storeLimit");
|
||||
} finally {
|
||||
|
|
|
@ -138,7 +138,7 @@ public class TestPutDeleteEtcCellIteration {
|
|||
byte [] bytes = Bytes.toBytes(i);
|
||||
cells[i] = new KeyValue(ROW, bytes, bytes, TIMESTAMP, bytes);
|
||||
}
|
||||
Result r = new Result(Arrays.asList(cells));
|
||||
Result r = Result.create(Arrays.asList(cells));
|
||||
int index = 0;
|
||||
for (CellScanner cellScanner = r.cellScanner(); cellScanner.advance();) {
|
||||
Cell cell = cellScanner.current();
|
||||
|
|
|
@ -65,15 +65,15 @@ public class TestResult extends TestCase {
|
|||
|
||||
Arrays.sort(kvs, KeyValue.COMPARATOR);
|
||||
|
||||
Result r = new Result(kvs);
|
||||
Result r = Result.create(kvs);
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
final byte[] qf = Bytes.toBytes(i);
|
||||
|
||||
List<Cell> ks = r.getColumn(family, qf);
|
||||
List<Cell> ks = r.getColumnCells(family, qf);
|
||||
assertEquals(1, ks.size());
|
||||
assertTrue(CellUtil.matchingQualifier(ks.get(0), qf));
|
||||
assertEquals(ks.get(0), r.getColumnLatest(family, qf));
|
||||
assertEquals(ks.get(0), r.getColumnLatestCell(family, qf));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,15 +87,15 @@ public class TestResult extends TestCase {
|
|||
|
||||
Arrays.sort(kvs, KeyValue.COMPARATOR);
|
||||
|
||||
Result r = new Result(kvs);
|
||||
Result r = Result.create(kvs);
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
final byte[] qf = Bytes.toBytes(i);
|
||||
|
||||
List<Cell> ks = r.getColumn(family, qf);
|
||||
List<Cell> ks = r.getColumnCells(family, qf);
|
||||
assertEquals(2, ks.size());
|
||||
assertTrue(CellUtil.matchingQualifier(ks.get(0), qf));
|
||||
assertEquals(200, ks.get(0).getTimestamp());
|
||||
assertEquals(ks.get(0), r.getColumnLatest(family, qf));
|
||||
assertEquals(ks.get(0), r.getColumnLatestCell(family, qf));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class TestResult extends TestCase {
|
|||
|
||||
Arrays.sort(kvs, KeyValue.COMPARATOR);
|
||||
|
||||
Result r = new Result(kvs);
|
||||
Result r = Result.create(kvs);
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
final byte[] qf = Bytes.toBytes(i);
|
||||
|
@ -124,7 +124,7 @@ public class TestResult extends TestCase {
|
|||
|
||||
Arrays.sort(kvs, KeyValue.COMPARATOR);
|
||||
|
||||
Result r = new Result(kvs);
|
||||
Result r = Result.create(kvs);
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
final byte[] qf = Bytes.toBytes(i);
|
||||
|
||||
|
@ -138,7 +138,7 @@ public class TestResult extends TestCase {
|
|||
|
||||
Arrays.sort(kvs, KeyValue.COMPARATOR);
|
||||
|
||||
Result r = new Result(kvs);
|
||||
Result r = Result.create(kvs);
|
||||
ByteBuffer loadValueBuffer = ByteBuffer.allocate(1024);
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
|
@ -165,7 +165,7 @@ public class TestResult extends TestCase {
|
|||
|
||||
ByteBuffer loadValueBuffer = ByteBuffer.allocate(1024);
|
||||
|
||||
Result r = new Result(kvs);
|
||||
Result r = Result.create(kvs);
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
final byte[] qf = Bytes.toBytes(i);
|
||||
|
||||
|
@ -188,8 +188,8 @@ public class TestResult extends TestCase {
|
|||
KeyValue kv1 = new KeyValue(row, family, qual, value);
|
||||
KeyValue kv2 = new KeyValue(row, family, qual, value1);
|
||||
|
||||
Result r1 = new Result(new KeyValue[] {kv1});
|
||||
Result r2 = new Result(new KeyValue[] {kv2});
|
||||
Result r1 = Result.create(new KeyValue[] {kv1});
|
||||
Result r2 = Result.create(new KeyValue[] {kv2});
|
||||
// no exception thrown
|
||||
Result.compareResults(r1, r1);
|
||||
try {
|
||||
|
@ -226,7 +226,7 @@ public class TestResult extends TestCase {
|
|||
Bytes.toBytes(valueSB.toString()), 1, n);
|
||||
Arrays.sort(kvs, KeyValue.COMPARATOR);
|
||||
ByteBuffer loadValueBuffer = ByteBuffer.allocate(1024);
|
||||
Result r = new Result(kvs);
|
||||
Result r = Result.create(kvs);
|
||||
|
||||
byte[][] qfs = new byte[n][Bytes.SIZEOF_INT];
|
||||
for (int i = 0; i < n; ++i) {
|
||||
|
|
|
@ -324,7 +324,7 @@ public class TestScannersFromClientSide {
|
|||
kvListScan.add(kv);
|
||||
}
|
||||
}
|
||||
result = new Result(kvListScan);
|
||||
result = Result.create(kvListScan);
|
||||
verifyResult(result, kvListExp, toLog, "Testing scan with maxResults");
|
||||
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ public class TestChangingEncoding {
|
|||
Get get = new Get(getRowKey(batchId, i));
|
||||
Result result = table.get(get);
|
||||
for (int j = 0; j < NUM_COLS_PER_ROW; ++j) {
|
||||
Cell kv = result.getColumnLatest(CF_BYTES, getQualifier(j));
|
||||
Cell kv = result.getColumnLatestCell(CF_BYTES, getQualifier(j));
|
||||
assertTrue(CellUtil.matchingValue(kv, getValue(batchId, i, j)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ public class TestHRegion extends HBaseTestCase {
|
|||
Get get = new Get(row);
|
||||
Result result = region.get(get);
|
||||
for (long i = minSeqId; i <= maxSeqId; i += 10) {
|
||||
List<Cell> kvs = result.getColumn(family, Bytes.toBytes(i));
|
||||
List<Cell> kvs = result.getColumnCells(family, Bytes.toBytes(i));
|
||||
assertEquals(1, kvs.size());
|
||||
assertEquals(Bytes.toBytes(i), CellUtil.cloneValue(kvs.get(0)));
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ public class TestHRegion extends HBaseTestCase {
|
|||
Get get = new Get(row);
|
||||
Result result = region.get(get);
|
||||
for (long i = minSeqId; i <= maxSeqId; i += 10) {
|
||||
List<Cell> kvs = result.getColumn(family, Bytes.toBytes(i));
|
||||
List<Cell> kvs = result.getColumnCells(family, Bytes.toBytes(i));
|
||||
if (i < recoverSeqId) {
|
||||
assertEquals(0, kvs.size());
|
||||
} else {
|
||||
|
@ -3609,7 +3609,7 @@ public class TestHRegion extends HBaseTestCase {
|
|||
get.addColumn(Incrementer.family, Incrementer.qualifier);
|
||||
get.setMaxVersions(1);
|
||||
Result res = this.region.get(get);
|
||||
List<Cell> kvs = res.getColumn(Incrementer.family,
|
||||
List<Cell> kvs = res.getColumnCells(Incrementer.family,
|
||||
Incrementer.qualifier);
|
||||
|
||||
//we just got the latest version
|
||||
|
@ -3703,7 +3703,7 @@ public class TestHRegion extends HBaseTestCase {
|
|||
get.addColumn(Appender.family, Appender.qualifier);
|
||||
get.setMaxVersions(1);
|
||||
Result res = this.region.get(get);
|
||||
List<Cell> kvs = res.getColumn(Appender.family,
|
||||
List<Cell> kvs = res.getColumnCells(Appender.family,
|
||||
Appender.qualifier);
|
||||
|
||||
//we just got the latest version
|
||||
|
@ -3740,7 +3740,7 @@ public class TestHRegion extends HBaseTestCase {
|
|||
get.addColumn(family, qualifier);
|
||||
get.setMaxVersions();
|
||||
res = this.region.get(get);
|
||||
kvs = res.getColumn(family, qualifier);
|
||||
kvs = res.getColumnCells(family, qualifier);
|
||||
assertEquals(1, kvs.size());
|
||||
assertEquals(Bytes.toBytes("value0"), CellUtil.cloneValue(kvs.get(0)));
|
||||
|
||||
|
@ -3749,7 +3749,7 @@ public class TestHRegion extends HBaseTestCase {
|
|||
get.addColumn(family, qualifier);
|
||||
get.setMaxVersions();
|
||||
res = this.region.get(get);
|
||||
kvs = res.getColumn(family, qualifier);
|
||||
kvs = res.getColumnCells(family, qualifier);
|
||||
assertEquals(1, kvs.size());
|
||||
assertEquals(Bytes.toBytes("value0"), CellUtil.cloneValue(kvs.get(0)));
|
||||
|
||||
|
@ -3761,7 +3761,7 @@ public class TestHRegion extends HBaseTestCase {
|
|||
get.addColumn(family, qualifier);
|
||||
get.setMaxVersions();
|
||||
res = this.region.get(get);
|
||||
kvs = res.getColumn(family, qualifier);
|
||||
kvs = res.getColumnCells(family, qualifier);
|
||||
assertEquals(1, kvs.size());
|
||||
assertEquals(Bytes.toBytes("value1"), CellUtil.cloneValue(kvs.get(0)));
|
||||
|
||||
|
@ -3770,7 +3770,7 @@ public class TestHRegion extends HBaseTestCase {
|
|||
get.addColumn(family, qualifier);
|
||||
get.setMaxVersions();
|
||||
res = this.region.get(get);
|
||||
kvs = res.getColumn(family, qualifier);
|
||||
kvs = res.getColumnCells(family, qualifier);
|
||||
assertEquals(1, kvs.size());
|
||||
assertEquals(Bytes.toBytes("value1"), CellUtil.cloneValue(kvs.get(0)));
|
||||
}
|
||||
|
|
|
@ -832,7 +832,7 @@ public class TestKeepDeletes {
|
|||
|
||||
private void checkResult(Result r, byte[] fam, byte[] col, byte[] ... vals) {
|
||||
assertEquals(r.size(), vals.length);
|
||||
List<Cell> kvs = r.getColumn(fam, col);
|
||||
List<Cell> kvs = r.getColumnCells(fam, col);
|
||||
assertEquals(kvs.size(), vals.length);
|
||||
for (int i=0;i<vals.length;i++) {
|
||||
assertArrayEquals(CellUtil.cloneValue(kvs.get(i)), vals[i]);
|
||||
|
|
|
@ -461,7 +461,7 @@ public class TestMinVersions {
|
|||
|
||||
private void checkResult(Result r, byte[] col, byte[] ... vals) {
|
||||
assertEquals(r.size(), vals.length);
|
||||
List<Cell> kvs = r.getColumn(col, col);
|
||||
List<Cell> kvs = r.getColumnCells(col, col);
|
||||
assertEquals(kvs.size(), vals.length);
|
||||
for (int i=0;i<vals.length;i++) {
|
||||
assertTrue(CellUtil.matchingValue(kvs.get(i), vals[i]));
|
||||
|
|
|
@ -180,7 +180,7 @@ public class MultiThreadedUpdater extends MultiThreadedWriterBase {
|
|||
byte[] hashCodeBytes = Bytes.toBytes(hashCode);
|
||||
byte[] checkedValue = HConstants.EMPTY_BYTE_ARRAY;
|
||||
if (hashCode % 2 == 0) {
|
||||
Cell kv = result.getColumnLatest(cf, column);
|
||||
Cell kv = result.getColumnLatestCell(cf, column);
|
||||
checkedValue = kv != null ? CellUtil.cloneValue(kv) : null;
|
||||
Preconditions.checkNotNull(checkedValue,
|
||||
"Column value to be checked should not be null");
|
||||
|
|
|
@ -1281,9 +1281,9 @@ public class TestHBaseFsck {
|
|||
|
||||
Get get = new Get(hri.getRegionName());
|
||||
Result result = meta.get(get);
|
||||
assertTrue(result.getColumn(HConstants.CATALOG_FAMILY,
|
||||
assertTrue(result.getColumnCells(HConstants.CATALOG_FAMILY,
|
||||
HConstants.SPLITA_QUALIFIER).isEmpty());
|
||||
assertTrue(result.getColumn(HConstants.CATALOG_FAMILY,
|
||||
assertTrue(result.getColumnCells(HConstants.CATALOG_FAMILY,
|
||||
HConstants.SPLITB_QUALIFIER).isEmpty());
|
||||
TEST_UTIL.getHBaseAdmin().flush(TableName.META_TABLE_NAME.getName());
|
||||
|
||||
|
|
Loading…
Reference in New Issue