HBASE-17737 Thrift2 proxy should support scan timeRange per column family
-- .../hadoop/hbase/thrift2/ThriftUtilities.java | 11 + .../hadoop/hbase/thrift2/generated/TScan.java | 234 ++++++++++++++++++--- .../org/apache/hadoop/hbase/thrift2/hbase.thrift | 3 +- .../thrift2/TestThriftHBaseServiceHandler.java | 63 ++++++ 4 files changed, 279 insertions(+), 32 deletions(-) Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
58c76192bd
commit
e239e8d2d3
|
@ -26,6 +26,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HRegionLocation;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
|
@ -434,6 +435,16 @@ public class ThriftUtilities {
|
|||
out.setCacheBlocks(in.isCacheBlocks());
|
||||
}
|
||||
|
||||
if (in.isSetColFamTimeRangeMap()) {
|
||||
Map<ByteBuffer, TTimeRange> colFamTimeRangeMap = in.getColFamTimeRangeMap();
|
||||
if (MapUtils.isNotEmpty(colFamTimeRangeMap)) {
|
||||
for (Map.Entry<ByteBuffer, TTimeRange> entry : colFamTimeRangeMap.entrySet()) {
|
||||
out.setColumnFamilyTimeRange(Bytes.toBytes(entry.getKey()),
|
||||
entry.getValue().getMinStamp(), entry.getValue().getMaxStamp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
|
||||
/**
|
||||
* Any timestamps in the columns are ignored, use timeRange to select by timestamp.
|
||||
* Any timestamps in the columns are ignored but the colFamTimeRangeMap included, use timeRange to select by timestamp.
|
||||
* Max versions defaults to 1.
|
||||
*/
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-05-25")
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-03-06")
|
||||
public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, java.io.Serializable, Cloneable, Comparable<TScan> {
|
||||
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TScan");
|
||||
|
||||
|
@ -54,6 +54,7 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
private static final org.apache.thrift.protocol.TField AUTHORIZATIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("authorizations", org.apache.thrift.protocol.TType.STRUCT, (short)10);
|
||||
private static final org.apache.thrift.protocol.TField REVERSED_FIELD_DESC = new org.apache.thrift.protocol.TField("reversed", org.apache.thrift.protocol.TType.BOOL, (short)11);
|
||||
private static final org.apache.thrift.protocol.TField CACHE_BLOCKS_FIELD_DESC = new org.apache.thrift.protocol.TField("cacheBlocks", org.apache.thrift.protocol.TType.BOOL, (short)12);
|
||||
private static final org.apache.thrift.protocol.TField COL_FAM_TIME_RANGE_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("colFamTimeRangeMap", org.apache.thrift.protocol.TType.MAP, (short)13);
|
||||
|
||||
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
|
||||
static {
|
||||
|
@ -73,6 +74,7 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
public TAuthorization authorizations; // optional
|
||||
public boolean reversed; // optional
|
||||
public boolean cacheBlocks; // optional
|
||||
public Map<ByteBuffer,TTimeRange> colFamTimeRangeMap; // optional
|
||||
|
||||
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
|
||||
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
|
||||
|
@ -87,7 +89,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
ATTRIBUTES((short)9, "attributes"),
|
||||
AUTHORIZATIONS((short)10, "authorizations"),
|
||||
REVERSED((short)11, "reversed"),
|
||||
CACHE_BLOCKS((short)12, "cacheBlocks");
|
||||
CACHE_BLOCKS((short)12, "cacheBlocks"),
|
||||
COL_FAM_TIME_RANGE_MAP((short)13, "colFamTimeRangeMap");
|
||||
|
||||
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
|
||||
|
||||
|
@ -126,6 +129,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
return REVERSED;
|
||||
case 12: // CACHE_BLOCKS
|
||||
return CACHE_BLOCKS;
|
||||
case 13: // COL_FAM_TIME_RANGE_MAP
|
||||
return COL_FAM_TIME_RANGE_MAP;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -172,7 +177,7 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
private static final int __REVERSED_ISSET_ID = 3;
|
||||
private static final int __CACHEBLOCKS_ISSET_ID = 4;
|
||||
private byte __isset_bitfield = 0;
|
||||
private static final _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.COLUMNS,_Fields.CACHING,_Fields.MAX_VERSIONS,_Fields.TIME_RANGE,_Fields.FILTER_STRING,_Fields.BATCH_SIZE,_Fields.ATTRIBUTES,_Fields.AUTHORIZATIONS,_Fields.REVERSED,_Fields.CACHE_BLOCKS};
|
||||
private static final _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.COLUMNS,_Fields.CACHING,_Fields.MAX_VERSIONS,_Fields.TIME_RANGE,_Fields.FILTER_STRING,_Fields.BATCH_SIZE,_Fields.ATTRIBUTES,_Fields.AUTHORIZATIONS,_Fields.REVERSED,_Fields.CACHE_BLOCKS,_Fields.COL_FAM_TIME_RANGE_MAP};
|
||||
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
|
||||
static {
|
||||
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
|
||||
|
@ -203,6 +208,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
|
||||
tmpMap.put(_Fields.CACHE_BLOCKS, new org.apache.thrift.meta_data.FieldMetaData("cacheBlocks", org.apache.thrift.TFieldRequirementType.OPTIONAL,
|
||||
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
|
||||
tmpMap.put(_Fields.COL_FAM_TIME_RANGE_MAP, new org.apache.thrift.meta_data.FieldMetaData("colFamTimeRangeMap", org.apache.thrift.TFieldRequirementType.OPTIONAL,
|
||||
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
|
||||
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true),
|
||||
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TTimeRange.class))));
|
||||
metaDataMap = Collections.unmodifiableMap(tmpMap);
|
||||
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TScan.class, metaDataMap);
|
||||
}
|
||||
|
@ -248,6 +257,21 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
this.reversed = other.reversed;
|
||||
this.cacheBlocks = other.cacheBlocks;
|
||||
if (other.isSetColFamTimeRangeMap()) {
|
||||
Map<ByteBuffer,TTimeRange> __this__colFamTimeRangeMap = new HashMap<ByteBuffer,TTimeRange>(other.colFamTimeRangeMap.size());
|
||||
for (Map.Entry<ByteBuffer, TTimeRange> other_element : other.colFamTimeRangeMap.entrySet()) {
|
||||
|
||||
ByteBuffer other_element_key = other_element.getKey();
|
||||
TTimeRange other_element_value = other_element.getValue();
|
||||
|
||||
ByteBuffer __this__colFamTimeRangeMap_copy_key = org.apache.thrift.TBaseHelper.copyBinary(other_element_key);
|
||||
|
||||
TTimeRange __this__colFamTimeRangeMap_copy_value = new TTimeRange(other_element_value);
|
||||
|
||||
__this__colFamTimeRangeMap.put(__this__colFamTimeRangeMap_copy_key, __this__colFamTimeRangeMap_copy_value);
|
||||
}
|
||||
this.colFamTimeRangeMap = __this__colFamTimeRangeMap;
|
||||
}
|
||||
}
|
||||
|
||||
public TScan deepCopy() {
|
||||
|
@ -273,6 +297,7 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
this.reversed = false;
|
||||
setCacheBlocksIsSet(false);
|
||||
this.cacheBlocks = false;
|
||||
this.colFamTimeRangeMap = null;
|
||||
}
|
||||
|
||||
public byte[] getStartRow() {
|
||||
|
@ -614,6 +639,41 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CACHEBLOCKS_ISSET_ID, value);
|
||||
}
|
||||
|
||||
public int getColFamTimeRangeMapSize() {
|
||||
return (this.colFamTimeRangeMap == null) ? 0 : this.colFamTimeRangeMap.size();
|
||||
}
|
||||
|
||||
public void putToColFamTimeRangeMap(ByteBuffer key, TTimeRange val) {
|
||||
if (this.colFamTimeRangeMap == null) {
|
||||
this.colFamTimeRangeMap = new HashMap<ByteBuffer,TTimeRange>();
|
||||
}
|
||||
this.colFamTimeRangeMap.put(key, val);
|
||||
}
|
||||
|
||||
public Map<ByteBuffer,TTimeRange> getColFamTimeRangeMap() {
|
||||
return this.colFamTimeRangeMap;
|
||||
}
|
||||
|
||||
public TScan setColFamTimeRangeMap(Map<ByteBuffer,TTimeRange> colFamTimeRangeMap) {
|
||||
this.colFamTimeRangeMap = colFamTimeRangeMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void unsetColFamTimeRangeMap() {
|
||||
this.colFamTimeRangeMap = null;
|
||||
}
|
||||
|
||||
/** Returns true if field colFamTimeRangeMap is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSetColFamTimeRangeMap() {
|
||||
return this.colFamTimeRangeMap != null;
|
||||
}
|
||||
|
||||
public void setColFamTimeRangeMapIsSet(boolean value) {
|
||||
if (!value) {
|
||||
this.colFamTimeRangeMap = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFieldValue(_Fields field, Object value) {
|
||||
switch (field) {
|
||||
case START_ROW:
|
||||
|
@ -712,6 +772,14 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
break;
|
||||
|
||||
case COL_FAM_TIME_RANGE_MAP:
|
||||
if (value == null) {
|
||||
unsetColFamTimeRangeMap();
|
||||
} else {
|
||||
setColFamTimeRangeMap((Map<ByteBuffer,TTimeRange>)value);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,6 +821,9 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
case CACHE_BLOCKS:
|
||||
return isCacheBlocks();
|
||||
|
||||
case COL_FAM_TIME_RANGE_MAP:
|
||||
return getColFamTimeRangeMap();
|
||||
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -788,6 +859,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
return isSetReversed();
|
||||
case CACHE_BLOCKS:
|
||||
return isSetCacheBlocks();
|
||||
case COL_FAM_TIME_RANGE_MAP:
|
||||
return isSetColFamTimeRangeMap();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -913,6 +986,15 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean this_present_colFamTimeRangeMap = true && this.isSetColFamTimeRangeMap();
|
||||
boolean that_present_colFamTimeRangeMap = true && that.isSetColFamTimeRangeMap();
|
||||
if (this_present_colFamTimeRangeMap || that_present_colFamTimeRangeMap) {
|
||||
if (!(this_present_colFamTimeRangeMap && that_present_colFamTimeRangeMap))
|
||||
return false;
|
||||
if (!this.colFamTimeRangeMap.equals(that.colFamTimeRangeMap))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -980,6 +1062,11 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
if (present_cacheBlocks)
|
||||
list.add(cacheBlocks);
|
||||
|
||||
boolean present_colFamTimeRangeMap = true && (isSetColFamTimeRangeMap());
|
||||
list.add(present_colFamTimeRangeMap);
|
||||
if (present_colFamTimeRangeMap)
|
||||
list.add(colFamTimeRangeMap);
|
||||
|
||||
return list.hashCode();
|
||||
}
|
||||
|
||||
|
@ -1111,6 +1198,16 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
return lastComparison;
|
||||
}
|
||||
}
|
||||
lastComparison = Boolean.valueOf(isSetColFamTimeRangeMap()).compareTo(other.isSetColFamTimeRangeMap());
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
if (isSetColFamTimeRangeMap()) {
|
||||
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colFamTimeRangeMap, other.colFamTimeRangeMap);
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1230,6 +1327,16 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
sb.append(this.cacheBlocks);
|
||||
first = false;
|
||||
}
|
||||
if (isSetColFamTimeRangeMap()) {
|
||||
if (!first) sb.append(", ");
|
||||
sb.append("colFamTimeRangeMap:");
|
||||
if (this.colFamTimeRangeMap == null) {
|
||||
sb.append("null");
|
||||
} else {
|
||||
sb.append(this.colFamTimeRangeMap);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -1402,6 +1509,27 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
case 13: // COL_FAM_TIME_RANGE_MAP
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
|
||||
{
|
||||
org.apache.thrift.protocol.TMap _map113 = iprot.readMapBegin();
|
||||
struct.colFamTimeRangeMap = new HashMap<ByteBuffer,TTimeRange>(2*_map113.size);
|
||||
ByteBuffer _key114;
|
||||
TTimeRange _val115;
|
||||
for (int _i116 = 0; _i116 < _map113.size; ++_i116)
|
||||
{
|
||||
_key114 = iprot.readBinary();
|
||||
_val115 = new TTimeRange();
|
||||
_val115.read(iprot);
|
||||
struct.colFamTimeRangeMap.put(_key114, _val115);
|
||||
}
|
||||
iprot.readMapEnd();
|
||||
}
|
||||
struct.setColFamTimeRangeMapIsSet(true);
|
||||
} else {
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
|
@ -1436,9 +1564,9 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
|
||||
{
|
||||
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.columns.size()));
|
||||
for (TColumn _iter113 : struct.columns)
|
||||
for (TColumn _iter117 : struct.columns)
|
||||
{
|
||||
_iter113.write(oprot);
|
||||
_iter117.write(oprot);
|
||||
}
|
||||
oprot.writeListEnd();
|
||||
}
|
||||
|
@ -1479,10 +1607,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
|
||||
{
|
||||
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.attributes.size()));
|
||||
for (Map.Entry<ByteBuffer, ByteBuffer> _iter114 : struct.attributes.entrySet())
|
||||
for (Map.Entry<ByteBuffer, ByteBuffer> _iter118 : struct.attributes.entrySet())
|
||||
{
|
||||
oprot.writeBinary(_iter114.getKey());
|
||||
oprot.writeBinary(_iter114.getValue());
|
||||
oprot.writeBinary(_iter118.getKey());
|
||||
oprot.writeBinary(_iter118.getValue());
|
||||
}
|
||||
oprot.writeMapEnd();
|
||||
}
|
||||
|
@ -1506,6 +1634,21 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
oprot.writeBool(struct.cacheBlocks);
|
||||
oprot.writeFieldEnd();
|
||||
}
|
||||
if (struct.colFamTimeRangeMap != null) {
|
||||
if (struct.isSetColFamTimeRangeMap()) {
|
||||
oprot.writeFieldBegin(COL_FAM_TIME_RANGE_MAP_FIELD_DESC);
|
||||
{
|
||||
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, struct.colFamTimeRangeMap.size()));
|
||||
for (Map.Entry<ByteBuffer, TTimeRange> _iter119 : struct.colFamTimeRangeMap.entrySet())
|
||||
{
|
||||
oprot.writeBinary(_iter119.getKey());
|
||||
_iter119.getValue().write(oprot);
|
||||
}
|
||||
oprot.writeMapEnd();
|
||||
}
|
||||
oprot.writeFieldEnd();
|
||||
}
|
||||
}
|
||||
oprot.writeFieldStop();
|
||||
oprot.writeStructEnd();
|
||||
}
|
||||
|
@ -1560,7 +1703,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
if (struct.isSetCacheBlocks()) {
|
||||
optionals.set(11);
|
||||
}
|
||||
oprot.writeBitSet(optionals, 12);
|
||||
if (struct.isSetColFamTimeRangeMap()) {
|
||||
optionals.set(12);
|
||||
}
|
||||
oprot.writeBitSet(optionals, 13);
|
||||
if (struct.isSetStartRow()) {
|
||||
oprot.writeBinary(struct.startRow);
|
||||
}
|
||||
|
@ -1570,9 +1716,9 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
if (struct.isSetColumns()) {
|
||||
{
|
||||
oprot.writeI32(struct.columns.size());
|
||||
for (TColumn _iter115 : struct.columns)
|
||||
for (TColumn _iter120 : struct.columns)
|
||||
{
|
||||
_iter115.write(oprot);
|
||||
_iter120.write(oprot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1594,10 +1740,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
if (struct.isSetAttributes()) {
|
||||
{
|
||||
oprot.writeI32(struct.attributes.size());
|
||||
for (Map.Entry<ByteBuffer, ByteBuffer> _iter116 : struct.attributes.entrySet())
|
||||
for (Map.Entry<ByteBuffer, ByteBuffer> _iter121 : struct.attributes.entrySet())
|
||||
{
|
||||
oprot.writeBinary(_iter116.getKey());
|
||||
oprot.writeBinary(_iter116.getValue());
|
||||
oprot.writeBinary(_iter121.getKey());
|
||||
oprot.writeBinary(_iter121.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1610,12 +1756,22 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
if (struct.isSetCacheBlocks()) {
|
||||
oprot.writeBool(struct.cacheBlocks);
|
||||
}
|
||||
if (struct.isSetColFamTimeRangeMap()) {
|
||||
{
|
||||
oprot.writeI32(struct.colFamTimeRangeMap.size());
|
||||
for (Map.Entry<ByteBuffer, TTimeRange> _iter122 : struct.colFamTimeRangeMap.entrySet())
|
||||
{
|
||||
oprot.writeBinary(_iter122.getKey());
|
||||
_iter122.getValue().write(oprot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(org.apache.thrift.protocol.TProtocol prot, TScan struct) throws org.apache.thrift.TException {
|
||||
TTupleProtocol iprot = (TTupleProtocol) prot;
|
||||
BitSet incoming = iprot.readBitSet(12);
|
||||
BitSet incoming = iprot.readBitSet(13);
|
||||
if (incoming.get(0)) {
|
||||
struct.startRow = iprot.readBinary();
|
||||
struct.setStartRowIsSet(true);
|
||||
|
@ -1626,14 +1782,14 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
if (incoming.get(2)) {
|
||||
{
|
||||
org.apache.thrift.protocol.TList _list117 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
|
||||
struct.columns = new ArrayList<TColumn>(_list117.size);
|
||||
TColumn _elem118;
|
||||
for (int _i119 = 0; _i119 < _list117.size; ++_i119)
|
||||
org.apache.thrift.protocol.TList _list123 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
|
||||
struct.columns = new ArrayList<TColumn>(_list123.size);
|
||||
TColumn _elem124;
|
||||
for (int _i125 = 0; _i125 < _list123.size; ++_i125)
|
||||
{
|
||||
_elem118 = new TColumn();
|
||||
_elem118.read(iprot);
|
||||
struct.columns.add(_elem118);
|
||||
_elem124 = new TColumn();
|
||||
_elem124.read(iprot);
|
||||
struct.columns.add(_elem124);
|
||||
}
|
||||
}
|
||||
struct.setColumnsIsSet(true);
|
||||
|
@ -1661,15 +1817,15 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
if (incoming.get(8)) {
|
||||
{
|
||||
org.apache.thrift.protocol.TMap _map120 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
|
||||
struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map120.size);
|
||||
ByteBuffer _key121;
|
||||
ByteBuffer _val122;
|
||||
for (int _i123 = 0; _i123 < _map120.size; ++_i123)
|
||||
org.apache.thrift.protocol.TMap _map126 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
|
||||
struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map126.size);
|
||||
ByteBuffer _key127;
|
||||
ByteBuffer _val128;
|
||||
for (int _i129 = 0; _i129 < _map126.size; ++_i129)
|
||||
{
|
||||
_key121 = iprot.readBinary();
|
||||
_val122 = iprot.readBinary();
|
||||
struct.attributes.put(_key121, _val122);
|
||||
_key127 = iprot.readBinary();
|
||||
_val128 = iprot.readBinary();
|
||||
struct.attributes.put(_key127, _val128);
|
||||
}
|
||||
}
|
||||
struct.setAttributesIsSet(true);
|
||||
|
@ -1687,6 +1843,22 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
struct.cacheBlocks = iprot.readBool();
|
||||
struct.setCacheBlocksIsSet(true);
|
||||
}
|
||||
if (incoming.get(12)) {
|
||||
{
|
||||
org.apache.thrift.protocol.TMap _map130 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
|
||||
struct.colFamTimeRangeMap = new HashMap<ByteBuffer,TTimeRange>(2*_map130.size);
|
||||
ByteBuffer _key131;
|
||||
TTimeRange _val132;
|
||||
for (int _i133 = 0; _i133 < _map130.size; ++_i133)
|
||||
{
|
||||
_key131 = iprot.readBinary();
|
||||
_val132 = new TTimeRange();
|
||||
_val132.read(iprot);
|
||||
struct.colFamTimeRangeMap.put(_key131, _val132);
|
||||
}
|
||||
}
|
||||
struct.setColFamTimeRangeMapIsSet(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ struct TAppend {
|
|||
}
|
||||
|
||||
/**
|
||||
* Any timestamps in the columns are ignored, use timeRange to select by timestamp.
|
||||
* Any timestamps in the columns are ignored but the colFamTimeRangeMap included, use timeRange to select by timestamp.
|
||||
* Max versions defaults to 1.
|
||||
*/
|
||||
struct TScan {
|
||||
|
@ -225,6 +225,7 @@ struct TScan {
|
|||
10: optional TAuthorization authorizations
|
||||
11: optional bool reversed
|
||||
12: optional bool cacheBlocks
|
||||
13: optional map<binary,TTimeRange> colFamTimeRangeMap
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.hadoop.hbase.thrift2;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
@ -65,6 +66,7 @@ import org.apache.hadoop.hbase.thrift2.generated.TScan;
|
|||
import org.apache.hadoop.hbase.thrift2.generated.TMutation;
|
||||
import org.apache.hadoop.hbase.thrift2.generated.TRowMutations;
|
||||
import org.apache.hadoop.hbase.thrift2.generated.TDurability;
|
||||
import org.apache.hadoop.hbase.thrift2.generated.TTimeRange;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.thrift.TException;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -787,6 +789,67 @@ public class TestThriftHBaseServiceHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScanWithColumnFamilyTimeRange() throws Exception {
|
||||
ThriftHBaseServiceHandler handler = createHandler();
|
||||
ByteBuffer table = wrap(tableAname);
|
||||
|
||||
// insert data
|
||||
TColumnValue familyAColumnValue = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
|
||||
wrap(valueAname));
|
||||
TColumnValue familyBColumnValue = new TColumnValue(wrap(familyBname), wrap(qualifierBname),
|
||||
wrap(valueBname));
|
||||
long minTimestamp = System.currentTimeMillis();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
familyAColumnValue.setTimestamp(minTimestamp + i);
|
||||
familyBColumnValue.setTimestamp(minTimestamp + i);
|
||||
List<TColumnValue> columnValues = new ArrayList<>(2);
|
||||
columnValues.add(familyAColumnValue);
|
||||
columnValues.add(familyBColumnValue);
|
||||
TPut put = new TPut(wrap(("testScanWithColumnFamilyTimeRange" + i).getBytes()),
|
||||
columnValues);
|
||||
handler.put(table, put);
|
||||
}
|
||||
|
||||
// create scan instance with column family time range
|
||||
TScan scan = new TScan();
|
||||
Map<ByteBuffer,TTimeRange> colFamTimeRangeMap = new HashMap<>(2);
|
||||
colFamTimeRangeMap.put(wrap(familyAname), new TTimeRange(minTimestamp + 3, minTimestamp + 5));
|
||||
colFamTimeRangeMap.put(wrap(familyBname), new TTimeRange(minTimestamp + 6, minTimestamp + 9));
|
||||
scan.setColFamTimeRangeMap(colFamTimeRangeMap);
|
||||
|
||||
// get scanner and rows
|
||||
int scanId = handler.openScanner(table, scan);
|
||||
List<TResult> results = handler.getScannerRows(scanId, 5);
|
||||
assertEquals(5, results.size());
|
||||
int familyACount = 0;
|
||||
int familyBCount = 0;
|
||||
for (TResult result : results) {
|
||||
List<TColumnValue> columnValues = result.getColumnValues();
|
||||
if (CollectionUtils.isNotEmpty(columnValues)) {
|
||||
if (Bytes.equals(familyAname, columnValues.get(0).getFamily())) {
|
||||
familyACount++;
|
||||
} else if (Bytes.equals(familyBname, columnValues.get(0).getFamily())) {
|
||||
familyBCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
assertEquals(2, familyACount);
|
||||
assertEquals(3, familyBCount);
|
||||
|
||||
// check that we are at the end of the scan
|
||||
results = handler.getScannerRows(scanId, 1);
|
||||
assertEquals(0, results.size());
|
||||
|
||||
// close scanner and check that it was indeed closed
|
||||
handler.closeScanner(scanId);
|
||||
try {
|
||||
handler.getScannerRows(scanId, 1);
|
||||
fail("Scanner id should be invalid");
|
||||
} catch (TIllegalArgument e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutTTL() throws Exception {
|
||||
ThriftHBaseServiceHandler handler = createHandler();
|
||||
|
|
Loading…
Reference in New Issue