incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [4/4] More updates, added Bql parser.
Date Wed, 10 Oct 2012 02:01:29 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3fbd7f52/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurTuple.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurTuple.java
b/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurTuple.java
index 987fc07..aab7fc3 100644
--- a/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurTuple.java
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurTuple.java
@@ -26,11 +26,11 @@ public class BlurTuple {
 
     public Session openReadSession() throws BlurException, org.apache.thrift.TException;
 
-    public void executeQuery(Session session, String query) throws BlurException, org.apache.thrift.TException;
+    public QuerySession executeQuery(Session session, String query) throws BlurException,
org.apache.thrift.TException;
 
-    public List<Tuple> nextMetaDataResults(Session session, int batchSize) throws BlurException,
org.apache.thrift.TException;
+    public List<Tuple> nextMetaDataResults(QuerySession session, int batchSize) throws
BlurException, org.apache.thrift.TException;
 
-    public List<Tuple> nextResults(Session session, int batchSize) throws BlurException,
org.apache.thrift.TException;
+    public List<Tuple> nextResults(QuerySession session, int batchSize) throws BlurException,
org.apache.thrift.TException;
 
     public void closeReadSession(Session session) throws BlurException, org.apache.thrift.TException;
 
@@ -50,9 +50,9 @@ public class BlurTuple {
 
     public void executeQuery(Session session, String query, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.executeQuery_call>
resultHandler) throws org.apache.thrift.TException;
 
-    public void nextMetaDataResults(Session session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.nextMetaDataResults_call>
resultHandler) throws org.apache.thrift.TException;
+    public void nextMetaDataResults(QuerySession session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.nextMetaDataResults_call>
resultHandler) throws org.apache.thrift.TException;
 
-    public void nextResults(Session session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.nextResults_call>
resultHandler) throws org.apache.thrift.TException;
+    public void nextResults(QuerySession session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.nextResults_call>
resultHandler) throws org.apache.thrift.TException;
 
     public void closeReadSession(Session session, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.closeReadSession_call>
resultHandler) throws org.apache.thrift.TException;
 
@@ -111,10 +111,10 @@ public class BlurTuple {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT,
"openReadSession failed: unknown result");
     }
 
-    public void executeQuery(Session session, String query) throws BlurException, org.apache.thrift.TException
+    public QuerySession executeQuery(Session session, String query) throws BlurException,
org.apache.thrift.TException
     {
       send_executeQuery(session, query);
-      recv_executeQuery();
+      return recv_executeQuery();
     }
 
     public void send_executeQuery(Session session, String query) throws org.apache.thrift.TException
@@ -125,23 +125,26 @@ public class BlurTuple {
       sendBase("executeQuery", args);
     }
 
-    public void recv_executeQuery() throws BlurException, org.apache.thrift.TException
+    public QuerySession recv_executeQuery() throws BlurException, org.apache.thrift.TException
     {
       executeQuery_result result = new executeQuery_result();
       receiveBase(result, "executeQuery");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
       if (result.e != null) {
         throw result.e;
       }
-      return;
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT,
"executeQuery failed: unknown result");
     }
 
-    public List<Tuple> nextMetaDataResults(Session session, int batchSize) throws BlurException,
org.apache.thrift.TException
+    public List<Tuple> nextMetaDataResults(QuerySession session, int batchSize) throws
BlurException, org.apache.thrift.TException
     {
       send_nextMetaDataResults(session, batchSize);
       return recv_nextMetaDataResults();
     }
 
-    public void send_nextMetaDataResults(Session session, int batchSize) throws org.apache.thrift.TException
+    public void send_nextMetaDataResults(QuerySession session, int batchSize) throws org.apache.thrift.TException
     {
       nextMetaDataResults_args args = new nextMetaDataResults_args();
       args.setSession(session);
@@ -162,13 +165,13 @@ public class BlurTuple {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT,
"nextMetaDataResults failed: unknown result");
     }
 
-    public List<Tuple> nextResults(Session session, int batchSize) throws BlurException,
org.apache.thrift.TException
+    public List<Tuple> nextResults(QuerySession session, int batchSize) throws BlurException,
org.apache.thrift.TException
     {
       send_nextResults(session, batchSize);
       return recv_nextResults();
     }
 
