HBASE-937 Thrift getRow does not support specifying columns
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@707685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8b6b089f45
commit
9b91e0bfe4
|
@ -61,7 +61,9 @@ Release 0.19.0 - Unreleased
|
|||
(Clint Morgan via Stack)
|
||||
HBASE-943 to ColumnValueFilter: add filterIfColumnMissing property, add
|
||||
SubString operator (Clint Morgan via Stack)
|
||||
|
||||
HBASE-937 Thrift getRow does not support specifying columns
|
||||
(Doğacan Güney via Stack)
|
||||
|
||||
NEW FEATURES
|
||||
HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters]
|
||||
(Andrzej Bialecki via Stack)
|
||||
|
|
|
@ -279,6 +279,18 @@ service Hbase {
|
|||
TRowResult getRow(1:Text tableName, 2:Text row)
|
||||
throws (1:IOError io)
|
||||
|
||||
/**
|
||||
* Get the specified columns for the specified table and row at the latest
|
||||
* timestamp.
|
||||
*
|
||||
* @param tableName name of table
|
||||
* @param row row key
|
||||
* @param columns List of columns to return, null for all columns
|
||||
* @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist.
|
||||
*/
|
||||
TRowResult getRowWithColumns(1:Text tableName, 2:Text row, 3:list<Text> columns)
|
||||
throws (1:IOError io)
|
||||
|
||||
/**
|
||||
* Get all the data for the specified table and row at the specified
|
||||
* timestamp.
|
||||
|
@ -290,6 +302,18 @@ service Hbase {
|
|||
*/
|
||||
TRowResult getRowTs(1:Text tableName, 2:Text row, 3:i64 timestamp)
|
||||
throws (1:IOError io)
|
||||
|
||||
/**
|
||||
* Get the specified columns for the specified table and row at the specified
|
||||
* timestamp.
|
||||
*
|
||||
* @param tableName name of table
|
||||
* @param row row key
|
||||
* @param columns List of columns to return, null for all columns
|
||||
* @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist.
|
||||
*/
|
||||
TRowResult getRowWithColumnsTs(1:Text tableName, 2:Text row, 3:list<Text> columns, 4:i64 timestamp)
|
||||
throws (1:IOError io)
|
||||
|
||||
/**
|
||||
* Apply a series of mutations (updates/deletes) to a row in a
|
||||
|
|
|
@ -300,18 +300,38 @@ public class ThriftServer {
|
|||
|
||||
public TRowResult getRow(byte[] tableName, byte[] row)
|
||||
throws IOError {
|
||||
return getRowTs(tableName, row, HConstants.LATEST_TIMESTAMP);
|
||||
return getRowWithColumnsTs(tableName, row, null,
|
||||
HConstants.LATEST_TIMESTAMP);
|
||||
}
|
||||
|
||||
public TRowResult getRowWithColumns(byte[] tableName, byte[] row,
|
||||
List<byte[]> columns) throws IOError {
|
||||
return getRowWithColumnsTs(tableName, row, columns,
|
||||
HConstants.LATEST_TIMESTAMP);
|
||||
}
|
||||
|
||||
public TRowResult getRowTs(byte[] tableName, byte[] row,
|
||||
long timestamp) throws IOError {
|
||||
return getRowWithColumnsTs(tableName, row, null,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
public TRowResult getRowWithColumnsTs(byte[] tableName, byte[] row,
|
||||
List<byte[]> columns, long timestamp) throws IOError {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("getRowTs: table=" + new String(tableName) + ", row="
|
||||
+ new String(row) + ", ts=" + timestamp);
|
||||
}
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
return ThriftUtilities.rowResultFromHBase(table.getRow(getText(row), timestamp));
|
||||
if (columns == null) {
|
||||
return ThriftUtilities.rowResultFromHBase(table.getRow(getText(row),
|
||||
timestamp));
|
||||
} else {
|
||||
byte[][] columnArr = columns.toArray(new byte[columns.size()][]);
|
||||
return ThriftUtilities.rowResultFromHBase(table.getRow(getText(row),
|
||||
columnArr, timestamp));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IOError(e.getMessage());
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -63,7 +63,7 @@ public class TestThriftServer extends HBaseClusterTestCase {
|
|||
// Run all tests
|
||||
doTestTableCreateDrop();
|
||||
doTestTableMutations();
|
||||
doTestTableTimestamps();
|
||||
doTestTableTimestampsAndColumns();
|
||||
doTestTableScanners();
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class TestThriftServer extends HBaseClusterTestCase {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void doTestTableTimestamps() throws Exception {
|
||||
public void doTestTableTimestampsAndColumns() throws Exception {
|
||||
// Setup
|
||||
ThriftServer.HBaseHandler handler = new ThriftServer.HBaseHandler();
|
||||
handler.createTable(tableAname, getColumnDescriptors());
|
||||
|
@ -206,7 +206,18 @@ public class TestThriftServer extends HBaseClusterTestCase {
|
|||
assertTrue(Bytes.equals(rowResult1.columns.get(columnBname).value, valueBname));
|
||||
assertTrue(Bytes.equals(rowResult2.columns.get(columnBname).value, valueCname));
|
||||
assertFalse(rowResult2.columns.containsKey(columnAname));
|
||||
|
||||
List<byte[]> columns = new ArrayList<byte[]>();
|
||||
columns.add(columnBname);
|
||||
|
||||
rowResult1 = handler.getRowWithColumns(tableAname, rowAname, columns);
|
||||
assertTrue(Bytes.equals(rowResult1.columns.get(columnBname).value, valueCname));
|
||||
assertFalse(rowResult1.columns.containsKey(columnAname));
|
||||
|
||||
rowResult1 = handler.getRowWithColumnsTs(tableAname, rowAname, columns, time1);
|
||||
assertTrue(Bytes.equals(rowResult1.columns.get(columnBname).value, valueBname));
|
||||
assertFalse(rowResult1.columns.containsKey(columnAname));
|
||||
|
||||
// Apply some timestamped deletes
|
||||
handler.deleteAllTs(tableAname, rowAname, columnBname, time1);
|
||||
handler.deleteAllRowTs(tableAname, rowBname, time2);
|
||||
|
|
Loading…
Reference in New Issue