You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2013/07/02 12:33:35 UTC
svn commit: r1498871 - in /hbase/trunk/hbase-server/src:
main/java/org/apache/hadoop/hbase/thrift2/
main/java/org/apache/hadoop/hbase/thrift2/generated/
main/resources/org/apache/hadoop/hbase/thrift2/
test/java/org/apache/hadoop/hbase/thrift2/
Author: larsgeorge
Date: Tue Jul 2 10:33:34 2013
New Revision: 1498871
URL: http://svn.apache.org/r1498871
Log:
HBASE-8774 Add BatchSize and Filter to Thrift2 (Hamed Madani)
Modified:
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TGet.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java
hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java?rev=1498871&r1=1498870&r2=1498871&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java Tue Jul 2 10:33:34 2013
@@ -23,6 +23,7 @@ import org.apache.hadoop.hbase.HConstant
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.client.*;
+import org.apache.hadoop.hbase.filter.ParseFilter;
import org.apache.hadoop.hbase.thrift2.generated.*;
import java.io.IOException;
@@ -73,6 +74,11 @@ public class ThriftUtilities {
}
}
+ if (in.isSetFilterString()) {
+ ParseFilter parseFilter = new ParseFilter();
+ out.setFilter(parseFilter.parseFilterString(in.getFilterString()));
+ }
+
return out;
}
@@ -314,6 +320,15 @@ public class ThriftUtilities {
out.setTimeRange(timeRange.getMinStamp(), timeRange.getMaxStamp());
}
+ if (in.isSetBatchSize()) {
+ out.setBatch(in.getBatchSize());
+ }
+
+ if (in.isSetFilterString()) {
+ ParseFilter parseFilter = new ParseFilter();
+ out.setFilter(parseFilter.parseFilterString(in.getFilterString()));
+ }
+
return out;
}
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TGet.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TGet.java?rev=1498871&r1=1498870&r2=1498871&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TGet.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TGet.java Tue Jul 2 10:33:34 2013
@@ -32,17 +32,17 @@ import org.slf4j.LoggerFactory;
/**
* Used to perform Get operations on a single row.
- *
+ *
* The scope can be further narrowed down by specifying a list of
* columns or column families.
- *
+ *
* To get everything for a row, instantiate a Get object with just the row to get.
* To further define the scope of what to get you can add a timestamp or time range
* with an optional maximum number of versions to return.
- *
+ *
* If you specify a time range and a timestamp the range is ignored.
* Timestamps on TColumns are ignored.
- *
+ *
* TODO: Filter, Locks
*/
public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.io.Serializable, Cloneable {
@@ -53,6 +53,7 @@ public class TGet implements org.apache.
private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)3);
private static final org.apache.thrift.protocol.TField TIME_RANGE_FIELD_DESC = new org.apache.thrift.protocol.TField("timeRange", org.apache.thrift.protocol.TType.STRUCT, (short)4);
private static final org.apache.thrift.protocol.TField MAX_VERSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("maxVersions", org.apache.thrift.protocol.TType.I32, (short)5);
+ private static final org.apache.thrift.protocol.TField FILTER_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("filterString", org.apache.thrift.protocol.TType.STRING, (short)6);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -65,6 +66,7 @@ public class TGet implements org.apache.
public long timestamp; // optional
public TTimeRange timeRange; // optional
public int maxVersions; // optional
+ public ByteBuffer filterString; // 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 {
@@ -72,7 +74,8 @@ public class TGet implements org.apache.
COLUMNS((short)2, "columns"),
TIMESTAMP((short)3, "timestamp"),
TIME_RANGE((short)4, "timeRange"),
- MAX_VERSIONS((short)5, "maxVersions");
+ MAX_VERSIONS((short)5, "maxVersions"),
+ FILTER_STRING((short)6, "filterString");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -97,6 +100,8 @@ public class TGet implements org.apache.
return TIME_RANGE;
case 5: // MAX_VERSIONS
return MAX_VERSIONS;
+ case 6: // FILTER_STRING
+ return FILTER_STRING;
default:
return null;
}
@@ -140,21 +145,23 @@ public class TGet implements org.apache.
private static final int __TIMESTAMP_ISSET_ID = 0;
private static final int __MAXVERSIONS_ISSET_ID = 1;
private byte __isset_bitfield = 0;
- private _Fields optionals[] = {_Fields.COLUMNS,_Fields.TIMESTAMP,_Fields.TIME_RANGE,_Fields.MAX_VERSIONS};
+ private _Fields optionals[] = {_Fields.COLUMNS,_Fields.TIMESTAMP,_Fields.TIME_RANGE,_Fields.MAX_VERSIONS,_Fields.FILTER_STRING};
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);
- tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
- tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL,
- new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+ tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumn.class))));
- tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
- tmpMap.put(_Fields.TIME_RANGE, new org.apache.thrift.meta_data.FieldMetaData("timeRange", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ tmpMap.put(_Fields.TIME_RANGE, new org.apache.thrift.meta_data.FieldMetaData("timeRange", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TTimeRange.class)));
- tmpMap.put(_Fields.MAX_VERSIONS, new org.apache.thrift.meta_data.FieldMetaData("maxVersions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ tmpMap.put(_Fields.MAX_VERSIONS, new org.apache.thrift.meta_data.FieldMetaData("maxVersions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+ tmpMap.put(_Fields.FILTER_STRING, new org.apache.thrift.meta_data.FieldMetaData("filterString", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TGet.class, metaDataMap);
}
@@ -190,6 +197,10 @@ public class TGet implements org.apache.
this.timeRange = new TTimeRange(other.timeRange);
}
this.maxVersions = other.maxVersions;
+ if (other.isSetFilterString()) {
+ this.filterString = org.apache.thrift.TBaseHelper.copyBinary(other.filterString);
+;
+ }
}
public TGet deepCopy() {
@@ -205,6 +216,7 @@ public class TGet implements org.apache.
this.timeRange = null;
setMaxVersionsIsSet(false);
this.maxVersions = 0;
+ this.filterString = null;
}
public byte[] getRow() {
@@ -350,6 +362,40 @@ public class TGet implements org.apache.
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __MAXVERSIONS_ISSET_ID, value);
}
+ public byte[] getFilterString() {
+ setFilterString(org.apache.thrift.TBaseHelper.rightSize(filterString));
+ return filterString == null ? null : filterString.array();
+ }
+
+ public ByteBuffer bufferForFilterString() {
+ return filterString;
+ }
+
+ public TGet setFilterString(byte[] filterString) {
+ setFilterString(filterString == null ? (ByteBuffer)null : ByteBuffer.wrap(filterString));
+ return this;
+ }
+
+ public TGet setFilterString(ByteBuffer filterString) {
+ this.filterString = filterString;
+ return this;
+ }
+
+ public void unsetFilterString() {
+ this.filterString = null;
+ }
+
+ /** Returns true if field filterString is set (has been assigned a value) and false otherwise */
+ public boolean isSetFilterString() {
+ return this.filterString != null;
+ }
+
+ public void setFilterStringIsSet(boolean value) {
+ if (!value) {
+ this.filterString = null;
+ }
+ }
+
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
@@ -392,6 +438,14 @@ public class TGet implements org.apache.
}
break;
+ case FILTER_STRING:
+ if (value == null) {
+ unsetFilterString();
+ } else {
+ setFilterString((ByteBuffer)value);
+ }
+ break;
+
}
}
@@ -412,6 +466,9 @@ public class TGet implements org.apache.
case MAX_VERSIONS:
return Integer.valueOf(getMaxVersions());
+ case FILTER_STRING:
+ return getFilterString();
+
}
throw new IllegalStateException();
}
@@ -433,6 +490,8 @@ public class TGet implements org.apache.
return isSetTimeRange();
case MAX_VERSIONS:
return isSetMaxVersions();
+ case FILTER_STRING:
+ return isSetFilterString();
}
throw new IllegalStateException();
}
@@ -495,6 +554,15 @@ public class TGet implements org.apache.
return false;
}
+ boolean this_present_filterString = true && this.isSetFilterString();
+ boolean that_present_filterString = true && that.isSetFilterString();
+ if (this_present_filterString || that_present_filterString) {
+ if (!(this_present_filterString && that_present_filterString))
+ return false;
+ if (!this.filterString.equals(that.filterString))
+ return false;
+ }
+
return true;
}
@@ -561,6 +629,16 @@ public class TGet implements org.apache.
return lastComparison;
}
}
+ lastComparison = Boolean.valueOf(isSetFilterString()).compareTo(typedOther.isSetFilterString());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetFilterString()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.filterString, typedOther.filterString);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -620,6 +698,16 @@ public class TGet implements org.apache.
sb.append(this.maxVersions);
first = false;
}
+ if (isSetFilterString()) {
+ if (!first) sb.append(", ");
+ sb.append("filterString:");
+ if (this.filterString == null) {
+ sb.append("null");
+ } else {
+ org.apache.thrift.TBaseHelper.toString(this.filterString, sb);
+ }
+ first = false;
+ }
sb.append(")");
return sb.toString();
}
@@ -667,7 +755,7 @@ public class TGet implements org.apache.
while (true)
{
schemeField = iprot.readFieldBegin();
- if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
@@ -675,7 +763,7 @@ public class TGet implements org.apache.
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.row = iprot.readBinary();
struct.setRowIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -686,7 +774,7 @@ public class TGet implements org.apache.
struct.columns = new ArrayList<TColumn>(_list8.size);
for (int _i9 = 0; _i9 < _list8.size; ++_i9)
{
- TColumn _elem10; // required
+ TColumn _elem10; // optional
_elem10 = new TColumn();
_elem10.read(iprot);
struct.columns.add(_elem10);
@@ -694,7 +782,7 @@ public class TGet implements org.apache.
iprot.readListEnd();
}
struct.setColumnsIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -702,7 +790,7 @@ public class TGet implements org.apache.
if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
struct.timestamp = iprot.readI64();
struct.setTimestampIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -711,7 +799,7 @@ public class TGet implements org.apache.
struct.timeRange = new TTimeRange();
struct.timeRange.read(iprot);
struct.setTimeRangeIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -719,7 +807,15 @@ public class TGet implements org.apache.
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.maxVersions = iprot.readI32();
struct.setMaxVersionsIsSet(true);
- } else {
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 6: // FILTER_STRING
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.filterString = iprot.readBinary();
+ struct.setFilterStringIsSet(true);
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -774,6 +870,13 @@ public class TGet implements org.apache.
oprot.writeI32(struct.maxVersions);
oprot.writeFieldEnd();
}
+ if (struct.filterString != null) {
+ if (struct.isSetFilterString()) {
+ oprot.writeFieldBegin(FILTER_STRING_FIELD_DESC);
+ oprot.writeBinary(struct.filterString);
+ oprot.writeFieldEnd();
+ }
+ }
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@@ -805,7 +908,10 @@ public class TGet implements org.apache.
if (struct.isSetMaxVersions()) {
optionals.set(3);
}
- oprot.writeBitSet(optionals, 4);
+ if (struct.isSetFilterString()) {
+ optionals.set(4);
+ }
+ oprot.writeBitSet(optionals, 5);
if (struct.isSetColumns()) {
{
oprot.writeI32(struct.columns.size());
@@ -824,6 +930,9 @@ public class TGet implements org.apache.
if (struct.isSetMaxVersions()) {
oprot.writeI32(struct.maxVersions);
}
+ if (struct.isSetFilterString()) {
+ oprot.writeBinary(struct.filterString);
+ }
}
@Override
@@ -831,14 +940,14 @@ public class TGet implements org.apache.
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.row = iprot.readBinary();
struct.setRowIsSet(true);
- BitSet incoming = iprot.readBitSet(4);
+ BitSet incoming = iprot.readBitSet(5);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.columns = new ArrayList<TColumn>(_list13.size);
for (int _i14 = 0; _i14 < _list13.size; ++_i14)
{
- TColumn _elem15; // required
+ TColumn _elem15; // optional
_elem15 = new TColumn();
_elem15.read(iprot);
struct.columns.add(_elem15);
@@ -859,6 +968,10 @@ public class TGet implements org.apache.
struct.maxVersions = iprot.readI32();
struct.setMaxVersionsIsSet(true);
}
+ if (incoming.get(4)) {
+ struct.filterString = iprot.readBinary();
+ struct.setFilterStringIsSet(true);
+ }
}
}
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java?rev=1498871&r1=1498870&r2=1498871&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java Tue Jul 2 10:33:34 2013
@@ -43,6 +43,8 @@ public class TScan implements org.apache
private static final org.apache.thrift.protocol.TField CACHING_FIELD_DESC = new org.apache.thrift.protocol.TField("caching", org.apache.thrift.protocol.TType.I32, (short)4);
private static final org.apache.thrift.protocol.TField MAX_VERSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("maxVersions", org.apache.thrift.protocol.TType.I32, (short)5);
private static final org.apache.thrift.protocol.TField TIME_RANGE_FIELD_DESC = new org.apache.thrift.protocol.TField("timeRange", org.apache.thrift.protocol.TType.STRUCT, (short)6);
+ private static final org.apache.thrift.protocol.TField FILTER_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("filterString", org.apache.thrift.protocol.TType.STRING, (short)7);
+ private static final org.apache.thrift.protocol.TField BATCH_SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("batchSize", org.apache.thrift.protocol.TType.I32, (short)8);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -56,6 +58,8 @@ public class TScan implements org.apache
public int caching; // optional
public int maxVersions; // optional
public TTimeRange timeRange; // optional
+ public ByteBuffer filterString; // optional
+ public int batchSize; // 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 {
@@ -64,7 +68,9 @@ public class TScan implements org.apache
COLUMNS((short)3, "columns"),
CACHING((short)4, "caching"),
MAX_VERSIONS((short)5, "maxVersions"),
- TIME_RANGE((short)6, "timeRange");
+ TIME_RANGE((short)6, "timeRange"),
+ FILTER_STRING((short)7, "filterString"),
+ BATCH_SIZE((short)8, "batchSize");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -91,6 +97,10 @@ public class TScan implements org.apache
return MAX_VERSIONS;
case 6: // TIME_RANGE
return TIME_RANGE;
+ case 7: // FILTER_STRING
+ return FILTER_STRING;
+ case 8: // BATCH_SIZE
+ return BATCH_SIZE;
default:
return null;
}
@@ -133,24 +143,29 @@ public class TScan implements org.apache
// isset id assignments
private static final int __CACHING_ISSET_ID = 0;
private static final int __MAXVERSIONS_ISSET_ID = 1;
+ private static final int __BATCHSIZE_ISSET_ID = 2;
private byte __isset_bitfield = 0;
- private _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.COLUMNS,_Fields.CACHING,_Fields.MAX_VERSIONS,_Fields.TIME_RANGE};
+ private _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.COLUMNS,_Fields.CACHING,_Fields.MAX_VERSIONS,_Fields.TIME_RANGE,_Fields.FILTER_STRING,_Fields.BATCH_SIZE};
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);
- tmpMap.put(_Fields.START_ROW, new org.apache.thrift.meta_data.FieldMetaData("startRow", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ tmpMap.put(_Fields.START_ROW, new org.apache.thrift.meta_data.FieldMetaData("startRow", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
- tmpMap.put(_Fields.STOP_ROW, new org.apache.thrift.meta_data.FieldMetaData("stopRow", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ tmpMap.put(_Fields.STOP_ROW, new org.apache.thrift.meta_data.FieldMetaData("stopRow", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
- tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL,
- new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+ tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumn.class))));
- tmpMap.put(_Fields.CACHING, new org.apache.thrift.meta_data.FieldMetaData("caching", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ tmpMap.put(_Fields.CACHING, new org.apache.thrift.meta_data.FieldMetaData("caching", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
- tmpMap.put(_Fields.MAX_VERSIONS, new org.apache.thrift.meta_data.FieldMetaData("maxVersions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ tmpMap.put(_Fields.MAX_VERSIONS, new org.apache.thrift.meta_data.FieldMetaData("maxVersions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
- tmpMap.put(_Fields.TIME_RANGE, new org.apache.thrift.meta_data.FieldMetaData("timeRange", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ tmpMap.put(_Fields.TIME_RANGE, new org.apache.thrift.meta_data.FieldMetaData("timeRange", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TTimeRange.class)));
+ tmpMap.put(_Fields.FILTER_STRING, new org.apache.thrift.meta_data.FieldMetaData("filterString", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
+ tmpMap.put(_Fields.BATCH_SIZE, new org.apache.thrift.meta_data.FieldMetaData("batchSize", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TScan.class, metaDataMap);
}
@@ -185,6 +200,11 @@ public class TScan implements org.apache
if (other.isSetTimeRange()) {
this.timeRange = new TTimeRange(other.timeRange);
}
+ if (other.isSetFilterString()) {
+ this.filterString = org.apache.thrift.TBaseHelper.copyBinary(other.filterString);
+;
+ }
+ this.batchSize = other.batchSize;
}
public TScan deepCopy() {
@@ -201,6 +221,9 @@ public class TScan implements org.apache
this.maxVersions = 1;
this.timeRange = null;
+ this.filterString = null;
+ setBatchSizeIsSet(false);
+ this.batchSize = 0;
}
public byte[] getStartRow() {
@@ -380,6 +403,63 @@ public class TScan implements org.apache
}
}
+ public byte[] getFilterString() {
+ setFilterString(org.apache.thrift.TBaseHelper.rightSize(filterString));
+ return filterString == null ? null : filterString.array();
+ }
+
+ public ByteBuffer bufferForFilterString() {
+ return filterString;
+ }
+
+ public TScan setFilterString(byte[] filterString) {
+ setFilterString(filterString == null ? (ByteBuffer)null : ByteBuffer.wrap(filterString));
+ return this;
+ }
+
+ public TScan setFilterString(ByteBuffer filterString) {
+ this.filterString = filterString;
+ return this;
+ }
+
+ public void unsetFilterString() {
+ this.filterString = null;
+ }
+
+ /** Returns true if field filterString is set (has been assigned a value) and false otherwise */
+ public boolean isSetFilterString() {
+ return this.filterString != null;
+ }
+
+ public void setFilterStringIsSet(boolean value) {
+ if (!value) {
+ this.filterString = null;
+ }
+ }
+
+ public int getBatchSize() {
+ return this.batchSize;
+ }
+
+ public TScan setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ setBatchSizeIsSet(true);
+ return this;
+ }
+
+ public void unsetBatchSize() {
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __BATCHSIZE_ISSET_ID);
+ }
+
+ /** Returns true if field batchSize is set (has been assigned a value) and false otherwise */
+ public boolean isSetBatchSize() {
+ return EncodingUtils.testBit(__isset_bitfield, __BATCHSIZE_ISSET_ID);
+ }
+
+ public void setBatchSizeIsSet(boolean value) {
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __BATCHSIZE_ISSET_ID, value);
+ }
+
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case START_ROW:
@@ -430,6 +510,22 @@ public class TScan implements org.apache
}
break;
+ case FILTER_STRING:
+ if (value == null) {
+ unsetFilterString();
+ } else {
+ setFilterString((ByteBuffer)value);
+ }
+ break;
+
+ case BATCH_SIZE:
+ if (value == null) {
+ unsetBatchSize();
+ } else {
+ setBatchSize((Integer)value);
+ }
+ break;
+
}
}
@@ -453,6 +549,12 @@ public class TScan implements org.apache
case TIME_RANGE:
return getTimeRange();
+ case FILTER_STRING:
+ return getFilterString();
+
+ case BATCH_SIZE:
+ return Integer.valueOf(getBatchSize());
+
}
throw new IllegalStateException();
}
@@ -476,6 +578,10 @@ public class TScan implements org.apache
return isSetMaxVersions();
case TIME_RANGE:
return isSetTimeRange();
+ case FILTER_STRING:
+ return isSetFilterString();
+ case BATCH_SIZE:
+ return isSetBatchSize();
}
throw new IllegalStateException();
}
@@ -547,6 +653,24 @@ public class TScan implements org.apache
return false;
}
+ boolean this_present_filterString = true && this.isSetFilterString();
+ boolean that_present_filterString = true && that.isSetFilterString();
+ if (this_present_filterString || that_present_filterString) {
+ if (!(this_present_filterString && that_present_filterString))
+ return false;
+ if (!this.filterString.equals(that.filterString))
+ return false;
+ }
+
+ boolean this_present_batchSize = true && this.isSetBatchSize();
+ boolean that_present_batchSize = true && that.isSetBatchSize();
+ if (this_present_batchSize || that_present_batchSize) {
+ if (!(this_present_batchSize && that_present_batchSize))
+ return false;
+ if (this.batchSize != that.batchSize)
+ return false;
+ }
+
return true;
}
@@ -623,6 +747,26 @@ public class TScan implements org.apache
return lastComparison;
}
}
+ lastComparison = Boolean.valueOf(isSetFilterString()).compareTo(typedOther.isSetFilterString());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetFilterString()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.filterString, typedOther.filterString);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetBatchSize()).compareTo(typedOther.isSetBatchSize());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetBatchSize()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.batchSize, typedOther.batchSize);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -694,6 +838,22 @@ public class TScan implements org.apache
}
first = false;
}
+ if (isSetFilterString()) {
+ if (!first) sb.append(", ");
+ sb.append("filterString:");
+ if (this.filterString == null) {
+ sb.append("null");
+ } else {
+ org.apache.thrift.TBaseHelper.toString(this.filterString, sb);
+ }
+ first = false;
+ }
+ if (isSetBatchSize()) {
+ if (!first) sb.append(", ");
+ sb.append("batchSize:");
+ sb.append(this.batchSize);
+ first = false;
+ }
sb.append(")");
return sb.toString();
}
@@ -738,7 +898,7 @@ public class TScan implements org.apache
while (true)
{
schemeField = iprot.readFieldBegin();
- if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
@@ -746,7 +906,7 @@ public class TScan implements org.apache
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.startRow = iprot.readBinary();
struct.setStartRowIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -754,7 +914,7 @@ public class TScan implements org.apache
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.stopRow = iprot.readBinary();
struct.setStopRowIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -765,7 +925,7 @@ public class TScan implements org.apache
struct.columns = new ArrayList<TColumn>(_list40.size);
for (int _i41 = 0; _i41 < _list40.size; ++_i41)
{
- TColumn _elem42; // required
+ TColumn _elem42; // optional
_elem42 = new TColumn();
_elem42.read(iprot);
struct.columns.add(_elem42);
@@ -773,7 +933,7 @@ public class TScan implements org.apache
iprot.readListEnd();
}
struct.setColumnsIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -781,7 +941,7 @@ public class TScan implements org.apache
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.caching = iprot.readI32();
struct.setCachingIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -789,7 +949,7 @@ public class TScan implements org.apache
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.maxVersions = iprot.readI32();
struct.setMaxVersionsIsSet(true);
- } else {
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -798,7 +958,23 @@ public class TScan implements org.apache
struct.timeRange = new TTimeRange();
struct.timeRange.read(iprot);
struct.setTimeRangeIsSet(true);
- } else {
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 7: // FILTER_STRING
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.filterString = iprot.readBinary();
+ struct.setFilterStringIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 8: // BATCH_SIZE
+ if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+ struct.batchSize = iprot.readI32();
+ struct.setBatchSizeIsSet(true);
+ } else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@@ -862,6 +1038,18 @@ public class TScan implements org.apache
oprot.writeFieldEnd();
}
}
+ if (struct.filterString != null) {
+ if (struct.isSetFilterString()) {
+ oprot.writeFieldBegin(FILTER_STRING_FIELD_DESC);
+ oprot.writeBinary(struct.filterString);
+ oprot.writeFieldEnd();
+ }
+ }
+ if (struct.isSetBatchSize()) {
+ oprot.writeFieldBegin(BATCH_SIZE_FIELD_DESC);
+ oprot.writeI32(struct.batchSize);
+ oprot.writeFieldEnd();
+ }
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@@ -898,7 +1086,13 @@ public class TScan implements org.apache
if (struct.isSetTimeRange()) {
optionals.set(5);
}
- oprot.writeBitSet(optionals, 6);
+ if (struct.isSetFilterString()) {
+ optionals.set(6);
+ }
+ if (struct.isSetBatchSize()) {
+ optionals.set(7);
+ }
+ oprot.writeBitSet(optionals, 8);
if (struct.isSetStartRow()) {
oprot.writeBinary(struct.startRow);
}
@@ -923,12 +1117,18 @@ public class TScan implements org.apache
if (struct.isSetTimeRange()) {
struct.timeRange.write(oprot);
}
+ if (struct.isSetFilterString()) {
+ oprot.writeBinary(struct.filterString);
+ }
+ if (struct.isSetBatchSize()) {
+ oprot.writeI32(struct.batchSize);
+ }
}
@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(6);
+ BitSet incoming = iprot.readBitSet(8);
if (incoming.get(0)) {
struct.startRow = iprot.readBinary();
struct.setStartRowIsSet(true);
@@ -943,7 +1143,7 @@ public class TScan implements org.apache
struct.columns = new ArrayList<TColumn>(_list45.size);
for (int _i46 = 0; _i46 < _list45.size; ++_i46)
{
- TColumn _elem47; // required
+ TColumn _elem47; // optional
_elem47 = new TColumn();
_elem47.read(iprot);
struct.columns.add(_elem47);
@@ -964,6 +1164,14 @@ public class TScan implements org.apache
struct.timeRange.read(iprot);
struct.setTimeRangeIsSet(true);
}
+ if (incoming.get(6)) {
+ struct.filterString = iprot.readBinary();
+ struct.setFilterStringIsSet(true);
+ }
+ if (incoming.get(7)) {
+ struct.batchSize = iprot.readI32();
+ struct.setBatchSizeIsSet(true);
+ }
}
}
Modified: hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift?rev=1498871&r1=1498870&r2=1498871&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift (original)
+++ hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift Tue Jul 2 10:33:34 2013
@@ -52,7 +52,7 @@ struct TColumnValue {
/**
* Represents a single cell and the amount to increment it by
- */
+ */
struct TColumnIncrement {
1: required binary family,
2: required binary qualifier,
@@ -89,8 +89,6 @@ enum TDeleteType {
*
* If you specify a time range and a timestamp the range is ignored.
* Timestamps on TColumns are ignored.
- *
- * TODO: Filter, Locks
*/
struct TGet {
1: required binary row,
@@ -100,6 +98,7 @@ struct TGet {
4: optional TTimeRange timeRange,
5: optional i32 maxVersions,
+ 6: optional binary filterString
}
/**
@@ -153,7 +152,7 @@ struct TDelete {
/**
* Used to perform Increment operations for a single row.
- *
+ *
* You can specify if this Increment should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
@@ -174,6 +173,8 @@ struct TScan {
4: optional i32 caching,
5: optional i32 maxVersions=1,
6: optional TTimeRange timeRange,
+ 7: optional binary filterString,
+ 8: optional i32 batchSize
}
//
@@ -353,7 +354,7 @@ service THBaseService {
/** the TDelete to execute if the check succeeds */
6: required TDelete deleteSingle
) throws (1: TIOError io)
-
+
TResult increment(
/** the table to increment the value on */
1: required binary table,
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java?rev=1498871&r1=1498870&r2=1498871&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java Tue Jul 2 10:33:34 2013
@@ -325,7 +325,7 @@ public class TestThriftHBaseServiceHandl
long timestamp1 = System.currentTimeMillis() - 10;
long timestamp2 = System.currentTimeMillis();
-
+
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname));
@@ -392,7 +392,7 @@ public class TestThriftHBaseServiceHandl
/**
* check that checkAndPut fails if the cell does not exist, then put in the cell, then check that the checkAndPut
* succeeds.
- *
+ *
* @throws Exception
*/
@Test
@@ -439,7 +439,7 @@ public class TestThriftHBaseServiceHandl
/**
* check that checkAndDelete fails if the cell does not exist, then put in the cell, then check that the
* checkAndDelete succeeds.
- *
+ *
* @throws Exception
*/
@Test
@@ -498,6 +498,8 @@ public class TestThriftHBaseServiceHandl
columns.add(column);
scan.setColumns(columns);
scan.setStartRow("testScan".getBytes());
+ // only get the key part
+ scan.setFilterString(ByteBuffer.wrap(("KeyOnlyFilter()").getBytes()));
TColumnValue columnValue = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname));
@@ -513,6 +515,7 @@ public class TestThriftHBaseServiceHandl
assertEquals(10, results.size());
for (int i = 0; i < 10; i++) {
assertArrayEquals(("testScan" + i).getBytes(), results.get(i).getRow());
+ assertArrayEquals(("").getBytes(), results.get(i).getColumnValues().get(0).getValue());
}
results = handler.getScannerRows(scanId, 10);