-    public void send_nextResults(Session session, int batchSize) throws org.apache.thrift.TException
+    public void send_nextResults(QuerySession session, int batchSize) throws org.apache.thrift.TException
     {
       nextResults_args args = new nextResults_args();
       args.setSession(session);
@@ -379,17 +382,17 @@ public class BlurTuple {
         prot.writeMessageEnd();
       }
 
-      public void getResult() throws BlurException, org.apache.thrift.TException {
+      public QuerySession getResult() throws BlurException, org.apache.thrift.TException
{
         if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
           throw new IllegalStateException("Method call not finished!");
         }
         org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
         org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
-        (new Client(prot)).recv_executeQuery();
+        return (new Client(prot)).recv_executeQuery();
       }
     }
 
-    public void nextMetaDataResults(Session session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<nextMetaDataResults_call>
resultHandler) throws org.apache.thrift.TException {
+    public void nextMetaDataResults(QuerySession session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<nextMetaDataResults_call>
resultHandler) throws org.apache.thrift.TException {
       checkReady();
       nextMetaDataResults_call method_call = new nextMetaDataResults_call(session, batchSize,
resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
@@ -397,9 +400,9 @@ public class BlurTuple {
     }
 
     public static class nextMetaDataResults_call extends org.apache.thrift.async.TAsyncMethodCall
{
-      private Session session;
+      private QuerySession session;
       private int batchSize;
-      public nextMetaDataResults_call(Session session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<nextMetaDataResults_call>
resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory
protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException
{
+      public nextMetaDataResults_call(QuerySession session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<nextMetaDataResults_call>
resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory
protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException
{
         super(client, protocolFactory, transport, resultHandler, false);
         this.session = session;
         this.batchSize = batchSize;
@@ -424,7 +427,7 @@ public class BlurTuple {
       }
     }
 
-    public void nextResults(Session session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<nextResults_call>
resultHandler) throws org.apache.thrift.TException {
+    public void nextResults(QuerySession session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<nextResults_call>
resultHandler) throws org.apache.thrift.TException {
       checkReady();
       nextResults_call method_call = new nextResults_call(session, batchSize, resultHandler,
this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
@@ -432,9 +435,9 @@ public class BlurTuple {
     }
 
     public static class nextResults_call extends org.apache.thrift.async.TAsyncMethodCall
{
-      private Session session;
+      private QuerySession session;
       private int batchSize;
-      public nextResults_call(Session session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<nextResults_call>
resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory
protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException
{
+      public nextResults_call(QuerySession session, int batchSize, org.apache.thrift.async.AsyncMethodCallback<nextResults_call>
resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory
protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException
{
         super(client, protocolFactory, transport, resultHandler, false);
         this.session = session;
         this.batchSize = batchSize;
@@ -676,7 +679,7 @@ public class BlurTuple {
       protected executeQuery_result getResult(I iface, executeQuery_args args) throws org.apache.thrift.TException
{
         executeQuery_result result = new executeQuery_result();
         try {
-          iface.executeQuery(args.session, args.query);
+          result.success = iface.executeQuery(args.session, args.query);
         } catch (BlurException e) {
           result.e = e;
         }
@@ -1804,12 +1807,15 @@ public class BlurTuple {
   public static class executeQuery_result implements org.apache.thrift.TBase<executeQuery_result,
executeQuery_result._Fields>, java.io.Serializable, Cloneable   {
     private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("executeQuery_result");
 
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success",
org.apache.thrift.protocol.TType.STRUCT, (short)0);
     private static final org.apache.thrift.protocol.TField E_FIELD_DESC = new org.apache.thrift.protocol.TField("e",
org.apache.thrift.protocol.TType.STRUCT, (short)1);
 
+    public QuerySession success; // required
     public BlurException e; // 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"),
       E((short)1, "e");
 
       private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -1825,6 +1831,8 @@ public class BlurTuple {
        */
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
           case 1: // E
             return E;
           default:
@@ -1871,6 +1879,8 @@ public class BlurTuple {
     public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields,
org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+      tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
QuerySession.class)));
       tmpMap.put(_Fields.E, new org.apache.thrift.meta_data.FieldMetaData("e", org.apache.thrift.TFieldRequirementType.DEFAULT,

           new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
@@ -1881,9 +1891,11 @@ public class BlurTuple {
     }
 
     public executeQuery_result(
+      QuerySession success,
       BlurException e)
     {
       this();
+      this.success = success;
       this.e = e;
     }
 
@@ -1891,6 +1903,9 @@ public class BlurTuple {
      * Performs a deep copy on <i>other</i>.
      */
     public executeQuery_result(executeQuery_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new QuerySession(other.success);
+      }
       if (other.isSetE()) {
         this.e = new BlurException(other.e);
       }
@@ -1902,9 +1917,34 @@ public class BlurTuple {
 
     @Override
     public void clear() {
+      this.success = null;
       this.e = null;
     }
 
+    public QuerySession getSuccess() {
+      return this.success;
+    }
+
+    public executeQuery_result setSuccess(QuerySession 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 BlurException getE() {
       return this.e;
     }
@@ -1931,6 +1971,14 @@ public class BlurTuple {
 
     public void setFieldValue(_Fields field, Object value) {
       switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((QuerySession)value);
+        }
+        break;
+
       case E:
         if (value == null) {
           unsetE();
@@ -1944,6 +1992,9 @@ public class BlurTuple {
 
     public Object getFieldValue(_Fields field) {
       switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
       case E:
         return getE();
 
@@ -1958,6 +2009,8 @@ public class BlurTuple {
       }
 
       switch (field) {
+      case SUCCESS:
+        return isSetSuccess();
       case E:
         return isSetE();
       }
@@ -1977,6 +2030,15 @@ public class BlurTuple {
       if (that == null)
         return false;
 
+      boolean this_present_success = true && this.isSetSuccess();
+      boolean that_present_success = true && that.isSetSuccess();
+      if (this_present_success || that_present_success) {
+        if (!(this_present_success && that_present_success))
+          return false;
+        if (!this.success.equals(that.success))
+          return false;
+      }
+
       boolean this_present_e = true && this.isSetE();
       boolean that_present_e = true && that.isSetE();
       if (this_present_e || that_present_e) {
@@ -2002,6 +2064,16 @@ public class BlurTuple {
       int lastComparison = 0;
       executeQuery_result typedOther = (executeQuery_result)other;
 
+      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetSuccess()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
       lastComparison = Boolean.valueOf(isSetE()).compareTo(typedOther.isSetE());
       if (lastComparison != 0) {
         return lastComparison;
@@ -2029,6 +2101,14 @@ public class BlurTuple {
           break;
         }
         switch (field.id) {
+          case 0: // SUCCESS
+            if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
+              this.success = new QuerySession();
+              this.success.read(iprot);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            }
+            break;
           case 1: // E
             if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
               this.e = new BlurException();
@@ -2051,7 +2131,11 @@ public class BlurTuple {
     public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException
{
       oprot.writeStructBegin(STRUCT_DESC);
 
-      if (this.isSetE()) {
+      if (this.isSetSuccess()) {
+        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+        this.success.write(oprot);
+        oprot.writeFieldEnd();
+      } else if (this.isSetE()) {
         oprot.writeFieldBegin(E_FIELD_DESC);
         this.e.write(oprot);
         oprot.writeFieldEnd();
@@ -2065,6 +2149,14 @@ public class BlurTuple {
       StringBuilder sb = new StringBuilder("executeQuery_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("e:");
       if (this.e == null) {
         sb.append("null");
@@ -2104,7 +2196,7 @@ public class BlurTuple {
     private static final org.apache.thrift.protocol.TField SESSION_FIELD_DESC = new org.apache.thrift.protocol.TField("session",
org.apache.thrift.protocol.TType.STRUCT, (short)1);
     private static final org.apache.thrift.protocol.TField BATCH_SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("batchSize",
org.apache.thrift.protocol.TType.I32, (short)2);
 
-    public Session session; // required
+    public QuerySession session; // required
     public int batchSize; // required
 
     /** The set of fields this struct contains, along with convenience methods for finding
and manipulating them. */
@@ -2176,7 +2268,7 @@ public class BlurTuple {
     static {
       Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields,
org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
       tmpMap.put(_Fields.SESSION, new org.apache.thrift.meta_data.FieldMetaData("session",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
Session.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
QuerySession.class)));
       tmpMap.put(_Fields.BATCH_SIZE, new org.apache.thrift.meta_data.FieldMetaData("batchSize",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
           new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
@@ -2187,7 +2279,7 @@ public class BlurTuple {
     }
 
     public nextMetaDataResults_args(
-      Session session,
+      QuerySession session,
       int batchSize)
     {
       this();
@@ -2203,7 +2295,7 @@ public class BlurTuple {
       __isset_bit_vector.clear();
       __isset_bit_vector.or(other.__isset_bit_vector);
       if (other.isSetSession()) {
-        this.session = new Session(other.session);
+        this.session = new QuerySession(other.session);
       }
       this.batchSize = other.batchSize;
     }
@@ -2219,11 +2311,11 @@ public class BlurTuple {
       this.batchSize = 0;
     }
 
-    public Session getSession() {
+    public QuerySession getSession() {
       return this.session;
     }
 
-    public nextMetaDataResults_args setSession(Session session) {
+    public nextMetaDataResults_args setSession(QuerySession session) {
       this.session = session;
       return this;
     }
@@ -2272,7 +2364,7 @@ public class BlurTuple {
         if (value == null) {
           unsetSession();
         } else {
-          setSession((Session)value);
+          setSession((QuerySession)value);
         }
         break;
 
@@ -2400,7 +2492,7 @@ public class BlurTuple {
         switch (field.id) {
           case 1: // SESSION
             if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
-              this.session = new Session();
+              this.session = new QuerySession();
               this.session.read(iprot);
             } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
@@ -2914,7 +3006,7 @@ public class BlurTuple {
     private static final org.apache.thrift.protocol.TField SESSION_FIELD_DESC = new org.apache.thrift.protocol.TField("session",
org.apache.thrift.protocol.TType.STRUCT, (short)1);
     private static final org.apache.thrift.protocol.TField BATCH_SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("batchSize",
org.apache.thrift.protocol.TType.I32, (short)2);
 
-    public Session session; // required
+    public QuerySession session; // required
     public int batchSize; // required
 
     /** The set of fields this struct contains, along with convenience methods for finding
and manipulating them. */
@@ -2986,7 +3078,7 @@ public class BlurTuple {
     static {
       Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields,
org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
       tmpMap.put(_Fields.SESSION, new org.apache.thrift.meta_data.FieldMetaData("session",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
Session.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
QuerySession.class)));
       tmpMap.put(_Fields.BATCH_SIZE, new org.apache.thrift.meta_data.FieldMetaData("batchSize",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
           new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
@@ -2997,7 +3089,7 @@ public class BlurTuple {
     }
 
     public nextResults_args(
-      Session session,
+      QuerySession session,
       int batchSize)
     {
       this();
@@ -3013,7 +3105,7 @@ public class BlurTuple {
       __isset_bit_vector.clear();
       __isset_bit_vector.or(other.__isset_bit_vector);
       if (other.isSetSession()) {
-        this.session = new Session(other.session);
+        this.session = new QuerySession(other.session);
       }
       this.batchSize = other.batchSize;
     }
@@ -3029,11 +3121,11 @@ public class BlurTuple {
       this.batchSize = 0;
     }
 
-    public Session getSession() {
+    public QuerySession getSession() {
       return this.session;
     }
 
-    public nextResults_args setSession(Session session) {
+    public nextResults_args setSession(QuerySession session) {
       this.session = session;
       return this;
     }
@@ -3082,7 +3174,7 @@ public class BlurTuple {
         if (value == null) {
           unsetSession();
         } else {
-          setSession((Session)value);
+          setSession((QuerySession)value);
         }
         break;
 
@@ -3210,7 +3302,7 @@ public class BlurTuple {
         switch (field.id) {
           case 1: // SESSION
             if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
-              this.session = new Session();
+              this.session = new QuerySession();
               this.session.read(iprot);
             } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3fbd7f52/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/QuerySession.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/QuerySession.java
b/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/QuerySession.java
new file mode 100644
index 0000000..a2253f8
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/QuerySession.java
@@ -0,0 +1,409 @@
+/**
+ * Autogenerated by Thrift Compiler (0.7.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package org.apache.blur.thrift.generated;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class QuerySession implements org.apache.thrift.TBase<QuerySession, QuerySession._Fields>,
java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("QuerySession");
+
+  private static final org.apache.thrift.protocol.TField SESSION_FIELD_DESC = new org.apache.thrift.protocol.TField("session",
org.apache.thrift.protocol.TType.STRUCT, (short)1);
+  private static final org.apache.thrift.protocol.TField QUERY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("queryId",
org.apache.thrift.protocol.TType.STRING, (short)2);
+
+  public Session session; // required
+  public String queryId; // 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 {
+    SESSION((short)1, "session"),
+    QUERY_ID((short)2, "queryId");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // SESSION
+          return SESSION;
+        case 2: // QUERY_ID
+          return QUERY_ID;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't
exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  // isset id assignments
+
+  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields,
org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.SESSION, new org.apache.thrift.meta_data.FieldMetaData("session",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
Session.class)));
+    tmpMap.put(_Fields.QUERY_ID, new org.apache.thrift.meta_data.FieldMetaData("queryId",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(QuerySession.class, metaDataMap);
+  }
+
+  public QuerySession() {
+  }
+
+  public QuerySession(
+    Session session,
+    String queryId)
+  {
+    this();
+    this.session = session;
+    this.queryId = queryId;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public QuerySession(QuerySession other) {
+    if (other.isSetSession()) {
+      this.session = new Session(other.session);
+    }
+    if (other.isSetQueryId()) {
+      this.queryId = other.queryId;
+    }
+  }
+
+  public QuerySession deepCopy() {
+    return new QuerySession(this);
+  }
+
+  @Override
+  public void clear() {
+    this.session = null;
+    this.queryId = null;
+  }
+
+  public Session getSession() {
+    return this.session;
+  }
+
+  public QuerySession setSession(Session session) {
+    this.session = session;
+    return this;
+  }
+
+  public void unsetSession() {
+    this.session = null;
+  }
+
+  /** Returns true if field session is set (has been assigned a value) and false otherwise
*/
+  public boolean isSetSession() {
+    return this.session != null;
+  }
+
+  public void setSessionIsSet(boolean value) {
+    if (!value) {
+      this.session = null;
+    }
+  }
+
+  public String getQueryId() {
+    return this.queryId;
+  }
+
+  public QuerySession setQueryId(String queryId) {
+    this.queryId = queryId;
+    return this;
+  }
+
+  public void unsetQueryId() {
+    this.queryId = null;
+  }
+
+  /** Returns true if field queryId is set (has been assigned a value) and false otherwise
*/
+  public boolean isSetQueryId() {
+    return this.queryId != null;
+  }
+
+  public void setQueryIdIsSet(boolean value) {
+    if (!value) {
+      this.queryId = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case SESSION:
+      if (value == null) {
+        unsetSession();
+      } else {
+        setSession((Session)value);
+      }
+      break;
+
+    case QUERY_ID:
+      if (value == null) {
+        unsetQueryId();
+      } else {
+        setQueryId((String)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case SESSION:
+      return getSession();
+
+    case QUERY_ID:
+      return getQueryId();
+
+    }
+    throw new IllegalStateException();
+  }
+
+  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and
false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
+    case SESSION:
+      return isSetSession();
+    case QUERY_ID:
+      return isSetQueryId();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof QuerySession)
+      return this.equals((QuerySession)that);
+    return false;
+  }
+
+  public boolean equals(QuerySession that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_session = true && this.isSetSession();
+    boolean that_present_session = true && that.isSetSession();
+    if (this_present_session || that_present_session) {
+      if (!(this_present_session && that_present_session))
+        return false;
+      if (!this.session.equals(that.session))
+        return false;
+    }
+
+    boolean this_present_queryId = true && this.isSetQueryId();
+    boolean that_present_queryId = true && that.isSetQueryId();
+    if (this_present_queryId || that_present_queryId) {
+      if (!(this_present_queryId && that_present_queryId))
+        return false;
+      if (!this.queryId.equals(that.queryId))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  public int compareTo(QuerySession other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    QuerySession typedOther = (QuerySession)other;
+
+    lastComparison = Boolean.valueOf(isSetSession()).compareTo(typedOther.isSetSession());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetSession()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.session, typedOther.session);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetQueryId()).compareTo(typedOther.isSetQueryId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetQueryId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryId, typedOther.queryId);
+      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
{
+    org.apache.thrift.protocol.TField field;
+    iprot.readStructBegin();
+    while (true)
+    {
+      field = iprot.readFieldBegin();
+      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
+        break;
+      }
+      switch (field.id) {
+        case 1: // SESSION
+          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
+            this.session = new Session();
+            this.session.read(iprot);
+          } else { 
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
+        case 2: // QUERY_ID
+          if (field.type == org.apache.thrift.protocol.TType.STRING) {
+            this.queryId = iprot.readString();
+          } else { 
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
+        default:
+          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+      }
+      iprot.readFieldEnd();
+    }
+    iprot.readStructEnd();
+
+    // check for required fields of primitive type, which can't be checked in the validate
method
+    validate();
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException
{
+    validate();
+
+    oprot.writeStructBegin(STRUCT_DESC);
+    if (this.session != null) {
+      oprot.writeFieldBegin(SESSION_FIELD_DESC);
+      this.session.write(oprot);
+      oprot.writeFieldEnd();
+    }
+    if (this.queryId != null) {
+      oprot.writeFieldBegin(QUERY_ID_FIELD_DESC);
+      oprot.writeString(this.queryId);
+      oprot.writeFieldEnd();
+    }
+    oprot.writeFieldStop();
+    oprot.writeStructEnd();
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("QuerySession(");
+    boolean first = true;
+
+    sb.append("session:");
+    if (this.session == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.session);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("queryId:");
+    if (this.queryId == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.queryId);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
{
+    try {
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3fbd7f52/src/blur-new-api-prototype/src/test/java/org/apache/blur/parser/BqlParserTest.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/test/java/org/apache/blur/parser/BqlParserTest.java
b/src/blur-new-api-prototype/src/test/java/org/apache/blur/parser/BqlParserTest.java
new file mode 100644
index 0000000..3d20a36
--- /dev/null
+++ b/src/blur-new-api-prototype/src/test/java/org/apache/blur/parser/BqlParserTest.java
@@ -0,0 +1,177 @@
+package org.apache.blur.parser;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+
+import org.apache.blur.parser.BqlParser.OrderBy;
+import org.apache.blur.parser.BqlParser.QueryType;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryparser.classic.ParseException;
+import org.apache.lucene.queryparser.classic.QueryParser;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.util.Version;
+import org.junit.Test;
+
+public class BqlParserTest {
+
+  @Test
+  public void testBqlSimpleSelect() throws BqlException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select * from tablename");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("*"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList((String) null), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertNull(parser.getTableNameAlias());
+    assertNull(parser.getLuceneQuery());
+    assertTrue(parser.getOrderByAttributes().isEmpty());
+    assertTrue(parser.getOrderByAttributesDirection().isEmpty());
+  }
+
+  @Test
+  public void testBqlSimpleSelectWithTableAlias() throws BqlException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select * from tablename as t1");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("*"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList((String) null), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertNull(parser.getLuceneQuery());
+    assertTrue(parser.getOrderByAttributes().isEmpty());
+    assertTrue(parser.getOrderByAttributesDirection().isEmpty());
+  }
+
+  @Test
+  public void testBqlSelectSingleAttributeWithTableAlias() throws BqlException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1 from tablename as t1");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList((String) null), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertNull(parser.getLuceneQuery());
+    assertTrue(parser.getOrderByAttributes().isEmpty());
+    assertTrue(parser.getOrderByAttributesDirection().isEmpty());
+  }
+
+  @Test
+  public void testBqlTwoAttributeWithTableAlias() throws BqlException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1,col2 from tablename as t1");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList(null, null), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertNull(parser.getLuceneQuery());
+    assertTrue(parser.getOrderByAttributes().isEmpty());
+    assertTrue(parser.getOrderByAttributesDirection().isEmpty());
+  }
+
+  @Test
+  public void testBqlTwoAttributeWithSpaceWithTableAlias() throws BqlException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1, col2 from tablename as t1");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList(null, null), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertNull(parser.getLuceneQuery());
+    assertTrue(parser.getOrderByAttributes().isEmpty());
+    assertTrue(parser.getOrderByAttributesDirection().isEmpty());
+  }
+
+  @Test
+  public void testBqlTwoAttributeWithSpaceAndAliasWithTableAlias() throws BqlException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1, col2 as c2 from tablename as t1");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList(null, "c2"), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertNull(parser.getLuceneQuery());
+    assertTrue(parser.getOrderByAttributes().isEmpty());
+    assertTrue(parser.getOrderByAttributesDirection().isEmpty());
+  }
+
+  @Test
+  public void testBqlTwoAttributeWithSpaceAndAliasWithTableAliasWithWhere() throws BqlException,
ParseException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1, col2 as c2 from tablename as t1 where col2:val1 col3:val2");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList(null, "c2"), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertEquals(luceneParse(parser.getAnalyzer(), "col2:val1 col3:val2"), parser.getLuceneQuery());
+    assertTrue(parser.getOrderByAttributes().isEmpty());
+    assertTrue(parser.getOrderByAttributesDirection().isEmpty());
+  }
+
+  @Test
+  public void testBqlTwoAttributeWithSpaceAndAliasWithTableAliasWithWhereWithOrderBy() throws
BqlException, ParseException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1, col2 as c2 from tablename as t1 where col2:val1 col3:val2
order by col1");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList(null, "c2"), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertEquals(luceneParse(parser.getAnalyzer(), "col2:val1 col3:val2"), parser.getLuceneQuery());
+    assertEquals(Arrays.asList("col1"), parser.getOrderByAttributes());
+    assertEquals(Arrays.asList(OrderBy.ASC), parser.getOrderByAttributesDirection());
+  }
+
+  @Test
+  public void testBqlTwoAttributeWithSpaceAndAliasWithTableAliasWithWhereWithOrderByAsc()
throws BqlException, ParseException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1, col2 as c2 from tablename as t1 where col2:val1 col3:val2
order by asc col1");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList(null, "c2"), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertEquals(luceneParse(parser.getAnalyzer(), "col2:val1 col3:val2"), parser.getLuceneQuery());
+    assertEquals(Arrays.asList("col1"), parser.getOrderByAttributes());
+    assertEquals(Arrays.asList(OrderBy.ASC), parser.getOrderByAttributesDirection());
+  }
+
+  @Test
+  public void testBqlTwoAttributeWithSpaceAndAliasWithTableAliasWithWhereWithOrderByDesc()
throws BqlException, ParseException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1, col2 as c2 from tablename as t1 where col2:val1 col3:val2
order by desc col1");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList(null, "c2"), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertEquals(luceneParse(parser.getAnalyzer(), "col2:val1 col3:val2"), parser.getLuceneQuery());
+    assertEquals(Arrays.asList("col1"), parser.getOrderByAttributes());
+    assertEquals(Arrays.asList(OrderBy.DESC), parser.getOrderByAttributesDirection());
+  }
+
+  @Test
+  public void testBqlTwoAttributeWithSpaceAndAliasWithTableAliasWithWhereWithOrderByMulti()
throws BqlException, ParseException {
+    BqlParser parser = new BqlParser(new StandardAnalyzer(Version.LUCENE_40));
+    parser.parse("select col1, col2 as c2 from tablename as t1 where col2:val1 col3:val2
order by col1, desc col2");
+    assertEquals(QueryType.SELECT, parser.getQueryType());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getAttributeTokens());
+    assertEquals(Arrays.asList(null, "c2"), parser.getAttributeTokenAliases());
+    assertEquals("tablename", parser.getTableName());
+    assertEquals("t1", parser.getTableNameAlias());
+    assertEquals(luceneParse(parser.getAnalyzer(), "col2:val1 col3:val2"), parser.getLuceneQuery());
+    assertEquals(Arrays.asList("col1", "col2"), parser.getOrderByAttributes());
+    assertEquals(Arrays.asList(OrderBy.ASC, OrderBy.DESC), parser.getOrderByAttributesDirection());
+  }
+  
+  private Query luceneParse(Analyzer analyzer, String luceneQuery) throws ParseException
{
+    QueryParser parser = new QueryParser(Version.LUCENE_40, "default", analyzer);
+    return parser.parse(luceneQuery);
+  }
+}


Mime
View raw message