Repository: hbase
Updated Branches:
  refs/heads/branch-1 ec84118c9 -> 47872cec2


HBASE-17654 Add support for table.existsAll in thrift2 THBaseservice (Yechao 
Chen)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/47872cec
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/47872cec
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/47872cec

Branch: refs/heads/branch-1
Commit: 47872cec23ba2cf50b7232d4b4e01655a990ce51
Parents: ec84118
Author: tedyu <yuzhih...@gmail.com>
Authored: Mon Feb 27 08:44:58 2017 -0800
Committer: tedyu <yuzhih...@gmail.com>
Committed: Mon Feb 27 08:44:58 2017 -0800

----------------------------------------------------------------------
 .../thrift2/ThriftHBaseServiceHandler.java      |   18 +
 .../hbase/thrift2/generated/THBaseService.java  | 1148 ++++++++++++++++++
 .../apache/hadoop/hbase/thrift2/hbase.thrift    |   15 +
 .../thrift2/TestThriftHBaseServiceHandler.java  |   28 +
 4 files changed, 1209 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/47872cec/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java
----------------------------------------------------------------------
diff --git 
a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java
 
b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java
index 0165e79..b508a1f 100644
--- 
a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java
+++ 
b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java
@@ -39,6 +39,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.nio.ByteBuffer;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -251,6 +252,23 @@ public class ThriftHBaseServiceHandler implements 
THBaseService.Iface {
   }
 
   @Override
