diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java index 85d95ea..2fd3491 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java @@ -445,6 +445,10 @@ public class ThriftUtilities { } } + if (in.isSetSmall()) { + out.setSmall(in.isSmall()); + } + return out; } diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java index 7531052..ce921e8 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java @@ -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, java.io.Serializable, Cloneable, Comparable { 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, 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, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -75,6 +76,7 @@ public class TScan implements org.apache.thrift.TBase, jav public boolean reversed; // optional public boolean cacheBlocks; // optional public Map 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, 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 byName = new HashMap(); @@ -131,6 +134,8 @@ public class TScan implements org.apache.thrift.TBase, 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, 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); @@ -208,10 +214,12 @@ public class TScan implements org.apache.thrift.TBase, 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), + 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)))); + 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, jav } this.colFamTimeRangeMap = __this__colFamTimeRangeMap; } + this.small = other.small; } public TScan deepCopy() { @@ -298,6 +307,8 @@ public class TScan implements org.apache.thrift.TBase, 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, 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, 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, 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, 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, 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, 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, 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; } @@ -1215,11 +1286,11 @@ public class TScan implements org.apache.thrift.TBase, jav return _Fields.findByThriftId(fieldId); } - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot) throws TException { schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot) throws TException { schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @@ -1337,11 +1408,17 @@ public class TScan implements org.apache.thrift.TBase, jav } first = false; } + if (isSetSmall()) { + if (!first) sb.append(", "); + sb.append("small:"); + sb.append(this.small); + first = false; + } sb.append(")"); return sb.toString(); } - public void validate() throws org.apache.thrift.TException { + public void validate() throws TException { // check for required fields // check for sub-struct validity if (timeRange != null) { @@ -1355,7 +1432,7 @@ public class TScan implements org.apache.thrift.TBase, jav private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { + } catch (TException te) { throw new java.io.IOException(te); } } @@ -1365,7 +1442,7 @@ public class TScan implements org.apache.thrift.TBase, jav // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { + } catch (TException te) { throw new java.io.IOException(te); } } @@ -1378,7 +1455,7 @@ public class TScan implements org.apache.thrift.TBase, jav private static class TScanStandardScheme extends StandardScheme { - public void read(org.apache.thrift.protocol.TProtocol iprot, TScan struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot, TScan struct) throws TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) @@ -1526,7 +1603,15 @@ public class TScan implements org.apache.thrift.TBase, jav iprot.readMapEnd(); } struct.setColFamTimeRangeMapIsSet(true); - } else { + } else { + 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; @@ -1541,7 +1626,7 @@ public class TScan implements org.apache.thrift.TBase, jav struct.validate(); } - public void write(org.apache.thrift.protocol.TProtocol oprot, TScan struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot, TScan struct) throws TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); @@ -1649,6 +1734,11 @@ public class TScan implements org.apache.thrift.TBase, jav oprot.writeFieldEnd(); } } + if (struct.isSetSmall()) { + oprot.writeFieldBegin(SMALL_FIELD_DESC); + oprot.writeBool(struct.small); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -1664,7 +1754,7 @@ public class TScan implements org.apache.thrift.TBase, jav private static class TScanTupleScheme extends TupleScheme { @Override - public void write(org.apache.thrift.protocol.TProtocol prot, TScan struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol prot, TScan struct) throws TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetStartRow()) { @@ -1706,7 +1796,10 @@ public class TScan implements org.apache.thrift.TBase, 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, 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 { + public void read(org.apache.thrift.protocol.TProtocol prot, TScan struct) throws 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, jav } struct.setColFamTimeRangeMapIsSet(true); } + if (incoming.get(13)) { + struct.small = iprot.readBool(); + struct.setSmallIsSet(true); + } } } diff --git a/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift b/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift index 0bd8ece..eff92cb 100644 --- a/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift +++ b/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift @@ -226,6 +226,7 @@ struct TScan { 11: optional bool reversed 12: optional bool cacheBlocks 13: optional map colFamTimeRangeMap + 14: optional bool small } /** diff --git a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java index 4b202f6..05b5657 100644 --- a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java +++ b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java @@ -850,6 +850,49 @@ public class TestThriftHBaseServiceHandler { } } + 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 columnValues = new ArrayList(); + 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 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();