HBASE-889 The current Thrift API does not allow a new scanner to be created without supplying a column list unlike the other APIs.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@771545 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-05-05 03:57:26 +00:00
parent 31cd01f656
commit 08de99e307
2 changed files with 48 additions and 12 deletions

View File

@ -193,6 +193,9 @@ Release 0.20.0 - Unreleased
(Evgeny Ryabitskiy via Stack)
HBASE-1112 we will lose data if the table name happens to be the logs' dir
name (Samuel Guo via Stack)
HBASE-889 The current Thrift API does not allow a new scanner to be
created without supplying a column list unlike the other APIs.
(Tim Sell via Stack)
Release 0.19.0 - 01/21/2009
INCOMPATIBLE CHANGES

View File

@ -80,6 +80,22 @@ public class ThriftServer {
protected int nextScannerId = 0;
protected HashMap<Integer, Scanner> scannerMap = null;
/**
* Returns a list of all the column families for a given htable.
*
* @param table
* @return
* @throws IOException
*/
byte[][] getAllColumns(HTable table) throws IOException {
HColumnDescriptor[] cds = table.getTableDescriptor().getColumnFamilies();
byte[][] columns = new byte[cds.length][];
for (int i = 0; i < cds.length; i++) {
columns[i] = cds[i].getNameWithColon();
}
return columns;
}
/**
* Creates and returns an HTable instance from a given table name.
*
@ -468,9 +484,13 @@ public class ThriftServer {
List<byte[]> columns) throws IOError {
try {
HTable table = getTable(tableName);
Scanner scanner = table.getScanner(columns.toArray(new byte[0][]),
startRow);
return addScanner(scanner);
byte[][] columnsArray = null;
if ((columns == null) || (columns.size() == 0)) {
columnsArray = getAllColumns(table);
} else {
columnsArray = columns.toArray(new byte[0][]);
}
return addScanner(table.getScanner(columnsArray, startRow));
} catch (IOException e) {
throw new IOError(e.getMessage());
}
@ -480,9 +500,13 @@ public class ThriftServer {
byte[] stopRow, List<byte[]> columns) throws IOError, TException {
try {
HTable table = getTable(tableName);
Scanner scanner = table.getScanner(columns.toArray(new byte[0][]),
startRow, stopRow);
return addScanner(scanner);
byte[][] columnsArray = null;
if ((columns == null) || (columns.size() == 0)) {
columnsArray = getAllColumns(table);
} else {
columnsArray = columns.toArray(new byte[0][]);
}
return addScanner(table.getScanner(columnsArray, startRow, stopRow));
} catch (IOException e) {
throw new IOError(e.getMessage());
}
@ -492,9 +516,13 @@ public class ThriftServer {
List<byte[]> columns, long timestamp) throws IOError, TException {
try {
HTable table = getTable(tableName);
Scanner scanner = table.getScanner(columns.toArray(new byte[0][]),
startRow, timestamp);
return addScanner(scanner);
byte[][] columnsArray = null;
if ((columns == null) || (columns.size() == 0)) {
columnsArray = getAllColumns(table);
} else {
columnsArray = columns.toArray(new byte[0][]);
}
return addScanner(table.getScanner(columnsArray, startRow, timestamp));
} catch (IOException e) {
throw new IOError(e.getMessage());
}
@ -505,9 +533,14 @@ public class ThriftServer {
throws IOError, TException {
try {
HTable table = getTable(tableName);
Scanner scanner = table.getScanner(columns.toArray(new byte[0][]),
startRow, stopRow, timestamp);
return addScanner(scanner);
byte[][] columnsArray = null;
if ((columns == null) || (columns.size() == 0)) {
columnsArray = getAllColumns(table);
} else {
columnsArray = columns.toArray(new byte[0][]);
}
return addScanner(table.getScanner(columnsArray, startRow, stopRow,
timestamp));
} catch (IOException e) {
throw new IOError(e.getMessage());
}