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/12 08:04:40 UTC
svn commit: r1502432 [2/2] - in /hbase/branches/0.95/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/thr...
Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java?rev=1502432&r1=1502431&r2=1502432&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java Fri Jul 12 06:04:39 2013
@@ -45,6 +45,7 @@ public class TScan implements org.apache
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 org.apache.thrift.protocol.TField ATTRIBUTES_FIELD_DESC = new org.apache.thrift.protocol.TField("attributes", org.apache.thrift.protocol.TType.MAP, (short)9);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -60,6 +61,7 @@ public class TScan implements org.apache
public TTimeRange timeRange; // optional
public ByteBuffer filterString; // optional
public int batchSize; // optional
+ public Map<ByteBuffer,ByteBuffer> attributes; // 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 {
@@ -70,7 +72,8 @@ public class TScan implements org.apache
MAX_VERSIONS((short)5, "maxVersions"),
TIME_RANGE((short)6, "timeRange"),
FILTER_STRING((short)7, "filterString"),
- BATCH_SIZE((short)8, "batchSize");
+ BATCH_SIZE((short)8, "batchSize"),
+ ATTRIBUTES((short)9, "attributes");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -101,6 +104,8 @@ public class TScan implements org.apache
return FILTER_STRING;
case 8: // BATCH_SIZE
return BATCH_SIZE;
+ case 9: // ATTRIBUTES
+ return ATTRIBUTES;
default:
return null;
}
@@ -145,7 +150,7 @@ public class TScan implements org.apache
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,_Fields.FILTER_STRING,_Fields.BATCH_SIZE};
+ 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,_Fields.ATTRIBUTES};
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);
@@ -166,6 +171,10 @@ public class TScan implements org.apache
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)));
+ tmpMap.put(_Fields.ATTRIBUTES, new org.apache.thrift.meta_data.FieldMetaData("attributes", 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.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TScan.class, metaDataMap);
}
@@ -205,6 +214,23 @@ public class TScan implements org.apache
;
}
this.batchSize = other.batchSize;
+ if (other.isSetAttributes()) {
+ Map<ByteBuffer,ByteBuffer> __this__attributes = new HashMap<ByteBuffer,ByteBuffer>();
+ for (Map.Entry<ByteBuffer, ByteBuffer> other_element : other.attributes.entrySet()) {
+
+ ByteBuffer other_element_key = other_element.getKey();
+ ByteBuffer other_element_value = other_element.getValue();
+
+ ByteBuffer __this__attributes_copy_key = org.apache.thrift.TBaseHelper.copyBinary(other_element_key);
+;
+
+ ByteBuffer __this__attributes_copy_value = org.apache.thrift.TBaseHelper.copyBinary(other_element_value);
+;
+
+ __this__attributes.put(__this__attributes_copy_key, __this__attributes_copy_value);
+ }
+ this.attributes = __this__attributes;
+ }
}
public TScan deepCopy() {
@@ -224,6 +250,7 @@ public class TScan implements org.apache
this.filterString = null;
setBatchSizeIsSet(false);
this.batchSize = 0;
+ this.attributes = null;
}
public byte[] getStartRow() {
@@ -460,6 +487,41 @@ public class TScan implements org.apache
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __BATCHSIZE_ISSET_ID, value);
}
+ public int getAttributesSize() {
+ return (this.attributes == null) ? 0 : this.attributes.size();
+ }
+
+ public void putToAttributes(ByteBuffer key, ByteBuffer val) {
+ if (this.attributes == null) {
+ this.attributes = new HashMap<ByteBuffer,ByteBuffer>();
+ }
+ this.attributes.put(key, val);
+ }
+
+ public Map<ByteBuffer,ByteBuffer> getAttributes() {
+ return this.attributes;
+ }
+
+ public TScan setAttributes(Map<ByteBuffer,ByteBuffer> attributes) {
+ this.attributes = attributes;
+ return this;
+ }
+
+ public void unsetAttributes() {
+ this.attributes = null;
+ }
+
+ /** Returns true if field attributes is set (has been assigned a value) and false otherwise */
+ public boolean isSetAttributes() {
+ return this.attributes != null;
+ }
+
+ public void setAttributesIsSet(boolean value) {
+ if (!value) {
+ this.attributes = null;
+ }
+ }
+
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case START_ROW:
@@ -526,6 +588,14 @@ public class TScan implements org.apache
}
break;
+ case ATTRIBUTES:
+ if (value == null) {
+ unsetAttributes();
+ } else {
+ setAttributes((Map<ByteBuffer,ByteBuffer>)value);
+ }
+ break;
+
}
}
@@ -555,6 +625,9 @@ public class TScan implements org.apache
case BATCH_SIZE:
return Integer.valueOf(getBatchSize());
+ case ATTRIBUTES:
+ return getAttributes();
+
}
throw new IllegalStateException();
}
@@ -582,6 +655,8 @@ public class TScan implements org.apache
return isSetFilterString();
case BATCH_SIZE:
return isSetBatchSize();
+ case ATTRIBUTES:
+ return isSetAttributes();
}
throw new IllegalStateException();
}
@@ -671,6 +746,15 @@ public class TScan implements org.apache
return false;
}
+ boolean this_present_attributes = true && this.isSetAttributes();
+ boolean that_present_attributes = true && that.isSetAttributes();
+ if (this_present_attributes || that_present_attributes) {
+ if (!(this_present_attributes && that_present_attributes))
+ return false;
+ if (!this.attributes.equals(that.attributes))
+ return false;
+ }
+
return true;
}
@@ -767,6 +851,16 @@ public class TScan implements org.apache
return lastComparison;
}
}
+ lastComparison = Boolean.valueOf(isSetAttributes()).compareTo(typedOther.isSetAttributes());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetAttributes()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.attributes, typedOther.attributes);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -854,6 +948,16 @@ public class TScan implements org.apache
sb.append(this.batchSize);
first = false;
}
+ if (isSetAttributes()) {
+ if (!first) sb.append(", ");
+ sb.append("attributes:");
+ if (this.attributes == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.attributes);
+ }
+ first = false;
+ }
sb.append(")");
return sb.toString();
}
@@ -921,14 +1025,14 @@ public class TScan implements org.apache
case 3: // COLUMNS
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
- org.apache.thrift.protocol.TList _list40 = iprot.readListBegin();
- struct.columns = new ArrayList<TColumn>(_list40.size);
- for (int _i41 = 0; _i41 < _list40.size; ++_i41)
+ org.apache.thrift.protocol.TList _list80 = iprot.readListBegin();
+ struct.columns = new ArrayList<TColumn>(_list80.size);
+ for (int _i81 = 0; _i81 < _list80.size; ++_i81)
{
- TColumn _elem42; // optional
- _elem42 = new TColumn();
- _elem42.read(iprot);
- struct.columns.add(_elem42);
+ TColumn _elem82; // required
+ _elem82 = new TColumn();
+ _elem82.read(iprot);
+ struct.columns.add(_elem82);
}
iprot.readListEnd();
}
@@ -978,6 +1082,26 @@ public class TScan implements org.apache
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
+ case 9: // ATTRIBUTES
+ if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
+ {
+ org.apache.thrift.protocol.TMap _map83 = iprot.readMapBegin();
+ struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map83.size);
+ for (int _i84 = 0; _i84 < _map83.size; ++_i84)
+ {
+ ByteBuffer _key85; // required
+ ByteBuffer _val86; // required
+ _key85 = iprot.readBinary();
+ _val86 = iprot.readBinary();
+ struct.attributes.put(_key85, _val86);
+ }
+ iprot.readMapEnd();
+ }
+ struct.setAttributesIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@@ -1012,9 +1136,9 @@ public class TScan implements org.apache
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.columns.size()));
- for (TColumn _iter43 : struct.columns)
+ for (TColumn _iter87 : struct.columns)
{
- _iter43.write(oprot);
+ _iter87.write(oprot);
}
oprot.writeListEnd();
}
@@ -1050,6 +1174,21 @@ public class TScan implements org.apache
oprot.writeI32(struct.batchSize);
oprot.writeFieldEnd();
}
+ if (struct.attributes != null) {
+ if (struct.isSetAttributes()) {
+ 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> _iter88 : struct.attributes.entrySet())
+ {
+ oprot.writeBinary(_iter88.getKey());
+ oprot.writeBinary(_iter88.getValue());
+ }
+ oprot.writeMapEnd();
+ }
+ oprot.writeFieldEnd();
+ }
+ }
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@@ -1092,7 +1231,10 @@ public class TScan implements org.apache
if (struct.isSetBatchSize()) {
optionals.set(7);
}
- oprot.writeBitSet(optionals, 8);
+ if (struct.isSetAttributes()) {
+ optionals.set(8);
+ }
+ oprot.writeBitSet(optionals, 9);
if (struct.isSetStartRow()) {
oprot.writeBinary(struct.startRow);
}
@@ -1102,9 +1244,9 @@ public class TScan implements org.apache
if (struct.isSetColumns()) {
{
oprot.writeI32(struct.columns.size());
- for (TColumn _iter44 : struct.columns)
+ for (TColumn _iter89 : struct.columns)
{
- _iter44.write(oprot);
+ _iter89.write(oprot);
}
}
}
@@ -1123,12 +1265,22 @@ public class TScan implements org.apache
if (struct.isSetBatchSize()) {
oprot.writeI32(struct.batchSize);
}
+ if (struct.isSetAttributes()) {
+ {
+ oprot.writeI32(struct.attributes.size());
+ for (Map.Entry<ByteBuffer, ByteBuffer> _iter90 : struct.attributes.entrySet())
+ {
+ oprot.writeBinary(_iter90.getKey());
+ oprot.writeBinary(_iter90.getValue());
+ }
+ }
+ }
}
@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(8);
+ BitSet incoming = iprot.readBitSet(9);
if (incoming.get(0)) {
struct.startRow = iprot.readBinary();
struct.setStartRowIsSet(true);
@@ -1139,14 +1291,14 @@ public class TScan implements org.apache
}
if (incoming.get(2)) {
{
- org.apache.thrift.protocol.TList _list45 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
- struct.columns = new ArrayList<TColumn>(_list45.size);
- for (int _i46 = 0; _i46 < _list45.size; ++_i46)
+ org.apache.thrift.protocol.TList _list91 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+ struct.columns = new ArrayList<TColumn>(_list91.size);
+ for (int _i92 = 0; _i92 < _list91.size; ++_i92)
{
- TColumn _elem47; // optional
- _elem47 = new TColumn();
- _elem47.read(iprot);
- struct.columns.add(_elem47);
+ TColumn _elem93; // required
+ _elem93 = new TColumn();
+ _elem93.read(iprot);
+ struct.columns.add(_elem93);
}
}
struct.setColumnsIsSet(true);
@@ -1172,6 +1324,21 @@ public class TScan implements org.apache
struct.batchSize = iprot.readI32();
struct.setBatchSizeIsSet(true);
}
+ if (incoming.get(8)) {
+ {
+ org.apache.thrift.protocol.TMap _map94 = 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*_map94.size);
+ for (int _i95 = 0; _i95 < _map94.size; ++_i95)
+ {
+ ByteBuffer _key96; // required
+ ByteBuffer _val97; // required
+ _key96 = iprot.readBinary();
+ _val97 = iprot.readBinary();
+ struct.attributes.put(_key96, _val97);
+ }
+ }
+ struct.setAttributesIsSet(true);
+ }
}
}
Modified: hbase/branches/0.95/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift?rev=1502432&r1=1502431&r2=1502432&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift (original)
+++ hbase/branches/0.95/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift Fri Jul 12 06:04:39 2013
@@ -98,7 +98,8 @@ struct TGet {
4: optional TTimeRange timeRange,
5: optional i32 maxVersions,
- 6: optional binary filterString
+ 6: optional binary filterString,
+ 7: optional map<binary, binary> attributes
}
/**
@@ -116,7 +117,8 @@ struct TPut {
1: required binary row,
2: required list<TColumnValue> columnValues
3: optional i64 timestamp,
- 4: optional bool writeToWal = 1
+ 4: optional bool writeToWal = 1,
+ 5: optional map<binary, binary> attributes
}
/**
@@ -147,7 +149,8 @@ struct TDelete {
2: optional list<TColumn> columns,
3: optional i64 timestamp,
4: optional TDeleteType deleteType = 1,
- 5: optional bool writeToWal = 1
+ 5: optional bool writeToWal = 1,
+ 6: optional map<binary, binary> attributes
}
/**
@@ -159,7 +162,8 @@ struct TDelete {
struct TIncrement {
1: required binary row,
2: required list<TColumnIncrement> columns,
- 3: optional bool writeToWal = 1
+ 3: optional bool writeToWal = 1,
+ 4: optional map<binary, binary> attributes
}
/**
@@ -174,7 +178,8 @@ struct TScan {
5: optional i32 maxVersions=1,
6: optional TTimeRange timeRange,
7: optional binary filterString,
- 8: optional i32 batchSize
+ 8: optional i32 batchSize,
+ 9: optional map<binary, binary> attributes
}
//
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java?rev=1502432&r1=1502431&r2=1502432&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java Fri Jul 12 06:04:39 2013
@@ -26,7 +26,12 @@ import org.apache.hadoop.hbase.HBaseTest
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MediumTests;
+import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Increment;
+import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.filter.ParseFilter;
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.thrift.ThriftMetrics;
@@ -57,7 +62,13 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import java.util.HashMap;
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.getFromThrift;
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.putFromThrift;
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.scanFromThrift;
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.incrementFromThrift;
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.deleteFromThrift;
import static org.junit.Assert.*;
import static java.nio.ByteBuffer.wrap;
@@ -694,5 +705,43 @@ public class TestThriftHBaseServiceHandl
return m;
}
+ @Test
+ public void testAttribute() throws Exception {
+ byte[] rowName = "testAttribute".getBytes();
+ byte[] attributeKey = "attribute1".getBytes();
+ byte[] attributeValue = "value1".getBytes();
+ Map<ByteBuffer, ByteBuffer> attributes = new HashMap<ByteBuffer, ByteBuffer>();
+ attributes.put(wrap(attributeKey), wrap(attributeValue));
+
+ TGet tGet = new TGet(wrap(rowName));
+ tGet.setAttributes(attributes);
+ Get get = getFromThrift(tGet);
+ assertArrayEquals(get.getAttribute("attribute1"), attributeValue);
+
+ List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
+ columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));
+ TPut tPut = new TPut(wrap(rowName) , columnValues);
+ tPut.setAttributes(attributes);
+ Put put = putFromThrift(tPut);
+ assertArrayEquals(put.getAttribute("attribute1"), attributeValue);
+
+ TScan tScan = new TScan();
+ tScan.setAttributes(attributes);
+ Scan scan = scanFromThrift(tScan);
+ assertArrayEquals(scan.getAttribute("attribute1"), attributeValue);
+
+ List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
+ incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
+ TIncrement tIncrement = new TIncrement(wrap(rowName), incrementColumns);
+ tIncrement.setAttributes(attributes);
+ Increment increment = incrementFromThrift(tIncrement);
+ assertArrayEquals(increment.getAttribute("attribute1"), attributeValue);
+
+ TDelete tDelete = new TDelete(wrap(rowName));
+ tDelete.setAttributes(attributes);
+ Delete delete = deleteFromThrift(tDelete);
+ assertArrayEquals(delete.getAttribute("attribute1"), attributeValue);
+ }
+
}