HBASE-17831 Support small scan in thrift2 (Guangxu Cheng)
This commit is contained in:
parent
babb857940
commit
6fe3b5e0f1
|
@ -446,6 +446,10 @@ public class ThriftUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
if (in.isSetSmall()) {
|
||||
out.setSmall(in.isSmall());
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
|
|||
* 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 = "2017-03-06")
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-03-24")
|
||||
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");
|
||||
|
||||
|
@ -55,6 +55,7 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
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 org.apache.thrift.protocol.TField SMALL_FIELD_DESC = new org.apache.thrift.protocol.TField("small", org.apache.thrift.protocol.TType.BOOL, (short)14);
|
||||
|
||||
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
|
||||
static {
|
||||
|
@ -75,6 +76,7 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
public boolean reversed; // optional
|
||||
public boolean cacheBlocks; // optional
|
||||
public Map<ByteBuffer,TTimeRange> colFamTimeRangeMap; // optional
|
||||
public boolean small; // 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 {
|
||||
|
@ -90,7 +92,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
AUTHORIZATIONS((short)10, "authorizations"),
|
||||
REVERSED((short)11, "reversed"),
|
||||
CACHE_BLOCKS((short)12, "cacheBlocks"),
|
||||
COL_FAM_TIME_RANGE_MAP((short)13, "colFamTimeRangeMap");
|
||||
COL_FAM_TIME_RANGE_MAP((short)13, "colFamTimeRangeMap"),
|
||||
SMALL((short)14, "small");
|
||||
|
||||
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
|
||||
|
||||
|
@ -131,6 +134,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
return CACHE_BLOCKS;
|
||||
case 13: // COL_FAM_TIME_RANGE_MAP
|
||||
return COL_FAM_TIME_RANGE_MAP;
|
||||
case 14: // SMALL
|
||||
return SMALL;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -176,8 +181,9 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
private static final int __BATCHSIZE_ISSET_ID = 2;
|
||||
private static final int __REVERSED_ISSET_ID = 3;
|
||||
private static final int __CACHEBLOCKS_ISSET_ID = 4;
|
||||
private static final int __SMALL_ISSET_ID = 5;
|
||||
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,_Fields.COL_FAM_TIME_RANGE_MAP};
|
||||
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,_Fields.SMALL};
|
||||
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);
|
||||
|
@ -212,6 +218,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
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))));
|
||||
tmpMap.put(_Fields.SMALL, new org.apache.thrift.meta_data.FieldMetaData("small", org.apache.thrift.TFieldRequirementType.OPTIONAL,
|
||||
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
|
||||
metaDataMap = Collections.unmodifiableMap(tmpMap);
|
||||
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TScan.class, metaDataMap);
|
||||
}
|
||||
|
@ -272,6 +280,7 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
this.colFamTimeRangeMap = __this__colFamTimeRangeMap;
|
||||
}
|
||||
this.small = other.small;
|
||||
}
|
||||
|
||||
public TScan deepCopy() {
|
||||
|
@ -298,6 +307,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
setCacheBlocksIsSet(false);
|
||||
this.cacheBlocks = false;
|
||||
this.colFamTimeRangeMap = null;
|
||||
setSmallIsSet(false);
|
||||
this.small = false;
|
||||
}
|
||||
|
||||
public byte[] getStartRow() {
|
||||
|
@ -674,6 +685,29 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isSmall() {
|
||||
return this.small;
|
||||
}
|
||||
|
||||
public TScan setSmall(boolean small) {
|
||||
this.small = small;
|
||||
setSmallIsSet(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void unsetSmall() {
|
||||
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SMALL_ISSET_ID);
|
||||
}
|
||||
|
||||
/** Returns true if field small is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSetSmall() {
|
||||
return EncodingUtils.testBit(__isset_bitfield, __SMALL_ISSET_ID);
|
||||
}
|
||||
|
||||
public void setSmallIsSet(boolean value) {
|
||||
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SMALL_ISSET_ID, value);
|
||||
}
|
||||
|
||||
public void setFieldValue(_Fields field, Object value) {
|
||||
switch (field) {
|
||||
case START_ROW:
|
||||
|
@ -780,6 +814,14 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
if (value == null) {
|
||||
unsetSmall();
|
||||
} else {
|
||||
setSmall((Boolean)value);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -824,6 +866,9 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
case COL_FAM_TIME_RANGE_MAP:
|
||||
return getColFamTimeRangeMap();
|
||||
|
||||
case SMALL:
|
||||
return isSmall();
|
||||
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -861,6 +906,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
return isSetCacheBlocks();
|
||||
case COL_FAM_TIME_RANGE_MAP:
|
||||
return isSetColFamTimeRangeMap();
|
||||
case SMALL:
|
||||
return isSetSmall();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -995,6 +1042,15 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean this_present_small = true && this.isSetSmall();
|
||||
boolean that_present_small = true && that.isSetSmall();
|
||||
if (this_present_small || that_present_small) {
|
||||
if (!(this_present_small && that_present_small))
|
||||
return false;
|
||||
if (this.small != that.small)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1067,6 +1123,11 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
if (present_colFamTimeRangeMap)
|
||||
list.add(colFamTimeRangeMap);
|
||||
|
||||
boolean present_small = true && (isSetSmall());
|
||||
list.add(present_small);
|
||||
if (present_small)
|
||||
list.add(small);
|
||||
|
||||
return list.hashCode();
|
||||
}
|
||||
|
||||
|
@ -1208,6 +1269,16 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
return lastComparison;
|
||||
}
|
||||
}
|
||||
lastComparison = Boolean.valueOf(isSetSmall()).compareTo(other.isSetSmall());
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
if (isSetSmall()) {
|
||||
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.small, other.small);
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1337,6 +1408,12 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
first = false;
|
||||
}
|
||||
if (isSetSmall()) {
|
||||
if (!first) sb.append(", ");
|
||||
sb.append("small:");
|
||||
sb.append(this.small);
|
||||
first = false;
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -1530,6 +1607,14 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
case 14: // SMALL
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
|
||||
struct.small = iprot.readBool();
|
||||
struct.setSmallIsSet(true);
|
||||
} else {
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
|
@ -1649,6 +1734,11 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
oprot.writeFieldEnd();
|
||||
}
|
||||
}
|
||||
if (struct.isSetSmall()) {
|
||||
oprot.writeFieldBegin(SMALL_FIELD_DESC);
|
||||
oprot.writeBool(struct.small);
|
||||
oprot.writeFieldEnd();
|
||||
}
|
||||
oprot.writeFieldStop();
|
||||
oprot.writeStructEnd();
|
||||
}
|
||||
|
@ -1706,7 +1796,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
if (struct.isSetColFamTimeRangeMap()) {
|
||||
optionals.set(12);
|
||||
}
|
||||
oprot.writeBitSet(optionals, 13);
|
||||
if (struct.isSetSmall()) {
|
||||
optionals.set(13);
|
||||
}
|
||||
oprot.writeBitSet(optionals, 14);
|
||||
if (struct.isSetStartRow()) {
|
||||
oprot.writeBinary(struct.startRow);
|
||||
}
|
||||
|
@ -1766,12 +1859,15 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
}
|
||||
}
|
||||
if (struct.isSetSmall()) {
|
||||
oprot.writeBool(struct.small);
|
||||
}
|
||||
}
|
||||
|
||||
@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(13);
|
||||
BitSet incoming = iprot.readBitSet(14);
|
||||
if (incoming.get(0)) {
|
||||
struct.startRow = iprot.readBinary();
|
||||
struct.setStartRowIsSet(true);
|
||||
|
@ -1859,6 +1955,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
|
|||
}
|
||||
struct.setColFamTimeRangeMapIsSet(true);
|
||||
}
|
||||
if (incoming.get(13)) {
|
||||
struct.small = iprot.readBool();
|
||||
struct.setSmallIsSet(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,6 +226,7 @@ struct TScan {
|
|||
11: optional bool reversed
|
||||
12: optional bool cacheBlocks
|
||||
13: optional map<binary,TTimeRange> colFamTimeRangeMap
|
||||
14: optional bool small
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -844,6 +844,50 @@ public class TestThriftHBaseServiceHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmallScan() throws Exception {
|
||||
ThriftHBaseServiceHandler handler = createHandler();
|
||||
ByteBuffer table = wrap(tableAname);
|
||||
|
||||
// insert data
|
||||
TColumnValue columnValue = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
|
||||
wrap(valueAname));
|
||||
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
|
||||
columnValues.add(columnValue);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
TPut put = new TPut(wrap(("testSmallScan" + i).getBytes()), columnValues);
|
||||
handler.put(table, put);
|
||||
}
|
||||
|
||||
// small scan instance
|
||||
TScan scan = new TScan();
|
||||
scan.setStartRow("testSmallScan".getBytes());
|
||||
scan.setStopRow("testSmallScan\uffff".getBytes());
|
||||
scan.setSmall(true);
|
||||
scan.setCaching(2);
|
||||
|
||||
// get scanner and rows
|
||||
int scanId = handler.openScanner(table, scan);
|
||||
List<TResult> results = handler.getScannerRows(scanId, 10);
|
||||
assertEquals(10, results.size());
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// check if the rows are returned and in order
|
||||
assertArrayEquals(("testSmallScan" + i).getBytes(), results.get(i).getRow());
|
||||
}
|
||||
|
||||
// check that we are at the end of the scan
|
||||
results = handler.getScannerRows(scanId, 10);
|
||||
assertEquals(0, results.size());
|
||||
|
||||
// close scanner and check that it was indeed closed
|
||||
handler.closeScanner(scanId);
|
||||
try {
|
||||
handler.getScannerRows(scanId, 10);
|
||||
fail("Scanner id should be invalid");
|
||||
} catch (TIllegalArgument e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutTTL() throws Exception {
|
||||
ThriftHBaseServiceHandler handler = createHandler();
|
||||
|
|
Loading…
Reference in New Issue