+  public List<Boolean> existsAll(ByteBuffer table, List<TGet> gets) throws 
TIOError, TException {
+    Table htable = getTable(table);
+    try {
+      boolean[] exists = htable.existsAll(getsFromThrift(gets));
+      List<Boolean> result = new ArrayList<>(exists.length);
+      for (boolean exist : exists) {
+        result.add(exist);
+      }
+      return result;
+    } catch (IOException e) {
+      throw getTIOError(e);
+    } finally {
+      closeTable(htable);
+    }
+  }
+
+  @Override
   public TResult get(ByteBuffer table, TGet get) throws TIOError, TException {
     Table htable = getTable(table);
     try {

http://git-wip-us.apache.org/repos/asf/hbase/blob/47872cec/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/THBaseService.java
----------------------------------------------------------------------
diff --git 
a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/THBaseService.java
 
b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/THBaseService.java
index 2dc7fc7..75ca93d 100644
--- 
a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/THBaseService.java
+++ 
b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/THBaseService.java
@@ -51,6 +51,18 @@ public class THBaseService {
     public boolean exists(ByteBuffer table, TGet tget) throws TIOError, 
org.apache.thrift.TException;
 
     /**
+     * Test for the existence of columns in the table, as specified by the 
TGets.
+     *
+     * This will return an array of booleans. Each value will be true if the 
related Get matches
+     * one or more keys, false if not.
+     *
+     * @param table the table to check on
+     *
+     * @param tgets a list of TGets to check for
+     */
+    public List<Boolean> existsAll(ByteBuffer table, List<TGet> tgets) throws 
TIOError, org.apache.thrift.TException;
+
+    /**
      * Method for getting data from a row.
      * 
      * If the row cannot be found an empty Result is returned.
@@ -276,6 +288,8 @@ public class THBaseService {
 
     public void exists(ByteBuffer table, TGet tget, 
org.apache.thrift.async.AsyncMethodCallback resultHandler) throws 
org.apache.thrift.TException;
 
+    public void existsAll(ByteBuffer table, List<TGet> tgets, 
org.apache.thrift.async.AsyncMethodCallback<AsyncClient.existsAll_call> 
resultHandler) throws org.apache.thrift.TException;
+
     public void get(ByteBuffer table, TGet tget, 
org.apache.thrift.async.AsyncMethodCallback resultHandler) throws 
org.apache.thrift.TException;
 
     public void getMultiple(ByteBuffer table, List<TGet> tgets, 
org.apache.thrift.async.AsyncMethodCallback resultHandler) throws 
org.apache.thrift.TException;
@@ -361,6 +375,33 @@ public class THBaseService {
       throw new 
org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT,
 "exists failed: unknown result");
     }
 
+    public List<Boolean> existsAll(ByteBuffer table, List<TGet> tgets) throws 
TIOError, org.apache.thrift.TException
+    {
+      send_existsAll(table, tgets);
+      return recv_existsAll();
+    }
+
+    public void send_existsAll(ByteBuffer table, List<TGet> tgets) throws 
org.apache.thrift.TException
+    {
+      existsAll_args args = new existsAll_args();
+      args.setTable(table);
+      args.setTgets(tgets);
+      sendBase("existsAll", args);
+    }
+
+    public List<Boolean> recv_existsAll() throws TIOError, 
org.apache.thrift.TException
+    {
+      existsAll_result result = new existsAll_result();
+      receiveBase(result, "existsAll");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.io != null) {
+        throw result.io;
+      }
+      throw new 
org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT,
 "existsAll failed: unknown result");
+    }
+
     public TResult get(ByteBuffer table, TGet tget) throws TIOError, 
org.apache.thrift.TException
     {
       send_get(table, tget);
@@ -904,6 +945,41 @@ public class THBaseService {
       }
     }
 
+    public void existsAll(ByteBuffer table, List<TGet> tgets, 
org.apache.thrift.async.AsyncMethodCallback<existsAll_call> resultHandler) 
throws org.apache.thrift.TException {
+      checkReady();
+      existsAll_call method_call = new existsAll_call(table, tgets, 
resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class existsAll_call extends 
org.apache.thrift.async.TAsyncMethodCall {
+      private ByteBuffer table;
+      private List<TGet> tgets;
+      public existsAll_call(ByteBuffer table, List<TGet> tgets, 
org.apache.thrift.async.AsyncMethodCallback<existsAll_call> resultHandler, 
org.apache.thrift.async.TAsyncClient client, 
org.apache.thrift.protocol.TProtocolFactory protocolFactory, 
org.apache.thrift.transport.TNonblockingTransport transport) throws 
org.apache.thrift.TException {
+        super(client, protocolFactory, transport, resultHandler, false);
+        this.table = table;
+        this.tgets = tgets;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws 
org.apache.thrift.TException {
+        prot.writeMessageBegin(new 
org.apache.thrift.protocol.TMessage("existsAll", 
org.apache.thrift.protocol.TMessageType.CALL, 0));
+        existsAll_args args = new existsAll_args();
+        args.setTable(table);
+        args.setTgets(tgets);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public List<Boolean> getResult() throws TIOError, 
org.apache.thrift.TException {
+        if (getState() != 
org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
+          throw new IllegalStateException("Method call not finished!");
+        }
+        org.apache.thrift.transport.TMemoryInputTransport memoryTransport = 
new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
+        org.apache.thrift.protocol.TProtocol prot = 
client.getProtocolFactory().getProtocol(memoryTransport);
+        return (new Client(prot)).recv_existsAll();
+      }
+    }
+
     public void get(ByteBuffer table, TGet tget, 
org.apache.thrift.async.AsyncMethodCallback resultHandler) throws 
org.apache.thrift.TException {
       checkReady();
       get_call method_call = new get_call(table, tget, resultHandler, this, 
___protocolFactory, ___transport);
@@ -1587,6 +1663,7 @@ public class THBaseService {
 
     private static <I extends Iface> Map<String,  
org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> 
getProcessMap(Map<String,  org.apache.thrift.ProcessFunction<I, ? extends  
org.apache.thrift.TBase>> processMap) {
       processMap.put("exists", new exists());
+      processMap.put("existsAll", new existsAll());
       processMap.put("get", new get());
       processMap.put("getMultiple", new getMultiple());
       processMap.put("put", new put());
@@ -1633,6 +1710,29 @@ public class THBaseService {
       }
     }
 
+    public static class existsAll<I extends Iface> extends 
org.apache.thrift.ProcessFunction<I, existsAll_args> {
+      public existsAll() {
+        super("existsAll");
+      }
+
+      public existsAll_args getEmptyArgsInstance() {
+        return new existsAll_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public existsAll_result getResult(I iface, existsAll_args args) throws 
org.apache.thrift.TException {
+        existsAll_result result = new existsAll_result();
+        try {
+          result.success = iface.existsAll(args.table, args.tgets);
+        } catch (TIOError io) {
+          result.io = io;
+        }
+        return result;
+      }
+    }
     public static class get<I extends Iface> extends 
org.apache.thrift.ProcessFunction<I, get_args> {
       public get() {
         super("get");
@@ -4165,6 +4265,1054 @@ public class THBaseService {
 
   }
 
+  public static class existsAll_args implements 
org.apache.thrift.TBase<existsAll_args, existsAll_args._Fields>, 
java.io.Serializable, Cloneable {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new 
org.apache.thrift.protocol.TStruct("existsAll_args");
+
+    private static final org.apache.thrift.protocol.TField TABLE_FIELD_DESC = 
new org.apache.thrift.protocol.TField("table", 
org.apache.thrift.protocol.TType.STRING, (short) 1);
+    private static final org.apache.thrift.protocol.TField TGETS_FIELD_DESC = 
new org.apache.thrift.protocol.TField("tgets", 
org.apache.thrift.protocol.TType.LIST, (short) 2);
+
+    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes 
= new HashMap<Class<? extends IScheme>, SchemeFactory>();
+
+    static {
+      schemes.put(StandardScheme.class, new 
existsAll_argsStandardSchemeFactory());
+      schemes.put(TupleScheme.class, new existsAll_argsTupleSchemeFactory());
+    }
+
+    /**
+     * the table to check on
+     */
+    public ByteBuffer table; // required
+    /**
+     * a list of TGets to check for
+     */
+    public List<TGet> tgets; // required
+
+    /**
+     * The set of fields this struct contains, along with convenience methods 
for finding and manipulating them.
+     */
+    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+      /**
+       * the table to check on
+       */
+      TABLE((short) 1, "table"),
+      /**
+       * a list of TGets to check for
+       */
+      TGETS((short) 2, "tgets");
+
+      private static final Map<String, _Fields> byName = new HashMap<String, 
_Fields>();
+
+      static {
+        for (_Fields field : EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not 
found.
+       */
+      public static _Fields findByThriftId(int fieldId) {
+        switch (fieldId) {
+          case 1: // TABLE
+            return TABLE;
+          case 2: // TGETS
+            return TGETS;
+          default:
+            return null;
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, throwing an exception
+       * if it is not found.
+       */
+      public static _Fields findByThriftIdOrThrow(int fieldId) {
+        _Fields fields = findByThriftId(fieldId);
+        if (fields == null) throw new IllegalArgumentException("Field " + 
fieldId + " doesn't exist!");
+        return fields;
+      }
+
+      /**
+       * Find the _Fields constant that matches name, or null if its not found.
+       */
+      public static _Fields findByName(String name) {
+        return byName.get(name);
+      }
+
+      private final short _thriftId;
+      private final String _fieldName;
+
+      _Fields(short thriftId, String fieldName) {
+        _thriftId = thriftId;
+        _fieldName = fieldName;
+      }
+
+      public short getThriftFieldId() {
+        return _thriftId;
+      }
+
+      public String getFieldName() {
+        return _fieldName;
+      }
+    }
+
+    // isset id assignments
+    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.TABLE, new 
org.apache.thrift.meta_data.FieldMetaData("table", 
org.apache.thrift.TFieldRequirementType.REQUIRED,
+              new 
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING,
 true)));
+      tmpMap.put(_Fields.TGETS, new 
org.apache.thrift.meta_data.FieldMetaData("tgets", 
org.apache.thrift.TFieldRequirementType.REQUIRED,
+              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,
 TGet.class))));
+      metaDataMap = Collections.unmodifiableMap(tmpMap);
+      
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(existsAll_args.class,
 metaDataMap);
+    }
+
+    public existsAll_args() {
+    }
+
+    public existsAll_args(
+            ByteBuffer table,
+            List<TGet> tgets) {
+      this();
+      this.table = table;
+      this.tgets = tgets;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public existsAll_args(existsAll_args other) {
+      if (other.isSetTable()) {
+        this.table = org.apache.thrift.TBaseHelper.copyBinary(other.table);
+        ;
+      }
+      if (other.isSetTgets()) {
+        List<TGet> __this__tgets = new ArrayList<TGet>();
+        for (TGet other_element : other.tgets) {
+          __this__tgets.add(new TGet(other_element));
+        }
+        this.tgets = __this__tgets;
+      }
+    }
+
+    public existsAll_args deepCopy() {
+      return new existsAll_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.table = null;
+      this.tgets = null;
+    }
+
+    /**
+     * the table to check on
+     */
+    public byte[] getTable() {
+      setTable(org.apache.thrift.TBaseHelper.rightSize(table));
+      return table == null ? null : table.array();
+    }
+
+    public ByteBuffer bufferForTable() {
+      return table;
+    }
+
+    /**
+     * the table to check on
+     */
+    public existsAll_args setTable(byte[] table) {
+      setTable(table == null ? (ByteBuffer) null : ByteBuffer.wrap(table));
+      return this;
+    }
+
+    public existsAll_args setTable(ByteBuffer table) {
+      this.table = table;
+      return this;
+    }
+
+    public void unsetTable() {
+      this.table = null;
+    }
+
+    /**
+     * Returns true if field table is set (has been assigned a value) and 
false otherwise
+     */
+    public boolean isSetTable() {
+      return this.table != null;
+    }
+
+    public void setTableIsSet(boolean value) {
+      if (!value) {
+        this.table = null;
+      }
+    }
+
+    public int getTgetsSize() {
+      return (this.tgets == null) ? 0 : this.tgets.size();
+    }
+
+    public java.util.Iterator<TGet> getTgetsIterator() {
+      return (this.tgets == null) ? null : this.tgets.iterator();
+    }
+
+    public void addToTgets(TGet elem) {
+      if (this.tgets == null) {
+        this.tgets = new ArrayList<TGet>();
+      }
+      this.tgets.add(elem);
+    }
+
+    /**
+     * a list of TGets to check for
+     */
+    public List<TGet> getTgets() {
+      return this.tgets;
+    }
+
+    /**
+     * a list of TGets to check for
+     */
+    public existsAll_args setTgets(List<TGet> tgets) {
+      this.tgets = tgets;
+      return this;
+    }
+
+    public void unsetTgets() {
+      this.tgets = null;
+    }
+
+    /**
+     * Returns true if field tgets is set (has been assigned a value) and 
false otherwise
+     */
+    public boolean isSetTgets() {
+      return this.tgets != null;
+    }
+
+    public void setTgetsIsSet(boolean value) {
+      if (!value) {
+        this.tgets = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, Object value) {
+      switch (field) {
+        case TABLE:
+          if (value == null) {
+            unsetTable();
+          } else {
+            setTable((ByteBuffer) value);
+          }
+          break;
+
+        case TGETS:
+          if (value == null) {
+            unsetTgets();
+          } else {
+            setTgets((List<TGet>) value);
+          }
+          break;
+
+      }
+    }
+
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+        case TABLE:
+          return getTable();
+
+        case TGETS:
+          return getTgets();
+
+      }
+      throw new IllegalStateException();
+    }
+
+    /**
+     * Returns true if field corresponding to fieldID is set (has been 
assigned a value) and false otherwise
+     */
+    public boolean isSet(_Fields field) {
+      if (field == null) {
+        throw new IllegalArgumentException();
+      }
+
+      switch (field) {
+        case TABLE:
+          return isSetTable();
+        case TGETS:
+          return isSetTgets();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof existsAll_args)
+        return this.equals((existsAll_args) that);
+      return false;
+    }
+
+    public boolean equals(existsAll_args that) {
+      if (that == null)
+        return false;
+
+      boolean this_present_table = true && this.isSetTable();
+      boolean that_present_table = true && that.isSetTable();
+      if (this_present_table || that_present_table) {
+        if (!(this_present_table && that_present_table))
+          return false;
+        if (!this.table.equals(that.table))
+          return false;
+      }
+
+      boolean this_present_tgets = true && this.isSetTgets();
+      boolean that_present_tgets = true && that.isSetTgets();
+      if (this_present_tgets || that_present_tgets) {
+        if (!(this_present_tgets && that_present_tgets))
+          return false;
+        if (!this.tgets.equals(that.tgets))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      return 0;
+    }
+
+    public int compareTo(existsAll_args other) {
+      if (!getClass().equals(other.getClass())) {
+        return getClass().getName().compareTo(other.getClass().getName());
+      }
+
+      int lastComparison = 0;
+      existsAll_args typedOther = (existsAll_args) other;
+
+      lastComparison = 
Boolean.valueOf(isSetTable()).compareTo(typedOther.isSetTable());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetTable()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.table, 
typedOther.table);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      lastComparison = 
Boolean.valueOf(isSetTgets()).compareTo(typedOther.isSetTgets());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetTgets()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tgets, 
typedOther.tgets);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws 
org.apache.thrift.TException {
+      schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws 
org.apache.thrift.TException {
+      schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("existsAll_args(");
+      boolean first = true;
+
+      sb.append("table:");
+      if (this.table == null) {
+        sb.append("null");
+      } else {
+        org.apache.thrift.TBaseHelper.toString(this.table, sb);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("tgets:");
+      if (this.tgets == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.tgets);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      if (table == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required 
field 'table' was not present! Struct: " + toString());
+      }
+      if (tgets == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required 
field 'tgets' was not present! Struct: " + toString());
+      }
+      // check for sub-struct validity
+    }
+
+    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) {
+        throw new java.io.IOException(te);
+      }
+    }
+
+    private void readObject(java.io.ObjectInputStream in) throws 
java.io.IOException, ClassNotFoundException {
+      try {
+        read(new org.apache.thrift.protocol.TCompactProtocol(new 
org.apache.thrift.transport.TIOStreamTransport(in)));
+      } catch (org.apache.thrift.TException te) {
+        throw new java.io.IOException(te);
+      }
+    }
+
+    private static class existsAll_argsStandardSchemeFactory implements 
SchemeFactory {
+      public existsAll_argsStandardScheme getScheme() {
+        return new existsAll_argsStandardScheme();
+      }
+    }
+
+    private static class existsAll_argsStandardScheme extends 
StandardScheme<existsAll_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, 
existsAll_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TField schemeField;
+        iprot.readStructBegin();
+        while (true) {
+          schemeField = iprot.readFieldBegin();
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+            break;
+          }
+          switch (schemeField.id) {
+            case 1: // TABLE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) 
{
+                struct.table = iprot.readBinary();
+                struct.setTableIsSet(true);
+              } else {
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, 
schemeField.type);
+              }
+              break;
+            case 2: // TGETS
+              if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
+                {
+                  org.apache.thrift.protocol.TList _list132 = 
iprot.readListBegin();
+                  struct.tgets = new ArrayList<TGet>(_list132.size);
+                  for (int _i133 = 0; _i133 < _list132.size; ++_i133) {
+                    TGet _elem134; // required
+                    _elem134 = new TGet();
+                    _elem134.read(iprot);
+                    struct.tgets.add(_elem134);
+                  }
+                  iprot.readListEnd();
+                }
+                struct.setTgetsIsSet(true);
+              } else {
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, 
schemeField.type);
+              }
+              break;
+            default:
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, 
schemeField.type);
+          }
+          iprot.readFieldEnd();
+        }
+        iprot.readStructEnd();
+
+        // check for required fields of primitive type, which can't be checked 
in the validate method
+        struct.validate();
+      }
+
+      public void write(org.apache.thrift.protocol.TProtocol oprot, 
existsAll_args struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.table != null) {
+          oprot.writeFieldBegin(TABLE_FIELD_DESC);
+          oprot.writeBinary(struct.table);
+          oprot.writeFieldEnd();
+        }
+        if (struct.tgets != null) {
+          oprot.writeFieldBegin(TGETS_FIELD_DESC);
+          {
+            oprot.writeListBegin(new 
org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, 
struct.tgets.size()));
+            for (TGet _iter135 : struct.tgets) {
+              _iter135.write(oprot);
+            }
+            oprot.writeListEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class existsAll_argsTupleSchemeFactory implements 
SchemeFactory {
+      public existsAll_argsTupleScheme getScheme() {
+        return new existsAll_argsTupleScheme();
+      }
+    }
+
+    private static class existsAll_argsTupleScheme extends 
TupleScheme<existsAll_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, 
existsAll_args struct) throws org.apache.thrift.TException {
+        TTupleProtocol oprot = (TTupleProtocol) prot;
+        oprot.writeBinary(struct.table);
+        {
+          oprot.writeI32(struct.tgets.size());
+          for (TGet _iter136 : struct.tgets) {
+            _iter136.write(oprot);
+          }
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, 
existsAll_args struct) throws org.apache.thrift.TException {
+        TTupleProtocol iprot = (TTupleProtocol) prot;
+        struct.table = iprot.readBinary();
+        struct.setTableIsSet(true);
+        {
+          org.apache.thrift.protocol.TList _list137 = new 
org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, 
iprot.readI32());
+          struct.tgets = new ArrayList<TGet>(_list137.size);
+          for (int _i138 = 0; _i138 < _list137.size; ++_i138) {
+            TGet _elem139; // required
+            _elem139 = new TGet();
+            _elem139.read(iprot);
+            struct.tgets.add(_elem139);
+          }
+        }
+        struct.setTgetsIsSet(true);
+      }
+    }
+
+  }
+
+  public static class existsAll_result implements 
org.apache.thrift.TBase<existsAll_result, existsAll_result._Fields>, 
java.io.Serializable, Cloneable {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new 
org.apache.thrift.protocol.TStruct("existsAll_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC 
= new org.apache.thrift.protocol.TField("success", 
org.apache.thrift.protocol.TType.LIST, (short) 0);
+    private static final org.apache.thrift.protocol.TField IO_FIELD_DESC = new 
org.apache.thrift.protocol.TField("io", 
org.apache.thrift.protocol.TType.STRUCT, (short) 1);
+
+    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes 
= new HashMap<Class<? extends IScheme>, SchemeFactory>();
+
+    static {
+      schemes.put(StandardScheme.class, new 
existsAll_resultStandardSchemeFactory());
+      schemes.put(TupleScheme.class, new existsAll_resultTupleSchemeFactory());
+    }
+
+    public List<Boolean> success; // required
+    public TIOError io; // required
+
+    /**
+     * The set of fields this struct contains, along with convenience methods 
for finding and manipulating them.
+     */
+    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+      SUCCESS((short) 0, "success"),
+      IO((short) 1, "io");
+
+      private static final Map<String, _Fields> byName = new HashMap<String, 
_Fields>();
+
+      static {
+        for (_Fields field : EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not 
found.
+       */
+      public static _Fields findByThriftId(int fieldId) {
+        switch (fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // IO
+            return IO;
+          default:
+            return null;
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, throwing an exception
+       * if it is not found.
+       */
+      public static _Fields findByThriftIdOrThrow(int fieldId) {
+        _Fields fields = findByThriftId(fieldId);
+        if (fields == null) throw new IllegalArgumentException("Field " + 
fieldId + " doesn't exist!");
+        return fields;
+      }
+
+      /**
+       * Find the _Fields constant that matches name, or null if its not found.
+       */
+      public static _Fields findByName(String name) {
+        return byName.get(name);
+      }
+
+      private final short _thriftId;
+      private final String _fieldName;
+
+      _Fields(short thriftId, String fieldName) {
+        _thriftId = thriftId;
+        _fieldName = fieldName;
+      }
+
+      public short getThriftFieldId() {
+        return _thriftId;
+      }
+
+      public String getFieldName() {
+        return _fieldName;
+      }
+    }
+
+    // isset id assignments
+    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.SUCCESS, new 
org.apache.thrift.meta_data.FieldMetaData("success", 
org.apache.thrift.TFieldRequirementType.DEFAULT,
+              new 
org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+                      new 
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))));
+      tmpMap.put(_Fields.IO, new 
org.apache.thrift.meta_data.FieldMetaData("io", 
org.apache.thrift.TFieldRequirementType.DEFAULT,
+              new 
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
+      metaDataMap = Collections.unmodifiableMap(tmpMap);
+      
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(existsAll_result.class,
 metaDataMap);
+    }
+
+    public existsAll_result() {
+    }
+
+    public existsAll_result(
+            List<Boolean> success,
+            TIOError io) {
+      this();
+      this.success = success;
+      this.io = io;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public existsAll_result(existsAll_result other) {
+      if (other.isSetSuccess()) {
+        List<Boolean> __this__success = new ArrayList<Boolean>();
+        for (Boolean other_element : other.success) {
+          __this__success.add(other_element);
+        }
+        this.success = __this__success;
+      }
+      if (other.isSetIo()) {
+        this.io = new TIOError(other.io);
+      }
+    }
+
+    public existsAll_result deepCopy() {
+      return new existsAll_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.io = null;
+    }
+
+    public int getSuccessSize() {
+      return (this.success == null) ? 0 : this.success.size();
+    }
+
+    public java.util.Iterator<Boolean> getSuccessIterator() {
+      return (this.success == null) ? null : this.success.iterator();
+    }
+
+    public void addToSuccess(boolean elem) {
+      if (this.success == null) {
+        this.success = new ArrayList<Boolean>();
+      }
+      this.success.add(elem);
+    }
+
+    public List<Boolean> getSuccess() {
+      return this.success;
+    }
+
+    public existsAll_result setSuccess(List<Boolean> success) {
+      this.success = success;
+      return this;
+    }
+
+    public void unsetSuccess() {
+      this.success = null;
+    }
+
+    /**
+     * Returns true if field success is set (has been assigned a value) and 
false otherwise
+     */
+    public boolean isSetSuccess() {
+      return this.success != null;
+    }
+
+    public void setSuccessIsSet(boolean value) {
+      if (!value) {
+        this.success = null;
+      }
+    }
+
+    public TIOError getIo() {
+      return this.io;
+    }
+
+    public existsAll_result setIo(TIOError io) {
+      this.io = io;
+      return this;
+    }
+
+    public void unsetIo() {
+      this.io = null;
+    }
+
+    /**
+     * Returns true if field io is set (has been assigned a value) and false 
otherwise
+     */
+    public boolean isSetIo() {
+      return this.io != null;
+    }
+
+    public void setIoIsSet(boolean value) {
+      if (!value) {
+        this.io = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, Object value) {
+      switch (field) {
+        case SUCCESS:
+          if (value == null) {
+            unsetSuccess();
+          } else {
+            setSuccess((List<Boolean>) value);
+          }
+          break;
+
+        case IO:
+          if (value == null) {
+            unsetIo();
+          } else {
+            setIo((TIOError) value);
+          }
+          break;
+
+      }
+    }
+
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+        case SUCCESS:
+          return getSuccess();
+
+        case IO:
+          return getIo();
+
+      }
+      throw new IllegalStateException();
+    }
+
+    /**
+     * Returns true if field corresponding to fieldID is set (has been 
assigned a value) and false otherwise
+     */
+    public boolean isSet(_Fields field) {
+      if (field == null) {
+        throw new IllegalArgumentException();
+      }
+
+      switch (field) {
+        case SUCCESS:
+          return isSetSuccess();
+        case IO:
+          return isSetIo();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof existsAll_result)
+        return this.equals((existsAll_result) that);
+      return false;
+    }
+
+    public boolean equals(existsAll_result that) {
+      if (that == null)
+        return false;
+
+      boolean this_present_success = true && this.isSetSuccess();
+      boolean that_present_success = true && that.isSetSuccess();
+      if (this_present_success || that_present_success) {
+        if (!(this_present_success && that_present_success))
+          return false;
+        if (!this.success.equals(that.success))
+          return false;
+      }
+
+      boolean this_present_io = true && this.isSetIo();
+      boolean that_present_io = true && that.isSetIo();
+      if (this_present_io || that_present_io) {
+        if (!(this_present_io && that_present_io))
+          return false;
+        if (!this.io.equals(that.io))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      return 0;
+    }
+
+    public int compareTo(existsAll_result other) {
+      if (!getClass().equals(other.getClass())) {
+        return getClass().getName().compareTo(other.getClass().getName());
+      }
+
+      int lastComparison = 0;
+      existsAll_result typedOther = (existsAll_result) other;
+
+      lastComparison = 
Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetSuccess()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, 
typedOther.success);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      lastComparison = 
Boolean.valueOf(isSetIo()).compareTo(typedOther.isSetIo());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIo()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.io, 
typedOther.io);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws 
org.apache.thrift.TException {
+      schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws 
org.apache.thrift.TException {
+      schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("existsAll_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      if (this.success == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.success);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("io:");
+      if (this.io == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.io);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      // check for sub-struct validity
+    }
+
+    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) {
+        throw new java.io.IOException(te);
+      }
+    }
+
+    private void readObject(java.io.ObjectInputStream in) throws 
java.io.IOException, ClassNotFoundException {
+      try {
+        read(new org.apache.thrift.protocol.TCompactProtocol(new 
org.apache.thrift.transport.TIOStreamTransport(in)));
+      } catch (org.apache.thrift.TException te) {
+        throw new java.io.IOException(te);
+      }
+    }
+
+    private static class existsAll_resultStandardSchemeFactory implements 
SchemeFactory {
+      public existsAll_resultStandardScheme getScheme() {
+        return new existsAll_resultStandardScheme();
+      }
+    }
+
+    private static class existsAll_resultStandardScheme extends 
StandardScheme<existsAll_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, 
existsAll_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TField schemeField;
+        iprot.readStructBegin();
+        while (true) {
+          schemeField = iprot.readFieldBegin();
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+            break;
+          }
+          switch (schemeField.id) {
+            case 0: // SUCCESS
+              if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
+                {
+                  org.apache.thrift.protocol.TList _list140 = 
iprot.readListBegin();
+                  struct.success = new ArrayList<Boolean>(_list140.size);
+                  for (int _i141 = 0; _i141 < _list140.size; ++_i141) {
+                    boolean _elem142; // required
+                    _elem142 = iprot.readBool();
+                    struct.success.add(_elem142);
+                  }
+                  iprot.readListEnd();
+                }
+                struct.setSuccessIsSet(true);
+              } else {
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, 
schemeField.type);
+              }
+              break;
+            case 1: // IO
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) 
{
+                struct.io = new TIOError();
+                struct.io.read(iprot);
+                struct.setIoIsSet(true);
+              } else {
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, 
schemeField.type);
+              }
+              break;
+            default:
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, 
schemeField.type);
+          }
+          iprot.readFieldEnd();
+        }
+        iprot.readStructEnd();
+
+        // check for required fields of primitive type, which can't be checked 
in the validate method
+        struct.validate();
+      }
+
+      public void write(org.apache.thrift.protocol.TProtocol oprot, 
existsAll_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.success != null) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          {
+            oprot.writeListBegin(new 
org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.BOOL, 
struct.success.size()));
+            for (boolean _iter143 : struct.success) {
+              oprot.writeBool(_iter143);
+            }
+            oprot.writeListEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+        if (struct.io != null) {
+          oprot.writeFieldBegin(IO_FIELD_DESC);
+          struct.io.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class existsAll_resultTupleSchemeFactory implements 
SchemeFactory {
+      public existsAll_resultTupleScheme getScheme() {
+        return new existsAll_resultTupleScheme();
+      }
+    }
+
+    private static class existsAll_resultTupleScheme extends 
TupleScheme<existsAll_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, 
existsAll_result struct) throws org.apache.thrift.TException {
+        TTupleProtocol oprot = (TTupleProtocol) prot;
+        BitSet optionals = new BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetIo()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          {
+            oprot.writeI32(struct.success.size());
+            for (boolean _iter144 : struct.success) {
+              oprot.writeBool(_iter144);
+            }
+          }
+        }
+        if (struct.isSetIo()) {
+          struct.io.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, 
existsAll_result struct) throws org.apache.thrift.TException {
+        TTupleProtocol iprot = (TTupleProtocol) prot;
+        BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          {
+            org.apache.thrift.protocol.TList _list145 = new 
org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.BOOL, 
iprot.readI32());
+            struct.success = new ArrayList<Boolean>(_list145.size);
+            for (int _i146 = 0; _i146 < _list145.size; ++_i146) {
+              boolean _elem147; // required
+              _elem147 = iprot.readBool();
+              struct.success.add(_elem147);
+            }
+          }
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.io = new TIOError();
+          struct.io.read(iprot);
+          struct.setIoIsSet(true);
+        }
+      }
+    }
+
+  }
+
   public static class get_args implements org.apache.thrift.TBase<get_args, 
