HBASE-4658 Put attributes are not exposed via the ThriftServer (Dhruba)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1240294 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bd390004fb
commit
a2887a9bb7
|
@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.regionserver;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -113,8 +114,8 @@ public class HRegionThriftServer extends Thread {
|
|||
public List<TRowResult> getRowWithColumnsTs(ByteBuffer tableName,
|
||||
ByteBuffer rowb,
|
||||
List<ByteBuffer> columns,
|
||||
long timestamp)
|
||||
throws IOError {
|
||||
long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
byte [] row = rowb.array();
|
||||
HTable table = getTable(tableName.array());
|
||||
|
@ -146,7 +147,8 @@ public class HRegionThriftServer extends Thread {
|
|||
throw new IOError(e.getMessage());
|
||||
}
|
||||
LOG.debug("ThriftServer redirecting getRowWithColumnsTs");
|
||||
return super.getRowWithColumnsTs(tableName, rowb, columns, timestamp);
|
||||
return super.getRowWithColumnsTs(tableName, rowb, columns, timestamp,
|
||||
attributes);
|
||||
} catch (IOException e) {
|
||||
throw new IOError(e.getMessage());
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
@ -53,6 +54,7 @@ import org.apache.hadoop.hbase.client.Delete;
|
|||
import org.apache.hadoop.hbase.client.Get;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.client.OperationWithAttributes;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
import org.apache.hadoop.hbase.client.ResultScanner;
|
||||
|
@ -581,22 +583,25 @@ public class ThriftServerRunner implements Runnable {
|
|||
@Deprecated
|
||||
@Override
|
||||
public List<TCell> get(
|
||||
ByteBuffer tableName, ByteBuffer row, ByteBuffer column)
|
||||
ByteBuffer tableName, ByteBuffer row, ByteBuffer column,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError {
|
||||
byte [][] famAndQf = KeyValue.parseColumn(getBytes(column));
|
||||
if(famAndQf.length == 1) {
|
||||
return get(tableName, row, famAndQf[0], new byte[0]);
|
||||
return get(tableName, row, famAndQf[0], new byte[0], attributes);
|
||||
}
|
||||
return get(tableName, row, famAndQf[0], famAndQf[1]);
|
||||
return get(tableName, row, famAndQf[0], famAndQf[1], attributes);
|
||||
}
|
||||
|
||||
protected List<TCell> get(ByteBuffer tableName,
|
||||
ByteBuffer row,
|
||||
byte[] family,
|
||||
byte[] qualifier) throws IOError {
|
||||
byte[] qualifier,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Get get = new Get(getBytes(row));
|
||||
addAttributes(get, attributes);
|
||||
if (qualifier == null || qualifier.length == 0) {
|
||||
get.addFamily(family);
|
||||
} else {
|
||||
|
@ -612,22 +617,25 @@ public class ThriftServerRunner implements Runnable {
|
|||
@Deprecated
|
||||
@Override
|
||||
public List<TCell> getVer(ByteBuffer tableName, ByteBuffer row,
|
||||
ByteBuffer column, int numVersions) throws IOError {
|
||||
ByteBuffer column, int numVersions,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
byte [][] famAndQf = KeyValue.parseColumn(getBytes(column));
|
||||
if(famAndQf.length == 1) {
|
||||
return getVer(tableName, row, famAndQf[0],
|
||||
new byte[0], numVersions);
|
||||
new byte[0], numVersions, attributes);
|
||||
}
|
||||
return getVer(tableName, row,
|
||||
famAndQf[0], famAndQf[1], numVersions);
|
||||
famAndQf[0], famAndQf[1], numVersions, attributes);
|
||||
}
|
||||
|
||||
public List<TCell> getVer(ByteBuffer tableName, ByteBuffer row,
|
||||
byte[] family,
|
||||
byte[] qualifier, int numVersions) throws IOError {
|
||||
byte[] qualifier, int numVersions,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Get get = new Get(getBytes(row));
|
||||
addAttributes(get, attributes);
|
||||
get.addColumn(family, qualifier);
|
||||
get.setMaxVersions(numVersions);
|
||||
Result result = table.get(get);
|
||||
|
@ -643,22 +651,25 @@ public class ThriftServerRunner implements Runnable {
|
|||
ByteBuffer row,
|
||||
ByteBuffer column,
|
||||
long timestamp,
|
||||
int numVersions) throws IOError {
|
||||
int numVersions,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
byte [][] famAndQf = KeyValue.parseColumn(getBytes(column));
|
||||
if(famAndQf.length == 1) {
|
||||
return getVerTs(tableName, row, famAndQf[0], new byte[0], timestamp,
|
||||
numVersions);
|
||||
numVersions, attributes);
|
||||
}
|
||||
return getVerTs(tableName, row, famAndQf[0], famAndQf[1], timestamp,
|
||||
numVersions);
|
||||
numVersions, attributes);
|
||||
}
|
||||
|
||||
protected List<TCell> getVerTs(ByteBuffer tableName,
|
||||
ByteBuffer row, byte [] family,
|
||||
byte [] qualifier, long timestamp, int numVersions) throws IOError {
|
||||
byte [] qualifier, long timestamp, int numVersions,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Get get = new Get(getBytes(row));
|
||||
addAttributes(get, attributes);
|
||||
get.addColumn(family, qualifier);
|
||||
get.setTimeRange(Long.MIN_VALUE, timestamp);
|
||||
get.setMaxVersions(numVersions);
|
||||
|
@ -670,40 +681,45 @@ public class ThriftServerRunner implements Runnable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TRowResult> getRow(ByteBuffer tableName, ByteBuffer row)
|
||||
throws IOError {
|
||||
public List<TRowResult> getRow(ByteBuffer tableName, ByteBuffer row,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
return getRowWithColumnsTs(tableName, row, null,
|
||||
HConstants.LATEST_TIMESTAMP);
|
||||
HConstants.LATEST_TIMESTAMP,
|
||||
attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TRowResult> getRowWithColumns(ByteBuffer tableName,
|
||||
ByteBuffer row,
|
||||
List<ByteBuffer> columns) throws IOError {
|
||||
List<ByteBuffer> columns,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
return getRowWithColumnsTs(tableName, row, columns,
|
||||
HConstants.LATEST_TIMESTAMP);
|
||||
HConstants.LATEST_TIMESTAMP,
|
||||
attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TRowResult> getRowTs(ByteBuffer tableName, ByteBuffer row,
|
||||
long timestamp) throws IOError {
|
||||
long timestamp, Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
return getRowWithColumnsTs(tableName, row, null,
|
||||
timestamp);
|
||||
timestamp, attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TRowResult> getRowWithColumnsTs(
|
||||
ByteBuffer tableName, ByteBuffer row, List<ByteBuffer> columns,
|
||||
long timestamp) throws IOError {
|
||||
long timestamp, Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
if (columns == null) {
|
||||
Get get = new Get(getBytes(row));
|
||||
addAttributes(get, attributes);
|
||||
get.setTimeRange(Long.MIN_VALUE, timestamp);
|
||||
Result result = table.get(get);
|
||||
return ThriftUtilities.rowResultFromHBase(result);
|
||||
}
|
||||
Get get = new Get(getBytes(row));
|
||||
addAttributes(get, attributes);
|
||||
for(ByteBuffer column : columns) {
|
||||
byte [][] famAndQf = KeyValue.parseColumn(getBytes(column));
|
||||
if (famAndQf.length == 1) {
|
||||
|
@ -722,37 +738,44 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
@Override
|
||||
public List<TRowResult> getRows(ByteBuffer tableName,
|
||||
List<ByteBuffer> rows)
|
||||
List<ByteBuffer> rows,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError {
|
||||
return getRowsWithColumnsTs(tableName, rows, null,
|
||||
HConstants.LATEST_TIMESTAMP);
|
||||
HConstants.LATEST_TIMESTAMP,
|
||||
attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TRowResult> getRowsWithColumns(ByteBuffer tableName,
|
||||
List<ByteBuffer> rows,
|
||||
List<ByteBuffer> columns) throws IOError {
|
||||
List<ByteBuffer> columns,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
return getRowsWithColumnsTs(tableName, rows, columns,
|
||||
HConstants.LATEST_TIMESTAMP);
|
||||
HConstants.LATEST_TIMESTAMP,
|
||||
attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TRowResult> getRowsTs(ByteBuffer tableName,
|
||||
List<ByteBuffer> rows,
|
||||
long timestamp) throws IOError {
|
||||
long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
return getRowsWithColumnsTs(tableName, rows, null,
|
||||
timestamp);
|
||||
timestamp, attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TRowResult> getRowsWithColumnsTs(ByteBuffer tableName,
|
||||
List<ByteBuffer> rows,
|
||||
List<ByteBuffer> columns, long timestamp) throws IOError {
|
||||
List<ByteBuffer> columns, long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
List<Get> gets = new ArrayList<Get>(rows.size());
|
||||
HTable table = getTable(tableName);
|
||||
for (ByteBuffer row : rows) {
|
||||
Get get = new Get(getBytes(row));
|
||||
addAttributes(get, attributes);
|
||||
if (columns != null) {
|
||||
|
||||
for(ByteBuffer column : columns) {
|
||||
|
@ -776,19 +799,22 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
@Override
|
||||
public void deleteAll(
|
||||
ByteBuffer tableName, ByteBuffer row, ByteBuffer column)
|
||||
ByteBuffer tableName, ByteBuffer row, ByteBuffer column,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError {
|
||||
deleteAllTs(tableName, row, column, HConstants.LATEST_TIMESTAMP);
|
||||
deleteAllTs(tableName, row, column, HConstants.LATEST_TIMESTAMP,
|
||||
attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllTs(ByteBuffer tableName,
|
||||
ByteBuffer row,
|
||||
ByteBuffer column,
|
||||
long timestamp) throws IOError {
|
||||
long timestamp, Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Delete delete = new Delete(getBytes(row));
|
||||
addAttributes(delete, attributes);
|
||||
byte [][] famAndQf = KeyValue.parseColumn(getBytes(column));
|
||||
if (famAndQf.length == 1) {
|
||||
delete.deleteFamily(famAndQf[0], timestamp);
|
||||
|
@ -804,16 +830,19 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
@Override
|
||||
public void deleteAllRow(
|
||||
ByteBuffer tableName, ByteBuffer row) throws IOError {
|
||||
deleteAllRowTs(tableName, row, HConstants.LATEST_TIMESTAMP);
|
||||
ByteBuffer tableName, ByteBuffer row,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
deleteAllRowTs(tableName, row, HConstants.LATEST_TIMESTAMP, attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllRowTs(
|
||||
ByteBuffer tableName, ByteBuffer row, long timestamp) throws IOError {
|
||||
ByteBuffer tableName, ByteBuffer row, long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Delete delete = new Delete(getBytes(row), timestamp, null);
|
||||
addAttributes(delete, attributes);
|
||||
table.delete(delete);
|
||||
} catch (IOException e) {
|
||||
throw new IOError(e.getMessage());
|
||||
|
@ -860,20 +889,25 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
@Override
|
||||
public void mutateRow(ByteBuffer tableName, ByteBuffer row,
|
||||
List<Mutation> mutations) throws IOError, IllegalArgument {
|
||||
mutateRowTs(tableName, row, mutations, HConstants.LATEST_TIMESTAMP);
|
||||
List<Mutation> mutations, Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError, IllegalArgument {
|
||||
mutateRowTs(tableName, row, mutations, HConstants.LATEST_TIMESTAMP,
|
||||
attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mutateRowTs(ByteBuffer tableName, ByteBuffer row,
|
||||
List<Mutation> mutations, long timestamp)
|
||||
List<Mutation> mutations, long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError, IllegalArgument {
|
||||
HTable table = null;
|
||||
try {
|
||||
table = getTable(tableName);
|
||||
Put put = new Put(getBytes(row), timestamp, null);
|
||||
addAttributes(put, attributes);
|
||||
|
||||
Delete delete = new Delete(getBytes(row));
|
||||
addAttributes(delete, attributes);
|
||||
|
||||
// I apologize for all this mess :)
|
||||
for (Mutation m : mutations) {
|
||||
|
@ -910,14 +944,16 @@ public class ThriftServerRunner implements Runnable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void mutateRows(ByteBuffer tableName, List<BatchMutation> rowBatches)
|
||||
public void mutateRows(ByteBuffer tableName, List<BatchMutation> rowBatches,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError, IllegalArgument, TException {
|
||||
mutateRowsTs(tableName, rowBatches, HConstants.LATEST_TIMESTAMP);
|
||||
mutateRowsTs(tableName, rowBatches, HConstants.LATEST_TIMESTAMP, attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mutateRowsTs(
|
||||
ByteBuffer tableName, List<BatchMutation> rowBatches, long timestamp)
|
||||
ByteBuffer tableName, List<BatchMutation> rowBatches, long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError, IllegalArgument, TException {
|
||||
List<Put> puts = new ArrayList<Put>();
|
||||
List<Delete> deletes = new ArrayList<Delete>();
|
||||
|
@ -926,7 +962,9 @@ public class ThriftServerRunner implements Runnable {
|
|||
byte[] row = getBytes(batch.row);
|
||||
List<Mutation> mutations = batch.mutations;
|
||||
Delete delete = new Delete(row);
|
||||
addAttributes(delete, attributes);
|
||||
Put put = new Put(row, timestamp, null);
|
||||
addAttributes(put, attributes);
|
||||
for (Mutation m : mutations) {
|
||||
byte[][] famAndQf = KeyValue.parseColumn(getBytes(m.column));
|
||||
if (m.isDelete) {
|
||||
|
@ -1033,11 +1071,13 @@ public class ThriftServerRunner implements Runnable {
|
|||
return scannerGetList(id,1);
|
||||
}
|
||||
|
||||
public int scannerOpenWithScan(ByteBuffer tableName, TScan tScan)
|
||||
public int scannerOpenWithScan(ByteBuffer tableName, TScan tScan,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Scan scan = new Scan();
|
||||
addAttributes(scan, attributes);
|
||||
if (tScan.isSetStartRow()) {
|
||||
scan.setStartRow(tScan.getStartRow());
|
||||
}
|
||||
|
@ -1073,10 +1113,12 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
@Override
|
||||
public int scannerOpen(ByteBuffer tableName, ByteBuffer startRow,
|
||||
List<ByteBuffer> columns) throws IOError {
|
||||
List<ByteBuffer> columns,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Scan scan = new Scan(getBytes(startRow));
|
||||
addAttributes(scan, attributes);
|
||||
if(columns != null && columns.size() != 0) {
|
||||
for(ByteBuffer column : columns) {
|
||||
byte [][] famQf = KeyValue.parseColumn(getBytes(column));
|
||||
|
@ -1095,11 +1137,13 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
@Override
|
||||
public int scannerOpenWithStop(ByteBuffer tableName, ByteBuffer startRow,
|
||||
ByteBuffer stopRow, List<ByteBuffer> columns)
|
||||
ByteBuffer stopRow, List<ByteBuffer> columns,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError, TException {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Scan scan = new Scan(getBytes(startRow), getBytes(stopRow));
|
||||
addAttributes(scan, attributes);
|
||||
if(columns != null && columns.size() != 0) {
|
||||
for(ByteBuffer column : columns) {
|
||||
byte [][] famQf = KeyValue.parseColumn(getBytes(column));
|
||||
|
@ -1119,11 +1163,13 @@ public class ThriftServerRunner implements Runnable {
|
|||
@Override
|
||||
public int scannerOpenWithPrefix(ByteBuffer tableName,
|
||||
ByteBuffer startAndPrefix,
|
||||
List<ByteBuffer> columns)
|
||||
List<ByteBuffer> columns,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError, TException {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Scan scan = new Scan(getBytes(startAndPrefix));
|
||||
addAttributes(scan, attributes);
|
||||
Filter f = new WhileMatchFilter(
|
||||
new PrefixFilter(getBytes(startAndPrefix)));
|
||||
scan.setFilter(f);
|
||||
|
@ -1145,10 +1191,12 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
@Override
|
||||
public int scannerOpenTs(ByteBuffer tableName, ByteBuffer startRow,
|
||||
List<ByteBuffer> columns, long timestamp) throws IOError, TException {
|
||||
List<ByteBuffer> columns, long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError, TException {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Scan scan = new Scan(getBytes(startRow));
|
||||
addAttributes(scan, attributes);
|
||||
scan.setTimeRange(Long.MIN_VALUE, timestamp);
|
||||
if (columns != null && columns.size() != 0) {
|
||||
for (ByteBuffer column : columns) {
|
||||
|
@ -1168,11 +1216,13 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
@Override
|
||||
public int scannerOpenWithStopTs(ByteBuffer tableName, ByteBuffer startRow,
|
||||
ByteBuffer stopRow, List<ByteBuffer> columns, long timestamp)
|
||||
ByteBuffer stopRow, List<ByteBuffer> columns, long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes)
|
||||
throws IOError, TException {
|
||||
try {
|
||||
HTable table = getTable(tableName);
|
||||
Scan scan = new Scan(getBytes(startRow), getBytes(stopRow));
|
||||
addAttributes(scan, attributes);
|
||||
scan.setTimeRange(Long.MIN_VALUE, timestamp);
|
||||
if (columns != null && columns.size() != 0) {
|
||||
for (ByteBuffer column : columns) {
|
||||
|
@ -1266,4 +1316,18 @@ public class ThriftServerRunner implements Runnable {
|
|||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds all the attributes into the Operation object
|
||||
*/
|
||||
private static void addAttributes(OperationWithAttributes op,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) {
|
||||
if (attributes == null || attributes.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<ByteBuffer, ByteBuffer> entry : attributes.entrySet()) {
|
||||
String name = Bytes.toStringBinary(entry.getKey());
|
||||
byte[] value = Bytes.toBytes(entry.getValue());
|
||||
op.setAttribute(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -266,7 +266,10 @@ service Hbase {
|
|||
2:Text row,
|
||||
|
||||
/** column name */
|
||||
3:Text column
|
||||
3:Text column,
|
||||
|
||||
/** Get attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -286,7 +289,10 @@ service Hbase {
|
|||
3:Text column,
|
||||
|
||||
/** number of versions to retrieve */
|
||||
4:i32 numVersions
|
||||
4:i32 numVersions,
|
||||
|
||||
/** Get attributes */
|
||||
5:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -310,7 +316,10 @@ service Hbase {
|
|||
4:i64 timestamp,
|
||||
|
||||
/** number of versions to retrieve */
|
||||
5:i32 numVersions
|
||||
5:i32 numVersions,
|
||||
|
||||
/** Get attributes */
|
||||
6:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -324,7 +333,10 @@ service Hbase {
|
|||
1:Text tableName,
|
||||
|
||||
/** row key */
|
||||
2:Text row
|
||||
2:Text row,
|
||||
|
||||
/** Get attributes */
|
||||
3:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -341,7 +353,10 @@ service Hbase {
|
|||
2:Text row,
|
||||
|
||||
/** List of columns to return, null for all columns */
|
||||
3:list<Text> columns
|
||||
3:list<Text> columns,
|
||||
|
||||
/** Get attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -358,7 +373,10 @@ service Hbase {
|
|||
2:Text row,
|
||||
|
||||
/** timestamp */
|
||||
3:i64 timestamp
|
||||
3:i64 timestamp,
|
||||
|
||||
/** Get attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -376,7 +394,10 @@ service Hbase {
|
|||
|
||||
/** List of columns to return, null for all columns */
|
||||
3:list<Text> columns,
|
||||
4:i64 timestamp
|
||||
4:i64 timestamp,
|
||||
|
||||
/** Get attributes */
|
||||
5:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -391,6 +412,9 @@ service Hbase {
|
|||
|
||||
/** row keys */
|
||||
2:list<Text> rows
|
||||
|
||||
/** Get attributes */
|
||||
3:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -404,10 +428,13 @@ service Hbase {
|
|||
1:Text tableName,
|
||||
|
||||
/** row keys */
|
||||
2:list<Text> rows
|
||||
2:list<Text> rows,
|
||||
|
||||
/** List of columns to return, null for all columns */
|
||||
3:list<Text> columns
|
||||
3:list<Text> columns,
|
||||
|
||||
/** Get attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -424,7 +451,10 @@ service Hbase {
|
|||
2:list<Text> rows
|
||||
|
||||
/** timestamp */
|
||||
3:i64 timestamp
|
||||
3:i64 timestamp,
|
||||
|
||||
/** Get attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -442,7 +472,10 @@ service Hbase {
|
|||
|
||||
/** List of columns to return, null for all columns */
|
||||
3:list<Text> columns,
|
||||
4:i64 timestamp
|
||||
4:i64 timestamp,
|
||||
|
||||
/** Get attributes */
|
||||
5:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -459,7 +492,10 @@ service Hbase {
|
|||
2:Text row,
|
||||
|
||||
/** list of mutation commands */
|
||||
3:list<Mutation> mutations
|
||||
3:list<Mutation> mutations,
|
||||
|
||||
/** Mutation attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io, 2:IllegalArgument ia)
|
||||
|
||||
/**
|
||||
|
@ -479,7 +515,10 @@ service Hbase {
|
|||
3:list<Mutation> mutations,
|
||||
|
||||
/** timestamp */
|
||||
4:i64 timestamp
|
||||
4:i64 timestamp,
|
||||
|
||||
/** Mutation attributes */
|
||||
5:map<Text, Text> attributes
|
||||
) throws (1:IOError io, 2:IllegalArgument ia)
|
||||
|
||||
/**
|
||||
|
@ -493,7 +532,10 @@ service Hbase {
|
|||
1:Text tableName,
|
||||
|
||||
/** list of row batches */
|
||||
2:list<BatchMutation> rowBatches
|
||||
2:list<BatchMutation> rowBatches,
|
||||
|
||||
/** Mutation attributes */
|
||||
3:map<Text, Text> attributes
|
||||
) throws (1:IOError io, 2:IllegalArgument ia)
|
||||
|
||||
/**
|
||||
|
@ -510,7 +552,10 @@ service Hbase {
|
|||
2:list<BatchMutation> rowBatches,
|
||||
|
||||
/** timestamp */
|
||||
3:i64 timestamp
|
||||
3:i64 timestamp,
|
||||
|
||||
/** Mutation attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io, 2:IllegalArgument ia)
|
||||
|
||||
/**
|
||||
|
@ -541,7 +586,10 @@ service Hbase {
|
|||
2:Text row,
|
||||
|
||||
/** name of column whose value is to be deleted */
|
||||
3:Text column
|
||||
3:Text column,
|
||||
|
||||
/** Delete attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -559,7 +607,10 @@ service Hbase {
|
|||
3:Text column,
|
||||
|
||||
/** timestamp */
|
||||
4:i64 timestamp
|
||||
4:i64 timestamp,
|
||||
|
||||
/** Delete attributes */
|
||||
5:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -570,7 +621,10 @@ service Hbase {
|
|||
1:Text tableName,
|
||||
|
||||
/** key of the row to be completely deleted. */
|
||||
2:Text row
|
||||
2:Text row,
|
||||
|
||||
/** Delete attributes */
|
||||
3:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -585,7 +639,10 @@ service Hbase {
|
|||
2:Text row,
|
||||
|
||||
/** timestamp */
|
||||
3:i64 timestamp
|
||||
3:i64 timestamp,
|
||||
|
||||
/** Delete attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -597,7 +654,10 @@ service Hbase {
|
|||
1:Text tableName,
|
||||
|
||||
/** Scan instance */
|
||||
2:TScan scan
|
||||
2:TScan scan,
|
||||
|
||||
/** Scan attributes */
|
||||
3:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -621,7 +681,10 @@ service Hbase {
|
|||
* columns of the specified column family are returned. It's also possible
|
||||
* to pass a regex in the column qualifier.
|
||||
*/
|
||||
3:list<Text> columns
|
||||
3:list<Text> columns,
|
||||
|
||||
/** Scan attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -652,7 +715,10 @@ service Hbase {
|
|||
* columns of the specified column family are returned. It's also possible
|
||||
* to pass a regex in the column qualifier.
|
||||
*/
|
||||
4:list<Text> columns
|
||||
4:list<Text> columns,
|
||||
|
||||
/** Scan attributes */
|
||||
5:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -669,7 +735,10 @@ service Hbase {
|
|||
2:Text startAndPrefix,
|
||||
|
||||
/** the columns you want returned */
|
||||
3:list<Text> columns
|
||||
3:list<Text> columns,
|
||||
|
||||
/** Scan attributes */
|
||||
4:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -697,7 +766,10 @@ service Hbase {
|
|||
3:list<Text> columns,
|
||||
|
||||
/** timestamp */
|
||||
4:i64 timestamp
|
||||
4:i64 timestamp,
|
||||
|
||||
/** Scan attributes */
|
||||
5:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
@ -732,7 +804,10 @@ service Hbase {
|
|||
4:list<Text> columns,
|
||||
|
||||
/** timestamp */
|
||||
5:i64 timestamp
|
||||
5:i64 timestamp,
|
||||
|
||||
/** Scan attributes */
|
||||
6:map<Text, Text> attributes
|
||||
) throws (1:IOError io)
|
||||
|
||||
/**
|
||||
|
|
|
@ -203,12 +203,12 @@ public class TestThriftServer {
|
|||
// Apply a few Mutations to rowA
|
||||
// mutations.add(new Mutation(false, columnAname, valueAname));
|
||||
// mutations.add(new Mutation(false, columnBname, valueBname));
|
||||
handler.mutateRow(tableAname, rowAname, getMutations());
|
||||
handler.mutateRow(tableAname, rowAname, getMutations(), null);
|
||||
|
||||
// Assert that the changes were made
|
||||
assertEquals(valueAname,
|
||||
handler.get(tableAname, rowAname, columnAname).get(0).value);
|
||||
TRowResult rowResult1 = handler.getRow(tableAname, rowAname).get(0);
|
||||
handler.get(tableAname, rowAname, columnAname, null).get(0).value);
|
||||
TRowResult rowResult1 = handler.getRow(tableAname, rowAname, null).get(0);
|
||||
assertEquals(rowAname, rowResult1.row);
|
||||
assertEquals(valueBname,
|
||||
rowResult1.columns.get(columnBname).value);
|
||||
|
@ -221,37 +221,37 @@ public class TestThriftServer {
|
|||
// rowBmutations.add(new Mutation(false, columnAname, valueCname));
|
||||
// rowBmutations.add(new Mutation(false, columnBname, valueDname));
|
||||
// batchMutations.add(new BatchMutation(rowBname, rowBmutations));
|
||||
handler.mutateRows(tableAname, getBatchMutations());
|
||||
handler.mutateRows(tableAname, getBatchMutations(), null);
|
||||
|
||||
// Assert that changes were made to rowA
|
||||
List<TCell> cells = handler.get(tableAname, rowAname, columnAname);
|
||||
List<TCell> cells = handler.get(tableAname, rowAname, columnAname, null);
|
||||
assertFalse(cells.size() > 0);
|
||||
assertEquals(valueCname, handler.get(tableAname, rowAname, columnBname).get(0).value);
|
||||
List<TCell> versions = handler.getVer(tableAname, rowAname, columnBname, MAXVERSIONS);
|
||||
assertEquals(valueCname, handler.get(tableAname, rowAname, columnBname, null).get(0).value);
|
||||
List<TCell> versions = handler.getVer(tableAname, rowAname, columnBname, MAXVERSIONS, null);
|
||||
assertEquals(valueCname, versions.get(0).value);
|
||||
assertEquals(valueBname, versions.get(1).value);
|
||||
|
||||
// Assert that changes were made to rowB
|
||||
TRowResult rowResult2 = handler.getRow(tableAname, rowBname).get(0);
|
||||
TRowResult rowResult2 = handler.getRow(tableAname, rowBname, null).get(0);
|
||||
assertEquals(rowBname, rowResult2.row);
|
||||
assertEquals(valueCname, rowResult2.columns.get(columnAname).value);
|
||||
assertEquals(valueDname, rowResult2.columns.get(columnBname).value);
|
||||
|
||||
// Apply some deletes
|
||||
handler.deleteAll(tableAname, rowAname, columnBname);
|
||||
handler.deleteAllRow(tableAname, rowBname);
|
||||
handler.deleteAll(tableAname, rowAname, columnBname, null);
|
||||
handler.deleteAllRow(tableAname, rowBname, null);
|
||||
|
||||
// Assert that the deletes were applied
|
||||
int size = handler.get(tableAname, rowAname, columnBname).size();
|
||||
int size = handler.get(tableAname, rowAname, columnBname, null).size();
|
||||
assertEquals(0, size);
|
||||
size = handler.getRow(tableAname, rowBname).size();
|
||||
size = handler.getRow(tableAname, rowBname, null).size();
|
||||
assertEquals(0, size);
|
||||
|
||||
// Try null mutation
|
||||
List<Mutation> mutations = new ArrayList<Mutation>();
|
||||
mutations.add(new Mutation(false, columnAname, null, true));
|
||||
handler.mutateRow(tableAname, rowAname, mutations);
|
||||
TRowResult rowResult3 = handler.getRow(tableAname, rowAname).get(0);
|
||||
handler.mutateRow(tableAname, rowAname, mutations, null);
|
||||
TRowResult rowResult3 = handler.getRow(tableAname, rowAname, null).get(0);
|
||||
assertEquals(rowAname, rowResult3.row);
|
||||
assertEquals(0, rowResult3.columns.get(columnAname).value.array().length);
|
||||
|
||||
|
@ -275,16 +275,16 @@ public class TestThriftServer {
|
|||
|
||||
// Apply timestamped Mutations to rowA
|
||||
long time1 = System.currentTimeMillis();
|
||||
handler.mutateRowTs(tableAname, rowAname, getMutations(), time1);
|
||||
handler.mutateRowTs(tableAname, rowAname, getMutations(), time1, null);
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
// Apply timestamped BatchMutations for rowA and rowB
|
||||
long time2 = System.currentTimeMillis();
|
||||
handler.mutateRowsTs(tableAname, getBatchMutations(), time2);
|
||||
handler.mutateRowsTs(tableAname, getBatchMutations(), time2, null);
|
||||
|
||||
// Apply an overlapping timestamped mutation to rowB
|
||||
handler.mutateRowTs(tableAname, rowBname, getMutations(), time2);
|
||||
handler.mutateRowTs(tableAname, rowBname, getMutations(), time2, null);
|
||||
|
||||
// the getVerTs is [inf, ts) so you need to increment one.
|
||||
time1 += 1;
|
||||
|
@ -292,12 +292,12 @@ public class TestThriftServer {
|
|||
|
||||
// Assert that the timestamp-related methods retrieve the correct data
|
||||
assertEquals(2, handler.getVerTs(tableAname, rowAname, columnBname, time2,
|
||||
MAXVERSIONS).size());
|
||||
MAXVERSIONS, null).size());
|
||||
assertEquals(1, handler.getVerTs(tableAname, rowAname, columnBname, time1,
|
||||
MAXVERSIONS).size());
|
||||
MAXVERSIONS, null).size());
|
||||
|
||||
TRowResult rowResult1 = handler.getRowTs(tableAname, rowAname, time1).get(0);
|
||||
TRowResult rowResult2 = handler.getRowTs(tableAname, rowAname, time2).get(0);
|
||||
TRowResult rowResult1 = handler.getRowTs(tableAname, rowAname, time1, null).get(0);
|
||||
TRowResult rowResult2 = handler.getRowTs(tableAname, rowAname, time2, null).get(0);
|
||||
// columnA was completely deleted
|
||||
//assertTrue(Bytes.equals(rowResult1.columns.get(columnAname).value, valueAname));
|
||||
assertEquals(rowResult1.columns.get(columnBname).value, valueBname);
|
||||
|
@ -309,31 +309,31 @@ public class TestThriftServer {
|
|||
List<ByteBuffer> columns = new ArrayList<ByteBuffer>();
|
||||
columns.add(columnBname);
|
||||
|
||||
rowResult1 = handler.getRowWithColumns(tableAname, rowAname, columns).get(0);
|
||||
rowResult1 = handler.getRowWithColumns(tableAname, rowAname, columns, null).get(0);
|
||||
assertEquals(rowResult1.columns.get(columnBname).value, valueCname);
|
||||
assertFalse(rowResult1.columns.containsKey(columnAname));
|
||||
|
||||
rowResult1 = handler.getRowWithColumnsTs(tableAname, rowAname, columns, time1).get(0);
|
||||
rowResult1 = handler.getRowWithColumnsTs(tableAname, rowAname, columns, time1, null).get(0);
|
||||
assertEquals(rowResult1.columns.get(columnBname).value, valueBname);
|
||||
assertFalse(rowResult1.columns.containsKey(columnAname));
|
||||
|
||||
// Apply some timestamped deletes
|
||||
// this actually deletes _everything_.
|
||||
// nukes everything in columnB: forever.
|
||||
handler.deleteAllTs(tableAname, rowAname, columnBname, time1);
|
||||
handler.deleteAllRowTs(tableAname, rowBname, time2);
|
||||
handler.deleteAllTs(tableAname, rowAname, columnBname, time1, null);
|
||||
handler.deleteAllRowTs(tableAname, rowBname, time2, null);
|
||||
|
||||
// Assert that the timestamp-related methods retrieve the correct data
|
||||
int size = handler.getVerTs(tableAname, rowAname, columnBname, time1, MAXVERSIONS).size();
|
||||
int size = handler.getVerTs(tableAname, rowAname, columnBname, time1, MAXVERSIONS, null).size();
|
||||
assertEquals(0, size);
|
||||
|
||||
size = handler.getVerTs(tableAname, rowAname, columnBname, time2, MAXVERSIONS).size();
|
||||
size = handler.getVerTs(tableAname, rowAname, columnBname, time2, MAXVERSIONS, null).size();
|
||||
assertEquals(1, size);
|
||||
|
||||
// should be available....
|
||||
assertEquals(handler.get(tableAname, rowAname, columnBname).get(0).value, valueCname);
|
||||
assertEquals(handler.get(tableAname, rowAname, columnBname, null).get(0).value, valueCname);
|
||||
|
||||
assertEquals(0, handler.getRow(tableAname, rowBname).size());
|
||||
assertEquals(0, handler.getRow(tableAname, rowBname, null).size());
|
||||
|
||||
// Teardown
|
||||
handler.disableTable(tableAname);
|
||||
|
@ -354,7 +354,7 @@ public class TestThriftServer {
|
|||
|
||||
// Apply timestamped Mutations to rowA
|
||||
long time1 = System.currentTimeMillis();
|
||||
handler.mutateRowTs(tableAname, rowAname, getMutations(), time1);
|
||||
handler.mutateRowTs(tableAname, rowAname, getMutations(), time1, null);
|
||||
|
||||
// Sleep to assure that 'time1' and 'time2' will be different even with a
|
||||
// coarse grained system timer.
|
||||
|
@ -362,12 +362,12 @@ public class TestThriftServer {
|
|||
|
||||
// Apply timestamped BatchMutations for rowA and rowB
|
||||
long time2 = System.currentTimeMillis();
|
||||
handler.mutateRowsTs(tableAname, getBatchMutations(), time2);
|
||||
handler.mutateRowsTs(tableAname, getBatchMutations(), time2, null);
|
||||
|
||||
time1 += 1;
|
||||
|
||||
// Test a scanner on all rows and all columns, no timestamp
|
||||
int scanner1 = handler.scannerOpen(tableAname, rowAname, getColumnList(true, true));
|
||||
int scanner1 = handler.scannerOpen(tableAname, rowAname, getColumnList(true, true), null);
|
||||
TRowResult rowResult1a = handler.scannerGet(scanner1).get(0);
|
||||
assertEquals(rowResult1a.row, rowAname);
|
||||
// This used to be '1'. I don't know why when we are asking for two columns
|
||||
|
@ -384,7 +384,7 @@ public class TestThriftServer {
|
|||
closeScanner(scanner1, handler);
|
||||
|
||||
// Test a scanner on all rows and all columns, with timestamp
|
||||
int scanner2 = handler.scannerOpenTs(tableAname, rowAname, getColumnList(true, true), time1);
|
||||
int scanner2 = handler.scannerOpenTs(tableAname, rowAname, getColumnList(true, true), time1, null);
|
||||
TRowResult rowResult2a = handler.scannerGet(scanner2).get(0);
|
||||
assertEquals(rowResult2a.columns.size(), 1);
|
||||
// column A deleted, does not exist.
|
||||
|
@ -394,12 +394,12 @@ public class TestThriftServer {
|
|||
|
||||
// Test a scanner on the first row and first column only, no timestamp
|
||||
int scanner3 = handler.scannerOpenWithStop(tableAname, rowAname, rowBname,
|
||||
getColumnList(true, false));
|
||||
getColumnList(true, false), null);
|
||||
closeScanner(scanner3, handler);
|
||||
|
||||
// Test a scanner on the first row and second column only, with timestamp
|
||||
int scanner4 = handler.scannerOpenWithStopTs(tableAname, rowAname, rowBname,
|
||||
getColumnList(false, true), time1);
|
||||
getColumnList(false, true), time1, null);
|
||||
TRowResult rowResult4a = handler.scannerGet(scanner4).get(0);
|
||||
assertEquals(rowResult4a.columns.size(), 1);
|
||||
assertEquals(rowResult4a.columns.get(columnBname).value, valueBname);
|
||||
|
|
Loading…
Reference in New Issue