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:
Michael Stack 2008-10-24 17:03:24 +00:00
parent 8b6b089f45
commit 9b91e0bfe4
5 changed files with 989 additions and 117 deletions

View File

@ -61,6 +61,8 @@ Release 0.19.0 - Unreleased
(Clint Morgan via Stack) (Clint Morgan via Stack)
HBASE-943 to ColumnValueFilter: add filterIfColumnMissing property, add HBASE-943 to ColumnValueFilter: add filterIfColumnMissing property, add
SubString operator (Clint Morgan via Stack) SubString operator (Clint Morgan via Stack)
HBASE-937 Thrift getRow does not support specifying columns
(Doğacan Güney via Stack)
NEW FEATURES NEW FEATURES
HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters] HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters]

View File

@ -279,6 +279,18 @@ service Hbase {
TRowResult getRow(1:Text tableName, 2:Text row) TRowResult getRow(1:Text tableName, 2:Text row)
throws (1:IOError io) 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 * Get all the data for the specified table and row at the specified
* timestamp. * timestamp.
@ -291,6 +303,18 @@ service Hbase {
TRowResult getRowTs(1:Text tableName, 2:Text row, 3:i64 timestamp) TRowResult getRowTs(1:Text tableName, 2:Text row, 3:i64 timestamp)
throws (1:IOError io) 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 * Apply a series of mutations (updates/deletes) to a row in a
* single transaction. If an exception is thrown, then the * single transaction. If an exception is thrown, then the

View File

@ -300,18 +300,38 @@ public class ThriftServer {
public TRowResult getRow(byte[] tableName, byte[] row) public TRowResult getRow(byte[] tableName, byte[] row)
throws IOError { 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, public TRowResult getRowTs(byte[] tableName, byte[] row,
long timestamp) throws IOError { 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()) { if (LOG.isDebugEnabled()) {
LOG.debug("getRowTs: table=" + new String(tableName) + ", row=" LOG.debug("getRowTs: table=" + new String(tableName) + ", row="
+ new String(row) + ", ts=" + timestamp); + new String(row) + ", ts=" + timestamp);
} }
try { try {
HTable table = getTable(tableName); 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) { } catch (IOException e) {
throw new IOError(e.getMessage()); throw new IOError(e.getMessage());
} }

File diff suppressed because it is too large Load Diff

View File

@ -63,7 +63,7 @@ public class TestThriftServer extends HBaseClusterTestCase {
// Run all tests // Run all tests
doTestTableCreateDrop(); doTestTableCreateDrop();
doTestTableMutations(); doTestTableMutations();
doTestTableTimestamps(); doTestTableTimestampsAndColumns();
doTestTableScanners(); doTestTableScanners();
} }
@ -180,7 +180,7 @@ public class TestThriftServer extends HBaseClusterTestCase {
* *
* @throws Exception * @throws Exception
*/ */
public void doTestTableTimestamps() throws Exception { public void doTestTableTimestampsAndColumns() throws Exception {
// Setup // Setup
ThriftServer.HBaseHandler handler = new ThriftServer.HBaseHandler(); ThriftServer.HBaseHandler handler = new ThriftServer.HBaseHandler();
handler.createTable(tableAname, getColumnDescriptors()); handler.createTable(tableAname, getColumnDescriptors());
@ -207,6 +207,17 @@ public class TestThriftServer extends HBaseClusterTestCase {
assertTrue(Bytes.equals(rowResult2.columns.get(columnBname).value, valueCname)); assertTrue(Bytes.equals(rowResult2.columns.get(columnBname).value, valueCname));
assertFalse(rowResult2.columns.containsKey(columnAname)); 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 // Apply some timestamped deletes
handler.deleteAllTs(tableAname, rowAname, columnBname, time1); handler.deleteAllTs(tableAname, rowAname, columnBname, time1);
handler.deleteAllRowTs(tableAname, rowBname, time2); handler.deleteAllRowTs(tableAname, rowBname, time2);