/**
 * Autogenerated by Thrift Compiler (0.11.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package edu.cmu.lti.oaqa.similarity;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-11-03")
public class QueryService {

  public interface Iface {

    public void setQueryTimeParams(java.lang.String queryTimeParams) throws QueryException, org.apache.thrift.TException;

    public java.util.List<ReplyEntry> knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws QueryException, org.apache.thrift.TException;

    public java.util.List<ReplyEntry> rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws QueryException, org.apache.thrift.TException;

    public java.util.List<java.util.List<ReplyEntry>> knnQueryBatch(int k, java.util.List<java.nio.ByteBuffer> queryObj, boolean retExternId, boolean retObj, int numThreads) throws QueryException, org.apache.thrift.TException;

    public double getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2) throws QueryException, org.apache.thrift.TException;

  }

  public interface AsyncIface {

    public void setQueryTimeParams(java.lang.String queryTimeParams, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException;

    public void knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException;

    public void rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException;

    public void knnQueryBatch(int k, java.util.List<java.nio.ByteBuffer> queryObj, boolean retExternId, boolean retObj, int numThreads, org.apache.thrift.async.AsyncMethodCallback<java.util.List<java.util.List<ReplyEntry>>> resultHandler) throws org.apache.thrift.TException;

    public void getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2, org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> resultHandler) throws org.apache.thrift.TException;

  }

  public static class Client extends org.apache.thrift.TServiceClient implements Iface {
    public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
      public Factory() {}
      public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
        return new Client(prot);
      }
      public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
        return new Client(iprot, oprot);
      }
    }

    public Client(org.apache.thrift.protocol.TProtocol prot)
    {
      super(prot, prot);
    }

    public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
      super(iprot, oprot);
    }

    public void setQueryTimeParams(java.lang.String queryTimeParams) throws QueryException, org.apache.thrift.TException
    {
      send_setQueryTimeParams(queryTimeParams);
      recv_setQueryTimeParams();
    }

    public void send_setQueryTimeParams(java.lang.String queryTimeParams) throws org.apache.thrift.TException
    {
      setQueryTimeParams_args args = new setQueryTimeParams_args();
      args.setQueryTimeParams(queryTimeParams);
      sendBase("setQueryTimeParams", args);
    }

    public void recv_setQueryTimeParams() throws QueryException, org.apache.thrift.TException
    {
      setQueryTimeParams_result result = new setQueryTimeParams_result();
      receiveBase(result, "setQueryTimeParams");
      if (result.err != null) {
        throw result.err;
      }
      return;
    }

    public java.util.List<ReplyEntry> knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws QueryException, org.apache.thrift.TException
    {
      send_knnQuery(k, queryObj, retExternId, retObj);
      return recv_knnQuery();
    }

    public void send_knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws org.apache.thrift.TException
    {
      knnQuery_args args = new knnQuery_args();
      args.setK(k);
      args.setQueryObj(queryObj);
      args.setRetExternId(retExternId);
      args.setRetObj(retObj);
      sendBase("knnQuery", args);
    }

    public java.util.List<ReplyEntry> recv_knnQuery() throws QueryException, org.apache.thrift.TException
    {
      knnQuery_result result = new knnQuery_result();
      receiveBase(result, "knnQuery");
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.err != null) {
        throw result.err;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "knnQuery failed: unknown result");
    }

    public java.util.List<ReplyEntry> rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws QueryException, org.apache.thrift.TException
    {
      send_rangeQuery(r, queryObj, retExternId, retObj);
      return recv_rangeQuery();
    }

    public void send_rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws org.apache.thrift.TException
    {
      rangeQuery_args args = new rangeQuery_args();
      args.setR(r);
      args.setQueryObj(queryObj);
      args.setRetExternId(retExternId);
      args.setRetObj(retObj);
      sendBase("rangeQuery", args);
    }

    public java.util.List<ReplyEntry> recv_rangeQuery() throws QueryException, org.apache.thrift.TException
    {
      rangeQuery_result result = new rangeQuery_result();
      receiveBase(result, "rangeQuery");
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.err != null) {
        throw result.err;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "rangeQuery failed: unknown result");
    }

    public java.util.List<java.util.List<ReplyEntry>> knnQueryBatch(int k, java.util.List<java.nio.ByteBuffer> queryObj, boolean retExternId, boolean retObj, int numThreads) throws QueryException, org.apache.thrift.TException
    {
      send_knnQueryBatch(k, queryObj, retExternId, retObj, numThreads);
      return recv_knnQueryBatch();
    }

    public void send_knnQueryBatch(int k, java.util.List<java.nio.ByteBuffer> queryObj, boolean retExternId, boolean retObj, int numThreads) throws org.apache.thrift.TException
    {
      knnQueryBatch_args args = new knnQueryBatch_args();
      args.setK(k);
      args.setQueryObj(queryObj);
      args.setRetExternId(retExternId);
      args.setRetObj(retObj);
      args.setNumThreads(numThreads);
      sendBase("knnQueryBatch", args);
    }

    public java.util.List<java.util.List<ReplyEntry>> recv_knnQueryBatch() throws QueryException, org.apache.thrift.TException
    {
      knnQueryBatch_result result = new knnQueryBatch_result();
      receiveBase(result, "knnQueryBatch");
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.err != null) {
        throw result.err;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "knnQueryBatch failed: unknown result");
    }

    public double getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2) throws QueryException, org.apache.thrift.TException
    {
      send_getDistance(obj1, obj2);
      return recv_getDistance();
    }

    public void send_getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2) throws org.apache.thrift.TException
    {
      getDistance_args args = new getDistance_args();
      args.setObj1(obj1);
      args.setObj2(obj2);
      sendBase("getDistance", args);
    }

    public double recv_getDistance() throws QueryException, org.apache.thrift.TException
    {
      getDistance_result result = new getDistance_result();
      receiveBase(result, "getDistance");
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.err != null) {
        throw result.err;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getDistance failed: unknown result");
    }

  }
  public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
    public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
      private org.apache.thrift.async.TAsyncClientManager clientManager;
      private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
      public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
        this.clientManager = clientManager;
        this.protocolFactory = protocolFactory;
      }
      public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
        return new AsyncClient(protocolFactory, clientManager, transport);
      }
    }

    public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
      super(protocolFactory, clientManager, transport);
    }

    public void setQueryTimeParams(java.lang.String queryTimeParams, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException {
      checkReady();
      setQueryTimeParams_call method_call = new setQueryTimeParams_call(queryTimeParams, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class setQueryTimeParams_call extends org.apache.thrift.async.TAsyncMethodCall<Void> {
      private java.lang.String queryTimeParams;
      public setQueryTimeParams_call(java.lang.String queryTimeParams, org.apache.thrift.async.AsyncMethodCallback<Void> 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.queryTimeParams = queryTimeParams;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("setQueryTimeParams", org.apache.thrift.protocol.TMessageType.CALL, 0));
        setQueryTimeParams_args args = new setQueryTimeParams_args();
        args.setQueryTimeParams(queryTimeParams);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public Void getResult() throws QueryException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new java.lang.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 null;
      }
    }

    public void knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException {
      checkReady();
      knnQuery_call method_call = new knnQuery_call(k, queryObj, retExternId, retObj, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class knnQuery_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<ReplyEntry>> {
      private int k;
      private java.nio.ByteBuffer queryObj;
      private boolean retExternId;
      private boolean retObj;
      public knnQuery_call(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> 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.k = k;
        this.queryObj = queryObj;
        this.retExternId = retExternId;
        this.retObj = retObj;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("knnQuery", org.apache.thrift.protocol.TMessageType.CALL, 0));
        knnQuery_args args = new knnQuery_args();
        args.setK(k);
        args.setQueryObj(queryObj);
        args.setRetExternId(retExternId);
        args.setRetObj(retObj);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public java.util.List<ReplyEntry> getResult() throws QueryException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new java.lang.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_knnQuery();
      }
    }

    public void rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException {
      checkReady();
      rangeQuery_call method_call = new rangeQuery_call(r, queryObj, retExternId, retObj, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class rangeQuery_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<ReplyEntry>> {
      private double r;
      private java.nio.ByteBuffer queryObj;
      private boolean retExternId;
      private boolean retObj;
      public rangeQuery_call(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> 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.r = r;
        this.queryObj = queryObj;
        this.retExternId = retExternId;
        this.retObj = retObj;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("rangeQuery", org.apache.thrift.protocol.TMessageType.CALL, 0));
        rangeQuery_args args = new rangeQuery_args();
        args.setR(r);
        args.setQueryObj(queryObj);
        args.setRetExternId(retExternId);
        args.setRetObj(retObj);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public java.util.List<ReplyEntry> getResult() throws QueryException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new java.lang.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_rangeQuery();
      }
    }

    public void knnQueryBatch(int k, java.util.List<java.nio.ByteBuffer> queryObj, boolean retExternId, boolean retObj, int numThreads, org.apache.thrift.async.AsyncMethodCallback<java.util.List<java.util.List<ReplyEntry>>> resultHandler) throws org.apache.thrift.TException {
      checkReady();
      knnQueryBatch_call method_call = new knnQueryBatch_call(k, queryObj, retExternId, retObj, numThreads, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class knnQueryBatch_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<java.util.List<ReplyEntry>>> {
      private int k;
      private java.util.List<java.nio.ByteBuffer> queryObj;
      private boolean retExternId;
      private boolean retObj;
      private int numThreads;
      public knnQueryBatch_call(int k, java.util.List<java.nio.ByteBuffer> queryObj, boolean retExternId, boolean retObj, int numThreads, org.apache.thrift.async.AsyncMethodCallback<java.util.List<java.util.List<ReplyEntry>>> 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.k = k;
        this.queryObj = queryObj;
        this.retExternId = retExternId;
        this.retObj = retObj;
        this.numThreads = numThreads;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("knnQueryBatch", org.apache.thrift.protocol.TMessageType.CALL, 0));
        knnQueryBatch_args args = new knnQueryBatch_args();
        args.setK(k);
        args.setQueryObj(queryObj);
        args.setRetExternId(retExternId);
        args.setRetObj(retObj);
        args.setNumThreads(numThreads);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public java.util.List<java.util.List<ReplyEntry>> getResult() throws QueryException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new java.lang.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_knnQueryBatch();
      }
    }

    public void getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2, org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> resultHandler) throws org.apache.thrift.TException {
      checkReady();
      getDistance_call method_call = new getDistance_call(obj1, obj2, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class getDistance_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Double> {
      private java.nio.ByteBuffer obj1;
      private java.nio.ByteBuffer obj2;
      public getDistance_call(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2, org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> 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.obj1 = obj1;
        this.obj2 = obj2;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getDistance", org.apache.thrift.protocol.TMessageType.CALL, 0));
        getDistance_args args = new getDistance_args();
        args.setObj1(obj1);
        args.setObj2(obj2);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public java.lang.Double getResult() throws QueryException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new java.lang.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_getDistance();
      }
    }

  }

  public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName());
    public Processor(I iface) {
      super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
    }

    protected Processor(I iface, java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
      super(iface, getProcessMap(processMap));
    }

    private static <I extends Iface> java.util.Map<java.lang.String,  org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
      processMap.put("setQueryTimeParams", new setQueryTimeParams());
      processMap.put("knnQuery", new knnQuery());
      processMap.put("rangeQuery", new rangeQuery());
      processMap.put("knnQueryBatch", new knnQueryBatch());
      processMap.put("getDistance", new getDistance());
      return processMap;
    }

    public static class setQueryTimeParams<I extends Iface> extends org.apache.thrift.ProcessFunction<I, setQueryTimeParams_args> {
      public setQueryTimeParams() {
        super("setQueryTimeParams");
      }

      public setQueryTimeParams_args getEmptyArgsInstance() {
        return new setQueryTimeParams_args();
      }

      protected boolean isOneway() {
        return false;
      }

      @Override
      protected boolean handleRuntimeExceptions() {
        return false;
      }

      public setQueryTimeParams_result getResult(I iface, setQueryTimeParams_args args) throws org.apache.thrift.TException {
        setQueryTimeParams_result result = new setQueryTimeParams_result();
        try {
          iface.setQueryTimeParams(args.queryTimeParams);
        } catch (QueryException err) {
          result.err = err;
        }
        return result;
      }
    }

    public static class knnQuery<I extends Iface> extends org.apache.thrift.ProcessFunction<I, knnQuery_args> {
      public knnQuery() {
        super("knnQuery");
      }

      public knnQuery_args getEmptyArgsInstance() {
        return new knnQuery_args();
      }

      protected boolean isOneway() {
        return false;
      }

      @Override
      protected boolean handleRuntimeExceptions() {
        return false;
      }

      public knnQuery_result getResult(I iface, knnQuery_args args) throws org.apache.thrift.TException {
        knnQuery_result result = new knnQuery_result();
        try {
          result.success = iface.knnQuery(args.k, args.queryObj, args.retExternId, args.retObj);
        } catch (QueryException err) {
          result.err = err;
        }
        return result;
      }
    }

    public static class rangeQuery<I extends Iface> extends org.apache.thrift.ProcessFunction<I, rangeQuery_args> {
      public rangeQuery() {
        super("rangeQuery");
      }

      public rangeQuery_args getEmptyArgsInstance() {
        return new rangeQuery_args();
      }

      protected boolean isOneway() {
        return false;
      }

      @Override
      protected boolean handleRuntimeExceptions() {
        return false;
      }

      public rangeQuery_result getResult(I iface, rangeQuery_args args) throws org.apache.thrift.TException {
        rangeQuery_result result = new rangeQuery_result();
        try {
          result.success = iface.rangeQuery(args.r, args.queryObj, args.retExternId, args.retObj);
        } catch (QueryException err) {
          result.err = err;
        }
        return result;
      }
    }

    public static class knnQueryBatch<I extends Iface> extends org.apache.thrift.ProcessFunction<I, knnQueryBatch_args> {
      public knnQueryBatch() {
        super("knnQueryBatch");
      }

      public knnQueryBatch_args getEmptyArgsInstance() {
        return new knnQueryBatch_args();
      }

      protected boolean isOneway() {
        return false;
      }

      @Override
      protected boolean handleRuntimeExceptions() {
        return false;
      }

      public knnQueryBatch_result getResult(I iface, knnQueryBatch_args args) throws org.apache.thrift.TException {
        knnQueryBatch_result result = new knnQueryBatch_result();
        try {
          result.success = iface.knnQueryBatch(args.k, args.queryObj, args.retExternId, args.retObj, args.numThreads);
        } catch (QueryException err) {
          result.err = err;
        }
        return result;
      }
    }

    public static class getDistance<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getDistance_args> {
      public getDistance() {
        super("getDistance");
      }

      public getDistance_args getEmptyArgsInstance() {
        return new getDistance_args();
      }

      protected boolean isOneway() {
        return false;
      }

      @Override
      protected boolean handleRuntimeExceptions() {
        return false;
      }

      public getDistance_result getResult(I iface, getDistance_args args) throws org.apache.thrift.TException {
        getDistance_result result = new getDistance_result();
        try {
          result.success = iface.getDistance(args.obj1, args.obj2);
          result.setSuccessIsSet(true);
        } catch (QueryException err) {
          result.err = err;
        }
        return result;
      }
    }

  }

  public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());
    public AsyncProcessor(I iface) {
      super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
    }

    protected AsyncProcessor(I iface, java.util.Map<java.lang.String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
      super(iface, getProcessMap(processMap));
    }

    private static <I extends AsyncIface> java.util.Map<java.lang.String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<java.lang.String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
      processMap.put("setQueryTimeParams", new setQueryTimeParams());
      processMap.put("knnQuery", new knnQuery());
      processMap.put("rangeQuery", new rangeQuery());
      processMap.put("knnQueryBatch", new knnQueryBatch());
      processMap.put("getDistance", new getDistance());
      return processMap;
    }

    public static class setQueryTimeParams<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, setQueryTimeParams_args, Void> {
      public setQueryTimeParams() {
        super("setQueryTimeParams");
      }

      public setQueryTimeParams_args getEmptyArgsInstance() {
        return new setQueryTimeParams_args();
      }

      public org.apache.thrift.async.AsyncMethodCallback<Void> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
        final org.apache.thrift.AsyncProcessFunction fcall = this;
        return new org.apache.thrift.async.AsyncMethodCallback<Void>() { 
          public void onComplete(Void o) {
            setQueryTimeParams_result result = new setQueryTimeParams_result();
            try {
              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
            } catch (org.apache.thrift.transport.TTransportException e) {
              _LOGGER.error("TTransportException writing to internal frame buffer", e);
              fb.close();
            } catch (java.lang.Exception e) {
              _LOGGER.error("Exception writing to internal frame buffer", e);
              onError(e);
            }
          }
          public void onError(java.lang.Exception e) {
            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
            org.apache.thrift.TSerializable msg;
            setQueryTimeParams_result result = new setQueryTimeParams_result();
            if (e instanceof QueryException) {
              result.err = (QueryException) e;
              result.setErrIsSet(true);
              msg = result;
            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
              _LOGGER.error("TTransportException inside handler", e);
              fb.close();
              return;
            } else if (e instanceof org.apache.thrift.TApplicationException) {
              _LOGGER.error("TApplicationException inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = (org.apache.thrift.TApplicationException)e;
            } else {
              _LOGGER.error("Exception inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
            }
            try {
              fcall.sendResponse(fb,msg,msgType,seqid);
            } catch (java.lang.Exception ex) {
              _LOGGER.error("Exception writing to internal frame buffer", ex);
              fb.close();
            }
          }
        };
      }

      protected boolean isOneway() {
        return false;
      }

      public void start(I iface, setQueryTimeParams_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException {
        iface.setQueryTimeParams(args.queryTimeParams,resultHandler);
      }
    }

    public static class knnQuery<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, knnQuery_args, java.util.List<ReplyEntry>> {
      public knnQuery() {
        super("knnQuery");
      }

      public knnQuery_args getEmptyArgsInstance() {
        return new knnQuery_args();
      }

      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
        final org.apache.thrift.AsyncProcessFunction fcall = this;
        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>>() { 
          public void onComplete(java.util.List<ReplyEntry> o) {
            knnQuery_result result = new knnQuery_result();
            result.success = o;
            try {
              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
            } catch (org.apache.thrift.transport.TTransportException e) {
              _LOGGER.error("TTransportException writing to internal frame buffer", e);
              fb.close();
            } catch (java.lang.Exception e) {
              _LOGGER.error("Exception writing to internal frame buffer", e);
              onError(e);
            }
          }
          public void onError(java.lang.Exception e) {
            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
            org.apache.thrift.TSerializable msg;
            knnQuery_result result = new knnQuery_result();
            if (e instanceof QueryException) {
              result.err = (QueryException) e;
              result.setErrIsSet(true);
              msg = result;
            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
              _LOGGER.error("TTransportException inside handler", e);
              fb.close();
              return;
            } else if (e instanceof org.apache.thrift.TApplicationException) {
              _LOGGER.error("TApplicationException inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = (org.apache.thrift.TApplicationException)e;
            } else {
              _LOGGER.error("Exception inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
            }
            try {
              fcall.sendResponse(fb,msg,msgType,seqid);
            } catch (java.lang.Exception ex) {
              _LOGGER.error("Exception writing to internal frame buffer", ex);
              fb.close();
            }
          }
        };
      }

      protected boolean isOneway() {
        return false;
      }

      public void start(I iface, knnQuery_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException {
        iface.knnQuery(args.k, args.queryObj, args.retExternId, args.retObj,resultHandler);
      }
    }

    public static class rangeQuery<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, rangeQuery_args, java.util.List<ReplyEntry>> {
      public rangeQuery() {
        super("rangeQuery");
      }

      public rangeQuery_args getEmptyArgsInstance() {
        return new rangeQuery_args();
      }

      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
        final org.apache.thrift.AsyncProcessFunction fcall = this;
        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>>() { 
          public void onComplete(java.util.List<ReplyEntry> o) {
            rangeQuery_result result = new rangeQuery_result();
            result.success = o;
            try {
              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
            } catch (org.apache.thrift.transport.TTransportException e) {
              _LOGGER.error("TTransportException writing to internal frame buffer", e);
              fb.close();
            } catch (java.lang.Exception e) {
              _LOGGER.error("Exception writing to internal frame buffer", e);
              onError(e);
            }
          }
          public void onError(java.lang.Exception e) {
            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
            org.apache.thrift.TSerializable msg;
            rangeQuery_result result = new rangeQuery_result();
            if (e instanceof QueryException) {
              result.err = (QueryException) e;
              result.setErrIsSet(true);
              msg = result;
            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
              _LOGGER.error("TTransportException inside handler", e);
              fb.close();
              return;
            } else if (e instanceof org.apache.thrift.TApplicationException) {
              _LOGGER.error("TApplicationException inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = (org.apache.thrift.TApplicationException)e;
            } else {
              _LOGGER.error("Exception inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
            }
            try {
              fcall.sendResponse(fb,msg,msgType,seqid);
            } catch (java.lang.Exception ex) {
              _LOGGER.error("Exception writing to internal frame buffer", ex);
              fb.close();
            }
          }
        };
      }

      protected boolean isOneway() {
        return false;
      }

      public void start(I iface, rangeQuery_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException {
        iface.rangeQuery(args.r, args.queryObj, args.retExternId, args.retObj,resultHandler);
      }
    }

    public static class knnQueryBatch<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, knnQueryBatch_args, java.util.List<java.util.List<ReplyEntry>>> {
      public knnQueryBatch() {
        super("knnQueryBatch");
      }

      public knnQueryBatch_args getEmptyArgsInstance() {
        return new knnQueryBatch_args();
      }

      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<java.util.List<ReplyEntry>>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
        final org.apache.thrift.AsyncProcessFunction fcall = this;
        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<java.util.List<ReplyEntry>>>() { 
          public void onComplete(java.util.List<java.util.List<ReplyEntry>> o) {
            knnQueryBatch_result result = new knnQueryBatch_result();
            result.success = o;
            try {
              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
            } catch (org.apache.thrift.transport.TTransportException e) {
              _LOGGER.error("TTransportException writing to internal frame buffer", e);
              fb.close();
            } catch (java.lang.Exception e) {
              _LOGGER.error("Exception writing to internal frame buffer", e);
              onError(e);
            }
          }
          public void onError(java.lang.Exception e) {
            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
            org.apache.thrift.TSerializable msg;
            knnQueryBatch_result result = new knnQueryBatch_result();
            if (e instanceof QueryException) {
              result.err = (QueryException) e;
              result.setErrIsSet(true);
              msg = result;
            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
              _LOGGER.error("TTransportException inside handler", e);
              fb.close();
              return;
            } else if (e instanceof org.apache.thrift.TApplicationException) {
              _LOGGER.error("TApplicationException inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = (org.apache.thrift.TApplicationException)e;
            } else {
              _LOGGER.error("Exception inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
            }
            try {
              fcall.sendResponse(fb,msg,msgType,seqid);
            } catch (java.lang.Exception ex) {
              _LOGGER.error("Exception writing to internal frame buffer", ex);
              fb.close();
            }
          }
        };
      }

      protected boolean isOneway() {
        return false;
      }

      public void start(I iface, knnQueryBatch_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<java.util.List<ReplyEntry>>> resultHandler) throws org.apache.thrift.TException {
        iface.knnQueryBatch(args.k, args.queryObj, args.retExternId, args.retObj, args.numThreads,resultHandler);
      }
    }

    public static class getDistance<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getDistance_args, java.lang.Double> {
      public getDistance() {
        super("getDistance");
      }

      public getDistance_args getEmptyArgsInstance() {
        return new getDistance_args();
      }

      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
        final org.apache.thrift.AsyncProcessFunction fcall = this;
        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Double>() { 
          public void onComplete(java.lang.Double o) {
            getDistance_result result = new getDistance_result();
            result.success = o;
            result.setSuccessIsSet(true);
            try {
              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
            } catch (org.apache.thrift.transport.TTransportException e) {
              _LOGGER.error("TTransportException writing to internal frame buffer", e);
              fb.close();
            } catch (java.lang.Exception e) {
              _LOGGER.error("Exception writing to internal frame buffer", e);
              onError(e);
            }
          }
          public void onError(java.lang.Exception e) {
            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
            org.apache.thrift.TSerializable msg;
            getDistance_result result = new getDistance_result();
            if (e instanceof QueryException) {
              result.err = (QueryException) e;
              result.setErrIsSet(true);
              msg = result;
            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
              _LOGGER.error("TTransportException inside handler", e);
              fb.close();
              return;
            } else if (e instanceof org.apache.thrift.TApplicationException) {
              _LOGGER.error("TApplicationException inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = (org.apache.thrift.TApplicationException)e;
            } else {
              _LOGGER.error("Exception inside handler", e);
              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
            }
            try {
              fcall.sendResponse(fb,msg,msgType,seqid);
            } catch (java.lang.Exception ex) {
              _LOGGER.error("Exception writing to internal frame buffer", ex);
              fb.close();
            }
          }
        };
      }

      protected boolean isOneway() {
        return false;
      }

      public void start(I iface, getDistance_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> resultHandler) throws org.apache.thrift.TException {
        iface.getDistance(args.obj1, args.obj2,resultHandler);
      }
    }

  }

  public static class setQueryTimeParams_args implements org.apache.thrift.TBase<setQueryTimeParams_args, setQueryTimeParams_args._Fields>, java.io.Serializable, Cloneable, Comparable<setQueryTimeParams_args>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setQueryTimeParams_args");

    private static final org.apache.thrift.protocol.TField QUERY_TIME_PARAMS_FIELD_DESC = new org.apache.thrift.protocol.TField("queryTimeParams", org.apache.thrift.protocol.TType.STRING, (short)1);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setQueryTimeParams_argsStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setQueryTimeParams_argsTupleSchemeFactory();

    public java.lang.String queryTimeParams; // 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 {
      QUERY_TIME_PARAMS((short)1, "queryTimeParams");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // QUERY_TIME_PARAMS
            return QUERY_TIME_PARAMS;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
      tmpMap.put(_Fields.QUERY_TIME_PARAMS, new org.apache.thrift.meta_data.FieldMetaData("queryTimeParams", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setQueryTimeParams_args.class, metaDataMap);
    }

    public setQueryTimeParams_args() {
    }

    public setQueryTimeParams_args(
      java.lang.String queryTimeParams)
    {
      this();
      this.queryTimeParams = queryTimeParams;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public setQueryTimeParams_args(setQueryTimeParams_args other) {
      if (other.isSetQueryTimeParams()) {
        this.queryTimeParams = other.queryTimeParams;
      }
    }

    public setQueryTimeParams_args deepCopy() {
      return new setQueryTimeParams_args(this);
    }

    @Override
    public void clear() {
      this.queryTimeParams = null;
    }

    public java.lang.String getQueryTimeParams() {
      return this.queryTimeParams;
    }

    public setQueryTimeParams_args setQueryTimeParams(java.lang.String queryTimeParams) {
      this.queryTimeParams = queryTimeParams;
      return this;
    }

    public void unsetQueryTimeParams() {
      this.queryTimeParams = null;
    }

    /** Returns true if field queryTimeParams is set (has been assigned a value) and false otherwise */
    public boolean isSetQueryTimeParams() {
      return this.queryTimeParams != null;
    }

    public void setQueryTimeParamsIsSet(boolean value) {
      if (!value) {
        this.queryTimeParams = null;
      }
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case QUERY_TIME_PARAMS:
        if (value == null) {
          unsetQueryTimeParams();
        } else {
          setQueryTimeParams((java.lang.String)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case QUERY_TIME_PARAMS:
        return getQueryTimeParams();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case QUERY_TIME_PARAMS:
        return isSetQueryTimeParams();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof setQueryTimeParams_args)
        return this.equals((setQueryTimeParams_args)that);
      return false;
    }

    public boolean equals(setQueryTimeParams_args that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      boolean this_present_queryTimeParams = true && this.isSetQueryTimeParams();
      boolean that_present_queryTimeParams = true && that.isSetQueryTimeParams();
      if (this_present_queryTimeParams || that_present_queryTimeParams) {
        if (!(this_present_queryTimeParams && that_present_queryTimeParams))
          return false;
        if (!this.queryTimeParams.equals(that.queryTimeParams))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + ((isSetQueryTimeParams()) ? 131071 : 524287);
      if (isSetQueryTimeParams())
        hashCode = hashCode * 8191 + queryTimeParams.hashCode();

      return hashCode;
    }

    @Override
    public int compareTo(setQueryTimeParams_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetQueryTimeParams()).compareTo(other.isSetQueryTimeParams());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetQueryTimeParams()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryTimeParams, other.queryTimeParams);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
    }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("setQueryTimeParams_args(");
      boolean first = true;

      sb.append("queryTimeParams:");
      if (this.queryTimeParams == null) {
        sb.append("null");
      } else {
        sb.append(this.queryTimeParams);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
      // check for required fields
      if (queryTimeParams == null) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'queryTimeParams' 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, java.lang.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 setQueryTimeParams_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public setQueryTimeParams_argsStandardScheme getScheme() {
        return new setQueryTimeParams_argsStandardScheme();
      }
    }

    private static class setQueryTimeParams_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<setQueryTimeParams_args> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, setQueryTimeParams_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: // QUERY_TIME_PARAMS
              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                struct.queryTimeParams = iprot.readString();
                struct.setQueryTimeParamsIsSet(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, setQueryTimeParams_args struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        if (struct.queryTimeParams != null) {
          oprot.writeFieldBegin(QUERY_TIME_PARAMS_FIELD_DESC);
          oprot.writeString(struct.queryTimeParams);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class setQueryTimeParams_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public setQueryTimeParams_argsTupleScheme getScheme() {
        return new setQueryTimeParams_argsTupleScheme();
      }
    }

    private static class setQueryTimeParams_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<setQueryTimeParams_args> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, setQueryTimeParams_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        oprot.writeString(struct.queryTimeParams);
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, setQueryTimeParams_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        struct.queryTimeParams = iprot.readString();
        struct.setQueryTimeParamsIsSet(true);
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class setQueryTimeParams_result implements org.apache.thrift.TBase<setQueryTimeParams_result, setQueryTimeParams_result._Fields>, java.io.Serializable, Cloneable, Comparable<setQueryTimeParams_result>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setQueryTimeParams_result");

    private static final org.apache.thrift.protocol.TField ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setQueryTimeParams_resultStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setQueryTimeParams_resultTupleSchemeFactory();

    public QueryException err; // 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 {
      ERR((short)1, "err");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // ERR
            return ERR;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
      tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, 
          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setQueryTimeParams_result.class, metaDataMap);
    }

    public setQueryTimeParams_result() {
    }

    public setQueryTimeParams_result(
      QueryException err)
    {
      this();
      this.err = err;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public setQueryTimeParams_result(setQueryTimeParams_result other) {
      if (other.isSetErr()) {
        this.err = new QueryException(other.err);
      }
    }

    public setQueryTimeParams_result deepCopy() {
      return new setQueryTimeParams_result(this);
    }

    @Override
    public void clear() {
      this.err = null;
    }

    public QueryException getErr() {
      return this.err;
    }

    public setQueryTimeParams_result setErr(QueryException err) {
      this.err = err;
      return this;
    }

    public void unsetErr() {
      this.err = null;
    }

    /** Returns true if field err is set (has been assigned a value) and false otherwise */
    public boolean isSetErr() {
      return this.err != null;
    }

    public void setErrIsSet(boolean value) {
      if (!value) {
        this.err = null;
      }
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case ERR:
        if (value == null) {
          unsetErr();
        } else {
          setErr((QueryException)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case ERR:
        return getErr();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case ERR:
        return isSetErr();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof setQueryTimeParams_result)
        return this.equals((setQueryTimeParams_result)that);
      return false;
    }

    public boolean equals(setQueryTimeParams_result that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      boolean this_present_err = true && this.isSetErr();
      boolean that_present_err = true && that.isSetErr();
      if (this_present_err || that_present_err) {
        if (!(this_present_err && that_present_err))
          return false;
        if (!this.err.equals(that.err))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287);
      if (isSetErr())
        hashCode = hashCode * 8191 + err.hashCode();

      return hashCode;
    }

    @Override
    public int compareTo(setQueryTimeParams_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetErr()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
      }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("setQueryTimeParams_result(");
      boolean first = true;

      sb.append("err:");
      if (this.err == null) {
        sb.append("null");
      } else {
        sb.append(this.err);
      }
      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, java.lang.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 setQueryTimeParams_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public setQueryTimeParams_resultStandardScheme getScheme() {
        return new setQueryTimeParams_resultStandardScheme();
      }
    }

    private static class setQueryTimeParams_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<setQueryTimeParams_result> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, setQueryTimeParams_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 1: // ERR
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.err = new QueryException();
                struct.err.read(iprot);
                struct.setErrIsSet(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, setQueryTimeParams_result struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        if (struct.err != null) {
          oprot.writeFieldBegin(ERR_FIELD_DESC);
          struct.err.write(oprot);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class setQueryTimeParams_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public setQueryTimeParams_resultTupleScheme getScheme() {
        return new setQueryTimeParams_resultTupleScheme();
      }
    }

    private static class setQueryTimeParams_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<setQueryTimeParams_result> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, setQueryTimeParams_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet optionals = new java.util.BitSet();
        if (struct.isSetErr()) {
          optionals.set(0);
        }
        oprot.writeBitSet(optionals, 1);
        if (struct.isSetErr()) {
          struct.err.write(oprot);
        }
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, setQueryTimeParams_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet incoming = iprot.readBitSet(1);
        if (incoming.get(0)) {
          struct.err = new QueryException();
          struct.err.read(iprot);
          struct.setErrIsSet(true);
        }
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class knnQuery_args implements org.apache.thrift.TBase<knnQuery_args, knnQuery_args._Fields>, java.io.Serializable, Cloneable, Comparable<knnQuery_args>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("knnQuery_args");

    private static final org.apache.thrift.protocol.TField K_FIELD_DESC = new org.apache.thrift.protocol.TField("k", org.apache.thrift.protocol.TType.I32, (short)1);
    private static final org.apache.thrift.protocol.TField QUERY_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("queryObj", org.apache.thrift.protocol.TType.STRING, (short)2);
    private static final org.apache.thrift.protocol.TField RET_EXTERN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("retExternId", org.apache.thrift.protocol.TType.BOOL, (short)3);
    private static final org.apache.thrift.protocol.TField RET_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("retObj", org.apache.thrift.protocol.TType.BOOL, (short)4);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new knnQuery_argsStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new knnQuery_argsTupleSchemeFactory();

    public int k; // required
    public java.nio.ByteBuffer queryObj; // required
    public boolean retExternId; // required
    public boolean retObj; // 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 {
      K((short)1, "k"),
      QUERY_OBJ((short)2, "queryObj"),
      RET_EXTERN_ID((short)3, "retExternId"),
      RET_OBJ((short)4, "retObj");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // K
            return K;
          case 2: // QUERY_OBJ
            return QUERY_OBJ;
          case 3: // RET_EXTERN_ID
            return RET_EXTERN_ID;
          case 4: // RET_OBJ
            return RET_OBJ;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __K_ISSET_ID = 0;
    private static final int __RETEXTERNID_ISSET_ID = 1;
    private static final int __RETOBJ_ISSET_ID = 2;
    private byte __isset_bitfield = 0;
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
      tmpMap.put(_Fields.K, new org.apache.thrift.meta_data.FieldMetaData("k", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
      tmpMap.put(_Fields.QUERY_OBJ, new org.apache.thrift.meta_data.FieldMetaData("queryObj", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING          , true)));
      tmpMap.put(_Fields.RET_EXTERN_ID, new org.apache.thrift.meta_data.FieldMetaData("retExternId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
      tmpMap.put(_Fields.RET_OBJ, new org.apache.thrift.meta_data.FieldMetaData("retObj", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(knnQuery_args.class, metaDataMap);
    }

    public knnQuery_args() {
    }

    public knnQuery_args(
      int k,
      java.nio.ByteBuffer queryObj,
      boolean retExternId,
      boolean retObj)
    {
      this();
      this.k = k;
      setKIsSet(true);
      this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(queryObj);
      this.retExternId = retExternId;
      setRetExternIdIsSet(true);
      this.retObj = retObj;
      setRetObjIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public knnQuery_args(knnQuery_args other) {
      __isset_bitfield = other.__isset_bitfield;
      this.k = other.k;
      if (other.isSetQueryObj()) {
        this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(other.queryObj);
      }
      this.retExternId = other.retExternId;
      this.retObj = other.retObj;
    }

    public knnQuery_args deepCopy() {
      return new knnQuery_args(this);
    }

    @Override
    public void clear() {
      setKIsSet(false);
      this.k = 0;
      this.queryObj = null;
      setRetExternIdIsSet(false);
      this.retExternId = false;
      setRetObjIsSet(false);
      this.retObj = false;
    }

    public int getK() {
      return this.k;
    }

    public knnQuery_args setK(int k) {
      this.k = k;
      setKIsSet(true);
      return this;
    }

    public void unsetK() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __K_ISSET_ID);
    }

    /** Returns true if field k is set (has been assigned a value) and false otherwise */
    public boolean isSetK() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __K_ISSET_ID);
    }

    public void setKIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __K_ISSET_ID, value);
    }

    public byte[] getQueryObj() {
      setQueryObj(org.apache.thrift.TBaseHelper.rightSize(queryObj));
      return queryObj == null ? null : queryObj.array();
    }

    public java.nio.ByteBuffer bufferForQueryObj() {
      return org.apache.thrift.TBaseHelper.copyBinary(queryObj);
    }

    public knnQuery_args setQueryObj(byte[] queryObj) {
      this.queryObj = queryObj == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(queryObj.clone());
      return this;
    }

    public knnQuery_args setQueryObj(java.nio.ByteBuffer queryObj) {
      this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(queryObj);
      return this;
    }

    public void unsetQueryObj() {
      this.queryObj = null;
    }

    /** Returns true if field queryObj is set (has been assigned a value) and false otherwise */
    public boolean isSetQueryObj() {
      return this.queryObj != null;
    }

    public void setQueryObjIsSet(boolean value) {
      if (!value) {
        this.queryObj = null;
      }
    }

    public boolean isRetExternId() {
      return this.retExternId;
    }

    public knnQuery_args setRetExternId(boolean retExternId) {
      this.retExternId = retExternId;
      setRetExternIdIsSet(true);
      return this;
    }

    public void unsetRetExternId() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETEXTERNID_ISSET_ID);
    }

    /** Returns true if field retExternId is set (has been assigned a value) and false otherwise */
    public boolean isSetRetExternId() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETEXTERNID_ISSET_ID);
    }

    public void setRetExternIdIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETEXTERNID_ISSET_ID, value);
    }

    public boolean isRetObj() {
      return this.retObj;
    }

    public knnQuery_args setRetObj(boolean retObj) {
      this.retObj = retObj;
      setRetObjIsSet(true);
      return this;
    }

    public void unsetRetObj() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETOBJ_ISSET_ID);
    }

    /** Returns true if field retObj is set (has been assigned a value) and false otherwise */
    public boolean isSetRetObj() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETOBJ_ISSET_ID);
    }

    public void setRetObjIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETOBJ_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case K:
        if (value == null) {
          unsetK();
        } else {
          setK((java.lang.Integer)value);
        }
        break;

      case QUERY_OBJ:
        if (value == null) {
          unsetQueryObj();
        } else {
          if (value instanceof byte[]) {
            setQueryObj((byte[])value);
          } else {
            setQueryObj((java.nio.ByteBuffer)value);
          }
        }
        break;

      case RET_EXTERN_ID:
        if (value == null) {
          unsetRetExternId();
        } else {
          setRetExternId((java.lang.Boolean)value);
        }
        break;

      case RET_OBJ:
        if (value == null) {
          unsetRetObj();
        } else {
          setRetObj((java.lang.Boolean)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case K:
        return getK();

      case QUERY_OBJ:
        return getQueryObj();

      case RET_EXTERN_ID:
        return isRetExternId();

      case RET_OBJ:
        return isRetObj();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case K:
        return isSetK();
      case QUERY_OBJ:
        return isSetQueryObj();
      case RET_EXTERN_ID:
        return isSetRetExternId();
      case RET_OBJ:
        return isSetRetObj();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof knnQuery_args)
        return this.equals((knnQuery_args)that);
      return false;
    }

    public boolean equals(knnQuery_args that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      boolean this_present_k = true;
      boolean that_present_k = true;
      if (this_present_k || that_present_k) {
        if (!(this_present_k && that_present_k))
          return false;
        if (this.k != that.k)
          return false;
      }

      boolean this_present_queryObj = true && this.isSetQueryObj();
      boolean that_present_queryObj = true && that.isSetQueryObj();
      if (this_present_queryObj || that_present_queryObj) {
        if (!(this_present_queryObj && that_present_queryObj))
          return false;
        if (!this.queryObj.equals(that.queryObj))
          return false;
      }

      boolean this_present_retExternId = true;
      boolean that_present_retExternId = true;
      if (this_present_retExternId || that_present_retExternId) {
        if (!(this_present_retExternId && that_present_retExternId))
          return false;
        if (this.retExternId != that.retExternId)
          return false;
      }

      boolean this_present_retObj = true;
      boolean that_present_retObj = true;
      if (this_present_retObj || that_present_retObj) {
        if (!(this_present_retObj && that_present_retObj))
          return false;
        if (this.retObj != that.retObj)
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + k;

      hashCode = hashCode * 8191 + ((isSetQueryObj()) ? 131071 : 524287);
      if (isSetQueryObj())
        hashCode = hashCode * 8191 + queryObj.hashCode();

      hashCode = hashCode * 8191 + ((retExternId) ? 131071 : 524287);

      hashCode = hashCode * 8191 + ((retObj) ? 131071 : 524287);

      return hashCode;
    }

    @Override
    public int compareTo(knnQuery_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetK()).compareTo(other.isSetK());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetK()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.k, other.k);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetQueryObj()).compareTo(other.isSetQueryObj());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetQueryObj()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryObj, other.queryObj);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetRetExternId()).compareTo(other.isSetRetExternId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetRetExternId()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retExternId, other.retExternId);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetRetObj()).compareTo(other.isSetRetObj());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetRetObj()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retObj, other.retObj);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
    }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("knnQuery_args(");
      boolean first = true;

      sb.append("k:");
      sb.append(this.k);
      first = false;
      if (!first) sb.append(", ");
      sb.append("queryObj:");
      if (this.queryObj == null) {
        sb.append("null");
      } else {
        org.apache.thrift.TBaseHelper.toString(this.queryObj, sb);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("retExternId:");
      sb.append(this.retExternId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("retObj:");
      sb.append(this.retObj);
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
      // check for required fields
      // alas, we cannot check 'k' because it's a primitive and you chose the non-beans generator.
      if (queryObj == null) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'queryObj' was not present! Struct: " + toString());
      }
      // alas, we cannot check 'retExternId' because it's a primitive and you chose the non-beans generator.
      // alas, we cannot check 'retObj' because it's a primitive and you chose the non-beans generator.
      // 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, java.lang.ClassNotFoundException {
      try {
        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
        __isset_bitfield = 0;
        read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
      } catch (org.apache.thrift.TException te) {
        throw new java.io.IOException(te);
      }
    }

    private static class knnQuery_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public knnQuery_argsStandardScheme getScheme() {
        return new knnQuery_argsStandardScheme();
      }
    }

    private static class knnQuery_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<knnQuery_args> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, knnQuery_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: // K
              if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
                struct.k = iprot.readI32();
                struct.setKIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 2: // QUERY_OBJ
              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                struct.queryObj = iprot.readBinary();
                struct.setQueryObjIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 3: // RET_EXTERN_ID
              if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                struct.retExternId = iprot.readBool();
                struct.setRetExternIdIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 4: // RET_OBJ
              if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                struct.retObj = iprot.readBool();
                struct.setRetObjIsSet(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
        if (!struct.isSetK()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'k' was not found in serialized data! Struct: " + toString());
        }
        if (!struct.isSetRetExternId()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'retExternId' was not found in serialized data! Struct: " + toString());
        }
        if (!struct.isSetRetObj()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'retObj' was not found in serialized data! Struct: " + toString());
        }
        struct.validate();
      }

      public void write(org.apache.thrift.protocol.TProtocol oprot, knnQuery_args struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        oprot.writeFieldBegin(K_FIELD_DESC);
        oprot.writeI32(struct.k);
        oprot.writeFieldEnd();
        if (struct.queryObj != null) {
          oprot.writeFieldBegin(QUERY_OBJ_FIELD_DESC);
          oprot.writeBinary(struct.queryObj);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldBegin(RET_EXTERN_ID_FIELD_DESC);
        oprot.writeBool(struct.retExternId);
        oprot.writeFieldEnd();
        oprot.writeFieldBegin(RET_OBJ_FIELD_DESC);
        oprot.writeBool(struct.retObj);
        oprot.writeFieldEnd();
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class knnQuery_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public knnQuery_argsTupleScheme getScheme() {
        return new knnQuery_argsTupleScheme();
      }
    }

    private static class knnQuery_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<knnQuery_args> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, knnQuery_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        oprot.writeI32(struct.k);
        oprot.writeBinary(struct.queryObj);
        oprot.writeBool(struct.retExternId);
        oprot.writeBool(struct.retObj);
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, knnQuery_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        struct.k = iprot.readI32();
        struct.setKIsSet(true);
        struct.queryObj = iprot.readBinary();
        struct.setQueryObjIsSet(true);
        struct.retExternId = iprot.readBool();
        struct.setRetExternIdIsSet(true);
        struct.retObj = iprot.readBool();
        struct.setRetObjIsSet(true);
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class knnQuery_result implements org.apache.thrift.TBase<knnQuery_result, knnQuery_result._Fields>, java.io.Serializable, Cloneable, Comparable<knnQuery_result>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("knnQuery_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 ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new knnQuery_resultStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new knnQuery_resultTupleSchemeFactory();

    public java.util.List<ReplyEntry> success; // required
    public QueryException err; // 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"),
      ERR((short)1, "err");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // ERR
            return ERR;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.FieldValueMetaData(org.apache.thrift.protocol.TType.LIST          , "ReplyEntryList")));
      tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, 
          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(knnQuery_result.class, metaDataMap);
    }

    public knnQuery_result() {
    }

    public knnQuery_result(
      java.util.List<ReplyEntry> success,
      QueryException err)
    {
      this();
      this.success = success;
      this.err = err;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public knnQuery_result(knnQuery_result other) {
      if (other.isSetSuccess()) {
        java.util.List<ReplyEntry> __this__success = new java.util.ArrayList<ReplyEntry>(other.success.size());
        for (ReplyEntry other_element : other.success) {
          __this__success.add(new ReplyEntry(other_element));
        }
        this.success = __this__success;
      }
      if (other.isSetErr()) {
        this.err = new QueryException(other.err);
      }
    }

    public knnQuery_result deepCopy() {
      return new knnQuery_result(this);
    }

    @Override
    public void clear() {
      this.success = null;
      this.err = null;
    }

    public int getSuccessSize() {
      return (this.success == null) ? 0 : this.success.size();
    }

    public java.util.Iterator<ReplyEntry> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(ReplyEntry elem) {
      if (this.success == null) {
        this.success = new java.util.ArrayList<ReplyEntry>();
      }
      this.success.add(elem);
    }

    public java.util.List<ReplyEntry> getSuccess() {
      return this.success;
    }

    public knnQuery_result setSuccess(java.util.List<ReplyEntry> 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 QueryException getErr() {
      return this.err;
    }

    public knnQuery_result setErr(QueryException err) {
      this.err = err;
      return this;
    }

    public void unsetErr() {
      this.err = null;
    }

    /** Returns true if field err is set (has been assigned a value) and false otherwise */
    public boolean isSetErr() {
      return this.err != null;
    }

    public void setErrIsSet(boolean value) {
      if (!value) {
        this.err = null;
      }
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((java.util.List<ReplyEntry>)value);
        }
        break;

      case ERR:
        if (value == null) {
          unsetErr();
        } else {
          setErr((QueryException)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case ERR:
        return getErr();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case ERR:
        return isSetErr();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof knnQuery_result)
        return this.equals((knnQuery_result)that);
      return false;
    }

    public boolean equals(knnQuery_result that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      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_err = true && this.isSetErr();
      boolean that_present_err = true && that.isSetErr();
      if (this_present_err || that_present_err) {
        if (!(this_present_err && that_present_err))
          return false;
        if (!this.err.equals(that.err))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
      if (isSetSuccess())
        hashCode = hashCode * 8191 + success.hashCode();

      hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287);
      if (isSetErr())
        hashCode = hashCode * 8191 + err.hashCode();

      return hashCode;
    }

    @Override
    public int compareTo(knnQuery_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetSuccess()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetErr()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
      }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("knnQuery_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("err:");
      if (this.err == null) {
        sb.append("null");
      } else {
        sb.append(this.err);
      }
      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, java.lang.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 knnQuery_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public knnQuery_resultStandardScheme getScheme() {
        return new knnQuery_resultStandardScheme();
      }
    }

    private static class knnQuery_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<knnQuery_result> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, knnQuery_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 _list0 = iprot.readListBegin();
                  struct.success = new java.util.ArrayList<ReplyEntry>(_list0.size);
                  ReplyEntry _elem1;
                  for (int _i2 = 0; _i2 < _list0.size; ++_i2)
                  {
                    _elem1 = new ReplyEntry();
                    _elem1.read(iprot);
                    struct.success.add(_elem1);
                  }
                  iprot.readListEnd();
                }
                struct.setSuccessIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 1: // ERR
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.err = new QueryException();
                struct.err.read(iprot);
                struct.setErrIsSet(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, knnQuery_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.STRUCT, struct.success.size()));
            for (ReplyEntry _iter3 : struct.success)
            {
              _iter3.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
        if (struct.err != null) {
          oprot.writeFieldBegin(ERR_FIELD_DESC);
          struct.err.write(oprot);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class knnQuery_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public knnQuery_resultTupleScheme getScheme() {
        return new knnQuery_resultTupleScheme();
      }
    }

    private static class knnQuery_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<knnQuery_result> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, knnQuery_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet optionals = new java.util.BitSet();
        if (struct.isSetSuccess()) {
          optionals.set(0);
        }
        if (struct.isSetErr()) {
          optionals.set(1);
        }
        oprot.writeBitSet(optionals, 2);
        if (struct.isSetSuccess()) {
          {
            oprot.writeI32(struct.success.size());
            for (ReplyEntry _iter4 : struct.success)
            {
              _iter4.write(oprot);
            }
          }
        }
        if (struct.isSetErr()) {
          struct.err.write(oprot);
        }
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, knnQuery_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet incoming = iprot.readBitSet(2);
        if (incoming.get(0)) {
          {
            org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
            struct.success = new java.util.ArrayList<ReplyEntry>(_list5.size);
            ReplyEntry _elem6;
            for (int _i7 = 0; _i7 < _list5.size; ++_i7)
            {
              _elem6 = new ReplyEntry();
              _elem6.read(iprot);
              struct.success.add(_elem6);
            }
          }
          struct.setSuccessIsSet(true);
        }
        if (incoming.get(1)) {
          struct.err = new QueryException();
          struct.err.read(iprot);
          struct.setErrIsSet(true);
        }
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class rangeQuery_args implements org.apache.thrift.TBase<rangeQuery_args, rangeQuery_args._Fields>, java.io.Serializable, Cloneable, Comparable<rangeQuery_args>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("rangeQuery_args");

    private static final org.apache.thrift.protocol.TField R_FIELD_DESC = new org.apache.thrift.protocol.TField("r", org.apache.thrift.protocol.TType.DOUBLE, (short)1);
    private static final org.apache.thrift.protocol.TField QUERY_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("queryObj", org.apache.thrift.protocol.TType.STRING, (short)2);
    private static final org.apache.thrift.protocol.TField RET_EXTERN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("retExternId", org.apache.thrift.protocol.TType.BOOL, (short)3);
    private static final org.apache.thrift.protocol.TField RET_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("retObj", org.apache.thrift.protocol.TType.BOOL, (short)4);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new rangeQuery_argsStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new rangeQuery_argsTupleSchemeFactory();

    public double r; // required
    public java.nio.ByteBuffer queryObj; // required
    public boolean retExternId; // required
    public boolean retObj; // 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 {
      R((short)1, "r"),
      QUERY_OBJ((short)2, "queryObj"),
      RET_EXTERN_ID((short)3, "retExternId"),
      RET_OBJ((short)4, "retObj");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // R
            return R;
          case 2: // QUERY_OBJ
            return QUERY_OBJ;
          case 3: // RET_EXTERN_ID
            return RET_EXTERN_ID;
          case 4: // RET_OBJ
            return RET_OBJ;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __R_ISSET_ID = 0;
    private static final int __RETEXTERNID_ISSET_ID = 1;
    private static final int __RETOBJ_ISSET_ID = 2;
    private byte __isset_bitfield = 0;
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
      tmpMap.put(_Fields.R, new org.apache.thrift.meta_data.FieldMetaData("r", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
      tmpMap.put(_Fields.QUERY_OBJ, new org.apache.thrift.meta_data.FieldMetaData("queryObj", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING          , true)));
      tmpMap.put(_Fields.RET_EXTERN_ID, new org.apache.thrift.meta_data.FieldMetaData("retExternId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
      tmpMap.put(_Fields.RET_OBJ, new org.apache.thrift.meta_data.FieldMetaData("retObj", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(rangeQuery_args.class, metaDataMap);
    }

    public rangeQuery_args() {
    }

    public rangeQuery_args(
      double r,
      java.nio.ByteBuffer queryObj,
      boolean retExternId,
      boolean retObj)
    {
      this();
      this.r = r;
      setRIsSet(true);
      this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(queryObj);
      this.retExternId = retExternId;
      setRetExternIdIsSet(true);
      this.retObj = retObj;
      setRetObjIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public rangeQuery_args(rangeQuery_args other) {
      __isset_bitfield = other.__isset_bitfield;
      this.r = other.r;
      if (other.isSetQueryObj()) {
        this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(other.queryObj);
      }
      this.retExternId = other.retExternId;
      this.retObj = other.retObj;
    }

    public rangeQuery_args deepCopy() {
      return new rangeQuery_args(this);
    }

    @Override
    public void clear() {
      setRIsSet(false);
      this.r = 0.0;
      this.queryObj = null;
      setRetExternIdIsSet(false);
      this.retExternId = false;
      setRetObjIsSet(false);
      this.retObj = false;
    }

    public double getR() {
      return this.r;
    }

    public rangeQuery_args setR(double r) {
      this.r = r;
      setRIsSet(true);
      return this;
    }

    public void unsetR() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __R_ISSET_ID);
    }

    /** Returns true if field r is set (has been assigned a value) and false otherwise */
    public boolean isSetR() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __R_ISSET_ID);
    }

    public void setRIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __R_ISSET_ID, value);
    }

    public byte[] getQueryObj() {
      setQueryObj(org.apache.thrift.TBaseHelper.rightSize(queryObj));
      return queryObj == null ? null : queryObj.array();
    }

    public java.nio.ByteBuffer bufferForQueryObj() {
      return org.apache.thrift.TBaseHelper.copyBinary(queryObj);
    }

    public rangeQuery_args setQueryObj(byte[] queryObj) {
      this.queryObj = queryObj == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(queryObj.clone());
      return this;
    }

    public rangeQuery_args setQueryObj(java.nio.ByteBuffer queryObj) {
      this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(queryObj);
      return this;
    }

    public void unsetQueryObj() {
      this.queryObj = null;
    }

    /** Returns true if field queryObj is set (has been assigned a value) and false otherwise */
    public boolean isSetQueryObj() {
      return this.queryObj != null;
    }

    public void setQueryObjIsSet(boolean value) {
      if (!value) {
        this.queryObj = null;
      }
    }

    public boolean isRetExternId() {
      return this.retExternId;
    }

    public rangeQuery_args setRetExternId(boolean retExternId) {
      this.retExternId = retExternId;
      setRetExternIdIsSet(true);
      return this;
    }

    public void unsetRetExternId() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETEXTERNID_ISSET_ID);
    }

    /** Returns true if field retExternId is set (has been assigned a value) and false otherwise */
    public boolean isSetRetExternId() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETEXTERNID_ISSET_ID);
    }

    public void setRetExternIdIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETEXTERNID_ISSET_ID, value);
    }

    public boolean isRetObj() {
      return this.retObj;
    }

    public rangeQuery_args setRetObj(boolean retObj) {
      this.retObj = retObj;
      setRetObjIsSet(true);
      return this;
    }

    public void unsetRetObj() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETOBJ_ISSET_ID);
    }

    /** Returns true if field retObj is set (has been assigned a value) and false otherwise */
    public boolean isSetRetObj() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETOBJ_ISSET_ID);
    }

    public void setRetObjIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETOBJ_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case R:
        if (value == null) {
          unsetR();
        } else {
          setR((java.lang.Double)value);
        }
        break;

      case QUERY_OBJ:
        if (value == null) {
          unsetQueryObj();
        } else {
          if (value instanceof byte[]) {
            setQueryObj((byte[])value);
          } else {
            setQueryObj((java.nio.ByteBuffer)value);
          }
        }
        break;

      case RET_EXTERN_ID:
        if (value == null) {
          unsetRetExternId();
        } else {
          setRetExternId((java.lang.Boolean)value);
        }
        break;

      case RET_OBJ:
        if (value == null) {
          unsetRetObj();
        } else {
          setRetObj((java.lang.Boolean)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case R:
        return getR();

      case QUERY_OBJ:
        return getQueryObj();

      case RET_EXTERN_ID:
        return isRetExternId();

      case RET_OBJ:
        return isRetObj();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case R:
        return isSetR();
      case QUERY_OBJ:
        return isSetQueryObj();
      case RET_EXTERN_ID:
        return isSetRetExternId();
      case RET_OBJ:
        return isSetRetObj();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof rangeQuery_args)
        return this.equals((rangeQuery_args)that);
      return false;
    }

    public boolean equals(rangeQuery_args that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      boolean this_present_r = true;
      boolean that_present_r = true;
      if (this_present_r || that_present_r) {
        if (!(this_present_r && that_present_r))
          return false;
        if (this.r != that.r)
          return false;
      }

      boolean this_present_queryObj = true && this.isSetQueryObj();
      boolean that_present_queryObj = true && that.isSetQueryObj();
      if (this_present_queryObj || that_present_queryObj) {
        if (!(this_present_queryObj && that_present_queryObj))
          return false;
        if (!this.queryObj.equals(that.queryObj))
          return false;
      }

      boolean this_present_retExternId = true;
      boolean that_present_retExternId = true;
      if (this_present_retExternId || that_present_retExternId) {
        if (!(this_present_retExternId && that_present_retExternId))
          return false;
        if (this.retExternId != that.retExternId)
          return false;
      }

      boolean this_present_retObj = true;
      boolean that_present_retObj = true;
      if (this_present_retObj || that_present_retObj) {
        if (!(this_present_retObj && that_present_retObj))
          return false;
        if (this.retObj != that.retObj)
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(r);

      hashCode = hashCode * 8191 + ((isSetQueryObj()) ? 131071 : 524287);
      if (isSetQueryObj())
        hashCode = hashCode * 8191 + queryObj.hashCode();

      hashCode = hashCode * 8191 + ((retExternId) ? 131071 : 524287);

      hashCode = hashCode * 8191 + ((retObj) ? 131071 : 524287);

      return hashCode;
    }

    @Override
    public int compareTo(rangeQuery_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetR()).compareTo(other.isSetR());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetR()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.r, other.r);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetQueryObj()).compareTo(other.isSetQueryObj());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetQueryObj()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryObj, other.queryObj);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetRetExternId()).compareTo(other.isSetRetExternId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetRetExternId()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retExternId, other.retExternId);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetRetObj()).compareTo(other.isSetRetObj());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetRetObj()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retObj, other.retObj);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
    }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("rangeQuery_args(");
      boolean first = true;

      sb.append("r:");
      sb.append(this.r);
      first = false;
      if (!first) sb.append(", ");
      sb.append("queryObj:");
      if (this.queryObj == null) {
        sb.append("null");
      } else {
        org.apache.thrift.TBaseHelper.toString(this.queryObj, sb);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("retExternId:");
      sb.append(this.retExternId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("retObj:");
      sb.append(this.retObj);
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
      // check for required fields
      // alas, we cannot check 'r' because it's a primitive and you chose the non-beans generator.
      if (queryObj == null) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'queryObj' was not present! Struct: " + toString());
      }
      // alas, we cannot check 'retExternId' because it's a primitive and you chose the non-beans generator.
      // alas, we cannot check 'retObj' because it's a primitive and you chose the non-beans generator.
      // 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, java.lang.ClassNotFoundException {
      try {
        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
        __isset_bitfield = 0;
        read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
      } catch (org.apache.thrift.TException te) {
        throw new java.io.IOException(te);
      }
    }

    private static class rangeQuery_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public rangeQuery_argsStandardScheme getScheme() {
        return new rangeQuery_argsStandardScheme();
      }
    }

    private static class rangeQuery_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<rangeQuery_args> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, rangeQuery_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: // R
              if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) {
                struct.r = iprot.readDouble();
                struct.setRIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 2: // QUERY_OBJ
              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                struct.queryObj = iprot.readBinary();
                struct.setQueryObjIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 3: // RET_EXTERN_ID
              if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                struct.retExternId = iprot.readBool();
                struct.setRetExternIdIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 4: // RET_OBJ
              if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                struct.retObj = iprot.readBool();
                struct.setRetObjIsSet(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
        if (!struct.isSetR()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'r' was not found in serialized data! Struct: " + toString());
        }
        if (!struct.isSetRetExternId()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'retExternId' was not found in serialized data! Struct: " + toString());
        }
        if (!struct.isSetRetObj()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'retObj' was not found in serialized data! Struct: " + toString());
        }
        struct.validate();
      }

      public void write(org.apache.thrift.protocol.TProtocol oprot, rangeQuery_args struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        oprot.writeFieldBegin(R_FIELD_DESC);
        oprot.writeDouble(struct.r);
        oprot.writeFieldEnd();
        if (struct.queryObj != null) {
          oprot.writeFieldBegin(QUERY_OBJ_FIELD_DESC);
          oprot.writeBinary(struct.queryObj);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldBegin(RET_EXTERN_ID_FIELD_DESC);
        oprot.writeBool(struct.retExternId);
        oprot.writeFieldEnd();
        oprot.writeFieldBegin(RET_OBJ_FIELD_DESC);
        oprot.writeBool(struct.retObj);
        oprot.writeFieldEnd();
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class rangeQuery_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public rangeQuery_argsTupleScheme getScheme() {
        return new rangeQuery_argsTupleScheme();
      }
    }

    private static class rangeQuery_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<rangeQuery_args> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, rangeQuery_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        oprot.writeDouble(struct.r);
        oprot.writeBinary(struct.queryObj);
        oprot.writeBool(struct.retExternId);
        oprot.writeBool(struct.retObj);
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, rangeQuery_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        struct.r = iprot.readDouble();
        struct.setRIsSet(true);
        struct.queryObj = iprot.readBinary();
        struct.setQueryObjIsSet(true);
        struct.retExternId = iprot.readBool();
        struct.setRetExternIdIsSet(true);
        struct.retObj = iprot.readBool();
        struct.setRetObjIsSet(true);
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class rangeQuery_result implements org.apache.thrift.TBase<rangeQuery_result, rangeQuery_result._Fields>, java.io.Serializable, Cloneable, Comparable<rangeQuery_result>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("rangeQuery_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 ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new rangeQuery_resultStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new rangeQuery_resultTupleSchemeFactory();

    public java.util.List<ReplyEntry> success; // required
    public QueryException err; // 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"),
      ERR((short)1, "err");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // ERR
            return ERR;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.FieldValueMetaData(org.apache.thrift.protocol.TType.LIST          , "ReplyEntryList")));
      tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, 
          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(rangeQuery_result.class, metaDataMap);
    }

    public rangeQuery_result() {
    }

    public rangeQuery_result(
      java.util.List<ReplyEntry> success,
      QueryException err)
    {
      this();
      this.success = success;
      this.err = err;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public rangeQuery_result(rangeQuery_result other) {
      if (other.isSetSuccess()) {
        java.util.List<ReplyEntry> __this__success = new java.util.ArrayList<ReplyEntry>(other.success.size());
        for (ReplyEntry other_element : other.success) {
          __this__success.add(new ReplyEntry(other_element));
        }
        this.success = __this__success;
      }
      if (other.isSetErr()) {
        this.err = new QueryException(other.err);
      }
    }

    public rangeQuery_result deepCopy() {
      return new rangeQuery_result(this);
    }

    @Override
    public void clear() {
      this.success = null;
      this.err = null;
    }

    public int getSuccessSize() {
      return (this.success == null) ? 0 : this.success.size();
    }

    public java.util.Iterator<ReplyEntry> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(ReplyEntry elem) {
      if (this.success == null) {
        this.success = new java.util.ArrayList<ReplyEntry>();
      }
      this.success.add(elem);
    }

    public java.util.List<ReplyEntry> getSuccess() {
      return this.success;
    }

    public rangeQuery_result setSuccess(java.util.List<ReplyEntry> 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 QueryException getErr() {
      return this.err;
    }

    public rangeQuery_result setErr(QueryException err) {
      this.err = err;
      return this;
    }

    public void unsetErr() {
      this.err = null;
    }

    /** Returns true if field err is set (has been assigned a value) and false otherwise */
    public boolean isSetErr() {
      return this.err != null;
    }

    public void setErrIsSet(boolean value) {
      if (!value) {
        this.err = null;
      }
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((java.util.List<ReplyEntry>)value);
        }
        break;

      case ERR:
        if (value == null) {
          unsetErr();
        } else {
          setErr((QueryException)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case ERR:
        return getErr();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case ERR:
        return isSetErr();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof rangeQuery_result)
        return this.equals((rangeQuery_result)that);
      return false;
    }

    public boolean equals(rangeQuery_result that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      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_err = true && this.isSetErr();
      boolean that_present_err = true && that.isSetErr();
      if (this_present_err || that_present_err) {
        if (!(this_present_err && that_present_err))
          return false;
        if (!this.err.equals(that.err))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
      if (isSetSuccess())
        hashCode = hashCode * 8191 + success.hashCode();

      hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287);
      if (isSetErr())
        hashCode = hashCode * 8191 + err.hashCode();

      return hashCode;
    }

    @Override
    public int compareTo(rangeQuery_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetSuccess()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetErr()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
      }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("rangeQuery_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("err:");
      if (this.err == null) {
        sb.append("null");
      } else {
        sb.append(this.err);
      }
      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, java.lang.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 rangeQuery_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public rangeQuery_resultStandardScheme getScheme() {
        return new rangeQuery_resultStandardScheme();
      }
    }

    private static class rangeQuery_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<rangeQuery_result> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, rangeQuery_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 _list8 = iprot.readListBegin();
                  struct.success = new java.util.ArrayList<ReplyEntry>(_list8.size);
                  ReplyEntry _elem9;
                  for (int _i10 = 0; _i10 < _list8.size; ++_i10)
                  {
                    _elem9 = new ReplyEntry();
                    _elem9.read(iprot);
                    struct.success.add(_elem9);
                  }
                  iprot.readListEnd();
                }
                struct.setSuccessIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 1: // ERR
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.err = new QueryException();
                struct.err.read(iprot);
                struct.setErrIsSet(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, rangeQuery_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.STRUCT, struct.success.size()));
            for (ReplyEntry _iter11 : struct.success)
            {
              _iter11.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
        if (struct.err != null) {
          oprot.writeFieldBegin(ERR_FIELD_DESC);
          struct.err.write(oprot);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class rangeQuery_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public rangeQuery_resultTupleScheme getScheme() {
        return new rangeQuery_resultTupleScheme();
      }
    }

    private static class rangeQuery_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<rangeQuery_result> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, rangeQuery_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet optionals = new java.util.BitSet();
        if (struct.isSetSuccess()) {
          optionals.set(0);
        }
        if (struct.isSetErr()) {
          optionals.set(1);
        }
        oprot.writeBitSet(optionals, 2);
        if (struct.isSetSuccess()) {
          {
            oprot.writeI32(struct.success.size());
            for (ReplyEntry _iter12 : struct.success)
            {
              _iter12.write(oprot);
            }
          }
        }
        if (struct.isSetErr()) {
          struct.err.write(oprot);
        }
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, rangeQuery_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet incoming = iprot.readBitSet(2);
        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.success = new java.util.ArrayList<ReplyEntry>(_list13.size);
            ReplyEntry _elem14;
            for (int _i15 = 0; _i15 < _list13.size; ++_i15)
            {
              _elem14 = new ReplyEntry();
              _elem14.read(iprot);
              struct.success.add(_elem14);
            }
          }
          struct.setSuccessIsSet(true);
        }
        if (incoming.get(1)) {
          struct.err = new QueryException();
          struct.err.read(iprot);
          struct.setErrIsSet(true);
        }
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class knnQueryBatch_args implements org.apache.thrift.TBase<knnQueryBatch_args, knnQueryBatch_args._Fields>, java.io.Serializable, Cloneable, Comparable<knnQueryBatch_args>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("knnQueryBatch_args");

    private static final org.apache.thrift.protocol.TField K_FIELD_DESC = new org.apache.thrift.protocol.TField("k", org.apache.thrift.protocol.TType.I32, (short)1);
    private static final org.apache.thrift.protocol.TField QUERY_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("queryObj", org.apache.thrift.protocol.TType.LIST, (short)2);
    private static final org.apache.thrift.protocol.TField RET_EXTERN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("retExternId", org.apache.thrift.protocol.TType.BOOL, (short)3);
    private static final org.apache.thrift.protocol.TField RET_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("retObj", org.apache.thrift.protocol.TType.BOOL, (short)4);
    private static final org.apache.thrift.protocol.TField NUM_THREADS_FIELD_DESC = new org.apache.thrift.protocol.TField("numThreads", org.apache.thrift.protocol.TType.I32, (short)5);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new knnQueryBatch_argsStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new knnQueryBatch_argsTupleSchemeFactory();

    public int k; // required
    public java.util.List<java.nio.ByteBuffer> queryObj; // required
    public boolean retExternId; // required
    public boolean retObj; // required
    public int numThreads; // 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 {
      K((short)1, "k"),
      QUERY_OBJ((short)2, "queryObj"),
      RET_EXTERN_ID((short)3, "retExternId"),
      RET_OBJ((short)4, "retObj"),
      NUM_THREADS((short)5, "numThreads");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // K
            return K;
          case 2: // QUERY_OBJ
            return QUERY_OBJ;
          case 3: // RET_EXTERN_ID
            return RET_EXTERN_ID;
          case 4: // RET_OBJ
            return RET_OBJ;
          case 5: // NUM_THREADS
            return NUM_THREADS;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __K_ISSET_ID = 0;
    private static final int __RETEXTERNID_ISSET_ID = 1;
    private static final int __RETOBJ_ISSET_ID = 2;
    private static final int __NUMTHREADS_ISSET_ID = 3;
    private byte __isset_bitfield = 0;
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
      tmpMap.put(_Fields.K, new org.apache.thrift.meta_data.FieldMetaData("k", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
      tmpMap.put(_Fields.QUERY_OBJ, new org.apache.thrift.meta_data.FieldMetaData("queryObj", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          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.STRING              , true))));
      tmpMap.put(_Fields.RET_EXTERN_ID, new org.apache.thrift.meta_data.FieldMetaData("retExternId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
      tmpMap.put(_Fields.RET_OBJ, new org.apache.thrift.meta_data.FieldMetaData("retObj", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
      tmpMap.put(_Fields.NUM_THREADS, new org.apache.thrift.meta_data.FieldMetaData("numThreads", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(knnQueryBatch_args.class, metaDataMap);
    }

    public knnQueryBatch_args() {
    }

    public knnQueryBatch_args(
      int k,
      java.util.List<java.nio.ByteBuffer> queryObj,
      boolean retExternId,
      boolean retObj,
      int numThreads)
    {
      this();
      this.k = k;
      setKIsSet(true);
      this.queryObj = queryObj;
      this.retExternId = retExternId;
      setRetExternIdIsSet(true);
      this.retObj = retObj;
      setRetObjIsSet(true);
      this.numThreads = numThreads;
      setNumThreadsIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public knnQueryBatch_args(knnQueryBatch_args other) {
      __isset_bitfield = other.__isset_bitfield;
      this.k = other.k;
      if (other.isSetQueryObj()) {
        java.util.List<java.nio.ByteBuffer> __this__queryObj = new java.util.ArrayList<java.nio.ByteBuffer>(other.queryObj);
        this.queryObj = __this__queryObj;
      }
      this.retExternId = other.retExternId;
      this.retObj = other.retObj;
      this.numThreads = other.numThreads;
    }

    public knnQueryBatch_args deepCopy() {
      return new knnQueryBatch_args(this);
    }

    @Override
    public void clear() {
      setKIsSet(false);
      this.k = 0;
      this.queryObj = null;
      setRetExternIdIsSet(false);
      this.retExternId = false;
      setRetObjIsSet(false);
      this.retObj = false;
      setNumThreadsIsSet(false);
      this.numThreads = 0;
    }

    public int getK() {
      return this.k;
    }

    public knnQueryBatch_args setK(int k) {
      this.k = k;
      setKIsSet(true);
      return this;
    }

    public void unsetK() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __K_ISSET_ID);
    }

    /** Returns true if field k is set (has been assigned a value) and false otherwise */
    public boolean isSetK() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __K_ISSET_ID);
    }

    public void setKIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __K_ISSET_ID, value);
    }

    public int getQueryObjSize() {
      return (this.queryObj == null) ? 0 : this.queryObj.size();
    }

    public java.util.Iterator<java.nio.ByteBuffer> getQueryObjIterator() {
      return (this.queryObj == null) ? null : this.queryObj.iterator();
    }

    public void addToQueryObj(java.nio.ByteBuffer elem) {
      if (this.queryObj == null) {
        this.queryObj = new java.util.ArrayList<java.nio.ByteBuffer>();
      }
      this.queryObj.add(elem);
    }

    public java.util.List<java.nio.ByteBuffer> getQueryObj() {
      return this.queryObj;
    }

    public knnQueryBatch_args setQueryObj(java.util.List<java.nio.ByteBuffer> queryObj) {
      this.queryObj = queryObj;
      return this;
    }

    public void unsetQueryObj() {
      this.queryObj = null;
    }

    /** Returns true if field queryObj is set (has been assigned a value) and false otherwise */
    public boolean isSetQueryObj() {
      return this.queryObj != null;
    }

    public void setQueryObjIsSet(boolean value) {
      if (!value) {
        this.queryObj = null;
      }
    }

    public boolean isRetExternId() {
      return this.retExternId;
    }

    public knnQueryBatch_args setRetExternId(boolean retExternId) {
      this.retExternId = retExternId;
      setRetExternIdIsSet(true);
      return this;
    }

    public void unsetRetExternId() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETEXTERNID_ISSET_ID);
    }

    /** Returns true if field retExternId is set (has been assigned a value) and false otherwise */
    public boolean isSetRetExternId() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETEXTERNID_ISSET_ID);
    }

    public void setRetExternIdIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETEXTERNID_ISSET_ID, value);
    }

    public boolean isRetObj() {
      return this.retObj;
    }

    public knnQueryBatch_args setRetObj(boolean retObj) {
      this.retObj = retObj;
      setRetObjIsSet(true);
      return this;
    }

    public void unsetRetObj() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETOBJ_ISSET_ID);
    }

    /** Returns true if field retObj is set (has been assigned a value) and false otherwise */
    public boolean isSetRetObj() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETOBJ_ISSET_ID);
    }

    public void setRetObjIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETOBJ_ISSET_ID, value);
    }

    public int getNumThreads() {
      return this.numThreads;
    }

    public knnQueryBatch_args setNumThreads(int numThreads) {
      this.numThreads = numThreads;
      setNumThreadsIsSet(true);
      return this;
    }

    public void unsetNumThreads() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __NUMTHREADS_ISSET_ID);
    }

    /** Returns true if field numThreads is set (has been assigned a value) and false otherwise */
    public boolean isSetNumThreads() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __NUMTHREADS_ISSET_ID);
    }

    public void setNumThreadsIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __NUMTHREADS_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case K:
        if (value == null) {
          unsetK();
        } else {
          setK((java.lang.Integer)value);
        }
        break;

      case QUERY_OBJ:
        if (value == null) {
          unsetQueryObj();
        } else {
          setQueryObj((java.util.List<java.nio.ByteBuffer>)value);
        }
        break;

      case RET_EXTERN_ID:
        if (value == null) {
          unsetRetExternId();
        } else {
          setRetExternId((java.lang.Boolean)value);
        }
        break;

      case RET_OBJ:
        if (value == null) {
          unsetRetObj();
        } else {
          setRetObj((java.lang.Boolean)value);
        }
        break;

      case NUM_THREADS:
        if (value == null) {
          unsetNumThreads();
        } else {
          setNumThreads((java.lang.Integer)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case K:
        return getK();

      case QUERY_OBJ:
        return getQueryObj();

      case RET_EXTERN_ID:
        return isRetExternId();

      case RET_OBJ:
        return isRetObj();

      case NUM_THREADS:
        return getNumThreads();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case K:
        return isSetK();
      case QUERY_OBJ:
        return isSetQueryObj();
      case RET_EXTERN_ID:
        return isSetRetExternId();
      case RET_OBJ:
        return isSetRetObj();
      case NUM_THREADS:
        return isSetNumThreads();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof knnQueryBatch_args)
        return this.equals((knnQueryBatch_args)that);
      return false;
    }

    public boolean equals(knnQueryBatch_args that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      boolean this_present_k = true;
      boolean that_present_k = true;
      if (this_present_k || that_present_k) {
        if (!(this_present_k && that_present_k))
          return false;
        if (this.k != that.k)
          return false;
      }

      boolean this_present_queryObj = true && this.isSetQueryObj();
      boolean that_present_queryObj = true && that.isSetQueryObj();
      if (this_present_queryObj || that_present_queryObj) {
        if (!(this_present_queryObj && that_present_queryObj))
          return false;
        if (!this.queryObj.equals(that.queryObj))
          return false;
      }

      boolean this_present_retExternId = true;
      boolean that_present_retExternId = true;
      if (this_present_retExternId || that_present_retExternId) {
        if (!(this_present_retExternId && that_present_retExternId))
          return false;
        if (this.retExternId != that.retExternId)
          return false;
      }

      boolean this_present_retObj = true;
      boolean that_present_retObj = true;
      if (this_present_retObj || that_present_retObj) {
        if (!(this_present_retObj && that_present_retObj))
          return false;
        if (this.retObj != that.retObj)
          return false;
      }

      boolean this_present_numThreads = true;
      boolean that_present_numThreads = true;
      if (this_present_numThreads || that_present_numThreads) {
        if (!(this_present_numThreads && that_present_numThreads))
          return false;
        if (this.numThreads != that.numThreads)
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + k;

      hashCode = hashCode * 8191 + ((isSetQueryObj()) ? 131071 : 524287);
      if (isSetQueryObj())
        hashCode = hashCode * 8191 + queryObj.hashCode();

      hashCode = hashCode * 8191 + ((retExternId) ? 131071 : 524287);

      hashCode = hashCode * 8191 + ((retObj) ? 131071 : 524287);

      hashCode = hashCode * 8191 + numThreads;

      return hashCode;
    }

    @Override
    public int compareTo(knnQueryBatch_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetK()).compareTo(other.isSetK());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetK()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.k, other.k);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetQueryObj()).compareTo(other.isSetQueryObj());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetQueryObj()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryObj, other.queryObj);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetRetExternId()).compareTo(other.isSetRetExternId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetRetExternId()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retExternId, other.retExternId);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetRetObj()).compareTo(other.isSetRetObj());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetRetObj()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retObj, other.retObj);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetNumThreads()).compareTo(other.isSetNumThreads());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetNumThreads()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.numThreads, other.numThreads);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
    }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("knnQueryBatch_args(");
      boolean first = true;

      sb.append("k:");
      sb.append(this.k);
      first = false;
      if (!first) sb.append(", ");
      sb.append("queryObj:");
      if (this.queryObj == null) {
        sb.append("null");
      } else {
        org.apache.thrift.TBaseHelper.toString(this.queryObj, sb);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("retExternId:");
      sb.append(this.retExternId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("retObj:");
      sb.append(this.retObj);
      first = false;
      if (!first) sb.append(", ");
      sb.append("numThreads:");
      sb.append(this.numThreads);
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
      // check for required fields
      // alas, we cannot check 'k' because it's a primitive and you chose the non-beans generator.
      if (queryObj == null) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'queryObj' was not present! Struct: " + toString());
      }
      // alas, we cannot check 'retExternId' because it's a primitive and you chose the non-beans generator.
      // alas, we cannot check 'retObj' because it's a primitive and you chose the non-beans generator.
      // alas, we cannot check 'numThreads' because it's a primitive and you chose the non-beans generator.
      // 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, java.lang.ClassNotFoundException {
      try {
        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
        __isset_bitfield = 0;
        read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
      } catch (org.apache.thrift.TException te) {
        throw new java.io.IOException(te);
      }
    }

    private static class knnQueryBatch_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public knnQueryBatch_argsStandardScheme getScheme() {
        return new knnQueryBatch_argsStandardScheme();
      }
    }

    private static class knnQueryBatch_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<knnQueryBatch_args> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, knnQueryBatch_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: // K
              if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
                struct.k = iprot.readI32();
                struct.setKIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 2: // QUERY_OBJ
              if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
                {
                  org.apache.thrift.protocol.TList _list16 = iprot.readListBegin();
                  struct.queryObj = new java.util.ArrayList<java.nio.ByteBuffer>(_list16.size);
                  java.nio.ByteBuffer _elem17;
                  for (int _i18 = 0; _i18 < _list16.size; ++_i18)
                  {
                    _elem17 = iprot.readBinary();
                    struct.queryObj.add(_elem17);
                  }
                  iprot.readListEnd();
                }
                struct.setQueryObjIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 3: // RET_EXTERN_ID
              if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                struct.retExternId = iprot.readBool();
                struct.setRetExternIdIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 4: // RET_OBJ
              if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                struct.retObj = iprot.readBool();
                struct.setRetObjIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 5: // NUM_THREADS
              if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
                struct.numThreads = iprot.readI32();
                struct.setNumThreadsIsSet(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
        if (!struct.isSetK()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'k' was not found in serialized data! Struct: " + toString());
        }
        if (!struct.isSetRetExternId()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'retExternId' was not found in serialized data! Struct: " + toString());
        }
        if (!struct.isSetRetObj()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'retObj' was not found in serialized data! Struct: " + toString());
        }
        if (!struct.isSetNumThreads()) {
          throw new org.apache.thrift.protocol.TProtocolException("Required field 'numThreads' was not found in serialized data! Struct: " + toString());
        }
        struct.validate();
      }

      public void write(org.apache.thrift.protocol.TProtocol oprot, knnQueryBatch_args struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        oprot.writeFieldBegin(K_FIELD_DESC);
        oprot.writeI32(struct.k);
        oprot.writeFieldEnd();
        if (struct.queryObj != null) {
          oprot.writeFieldBegin(QUERY_OBJ_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.queryObj.size()));
            for (java.nio.ByteBuffer _iter19 : struct.queryObj)
            {
              oprot.writeBinary(_iter19);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
        oprot.writeFieldBegin(RET_EXTERN_ID_FIELD_DESC);
        oprot.writeBool(struct.retExternId);
        oprot.writeFieldEnd();
        oprot.writeFieldBegin(RET_OBJ_FIELD_DESC);
        oprot.writeBool(struct.retObj);
        oprot.writeFieldEnd();
        oprot.writeFieldBegin(NUM_THREADS_FIELD_DESC);
        oprot.writeI32(struct.numThreads);
        oprot.writeFieldEnd();
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class knnQueryBatch_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public knnQueryBatch_argsTupleScheme getScheme() {
        return new knnQueryBatch_argsTupleScheme();
      }
    }

    private static class knnQueryBatch_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<knnQueryBatch_args> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, knnQueryBatch_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        oprot.writeI32(struct.k);
        {
          oprot.writeI32(struct.queryObj.size());
          for (java.nio.ByteBuffer _iter20 : struct.queryObj)
          {
            oprot.writeBinary(_iter20);
          }
        }
        oprot.writeBool(struct.retExternId);
        oprot.writeBool(struct.retObj);
        oprot.writeI32(struct.numThreads);
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, knnQueryBatch_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        struct.k = iprot.readI32();
        struct.setKIsSet(true);
        {
          org.apache.thrift.protocol.TList _list21 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
          struct.queryObj = new java.util.ArrayList<java.nio.ByteBuffer>(_list21.size);
          java.nio.ByteBuffer _elem22;
          for (int _i23 = 0; _i23 < _list21.size; ++_i23)
          {
            _elem22 = iprot.readBinary();
            struct.queryObj.add(_elem22);
          }
        }
        struct.setQueryObjIsSet(true);
        struct.retExternId = iprot.readBool();
        struct.setRetExternIdIsSet(true);
        struct.retObj = iprot.readBool();
        struct.setRetObjIsSet(true);
        struct.numThreads = iprot.readI32();
        struct.setNumThreadsIsSet(true);
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class knnQueryBatch_result implements org.apache.thrift.TBase<knnQueryBatch_result, knnQueryBatch_result._Fields>, java.io.Serializable, Cloneable, Comparable<knnQueryBatch_result>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("knnQueryBatch_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 ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new knnQueryBatch_resultStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new knnQueryBatch_resultTupleSchemeFactory();

    public java.util.List<java.util.List<ReplyEntry>> success; // required
    public QueryException err; // 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"),
      ERR((short)1, "err");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // ERR
            return ERR;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.FieldValueMetaData(org.apache.thrift.protocol.TType.LIST          , "ReplyEntryListBatch")));
      tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, 
          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(knnQueryBatch_result.class, metaDataMap);
    }

    public knnQueryBatch_result() {
    }

    public knnQueryBatch_result(
      java.util.List<java.util.List<ReplyEntry>> success,
      QueryException err)
    {
      this();
      this.success = success;
      this.err = err;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public knnQueryBatch_result(knnQueryBatch_result other) {
      if (other.isSetSuccess()) {
        java.util.List<java.util.List<ReplyEntry>> __this__success = new java.util.ArrayList<java.util.List<ReplyEntry>>(other.success.size());
        for (java.util.List<ReplyEntry> other_element : other.success) {
          java.util.List<ReplyEntry> __this__success_copy = new java.util.ArrayList<ReplyEntry>(other_element.size());
          for (ReplyEntry other_element_element : other_element) {
            __this__success_copy.add(new ReplyEntry(other_element_element));
          }
          __this__success.add(__this__success_copy);
        }
        this.success = __this__success;
      }
      if (other.isSetErr()) {
        this.err = new QueryException(other.err);
      }
    }

    public knnQueryBatch_result deepCopy() {
      return new knnQueryBatch_result(this);
    }

    @Override
    public void clear() {
      this.success = null;
      this.err = null;
    }

    public int getSuccessSize() {
      return (this.success == null) ? 0 : this.success.size();
    }

    public java.util.Iterator<java.util.List<ReplyEntry>> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(java.util.List<ReplyEntry> elem) {
      if (this.success == null) {
        this.success = new java.util.ArrayList<java.util.List<ReplyEntry>>();
      }
      this.success.add(elem);
    }

    public java.util.List<java.util.List<ReplyEntry>> getSuccess() {
      return this.success;
    }

    public knnQueryBatch_result setSuccess(java.util.List<java.util.List<ReplyEntry>> 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 QueryException getErr() {
      return this.err;
    }

    public knnQueryBatch_result setErr(QueryException err) {
      this.err = err;
      return this;
    }

    public void unsetErr() {
      this.err = null;
    }

    /** Returns true if field err is set (has been assigned a value) and false otherwise */
    public boolean isSetErr() {
      return this.err != null;
    }

    public void setErrIsSet(boolean value) {
      if (!value) {
        this.err = null;
      }
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((java.util.List<java.util.List<ReplyEntry>>)value);
        }
        break;

      case ERR:
        if (value == null) {
          unsetErr();
        } else {
          setErr((QueryException)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case ERR:
        return getErr();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case ERR:
        return isSetErr();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof knnQueryBatch_result)
        return this.equals((knnQueryBatch_result)that);
      return false;
    }

    public boolean equals(knnQueryBatch_result that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      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_err = true && this.isSetErr();
      boolean that_present_err = true && that.isSetErr();
      if (this_present_err || that_present_err) {
        if (!(this_present_err && that_present_err))
          return false;
        if (!this.err.equals(that.err))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
      if (isSetSuccess())
        hashCode = hashCode * 8191 + success.hashCode();

      hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287);
      if (isSetErr())
        hashCode = hashCode * 8191 + err.hashCode();

      return hashCode;
    }

    @Override
    public int compareTo(knnQueryBatch_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetSuccess()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetErr()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
      }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("knnQueryBatch_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("err:");
      if (this.err == null) {
        sb.append("null");
      } else {
        sb.append(this.err);
      }
      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, java.lang.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 knnQueryBatch_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public knnQueryBatch_resultStandardScheme getScheme() {
        return new knnQueryBatch_resultStandardScheme();
      }
    }

    private static class knnQueryBatch_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<knnQueryBatch_result> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, knnQueryBatch_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 _list24 = iprot.readListBegin();
                  struct.success = new java.util.ArrayList<java.util.List<ReplyEntry>>(_list24.size);
                  java.util.List<ReplyEntry> _elem25;
                  for (int _i26 = 0; _i26 < _list24.size; ++_i26)
                  {
                    {
                      org.apache.thrift.protocol.TList _list27 = iprot.readListBegin();
                      _elem25 = new java.util.ArrayList<ReplyEntry>(_list27.size);
                      ReplyEntry _elem28;
                      for (int _i29 = 0; _i29 < _list27.size; ++_i29)
                      {
                        _elem28 = new ReplyEntry();
                        _elem28.read(iprot);
                        _elem25.add(_elem28);
                      }
                      iprot.readListEnd();
                    }
                    struct.success.add(_elem25);
                  }
                  iprot.readListEnd();
                }
                struct.setSuccessIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 1: // ERR
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.err = new QueryException();
                struct.err.read(iprot);
                struct.setErrIsSet(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, knnQueryBatch_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.LIST, struct.success.size()));
            for (java.util.List<ReplyEntry> _iter30 : struct.success)
            {
              {
                oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, _iter30.size()));
                for (ReplyEntry _iter31 : _iter30)
                {
                  _iter31.write(oprot);
                }
                oprot.writeListEnd();
              }
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
        if (struct.err != null) {
          oprot.writeFieldBegin(ERR_FIELD_DESC);
          struct.err.write(oprot);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class knnQueryBatch_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public knnQueryBatch_resultTupleScheme getScheme() {
        return new knnQueryBatch_resultTupleScheme();
      }
    }

    private static class knnQueryBatch_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<knnQueryBatch_result> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, knnQueryBatch_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet optionals = new java.util.BitSet();
        if (struct.isSetSuccess()) {
          optionals.set(0);
        }
        if (struct.isSetErr()) {
          optionals.set(1);
        }
        oprot.writeBitSet(optionals, 2);
        if (struct.isSetSuccess()) {
          {
            oprot.writeI32(struct.success.size());
            for (java.util.List<ReplyEntry> _iter32 : struct.success)
            {
              {
                oprot.writeI32(_iter32.size());
                for (ReplyEntry _iter33 : _iter32)
                {
                  _iter33.write(oprot);
                }
              }
            }
          }
        }
        if (struct.isSetErr()) {
          struct.err.write(oprot);
        }
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, knnQueryBatch_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet incoming = iprot.readBitSet(2);
        if (incoming.get(0)) {
          {
            org.apache.thrift.protocol.TList _list34 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.LIST, iprot.readI32());
            struct.success = new java.util.ArrayList<java.util.List<ReplyEntry>>(_list34.size);
            java.util.List<ReplyEntry> _elem35;
            for (int _i36 = 0; _i36 < _list34.size; ++_i36)
            {
              {
                org.apache.thrift.protocol.TList _list37 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
                _elem35 = new java.util.ArrayList<ReplyEntry>(_list37.size);
                ReplyEntry _elem38;
                for (int _i39 = 0; _i39 < _list37.size; ++_i39)
                {
                  _elem38 = new ReplyEntry();
                  _elem38.read(iprot);
                  _elem35.add(_elem38);
                }
              }
              struct.success.add(_elem35);
            }
          }
          struct.setSuccessIsSet(true);
        }
        if (incoming.get(1)) {
          struct.err = new QueryException();
          struct.err.read(iprot);
          struct.setErrIsSet(true);
        }
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class getDistance_args implements org.apache.thrift.TBase<getDistance_args, getDistance_args._Fields>, java.io.Serializable, Cloneable, Comparable<getDistance_args>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getDistance_args");

    private static final org.apache.thrift.protocol.TField OBJ1_FIELD_DESC = new org.apache.thrift.protocol.TField("obj1", org.apache.thrift.protocol.TType.STRING, (short)1);
    private static final org.apache.thrift.protocol.TField OBJ2_FIELD_DESC = new org.apache.thrift.protocol.TField("obj2", org.apache.thrift.protocol.TType.STRING, (short)2);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getDistance_argsStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getDistance_argsTupleSchemeFactory();

    public java.nio.ByteBuffer obj1; // required
    public java.nio.ByteBuffer obj2; // 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 {
      OBJ1((short)1, "obj1"),
      OBJ2((short)2, "obj2");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // OBJ1
            return OBJ1;
          case 2: // OBJ2
            return OBJ2;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
      tmpMap.put(_Fields.OBJ1, new org.apache.thrift.meta_data.FieldMetaData("obj1", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING          , true)));
      tmpMap.put(_Fields.OBJ2, new org.apache.thrift.meta_data.FieldMetaData("obj2", org.apache.thrift.TFieldRequirementType.REQUIRED, 
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING          , true)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getDistance_args.class, metaDataMap);
    }

    public getDistance_args() {
    }

    public getDistance_args(
      java.nio.ByteBuffer obj1,
      java.nio.ByteBuffer obj2)
    {
      this();
      this.obj1 = org.apache.thrift.TBaseHelper.copyBinary(obj1);
      this.obj2 = org.apache.thrift.TBaseHelper.copyBinary(obj2);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getDistance_args(getDistance_args other) {
      if (other.isSetObj1()) {
        this.obj1 = org.apache.thrift.TBaseHelper.copyBinary(other.obj1);
      }
      if (other.isSetObj2()) {
        this.obj2 = org.apache.thrift.TBaseHelper.copyBinary(other.obj2);
      }
    }

    public getDistance_args deepCopy() {
      return new getDistance_args(this);
    }

    @Override
    public void clear() {
      this.obj1 = null;
      this.obj2 = null;
    }

    public byte[] getObj1() {
      setObj1(org.apache.thrift.TBaseHelper.rightSize(obj1));
      return obj1 == null ? null : obj1.array();
    }

    public java.nio.ByteBuffer bufferForObj1() {
      return org.apache.thrift.TBaseHelper.copyBinary(obj1);
    }

    public getDistance_args setObj1(byte[] obj1) {
      this.obj1 = obj1 == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(obj1.clone());
      return this;
    }

    public getDistance_args setObj1(java.nio.ByteBuffer obj1) {
      this.obj1 = org.apache.thrift.TBaseHelper.copyBinary(obj1);
      return this;
    }

    public void unsetObj1() {
      this.obj1 = null;
    }

    /** Returns true if field obj1 is set (has been assigned a value) and false otherwise */
    public boolean isSetObj1() {
      return this.obj1 != null;
    }

    public void setObj1IsSet(boolean value) {
      if (!value) {
        this.obj1 = null;
      }
    }

    public byte[] getObj2() {
      setObj2(org.apache.thrift.TBaseHelper.rightSize(obj2));
      return obj2 == null ? null : obj2.array();
    }

    public java.nio.ByteBuffer bufferForObj2() {
      return org.apache.thrift.TBaseHelper.copyBinary(obj2);
    }

    public getDistance_args setObj2(byte[] obj2) {
      this.obj2 = obj2 == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(obj2.clone());
      return this;
    }

    public getDistance_args setObj2(java.nio.ByteBuffer obj2) {
      this.obj2 = org.apache.thrift.TBaseHelper.copyBinary(obj2);
      return this;
    }

    public void unsetObj2() {
      this.obj2 = null;
    }

    /** Returns true if field obj2 is set (has been assigned a value) and false otherwise */
    public boolean isSetObj2() {
      return this.obj2 != null;
    }

    public void setObj2IsSet(boolean value) {
      if (!value) {
        this.obj2 = null;
      }
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case OBJ1:
        if (value == null) {
          unsetObj1();
        } else {
          if (value instanceof byte[]) {
            setObj1((byte[])value);
          } else {
            setObj1((java.nio.ByteBuffer)value);
          }
        }
        break;

      case OBJ2:
        if (value == null) {
          unsetObj2();
        } else {
          if (value instanceof byte[]) {
            setObj2((byte[])value);
          } else {
            setObj2((java.nio.ByteBuffer)value);
          }
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case OBJ1:
        return getObj1();

      case OBJ2:
        return getObj2();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case OBJ1:
        return isSetObj1();
      case OBJ2:
        return isSetObj2();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof getDistance_args)
        return this.equals((getDistance_args)that);
      return false;
    }

    public boolean equals(getDistance_args that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      boolean this_present_obj1 = true && this.isSetObj1();
      boolean that_present_obj1 = true && that.isSetObj1();
      if (this_present_obj1 || that_present_obj1) {
        if (!(this_present_obj1 && that_present_obj1))
          return false;
        if (!this.obj1.equals(that.obj1))
          return false;
      }

      boolean this_present_obj2 = true && this.isSetObj2();
      boolean that_present_obj2 = true && that.isSetObj2();
      if (this_present_obj2 || that_present_obj2) {
        if (!(this_present_obj2 && that_present_obj2))
          return false;
        if (!this.obj2.equals(that.obj2))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + ((isSetObj1()) ? 131071 : 524287);
      if (isSetObj1())
        hashCode = hashCode * 8191 + obj1.hashCode();

      hashCode = hashCode * 8191 + ((isSetObj2()) ? 131071 : 524287);
      if (isSetObj2())
        hashCode = hashCode * 8191 + obj2.hashCode();

      return hashCode;
    }

    @Override
    public int compareTo(getDistance_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetObj1()).compareTo(other.isSetObj1());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetObj1()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.obj1, other.obj1);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetObj2()).compareTo(other.isSetObj2());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetObj2()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.obj2, other.obj2);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
    }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("getDistance_args(");
      boolean first = true;

      sb.append("obj1:");
      if (this.obj1 == null) {
        sb.append("null");
      } else {
        org.apache.thrift.TBaseHelper.toString(this.obj1, sb);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("obj2:");
      if (this.obj2 == null) {
        sb.append("null");
      } else {
        org.apache.thrift.TBaseHelper.toString(this.obj2, sb);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
      // check for required fields
      if (obj1 == null) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'obj1' was not present! Struct: " + toString());
      }
      if (obj2 == null) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'obj2' 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, java.lang.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 getDistance_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public getDistance_argsStandardScheme getScheme() {
        return new getDistance_argsStandardScheme();
      }
    }

    private static class getDistance_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getDistance_args> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, getDistance_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: // OBJ1
              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                struct.obj1 = iprot.readBinary();
                struct.setObj1IsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 2: // OBJ2
              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                struct.obj2 = iprot.readBinary();
                struct.setObj2IsSet(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, getDistance_args struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        if (struct.obj1 != null) {
          oprot.writeFieldBegin(OBJ1_FIELD_DESC);
          oprot.writeBinary(struct.obj1);
          oprot.writeFieldEnd();
        }
        if (struct.obj2 != null) {
          oprot.writeFieldBegin(OBJ2_FIELD_DESC);
          oprot.writeBinary(struct.obj2);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class getDistance_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public getDistance_argsTupleScheme getScheme() {
        return new getDistance_argsTupleScheme();
      }
    }

    private static class getDistance_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getDistance_args> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, getDistance_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        oprot.writeBinary(struct.obj1);
        oprot.writeBinary(struct.obj2);
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, getDistance_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        struct.obj1 = iprot.readBinary();
        struct.setObj1IsSet(true);
        struct.obj2 = iprot.readBinary();
        struct.setObj2IsSet(true);
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

  public static class getDistance_result implements org.apache.thrift.TBase<getDistance_result, getDistance_result._Fields>, java.io.Serializable, Cloneable, Comparable<getDistance_result>   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getDistance_result");

    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.DOUBLE, (short)0);
    private static final org.apache.thrift.protocol.TField ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1);

    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getDistance_resultStandardSchemeFactory();
    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getDistance_resultTupleSchemeFactory();

    public double success; // required
    public QueryException err; // 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"),
      ERR((short)1, "err");

      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

      static {
        for (_Fields field : java.util.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: // ERR
            return ERR;
          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 java.lang.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(java.lang.String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final java.lang.String _fieldName;

      _Fields(short thriftId, java.lang.String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public java.lang.String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __SUCCESS_ISSET_ID = 0;
    private byte __isset_bitfield = 0;
    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
      tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, 
          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class)));
      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getDistance_result.class, metaDataMap);
    }

    public getDistance_result() {
    }

    public getDistance_result(
      double success,
      QueryException err)
    {
      this();
      this.success = success;
      setSuccessIsSet(true);
      this.err = err;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getDistance_result(getDistance_result other) {
      __isset_bitfield = other.__isset_bitfield;
      this.success = other.success;
      if (other.isSetErr()) {
        this.err = new QueryException(other.err);
      }
    }

    public getDistance_result deepCopy() {
      return new getDistance_result(this);
    }

    @Override
    public void clear() {
      setSuccessIsSet(false);
      this.success = 0.0;
      this.err = null;
    }

    public double getSuccess() {
      return this.success;
    }

    public getDistance_result setSuccess(double success) {
      this.success = success;
      setSuccessIsSet(true);
      return this;
    }

    public void unsetSuccess() {
      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID);
    }

    /** Returns true if field success is set (has been assigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID);
    }

    public void setSuccessIsSet(boolean value) {
      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
    }

    public QueryException getErr() {
      return this.err;
    }

    public getDistance_result setErr(QueryException err) {
      this.err = err;
      return this;
    }

    public void unsetErr() {
      this.err = null;
    }

    /** Returns true if field err is set (has been assigned a value) and false otherwise */
    public boolean isSetErr() {
      return this.err != null;
    }

    public void setErrIsSet(boolean value) {
      if (!value) {
        this.err = null;
      }
    }

    public void setFieldValue(_Fields field, java.lang.Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((java.lang.Double)value);
        }
        break;

      case ERR:
        if (value == null) {
          unsetErr();
        } else {
          setErr((QueryException)value);
        }
        break;

      }
    }

    public java.lang.Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case ERR:
        return getErr();

      }
      throw new java.lang.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 java.lang.IllegalArgumentException();
      }

      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case ERR:
        return isSetErr();
      }
      throw new java.lang.IllegalStateException();
    }

    @Override
    public boolean equals(java.lang.Object that) {
      if (that == null)
        return false;
      if (that instanceof getDistance_result)
        return this.equals((getDistance_result)that);
      return false;
    }

    public boolean equals(getDistance_result that) {
      if (that == null)
        return false;
      if (this == that)
        return true;

      boolean this_present_success = true;
      boolean that_present_success = true;
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (this.success != that.success)
          return false;
      }

      boolean this_present_err = true && this.isSetErr();
      boolean that_present_err = true && that.isSetErr();
      if (this_present_err || that_present_err) {
        if (!(this_present_err && that_present_err))
          return false;
        if (!this.err.equals(that.err))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int hashCode = 1;

      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(success);

      hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287);
      if (isSetErr())
        hashCode = hashCode * 8191 + err.hashCode();

      return hashCode;
    }

    @Override
    public int compareTo(getDistance_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;

      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetSuccess()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetErr()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err);
        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 {
      scheme(iprot).read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      scheme(oprot).write(oprot, this);
      }

    @Override
    public java.lang.String toString() {
      java.lang.StringBuilder sb = new java.lang.StringBuilder("getDistance_result(");
      boolean first = true;

      sb.append("success:");
      sb.append(this.success);
      first = false;
      if (!first) sb.append(", ");
      sb.append("err:");
      if (this.err == null) {
        sb.append("null");
      } else {
        sb.append(this.err);
      }
      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, java.lang.ClassNotFoundException {
      try {
        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
        __isset_bitfield = 0;
        read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
      } catch (org.apache.thrift.TException te) {
        throw new java.io.IOException(te);
      }
    }

    private static class getDistance_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public getDistance_resultStandardScheme getScheme() {
        return new getDistance_resultStandardScheme();
      }
    }

    private static class getDistance_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getDistance_result> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, getDistance_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.DOUBLE) {
                struct.success = iprot.readDouble();
                struct.setSuccessIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 1: // ERR
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.err = new QueryException();
                struct.err.read(iprot);
                struct.setErrIsSet(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, getDistance_result struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        if (struct.isSetSuccess()) {
          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
          oprot.writeDouble(struct.success);
          oprot.writeFieldEnd();
        }
        if (struct.err != null) {
          oprot.writeFieldBegin(ERR_FIELD_DESC);
          struct.err.write(oprot);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class getDistance_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
      public getDistance_resultTupleScheme getScheme() {
        return new getDistance_resultTupleScheme();
      }
    }

    private static class getDistance_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getDistance_result> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, getDistance_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet optionals = new java.util.BitSet();
        if (struct.isSetSuccess()) {
          optionals.set(0);
        }
        if (struct.isSetErr()) {
          optionals.set(1);
        }
        oprot.writeBitSet(optionals, 2);
        if (struct.isSetSuccess()) {
          oprot.writeDouble(struct.success);
        }
        if (struct.isSetErr()) {
          struct.err.write(oprot);
        }
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, getDistance_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet incoming = iprot.readBitSet(2);
        if (incoming.get(0)) {
          struct.success = iprot.readDouble();
          struct.setSuccessIsSet(true);
        }
        if (incoming.get(1)) {
          struct.err = new QueryException();
          struct.err.read(iprot);
          struct.setErrIsSet(true);
        }
      }
    }

    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
    }
  }

}
