incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [17/19] Thrift re-package, sorry for the huge commit.
Date Thu, 23 May 2013 19:39:56 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBase.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBase.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBase.java
new file mode 100644
index 0000000..0676029
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBase.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import java.io.Serializable;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+
+/**
+ * Generic base interface for generated Thrift objects.
+ *
+ */
+public interface TBase<T extends TBase<?,?>, F extends TFieldIdEnum> extends Comparable<T>,  Serializable {
+
+  /**
+   * Reads the TObject from the given input protocol.
+   *
+   * @param iprot Input protocol
+   */
+  public void read(TProtocol iprot) throws TException;
+
+  /**
+   * Writes the objects out to the protocol
+   *
+   * @param oprot Output protocol
+   */
+  public void write(TProtocol oprot) throws TException;
+
+  /**
+   * Get the F instance that corresponds to fieldId.
+   */
+  public F fieldForId(int fieldId);
+
+  /**
+   * Check if a field is currently set or unset.
+   *
+   * @param field
+   */
+  public boolean isSet(F field);
+
+  /**
+   * Get a field's value by field variable. Primitive types will be wrapped in 
+   * the appropriate "boxed" types.
+   *
+   * @param field
+   */
+  public Object getFieldValue(F field);
+
+  /**
+   * Set a field's value by field variable. Primitive types must be "boxed" in
+   * the appropriate object wrapper type.
+   *
+   * @param field
+   */
+  public void setFieldValue(F field, Object value);
+
+  public TBase<T, F> deepCopy();
+
+  /**
+   * Return to the state of having just been initialized, as though you had just
+   * called the default constructor.
+   */
+  public void clear();
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBaseHelper.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBaseHelper.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBaseHelper.java
new file mode 100644
index 0000000..ff52bfe
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBaseHelper.java
@@ -0,0 +1,306 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import java.nio.ByteBuffer;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+public final class TBaseHelper {
+
+  private TBaseHelper(){}
+
+  private static final Comparator comparator = new NestedStructureComparator();
+
+  public static int compareTo(Object o1, Object o2) {
+    if (o1 instanceof Comparable) {
+      return compareTo((Comparable)o1, (Comparable)o2);
+    } else if (o1 instanceof List) {
+      return compareTo((List)o1, (List)o2);
+    } else if (o1 instanceof Set) {
+      return compareTo((Set)o1, (Set)o2);
+    } else if (o1 instanceof Map) {
+      return compareTo((Map)o1, (Map)o2);
+    } else if (o1 instanceof byte[]) {
+      return compareTo((byte[])o1, (byte[])o2);
+    } else {
+      throw new IllegalArgumentException("Cannot compare objects of type " + o1.getClass());
+    }
+  }
+
+  public static int compareTo(boolean a, boolean b) {
+    return Boolean.valueOf(a).compareTo(b);
+  }
+
+  public static int compareTo(byte a, byte b) {
+    if (a < b) {
+      return -1;
+    } else if (b < a) {
+      return 1;
+    } else {
+      return 0;
+    }
+  }
+
+  public static int compareTo(short a, short b) {
+    if (a < b) {
+      return -1;
+    } else if (b < a) {
+      return 1;
+    } else {
+      return 0;
+    }
+  }
+
+  public static int compareTo(int a, int b) {
+    if (a < b) {
+      return -1;
+    } else if (b < a) {
+      return 1;
+    } else {
+      return 0;
+    }
+  }
+
+  public static int compareTo(long a, long b) {
+    if (a < b) {
+      return -1;
+    } else if (b < a) {
+      return 1;
+    } else {
+      return 0;
+    }
+  }
+
+  public static int compareTo(double a, double b) {
+    if (a < b) {
+      return -1;
+    } else if (b < a) {
+      return 1;
+    } else {
+      return 0;
+    }
+  }
+
+  public static int compareTo(String a, String b) {
+    return a.compareTo(b);
+  }
+
+  public static int compareTo(byte[] a, byte[] b) {
+    int sizeCompare = compareTo(a.length, b.length);
+    if (sizeCompare != 0) {
+      return sizeCompare;
+    }
+    for (int i = 0; i < a.length; i++) {
+      int byteCompare = compareTo(a[i], b[i]);
+      if (byteCompare != 0) {
+        return byteCompare;
+      }
+    }
+    return 0;
+  }
+
+  public static int compareTo(Comparable a, Comparable b) {
+    return a.compareTo(b);
+  }
+
+  public static int compareTo(List a, List b) {
+    int lastComparison = compareTo(a.size(), b.size());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    for (int i = 0; i < a.size(); i++) {
+      lastComparison = comparator.compare(a.get(i), b.get(i));
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public static int compareTo(Set a, Set b) {
+    int lastComparison = compareTo(a.size(), b.size());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    SortedSet sortedA = new TreeSet(comparator);
+    sortedA.addAll(a);
+    SortedSet sortedB = new TreeSet(comparator);
+    sortedB.addAll(b);
+
+    Iterator iterA = sortedA.iterator();
+    Iterator iterB = sortedB.iterator();
+
+    // Compare each item.
+    while (iterA.hasNext() && iterB.hasNext()) {
+      lastComparison = comparator.compare(iterA.next(), iterB.next());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+
+    return 0;
+  }
+
+  public static int compareTo(Map a, Map b) {
+    int lastComparison = compareTo(a.size(), b.size());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+
+    // Sort a and b so we can compare them.
+    SortedMap sortedA = new TreeMap(comparator);
+    sortedA.putAll(a);
+    Iterator<Map.Entry> iterA = sortedA.entrySet().iterator();
+    SortedMap sortedB = new TreeMap(comparator);
+    sortedB.putAll(b);
+    Iterator<Map.Entry> iterB = sortedB.entrySet().iterator();
+
+    // Compare each item.
+    while (iterA.hasNext() && iterB.hasNext()) {
+      Map.Entry entryA = iterA.next();
+      Map.Entry entryB = iterB.next();
+      lastComparison = comparator.compare(entryA.getKey(), entryB.getKey());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      lastComparison = comparator.compare(entryA.getValue(), entryB.getValue());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+
+    return 0;
+  }
+
+  /**
+   * Comparator to compare items inside a structure (e.g. a list, set, or map).
+   */
+  private static class NestedStructureComparator implements Comparator {
+    public int compare(Object oA, Object oB) {
+      if (oA == null && oB == null) {
+        return 0;
+      } else if (oA == null) {
+        return -1;
+      } else if (oB == null) {
+        return 1;
+      } else if (oA instanceof List) {
+        return compareTo((List)oA, (List)oB);
+      } else if (oA instanceof Set) {
+        return compareTo((Set)oA, (Set)oB);
+      } else if (oA instanceof Map) {
+        return compareTo((Map)oA, (Map)oB);
+      } else if (oA instanceof byte[]) {
+        return compareTo((byte[])oA, (byte[])oB);
+      } else {
+        return compareTo((Comparable)oA, (Comparable)oB);
+      }
+    }
+  }
+
+  public static void toString(ByteBuffer bb, StringBuilder sb) {
+    byte[] buf = bb.array();
+
+    int arrayOffset = bb.arrayOffset();
+    int offset = arrayOffset + bb.position();
+    int origLimit = arrayOffset + bb.limit();
+    int limit = (origLimit - offset > 128) ? offset + 128 : origLimit;
+
+    for (int i = offset; i < limit; i++) {
+      if (i > offset) {
+        sb.append(" ");
+      }
+      sb.append(paddedByteString(buf[i]));
+    }
+    if (origLimit != limit) {
+      sb.append("...");
+    }
+  }
+
+  public static String paddedByteString(byte b) {
+    int extended = (b | 0x100) & 0x1ff;
+    return Integer.toHexString(extended).toUpperCase().substring(1);
+  }
+
+  public static byte[] byteBufferToByteArray(ByteBuffer byteBuffer) {
+    if (wrapsFullArray(byteBuffer)) {
+      return byteBuffer.array();
+    }
+    byte[] target = new byte[byteBuffer.remaining()];
+    byteBufferToByteArray(byteBuffer, target, 0);
+    return target;
+  }
+
+  public static boolean wrapsFullArray(ByteBuffer byteBuffer) {
+    return byteBuffer.hasArray()
+      && byteBuffer.position() == 0
+      && byteBuffer.arrayOffset() == 0
+      && byteBuffer.remaining() == byteBuffer.capacity();
+  }
+
+  public static int byteBufferToByteArray(ByteBuffer byteBuffer, byte[] target, int offset) {
+    int remaining = byteBuffer.remaining();
+    System.arraycopy(byteBuffer.array(),
+        byteBuffer.arrayOffset() + byteBuffer.position(),
+        target,
+        offset,
+        remaining);
+    return remaining;
+  }
+
+  public static ByteBuffer rightSize(ByteBuffer in) {
+    if (in == null) {
+      return null;
+    }
+    if (wrapsFullArray(in)) {
+      return in;
+    }
+    return ByteBuffer.wrap(byteBufferToByteArray(in));
+  }
+
+  public static ByteBuffer copyBinary(final ByteBuffer orig) {
+    if (orig == null) {
+      return null;
+    }
+    ByteBuffer copy = ByteBuffer.wrap(new byte[orig.remaining()]);
+    if (orig.hasArray()) {
+      System.arraycopy(orig.array(), orig.arrayOffset() + orig.position(), copy.array(), 0, orig.remaining());
+    } else {
+      orig.slice().get(copy.array());
+    }
+
+    return copy;
+  }
+
+  public static byte[] copyBinary(final byte[] orig) {
+    if (orig == null) {
+      return null;
+    }
+
+    byte[] copy = new byte[orig.length];
+    System.arraycopy(orig, 0, copy, 0, orig.length);
+    return copy;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBaseProcessor.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBaseProcessor.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBaseProcessor.java
new file mode 100644
index 0000000..035643d
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TBaseProcessor.java
@@ -0,0 +1,42 @@
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMessage;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMessageType;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType;
+
+public abstract class TBaseProcessor<I> implements TProcessor {
+  private final I iface;
+  private final Map<String,ProcessFunction<I, ? extends TBase>> processMap;
+
+  protected TBaseProcessor(I iface, Map<String, ProcessFunction<I, ? extends TBase>> processFunctionMap) {
+    this.iface = iface;
+    this.processMap = processFunctionMap;
+  }
+
+  public Map<String,ProcessFunction<I, ? extends TBase>> getProcessMapView() {
+    return Collections.unmodifiableMap(processMap);
+  }
+
+  @Override
+  public boolean process(TProtocol in, TProtocol out) throws TException {
+    TMessage msg = in.readMessageBegin();
+    ProcessFunction fn = processMap.get(msg.name);
+    if (fn == null) {
+      TProtocolUtil.skip(in, TType.STRUCT);
+      in.readMessageEnd();
+      TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
+      out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
+      x.write(out);
+      out.writeMessageEnd();
+      out.getTransport().flush();
+      return true;
+    }
+    fn.process(msg.seqid, in, out, iface);
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TByteArrayOutputStream.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TByteArrayOutputStream.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TByteArrayOutputStream.java
new file mode 100644
index 0000000..f425fd1
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TByteArrayOutputStream.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Class that allows access to the underlying buf without doing deep
+ * copies on it.
+ *
+ */
+public class TByteArrayOutputStream extends ByteArrayOutputStream {
+  public TByteArrayOutputStream(int size) {
+    super(size);
+  }
+
+  public TByteArrayOutputStream() {
+    super();
+  }
+
+  public byte[] get() {
+    return buf;
+  }
+
+  public int len() {
+    return count;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TDeserializer.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TDeserializer.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TDeserializer.java
new file mode 100644
index 0000000..cd81305
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TDeserializer.java
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TBinaryProtocol;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolFactory;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TMemoryInputTransport;
+
+/**
+ * Generic utility for easily deserializing objects from a byte array or Java
+ * String.
+ *
+ */
+public class TDeserializer {
+  private final TProtocol protocol_;
+  private final TMemoryInputTransport trans_;
+
+  /**
+   * Create a new TDeserializer that uses the TBinaryProtocol by default.
+   */
+  public TDeserializer() {
+    this(new TBinaryProtocol.Factory());
+  }
+
+  /**
+   * Create a new TDeserializer. It will use the TProtocol specified by the
+   * factory that is passed in.
+   *
+   * @param protocolFactory Factory to create a protocol
+   */
+  public TDeserializer(TProtocolFactory protocolFactory) {
+    trans_ = new TMemoryInputTransport();
+    protocol_ = protocolFactory.getProtocol(trans_);
+  }
+
+  /**
+   * Deserialize the Thrift object from a byte array.
+   *
+   * @param base The object to read into
+   * @param bytes The array to read from
+   */
+  public void deserialize(TBase base, byte[] bytes) throws TException {
+    try {
+      trans_.reset(bytes);
+      base.read(protocol_);
+    } finally {
+      trans_.clear();
+      protocol_.reset();
+    }
+  }
+
+  /**
+   * Deserialize the Thrift object from a Java string, using a specified
+   * character set for decoding.
+   *
+   * @param base The object to read into
+   * @param data The string to read from
+   * @param charset Valid JVM charset
+   */
+  public void deserialize(TBase base, String data, String charset) throws TException {
+    try {
+      deserialize(base, data.getBytes(charset));
+    } catch (UnsupportedEncodingException uex) {
+      throw new TException("JVM DOES NOT SUPPORT ENCODING: " + charset);
+    } finally {
+      protocol_.reset();
+    }
+  }
+
+  /**
+   * Deserialize only a single Thrift object (addressed by recursively using field id)
+   * from a byte record.   
+   * @param tb The object to read into
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path tb
+   * @param fieldIdPathRest The rest FieldId's that define a path tb
+   * @throws TException 
+   */
+  public void partialDeserialize(TBase tb, byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    try {
+      if (locateField(bytes, fieldIdPathFirst, fieldIdPathRest) != null) {
+        // if this line is reached, iprot will be positioned at the start of tb.
+        tb.read(protocol_);
+      }      
+    } catch (Exception e) {
+      throw new TException(e);
+    } finally {
+      trans_.clear();
+      protocol_.reset();
+    }
+  }
+
+  /**
+   * Deserialize only a boolean field (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to a boolean field
+   * @param fieldIdPathRest The rest FieldId's that define a path to a boolean field
+   * @throws TException
+   */
+  public Boolean partialDeserializeBool(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    return (Boolean) partialDeserializeField(TType.BOOL, bytes, fieldIdPathFirst, fieldIdPathRest);
+  }
+
+  /**
+   * Deserialize only a byte field (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to a byte field
+   * @param fieldIdPathRest The rest FieldId's that define a path to a byte field
+   * @throws TException
+   */
+  public Byte partialDeserializeByte(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    return (Byte) partialDeserializeField(TType.BYTE, bytes, fieldIdPathFirst, fieldIdPathRest);
+  }
+
+  /**
+   * Deserialize only a double field (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to a double field
+   * @param fieldIdPathRest The rest FieldId's that define a path to a double field
+   * @throws TException
+   */
+  public Double partialDeserializeDouble(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    return (Double) partialDeserializeField(TType.DOUBLE, bytes, fieldIdPathFirst, fieldIdPathRest);
+  }
+
+  /**
+   * Deserialize only an i16 field (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to an i16 field
+   * @param fieldIdPathRest The rest FieldId's that define a path to an i16 field
+   * @throws TException
+   */
+  public Short partialDeserializeI16(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    return (Short) partialDeserializeField(TType.I16, bytes, fieldIdPathFirst, fieldIdPathRest);
+  }
+
+  /**
+   * Deserialize only an i32 field (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to an i32 field
+   * @param fieldIdPathRest The rest FieldId's that define a path to an i32 field
+   * @throws TException
+   */
+  public Integer partialDeserializeI32(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    return (Integer) partialDeserializeField(TType.I32, bytes, fieldIdPathFirst, fieldIdPathRest);
+  }
+
+  /**
+   * Deserialize only an i64 field (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to an i64 field
+   * @param fieldIdPathRest The rest FieldId's that define a path to an i64 field
+   * @throws TException
+   */
+  public Long partialDeserializeI64(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    return (Long) partialDeserializeField(TType.I64, bytes, fieldIdPathFirst, fieldIdPathRest);
+  }
+
+  /**
+   * Deserialize only a string field (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to a string field
+   * @param fieldIdPathRest The rest FieldId's that define a path to a string field
+   * @throws TException
+   */
+  public String partialDeserializeString(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    return (String) partialDeserializeField(TType.STRING, bytes, fieldIdPathFirst, fieldIdPathRest);
+  }
+
+  /**
+   * Deserialize only a binary field (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to a binary field
+   * @param fieldIdPathRest The rest FieldId's that define a path to a binary field
+   * @throws TException
+   */
+  public ByteBuffer partialDeserializeByteArray(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    // TType does not have binary, so we use the arbitrary num 100
+    return (ByteBuffer) partialDeserializeField((byte)100, bytes, fieldIdPathFirst, fieldIdPathRest);
+  }
+
+  /**
+   * Deserialize only the id of the field set in a TUnion (addressed by recursively using field id)
+   * from a byte record.
+   * @param bytes The serialized object to read from
+   * @param fieldIdPathFirst First of the FieldId's that define a path to a TUnion
+   * @param fieldIdPathRest The rest FieldId's that define a path to a TUnion
+   * @throws TException
+   */
+  public Short partialDeserializeSetFieldIdInUnion(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest)  throws TException {
+    try {
+      TField field = locateField(bytes, fieldIdPathFirst, fieldIdPathRest);
+      if (field != null){
+        protocol_.readStructBegin(); // The Union
+        return protocol_.readFieldBegin().id; // The field set in the union
+      }
+      return null;
+    } catch (Exception e) {
+      throw new TException(e);
+    } finally {
+      trans_.clear();
+      protocol_.reset();
+    }
+  }
+
+  private Object partialDeserializeField(byte ttype, byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    try {
+      TField field = locateField(bytes, fieldIdPathFirst, fieldIdPathRest);
+      if (field != null) {
+        // if this point is reached, iprot will be positioned at the start of the field.
+        switch(ttype){
+          case TType.BOOL:
+            if (field.type == TType.BOOL){
+              return protocol_.readBool();
+            }
+            break;
+          case TType.BYTE:
+            if (field.type == TType.BYTE) {
+              return protocol_.readByte();
+            }
+            break;
+          case TType.DOUBLE:
+            if (field.type == TType.DOUBLE) {
+              return protocol_.readDouble();
+            }
+            break;
+          case TType.I16:
+            if (field.type == TType.I16) {
+              return protocol_.readI16();
+            }
+            break;
+          case TType.I32:
+            if (field.type == TType.I32) {
+              return protocol_.readI32();
+            }
+            break;
+          case TType.I64:
+            if (field.type == TType.I64) {
+              return protocol_.readI64();
+            }
+            break;
+          case TType.STRING:
+            if (field.type == TType.STRING) {
+              return protocol_.readString();
+            }
+            break;
+          case 100: // hack to differentiate between string and binary
+            if (field.type == TType.STRING) {
+              return protocol_.readBinary();
+            }
+            break;
+        }
+      }
+      return null;
+    } catch (Exception e) {
+      throw new TException(e);
+    } finally {
+      trans_.clear();
+      protocol_.reset();
+    }
+  }
+
+  private TField locateField(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
+    trans_.reset(bytes);
+
+    TFieldIdEnum[] fieldIdPath= new TFieldIdEnum[fieldIdPathRest.length + 1];
+    fieldIdPath[0] = fieldIdPathFirst;
+    for (int i = 0; i < fieldIdPathRest.length; i++){
+      fieldIdPath[i + 1] = fieldIdPathRest[i];
+    }
+
+    // index into field ID path being currently searched for
+    int curPathIndex = 0;
+
+    // this will be the located field, or null if it is not located
+    TField field = null;
+
+    protocol_.readStructBegin();
+
+    while (curPathIndex < fieldIdPath.length) {
+      field = protocol_.readFieldBegin();
+      // we can stop searching if we either see a stop or we go past the field
+      // id we're looking for (since fields should now be serialized in asc
+      // order).
+      if (field.type == TType.STOP || field.id > fieldIdPath[curPathIndex].getThriftFieldId()) {
+        return null;
+      }
+
+      if (field.id != fieldIdPath[curPathIndex].getThriftFieldId()) {
+        // Not the field we're looking for. Skip field.
+        TProtocolUtil.skip(protocol_, field.type);
+        protocol_.readFieldEnd();
+      } else {
+        // This field is the next step in the path. Step into field.
+        curPathIndex++;
+        if (curPathIndex < fieldIdPath.length) {
+          protocol_.readStructBegin();
+        }
+      }
+    }
+    return field;
+  }
+
+  /**
+   * Deserialize the Thrift object from a Java string, using the default JVM
+   * charset encoding.
+   *
+   * @param base The object to read into
+   * @param data The string to read from
+   */
+  public void fromString(TBase base, String data) throws TException {
+    deserialize(base, data.getBytes());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TEnum.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TEnum.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TEnum.java
new file mode 100644
index 0000000..01a32de
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TEnum.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+public interface TEnum {
+  public int getValue();
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TEnumHelper.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TEnumHelper.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TEnumHelper.java
new file mode 100644
index 0000000..8d5b3ff
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TEnumHelper.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import java.lang.InstantiationException;
+import java.lang.NoSuchMethodException;
+import java.lang.IllegalAccessException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Utility class with static methods for interacting with TEnum
+ */
+public class TEnumHelper {
+
+  /**
+   * Given a TEnum class and integer value, this method will return
+   * the associated constant from the given TEnum class.
+   * This method MUST be modified should the name of the 'findByValue' method
+   * change.
+   *
+   * @param enumClass TEnum from which to return a matching constant.
+   * @param value Value for which to return the constant.
+   *
+   * @return The constant in 'enumClass' whose value is 'value' or null if
+   *         something went wrong.
+   */
+  public static TEnum getByValue(Class<? extends TEnum> enumClass, int value) {
+    try {
+      Method method = enumClass.getMethod("findByValue", int.class);
+      return (TEnum) method.invoke(null, value);
+    } catch (NoSuchMethodException nsme) {
+      return null;
+    } catch (IllegalAccessException iae) {
+      return null;
+    } catch (InvocationTargetException ite) {
+      return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TException.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TException.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TException.java
new file mode 100644
index 0000000..5317ad9
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+/**
+ * Generic exception class for Thrift.
+ *
+ */
+public class TException extends Exception {
+
+  private static final long serialVersionUID = 1L;
+
+  public TException() {
+    super();
+  }
+
+  public TException(String message) {
+    super(message);
+  }
+
+  public TException(Throwable cause) {
+    super(cause);
+  }
+
+  public TException(String message, Throwable cause) {
+    super(message, cause);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TFieldIdEnum.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TFieldIdEnum.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TFieldIdEnum.java
new file mode 100644
index 0000000..8cb4b1b
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TFieldIdEnum.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+/**
+ * Interface for all generated struct Fields objects.
+ */
+public interface TFieldIdEnum {
+  /**
+   * Get the Thrift field id for the named field.
+   */
+  public short getThriftFieldId();
+
+  /**
+   * Get the field's name, exactly as in the IDL.
+   */
+  public String getFieldName();
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TFieldRequirementType.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TFieldRequirementType.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TFieldRequirementType.java
new file mode 100644
index 0000000..8cd29b8
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TFieldRequirementType.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+/**
+ * Requirement type constants.
+ *
+ */
+public final class TFieldRequirementType {
+  public static final byte REQUIRED  = 1;
+  public static final byte OPTIONAL = 2;
+  public static final byte DEFAULT = 3;
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TProcessor.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TProcessor.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TProcessor.java
new file mode 100644
index 0000000..d8d5315
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TProcessor.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+
+/**
+ * A processor is a generic object which operates upon an input stream and
+ * writes to some output stream.
+ *
+ */
+public interface TProcessor {
+  public boolean process(TProtocol in, TProtocol out)
+    throws TException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TProcessorFactory.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TProcessorFactory.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TProcessorFactory.java
new file mode 100644
index 0000000..3747971
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TProcessorFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransport;
+
+/**
+ * The default processor factory just returns a singleton
+ * instance.
+ */
+public class TProcessorFactory {
+
+  private final TProcessor processor_;
+
+  public TProcessorFactory(TProcessor processor) {
+    processor_ = processor;
+  }
+
+  public TProcessor getProcessor(TTransport trans) {
+    return processor_;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TSerializer.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TSerializer.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TSerializer.java
new file mode 100644
index 0000000..4547404
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TSerializer.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TBinaryProtocol;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolFactory;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport;
+
+/**
+ * Generic utility for easily serializing objects into a byte array or Java
+ * String.
+ *
+ */
+public class TSerializer {
+
+  /**
+   * This is the byte array that data is actually serialized into
+   */
+  private final ByteArrayOutputStream baos_ = new ByteArrayOutputStream();
+
+  /**
+   * This transport wraps that byte array
+   */
+  private final TIOStreamTransport transport_ = new TIOStreamTransport(baos_);
+
+  /**
+   * Internal protocol used for serializing objects.
+   */
+  private TProtocol protocol_;
+
+  /**
+   * Create a new TSerializer that uses the TBinaryProtocol by default.
+   */
+  public TSerializer() {
+    this(new TBinaryProtocol.Factory());
+  }
+
+  /**
+   * Create a new TSerializer. It will use the TProtocol specified by the
+   * factory that is passed in.
+   *
+   * @param protocolFactory Factory to create a protocol
+   */
+  public TSerializer(TProtocolFactory protocolFactory) {
+    protocol_ = protocolFactory.getProtocol(transport_);
+  }
+
+  /**
+   * Serialize the Thrift object into a byte array. The process is simple,
+   * just clear the byte array output, write the object into it, and grab the
+   * raw bytes.
+   *
+   * @param base The object to serialize
+   * @return Serialized object in byte[] format
+   */
+  public byte[] serialize(TBase base) throws TException {
+    baos_.reset();
+    base.write(protocol_);
+    return baos_.toByteArray();
+  }
+
+  /**
+   * Serialize the Thrift object into a Java string, using a specified
+   * character set for encoding.
+   *
+   * @param base The object to serialize
+   * @param charset Valid JVM charset
+   * @return Serialized object as a String
+   */
+  public String toString(TBase base, String charset) throws TException {
+    try {
+      return new String(serialize(base), charset);
+    } catch (UnsupportedEncodingException uex) {
+      throw new TException("JVM DOES NOT SUPPORT ENCODING: " + charset);
+    }
+  }
+
+  /**
+   * Serialize the Thrift object into a Java string, using the default JVM
+   * charset encoding.
+   *
+   * @param base The object to serialize
+   * @return Serialized object as a String
+   */
+  public String toString(TBase base) throws TException {
+    return new String(serialize(base));
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TServiceClient.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TServiceClient.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TServiceClient.java
new file mode 100644
index 0000000..e028e5b
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TServiceClient.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMessage;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMessageType;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+
+/**
+ * A TServiceClient is used to communicate with a TService implementation
+ * across protocols and transports.
+ */
+public abstract class TServiceClient {
+  public TServiceClient(TProtocol prot) {
+    this(prot, prot);
+  }
+
+  public TServiceClient(TProtocol iprot, TProtocol oprot) {
+    iprot_ = iprot;
+    oprot_ = oprot;
+  }
+
+  protected TProtocol iprot_;
+  protected TProtocol oprot_;
+
+  protected int seqid_;
+
+  /**
+   * Get the TProtocol being used as the input (read) protocol.
+   * @return the TProtocol being used as the input (read) protocol.
+   */
+  public TProtocol getInputProtocol() {
+    return this.iprot_;
+  }
+
+  /**
+   * Get the TProtocol being used as the output (write) protocol.
+   * @return the TProtocol being used as the output (write) protocol.
+   */
+  public TProtocol getOutputProtocol() {
+    return this.oprot_;
+  }
+
+  protected void sendBase(String methodName, TBase args) throws TException {
+    oprot_.writeMessageBegin(new TMessage(methodName, TMessageType.CALL, ++seqid_));
+    args.write(oprot_);
+    oprot_.writeMessageEnd();
+    oprot_.getTransport().flush();
+  }
+
+  protected void receiveBase(TBase result, String methodName) throws TException {
+    TMessage msg = iprot_.readMessageBegin();
+    if (msg.type == TMessageType.EXCEPTION) {
+      TApplicationException x = TApplicationException.read(iprot_);
+      iprot_.readMessageEnd();
+      throw x;
+    }
+    if (msg.seqid != seqid_) {
+      throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, methodName + " failed: out of sequence response");
+    }
+    result.read(iprot_);
+    iprot_.readMessageEnd();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TServiceClientFactory.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TServiceClientFactory.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TServiceClientFactory.java
new file mode 100644
index 0000000..d2639df
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TServiceClientFactory.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+
+/**
+ * A TServiceClientFactory provides a general way to get a TServiceClient
+ * connected to a remote TService via a protocol.
+ * @param <T>
+ */
+public interface TServiceClientFactory<T extends TServiceClient> {
+  /**
+   * Get a brand-new T using <i>prot</i> as both the input and output protocol.
+   * @param prot
+   * @return A brand-new T using <i>prot</i> as both the input and output protocol.
+   */
+  public T getClient(TProtocol prot);
+
+  /**
+   * Get a brand new T using the specified input and output protocols. The
+   * input and output protocols may be the same instance.
+   * @param iprot
+   * @param oprot
+   * @return a brand new T using the specified input and output protocols
+   */
+  public T getClient(TProtocol iprot, TProtocol oprot);
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TUnion.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TUnion.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TUnion.java
new file mode 100644
index 0000000..93786f4
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/TUnion.java
@@ -0,0 +1,279 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.thirdparty.thrift_0_9_0;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolException;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct;
+import org.apache.blur.thirdparty.thrift_0_9_0.scheme.IScheme;
+import org.apache.blur.thirdparty.thrift_0_9_0.scheme.SchemeFactory;
+import org.apache.blur.thirdparty.thrift_0_9_0.scheme.StandardScheme;
+import org.apache.blur.thirdparty.thrift_0_9_0.scheme.TupleScheme;
+
+public abstract class TUnion<T extends TUnion<?,?>, F extends TFieldIdEnum> implements TBase<T, F> {
+
+  protected Object value_;
+  protected F setField_;
+
+  protected TUnion() {
+    setField_ = null;
+    value_ = null;
+  }
+  
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new TUnionStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new TUnionTupleSchemeFactory());
+  }
+
+  protected TUnion(F setField, Object value) {
+    setFieldValue(setField, value);
+  }
+
+  protected TUnion(TUnion<T, F> other) {
+    if (!other.getClass().equals(this.getClass())) {
+      throw new ClassCastException();
+    }
+    setField_ = other.setField_;
+    value_ = deepCopyObject(other.value_);
+  }
+
+  private static Object deepCopyObject(Object o) {
+    if (o instanceof TBase) {
+      return ((TBase)o).deepCopy();
+    } else if (o instanceof ByteBuffer) {
+      return TBaseHelper.copyBinary((ByteBuffer)o);
+    } else if (o instanceof List) {
+      return deepCopyList((List)o);
+    } else if (o instanceof Set) {
+      return deepCopySet((Set)o);
+    } else if (o instanceof Map) {
+      return deepCopyMap((Map)o);
+    } else {
+      return o;
+    }
+  }
+
+  private static Map deepCopyMap(Map<Object, Object> map) {
+    Map copy = new HashMap();
+    for (Map.Entry<Object, Object> entry : map.entrySet()) {
+      copy.put(deepCopyObject(entry.getKey()), deepCopyObject(entry.getValue()));
+    }
+    return copy;
+  }
+
+  private static Set deepCopySet(Set set) {
+    Set copy = new HashSet();
+    for (Object o : set) {
+      copy.add(deepCopyObject(o));
+    }
+    return copy;
+  }
+
+  private static List deepCopyList(List list) {
+    List copy = new ArrayList(list.size());
+    for (Object o : list) {
+      copy.add(deepCopyObject(o));
+    }
+    return copy;
+  }
+
+  public F getSetField() {
+    return setField_;
+  }
+
+  public Object getFieldValue() {
+    return value_;
+  }
+
+  public Object getFieldValue(F fieldId) {
+    if (fieldId != setField_) {
+      throw new IllegalArgumentException("Cannot get the value of field " + fieldId + " because union's set field is " + setField_);
+    }
+
+    return getFieldValue();
+  }
+
+  public Object getFieldValue(int fieldId) {
+    return getFieldValue(enumForId((short)fieldId));
+  }
+
+  public boolean isSet() {
+    return setField_ != null;
+  }
+
+  public boolean isSet(F fieldId) {
+    return setField_ == fieldId;
+  }
+
+  public boolean isSet(int fieldId) {
+    return isSet(enumForId((short)fieldId));
+  }
+
+  public void read(TProtocol iprot) throws TException {
+    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+  }
+
+  public void setFieldValue(F fieldId, Object value) {
+    checkType(fieldId, value);
+    setField_ = fieldId;
+    value_ = value;
+  }
+
+  public void setFieldValue(int fieldId, Object value) {
+    setFieldValue(enumForId((short)fieldId), value);
+  }
+
+  public void write(TProtocol oprot) throws TException {
+    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+  }
+
+  /**
+   * Implementation should be generated so that we can efficiently type check 
+   * various values.
+   * @param setField
+   * @param value
+   */
+  protected abstract void checkType(F setField, Object value) throws ClassCastException;
+
+  /**
+   * Implementation should be generated to read the right stuff from the wire 
+   * based on the field header. 
+   * @param field
+   * @return read Object based on the field header, as specified by the argument.
+   */
+  protected abstract Object standardSchemeReadValue(TProtocol iprot, TField field) throws TException;
+  protected abstract void standardSchemeWriteValue(TProtocol oprot) throws TException;
+  
+  protected abstract Object tupleSchemeReadValue(TProtocol iprot, short fieldID) throws TException;
+  protected abstract void tupleSchemeWriteValue(TProtocol oprot) throws TException;
+
+  protected abstract TStruct getStructDesc();
+
+  protected abstract TField getFieldDesc(F setField);
+
+  protected abstract F enumForId(short id);
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append("<");
+    sb.append(this.getClass().getSimpleName());
+    sb.append(" ");
+
+    if (getSetField() != null) {
+      Object v = getFieldValue();
+      sb.append(getFieldDesc(getSetField()).name);
+      sb.append(":");
+      if(v instanceof ByteBuffer) {
+        TBaseHelper.toString((ByteBuffer)v, sb);
+      } else {
+        sb.append(v.toString());
+      }
+    }
+    sb.append(">");
+    return sb.toString();
+  }
+
+  public final void clear() {
+    this.setField_ = null;
+    this.value_ = null;
+  }
+  
+  private static class TUnionStandardSchemeFactory implements SchemeFactory {
+    public TUnionStandardScheme getScheme() {
+      return new TUnionStandardScheme();
+    }
+  }
+  
+  private static class TUnionStandardScheme extends StandardScheme<TUnion> {
+
+    @Override
+    public void read(TProtocol iprot, TUnion struct) throws TException {
+      struct.setField_ = null;
+      struct.value_ = null;
+
+      iprot.readStructBegin();
+
+      TField field = iprot.readFieldBegin();
+
+      struct.value_ = struct.standardSchemeReadValue(iprot, field);
+      if (struct.value_ != null) {
+        struct.setField_ = struct.enumForId(field.id);
+      }
+
+      iprot.readFieldEnd();
+      // this is so that we will eat the stop byte. we could put a check here to
+      // make sure that it actually *is* the stop byte, but it's faster to do it
+      // this way.
+      iprot.readFieldBegin();
+      iprot.readStructEnd();
+    }
+
+    @Override
+    public void write(TProtocol oprot, TUnion struct) throws TException {
+      if (struct.getSetField() == null || struct.getFieldValue() == null) {
+        throw new TProtocolException("Cannot write a TUnion with no set value!");
+      }
+      oprot.writeStructBegin(struct.getStructDesc());
+      oprot.writeFieldBegin(struct.getFieldDesc(struct.setField_));
+      struct.standardSchemeWriteValue(oprot);
+      oprot.writeFieldEnd();
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+  }
+  
+  private static class TUnionTupleSchemeFactory implements SchemeFactory {
+    public TUnionTupleScheme getScheme() {
+      return new TUnionTupleScheme();
+    }
+  }
+  
+  private static class TUnionTupleScheme extends TupleScheme<TUnion> {
+
+    @Override
+    public void read(TProtocol iprot, TUnion struct) throws TException {
+      struct.setField_ = null;
+      struct.value_ = null;
+      short fieldID = iprot.readI16();
+      struct.value_ = struct.tupleSchemeReadValue(iprot, fieldID);
+      if (struct.value_ != null) {
+        struct.setField_ = struct.enumForId(fieldID);
+      }
+    }
+
+    @Override
+    public void write(TProtocol oprot, TUnion struct) throws TException {
+      if (struct.getSetField() == null || struct.getFieldValue() == null) {
+        throw new TProtocolException("Cannot write a TUnion with no set value!");
+      }
+      oprot.writeI16(struct.setField_.getThriftFieldId());
+      struct.tupleSchemeWriteValue(oprot);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/AsyncMethodCallback.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/AsyncMethodCallback.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/AsyncMethodCallback.java
new file mode 100644
index 0000000..4c91157
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/AsyncMethodCallback.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.blur.thirdparty.thrift_0_9_0.async;
+
+
+public interface AsyncMethodCallback<T> {
+  /**
+   * This method will be called when the remote side has completed invoking
+   * your method call and the result is fully read. For oneway method calls,
+   * this method will be called as soon as we have completed writing out the
+   * request.
+   * @param response
+   */
+  public void onComplete(T response);
+
+  /**
+   * This method will be called when there is an unexpected clientside
+   * exception. This does not include application-defined exceptions that
+   * appear in the IDL, but rather things like IOExceptions.
+   * @param exception
+   */
+  public void onError(Exception exception);
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClient.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClient.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClient.java
new file mode 100644
index 0000000..7e2983b
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClient.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.blur.thirdparty.thrift_0_9_0.async;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolFactory;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TNonblockingTransport;
+
+public abstract class TAsyncClient {
+  protected final TProtocolFactory ___protocolFactory;
+  protected final TNonblockingTransport ___transport;
+  protected final TAsyncClientManager ___manager;
+  protected TAsyncMethodCall ___currentMethod;
+  private Exception ___error;
+  private long ___timeout;
+
+  public TAsyncClient(TProtocolFactory protocolFactory, TAsyncClientManager manager, TNonblockingTransport transport) {
+    this(protocolFactory, manager, transport, 0);
+  }
+
+  public TAsyncClient(TProtocolFactory protocolFactory, TAsyncClientManager manager, TNonblockingTransport transport, long timeout) {
+    this.___protocolFactory = protocolFactory;
+    this.___manager = manager;
+    this.___transport = transport;
+    this.___timeout = timeout;
+  }
+
+  public TProtocolFactory getProtocolFactory() {
+    return ___protocolFactory;
+  }
+
+  public long getTimeout() {
+    return ___timeout;
+  }
+
+  public boolean hasTimeout() {
+    return ___timeout > 0;
+  }
+
+  public void setTimeout(long timeout) {
+    this.___timeout = timeout;
+  }
+
+  /**
+   * Is the client in an error state?
+   * @return If client in an error state?
+   */
+  public boolean hasError() {
+    return ___error != null;
+  }
+
+  /**
+   * Get the client's error - returns null if no error
+   * @return Get the client's error. <br /> returns null if no error
+   */
+  public Exception getError() {
+    return ___error;
+  }
+
+  protected void checkReady() {
+    // Ensure we are not currently executing a method
+    if (___currentMethod != null) {
+      throw new IllegalStateException("Client is currently executing another method: " + ___currentMethod.getClass().getName());
+    }
+
+    // Ensure we're not in an error state
+    if (___error != null) {
+      throw new IllegalStateException("Client has an error!", ___error);
+    }
+  }
+
+  /**
+   * Called by delegate method when finished
+   */
+  protected void onComplete() {
+    ___currentMethod = null;
+  }
+
+  /**
+   * Called by delegate method on error
+   */
+  protected void onError(Exception exception) {
+    ___transport.close();
+    ___currentMethod = null;
+    ___error = exception;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClientFactory.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClientFactory.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClientFactory.java
new file mode 100644
index 0000000..034615c
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClientFactory.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.blur.thirdparty.thrift_0_9_0.async;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TNonblockingTransport;
+
+public interface TAsyncClientFactory<T extends TAsyncClient> {
+  public T getAsyncClient(TNonblockingTransport transport);
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClientManager.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClientManager.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClientManager.java
new file mode 100644
index 0000000..f273f88
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncClientManager.java
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.blur.thirdparty.thrift_0_9_0.async;
+
+import java.io.IOException;
+import java.nio.channels.ClosedSelectorException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Contains selector thread which transitions method call objects
+ */
+public class TAsyncClientManager {
+  private static final Logger LOGGER = LoggerFactory.getLogger(TAsyncClientManager.class.getName());
+
+  private final SelectThread selectThread;
+  private final ConcurrentLinkedQueue<TAsyncMethodCall> pendingCalls = new ConcurrentLinkedQueue<TAsyncMethodCall>();
+
+  public TAsyncClientManager() throws IOException {
+    this.selectThread = new SelectThread();
+    selectThread.start();
+  }
+
+  public void call(TAsyncMethodCall method) throws TException {
+    if (!isRunning()) {
+      throw new TException("SelectThread is not running");
+    }
+    method.prepareMethodCall();
+    pendingCalls.add(method);
+    selectThread.getSelector().wakeup();
+  }
+
+  public void stop() {
+    selectThread.finish();
+  }
+
+  public boolean isRunning() {
+    return selectThread.isAlive();
+  }
+
+  private class SelectThread extends Thread {
+    private final Selector selector;
+    private volatile boolean running;
+    private final TreeSet<TAsyncMethodCall> timeoutWatchSet = new TreeSet<TAsyncMethodCall>(new TAsyncMethodCallTimeoutComparator());
+
+    public SelectThread() throws IOException {
+      this.selector = SelectorProvider.provider().openSelector();
+      this.running = true;
+      this.setName("TAsyncClientManager#SelectorThread " + this.getId());
+
+      // We don't want to hold up the JVM when shutting down
+      setDaemon(true);
+    }
+
+    public Selector getSelector() {
+      return selector;
+    }
+
+    public void finish() {
+      running = false;
+      selector.wakeup();
+    }
+
+    public void run() {
+      while (running) {
+        try {
+          try {
+            if (timeoutWatchSet.size() == 0) {
+              // No timeouts, so select indefinitely
+              selector.select();
+            } else {
+              // We have a timeout pending, so calculate the time until then and select appropriately
+              long nextTimeout = timeoutWatchSet.first().getTimeoutTimestamp();
+              long selectTime = nextTimeout - System.currentTimeMillis();
+              if (selectTime > 0) {
+                // Next timeout is in the future, select and wake up then
+                selector.select(selectTime);
+              } else {
+                // Next timeout is now or in past, select immediately so we can time out
+                selector.selectNow();
+              }
+            }
+          } catch (IOException e) {
+            LOGGER.error("Caught IOException in TAsyncClientManager!", e);
+          }
+          transitionMethods();
+          timeoutMethods();
+          startPendingMethods();
+        } catch (Exception exception) {
+          LOGGER.error("Ignoring uncaught exception in SelectThread", exception);
+        }
+      }
+    }
+
+    // Transition methods for ready keys
+    private void transitionMethods() {
+      try {
+        Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
+        while (keys.hasNext()) {
+          SelectionKey key = keys.next();
+          keys.remove();
+          if (!key.isValid()) {
+            // this can happen if the method call experienced an error and the
+            // key was cancelled. can also happen if we timeout a method, which
+            // results in a channel close.
+            // just skip
+            continue;
+          }
+          TAsyncMethodCall methodCall = (TAsyncMethodCall)key.attachment();
+          methodCall.transition(key);
+
+          // If done or error occurred, remove from timeout watch set
+          if (methodCall.isFinished() || methodCall.getClient().hasError()) {
+            timeoutWatchSet.remove(methodCall);
+          }
+        }
+      } catch (ClosedSelectorException e) {
+        LOGGER.error("Caught ClosedSelectorException in TAsyncClientManager!", e);
+      }
+    }
+
+    // Timeout any existing method calls
+    private void timeoutMethods() {
+      Iterator<TAsyncMethodCall> iterator = timeoutWatchSet.iterator();
+      long currentTime = System.currentTimeMillis();
+      while (iterator.hasNext()) {
+        TAsyncMethodCall methodCall = iterator.next();
+        if (currentTime >= methodCall.getTimeoutTimestamp()) {
+          iterator.remove();
+          methodCall.onError(new TimeoutException("Operation " + methodCall.getClass() + " timed out after " + (currentTime - methodCall.getStartTime()) + " ms."));
+        } else {
+          break;
+        }
+      }
+    }
+
+    // Start any new calls
+    private void startPendingMethods() {
+      TAsyncMethodCall methodCall;
+      while ((methodCall = pendingCalls.poll()) != null) {
+        // Catch registration errors. method will catch transition errors and cleanup.
+        try {
+          methodCall.start(selector);
+
+          // If timeout specified and first transition went smoothly, add to timeout watch set
+          TAsyncClient client = methodCall.getClient();
+          if (client.hasTimeout() && !client.hasError()) {
+            timeoutWatchSet.add(methodCall);
+          }
+        } catch (Exception exception) {
+          LOGGER.warn("Caught exception in TAsyncClientManager!", exception);
+          methodCall.onError(exception);
+        }
+      }
+    }
+  }
+
+  /** Comparator used in TreeSet */
+  private static class TAsyncMethodCallTimeoutComparator implements Comparator<TAsyncMethodCall> {
+    public int compare(TAsyncMethodCall left, TAsyncMethodCall right) {
+      if (left.getTimeoutTimestamp() == right.getTimeoutTimestamp()) {
+        return (int)(left.getSequenceId() - right.getSequenceId());
+      } else {
+        return (int)(left.getTimeoutTimestamp() - right.getTimeoutTimestamp());
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncMethodCall.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncMethodCall.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncMethodCall.java
new file mode 100644
index 0000000..beb2218
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/async/TAsyncMethodCall.java
@@ -0,0 +1,270 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.blur.thirdparty.thrift_0_9_0.async;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolFactory;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TFramedTransport;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TMemoryBuffer;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TNonblockingTransport;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransportException;
+
+/**
+ * Encapsulates an async method call
+ * Need to generate:
+ *   - private void write_args(TProtocol protocol)
+ *   - public T getResult() throws <Exception_1>, <Exception_2>, ...
+ * @param <T>
+ */
+public abstract class TAsyncMethodCall<T> {
+
+  private static final int INITIAL_MEMORY_BUFFER_SIZE = 128;
+  private static AtomicLong sequenceIdCounter = new AtomicLong(0);
+
+  public static enum State {
+    CONNECTING,
+    WRITING_REQUEST_SIZE,
+    WRITING_REQUEST_BODY,
+    READING_RESPONSE_SIZE,
+    READING_RESPONSE_BODY,
+    RESPONSE_READ,
+    ERROR;
+  }
+
+  /**
+   * Next step in the call, initialized by start()
+   */
+  private State state = null;
+
+  protected final TNonblockingTransport transport;
+  private final TProtocolFactory protocolFactory;
+  protected final TAsyncClient client;
+  private final AsyncMethodCallback<T> callback;
+  private final boolean isOneway;
+  private long sequenceId;
+  
+  private ByteBuffer sizeBuffer;
+  private final byte[] sizeBufferArray = new byte[4];
+  private ByteBuffer frameBuffer;
+
+  private long startTime = System.currentTimeMillis();
+
+  protected TAsyncMethodCall(TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport, AsyncMethodCallback<T> callback, boolean isOneway) {
+    this.transport = transport;
+    this.callback = callback;
+    this.protocolFactory = protocolFactory;
+    this.client = client;
+    this.isOneway = isOneway;
+    this.sequenceId = TAsyncMethodCall.sequenceIdCounter.getAndIncrement();
+  }
+
+  protected State getState() {
+    return state;
+  }
+
+  protected boolean isFinished() {
+    return state == State.RESPONSE_READ;
+  }
+
+  protected long getStartTime() {
+    return startTime;
+  }
+  
+  protected long getSequenceId() {
+    return sequenceId;
+  }
+
+  public TAsyncClient getClient() {
+    return client;
+  }
+  
+  public boolean hasTimeout() {
+    return client.hasTimeout();
+  }
+  
+  public long getTimeoutTimestamp() {
+    return client.getTimeout() + startTime;
+  }
+
+  protected abstract void write_args(TProtocol protocol) throws TException;
+
+  /**
+   * Initialize buffers.
+   * @throws TException if buffer initialization fails
+   */
+  protected void prepareMethodCall() throws TException {
+    TMemoryBuffer memoryBuffer = new TMemoryBuffer(INITIAL_MEMORY_BUFFER_SIZE);
+    TProtocol protocol = protocolFactory.getProtocol(memoryBuffer);
+    write_args(protocol);
+
+    int length = memoryBuffer.length();
+    frameBuffer = ByteBuffer.wrap(memoryBuffer.getArray(), 0, length);
+
+    TFramedTransport.encodeFrameSize(length, sizeBufferArray);
+    sizeBuffer = ByteBuffer.wrap(sizeBufferArray);
+  }
+
+  /**
+   * Register with selector and start first state, which could be either connecting or writing.
+   * @throws IOException if register or starting fails
+   */
+  void start(Selector sel) throws IOException {
+    SelectionKey key;
+    if (transport.isOpen()) {
+      state = State.WRITING_REQUEST_SIZE;
+      key = transport.registerSelector(sel, SelectionKey.OP_WRITE);
+    } else {
+      state = State.CONNECTING;
+      key = transport.registerSelector(sel, SelectionKey.OP_CONNECT);
+
+      // non-blocking connect can complete immediately,
+      // in which case we should not expect the OP_CONNECT
+      if (transport.startConnect()) {
+        registerForFirstWrite(key);
+      }
+    }
+
+    key.attach(this);
+  }
+
+  void registerForFirstWrite(SelectionKey key) throws IOException {
+    state = State.WRITING_REQUEST_SIZE;
+    key.interestOps(SelectionKey.OP_WRITE);
+  }
+
+  protected ByteBuffer getFrameBuffer() {
+    return frameBuffer;
+  }
+
+  /**
+   * Transition to next state, doing whatever work is required. Since this
+   * method is only called by the selector thread, we can make changes to our
+   * select interests without worrying about concurrency.
+   * @param key
+   */
+  protected void transition(SelectionKey key) {
+    // Ensure key is valid
+    if (!key.isValid()) {
+      key.cancel();
+      Exception e = new TTransportException("Selection key not valid!");
+      onError(e);
+      return;
+    }
+
+    // Transition function
+    try {
+      switch (state) {
+        case CONNECTING:
+          doConnecting(key);
+          break;
+        case WRITING_REQUEST_SIZE:
+          doWritingRequestSize();
+          break;
+        case WRITING_REQUEST_BODY:
+          doWritingRequestBody(key);
+          break;
+        case READING_RESPONSE_SIZE:
+          doReadingResponseSize();
+          break;
+        case READING_RESPONSE_BODY:
+          doReadingResponseBody(key);
+          break;
+        default: // RESPONSE_READ, ERROR, or bug
+          throw new IllegalStateException("Method call in state " + state
+              + " but selector called transition method. Seems like a bug...");
+      }
+    } catch (Exception e) {
+      key.cancel();
+      key.attach(null);
+      onError(e);
+    }
+  }
+
+  protected void onError(Exception e) {
+    client.onError(e);
+    callback.onError(e);
+    state = State.ERROR;
+  }
+
+  private void doReadingResponseBody(SelectionKey key) throws IOException {
+    if (transport.read(frameBuffer) < 0) {
+      throw new IOException("Read call frame failed");
+    }
+    if (frameBuffer.remaining() == 0) {
+      cleanUpAndFireCallback(key);
+    }
+  }
+
+  private void cleanUpAndFireCallback(SelectionKey key) {
+    state = State.RESPONSE_READ;
+    key.interestOps(0);
+    // this ensures that the TAsyncMethod instance doesn't hang around
+    key.attach(null);
+    client.onComplete();
+    callback.onComplete((T)this);
+  }
+
+  private void doReadingResponseSize() throws IOException {
+    if (transport.read(sizeBuffer) < 0) {
+      throw new IOException("Read call frame size failed");
+    }
+    if (sizeBuffer.remaining() == 0) {
+      state = State.READING_RESPONSE_BODY;
+      frameBuffer = ByteBuffer.allocate(TFramedTransport.decodeFrameSize(sizeBufferArray));
+    }
+  }
+
+  private void doWritingRequestBody(SelectionKey key) throws IOException {
+    if (transport.write(frameBuffer) < 0) {
+      throw new IOException("Write call frame failed");
+    }
+    if (frameBuffer.remaining() == 0) {
+      if (isOneway) {
+        cleanUpAndFireCallback(key);
+      } else {
+        state = State.READING_RESPONSE_SIZE;
+        sizeBuffer.rewind();  // Prepare to read incoming frame size
+        key.interestOps(SelectionKey.OP_READ);
+      }
+    }
+  }
+
+  private void doWritingRequestSize() throws IOException {
+    if (transport.write(sizeBuffer) < 0) {
+      throw new IOException("Write call frame size failed");
+    }
+    if (sizeBuffer.remaining() == 0) {
+      state = State.WRITING_REQUEST_BODY;
+    }
+  }
+
+  private void doConnecting(SelectionKey key) throws IOException {
+    if (!key.isConnectable() || !transport.finishConnect()) {
+      throw new IOException("not connectable or finishConnect returned false after we got an OP_CONNECT");
+    }
+    registerForFirstWrite(key);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9f63daff/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/meta_data/EnumMetaData.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/meta_data/EnumMetaData.java b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/meta_data/EnumMetaData.java
new file mode 100644
index 0000000..47d3a18
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thirdparty/thrift_0_9_0/meta_data/EnumMetaData.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.blur.thirdparty.thrift_0_9_0.meta_data;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.TEnum;
+
+public class EnumMetaData extends FieldValueMetaData {
+  public final Class<? extends TEnum> enumClass;
+  
+  public EnumMetaData(byte type, Class<? extends TEnum> sClass){
+    super(type);
+    this.enumClass = sClass;
+  }    
+}


Mime
View raw message