get_args._Fields>, java.io.Serializable, Cloneable, Comparable<get_args>   {
     private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new 
org.apache.thrift.protocol.TStruct("get_args");
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/47872cec/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
----------------------------------------------------------------------
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 00f0203..96fe4f7 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
@@ -315,6 +315,21 @@ service THBaseService {
     2: required TGet tget
   ) throws (1:TIOError io)
 
+
+  /**
+  * Test for the existence of columns in the table, as specified by the TGets.
+  *
+  * This will return an array of booleans. Each value will be true if the 
related Get matches
+  * one or more keys, false if not.
+  */
+  list<bool> existsAll(
+    /** the table to check on */
+    1: required binary table,
+
+    /** a list of TGets to check for */
+    2: required list<TGet> tgets
+  ) throws (1:TIOError io)
+
   /**
    * Method for getting data from a row.
    *

http://git-wip-us.apache.org/repos/asf/hbase/blob/47872cec/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
----------------------------------------------------------------------
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 4591c78..3b0a3f1 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
@@ -201,6 +201,34 @@ public class TestThriftHBaseServiceHandler {
   }
 
   @Test
+  public void testExistsAll() throws TIOError, TException {
+    ThriftHBaseServiceHandler handler = createHandler();
+    byte[] rowName1 = "testExistsAll1".getBytes();
+    byte[] rowName2 = "testExistsAll2".getBytes();
+    ByteBuffer table = wrap(tableAname);
+
+    List<TGet> gets = new ArrayList<>();
+    gets.add(new TGet(wrap(rowName2)));
+    gets.add(new TGet(wrap(rowName2)));
+    List<Boolean> existsResult1 = handler.existsAll(table, gets);
+    assertFalse(existsResult1.get(0));
+    assertFalse(existsResult1.get(1));
+
+    List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
+    columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), 
wrap(valueAname)));
+    columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), 
wrap(valueBname)));
+    List<TPut> puts = new ArrayList<TPut>();
+    puts.add(new TPut(wrap(rowName1), columnValues));
+    puts.add(new TPut(wrap(rowName2), columnValues));
+
+    handler.putMultiple(table, puts);
+    List<Boolean> existsResult2 = handler.existsAll(table,gets );
+
+    assertTrue(existsResult2.get(0));
+    assertTrue(existsResult2.get(1));
+  }
+
+  @Test
   public void testPutGet() throws Exception {
     ThriftHBaseServiceHandler handler = createHandler();
     byte[] rowName = "testPutGet".getBytes();

Reply via email to