avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1598159 - in /avro/trunk: ./ lang/java/thrift/src/main/java/org/apache/avro/thrift/ lang/java/thrift/src/test/java/org/apache/avro/thrift/ lang/java/thrift/src/test/java/org/apache/avro/thrift/test/ lang/java/thrift/src/test/thrift/
Date Wed, 28 May 2014 22:19:54 GMT
Author: cutting
Date: Wed May 28 22:19:54 2014
New Revision: 1598159

URL: http://svn.apache.org/r1598159
Log:
AVRO-1512. Java: Support Thrift unions.

Added:
    avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java  
(with props)
Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java
    avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/TestThrift.java
    avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Test.java
    avro/trunk/lang/java/thrift/src/test/thrift/test.thrift

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1598159&r1=1598158&r2=1598159&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed May 28 22:19:54 2014
@@ -40,9 +40,11 @@ Trunk (not yet released)
     AVRO-1482. In specification, place "null" first in unions as best practice.
     (cutting)
 
-    AVRO-1476. Remove transient declaration from Schema.Field#position.
+    AVRO-1476. Java: Remove transient declaration from Schema.Field#position.
     (Robert Chu via cutting)
 
+    AVRO-1512. Java: Support Thrift unions. (cutting)
+
   BUG FIXES
 
     AVRO-1446. C#: Correctly handle system errors in RPC.

Modified: avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java?rev=1598159&r1=1598158&r2=1598159&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java (original)
+++ avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java Wed May
28 22:19:54 2014
@@ -81,6 +81,7 @@ public class ThriftData extends GenericD
 
   @Override
   protected void setField(Object r, String n, int pos, Object v, Object state) {
+    if (v == null && r instanceof TUnion) return;
     ((TBase)r).setFieldValue(((TFieldIdEnum[])state)[pos], v);
   }
 
@@ -111,7 +112,7 @@ public class ThriftData extends GenericD
 
   @Override
   protected boolean isRecord(Object datum) {
-    return datum instanceof TBase && !(datum instanceof TUnion);
+    return datum instanceof TBase;
   }
 
   @Override

Modified: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/TestThrift.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/TestThrift.java?rev=1598159&r1=1598158&r2=1598159&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/TestThrift.java (original)
+++ avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/TestThrift.java Wed May
28 22:19:54 2014
@@ -29,6 +29,7 @@ import org.apache.avro.io.EncoderFactory
 import static org.junit.Assert.assertEquals;
 
 import org.apache.avro.thrift.test.Test;
+import org.apache.avro.thrift.test.FooOrBar;
 import org.apache.avro.thrift.test.E;
 import org.apache.avro.thrift.test.Nested;
 
@@ -52,6 +53,7 @@ public class TestThrift {
     test.setSetField(Collections.singleton(8));
     test.setEnumField(E.X);
     test.setStructField(new Nested(9));
+    test.setFooOrBar(FooOrBar.foo("x"));
 
     System.out.println(test);
 

Added: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java?rev=1598159&view=auto
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java (added)
+++ avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java Wed
May 28 22:19:54 2014
@@ -0,0 +1,307 @@
+/**
+ * Autogenerated by Thrift Compiler (0.7.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package org.apache.avro.thrift.test;
+
+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 FooOrBar extends org.apache.thrift.TUnion<FooOrBar, FooOrBar._Fields>
{
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("FooOrBar");
+  private static final org.apache.thrift.protocol.TField FOO_FIELD_DESC = new org.apache.thrift.protocol.TField("foo",
org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField BAR_FIELD_DESC = new org.apache.thrift.protocol.TField("bar",
org.apache.thrift.protocol.TType.STRING, (short)2);
+
+  /** The set of fields this struct contains, along with convenience methods for finding
and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    FOO((short)1, "foo"),
+    BAR((short)2, "bar");
+
+    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: // FOO
+          return FOO;
+        case 2: // BAR
+          return BAR;
+        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;
+    }
+  }
+
+  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.FOO, new org.apache.thrift.meta_data.FieldMetaData("foo", org.apache.thrift.TFieldRequirementType.DEFAULT,

+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.BAR, new org.apache.thrift.meta_data.FieldMetaData("bar", 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(FooOrBar.class, metaDataMap);
+  }
+
+  public FooOrBar() {
+    super();
+  }
+
+  public FooOrBar(_Fields setField, Object value) {
+    super(setField, value);
+  }
+
+  public FooOrBar(FooOrBar other) {
+    super(other);
+  }
+  public FooOrBar deepCopy() {
+    return new FooOrBar(this);
+  }
+
+  public static FooOrBar foo(String value) {
+    FooOrBar x = new FooOrBar();
+    x.setFoo(value);
+    return x;
+  }
+
+  public static FooOrBar bar(String value) {
+    FooOrBar x = new FooOrBar();
+    x.setBar(value);
+    return x;
+  }
+
+
+  @Override
+  protected void checkType(_Fields setField, Object value) throws ClassCastException {
+    switch (setField) {
+      case FOO:
+        if (value instanceof String) {
+          break;
+        }
+        throw new ClassCastException("Was expecting value of type String for field 'foo',
but got " + value.getClass().getSimpleName());
+      case BAR:
+        if (value instanceof String) {
+          break;
+        }
+        throw new ClassCastException("Was expecting value of type String for field 'bar',
but got " + value.getClass().getSimpleName());
+      default:
+        throw new IllegalArgumentException("Unknown field id " + setField);
+    }
+  }
+
+  @Override
+  protected Object readValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField
field) throws org.apache.thrift.TException {
+    _Fields setField = _Fields.findByThriftId(field.id);
+    if (setField != null) {
+      switch (setField) {
+        case FOO:
+          if (field.type == FOO_FIELD_DESC.type) {
+            String foo;
+            foo = iprot.readString();
+            return foo;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        case BAR:
+          if (field.type == BAR_FIELD_DESC.type) {
+            String bar;
+            bar = iprot.readString();
+            return bar;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        default:
+          throw new IllegalStateException("setField wasn't null, but didn't match any of
the case statements!");
+      }
+    } else {
+      org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+      return null;
+    }
+  }
+
+  @Override
+  protected void writeValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException
{
+    switch (setField_) {
+      case FOO:
+        String foo = (String)value_;
+        oprot.writeString(foo);
+        return;
+      case BAR:
+        String bar = (String)value_;
+        oprot.writeString(bar);
+        return;
+      default:
+        throw new IllegalStateException("Cannot write union with unknown field " + setField_);
+    }
+  }
+
+  @Override
+  protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {
+    switch (setField) {
+      case FOO:
+        return FOO_FIELD_DESC;
+      case BAR:
+        return BAR_FIELD_DESC;
+      default:
+        throw new IllegalArgumentException("Unknown field id " + setField);
+    }
+  }
+
+  @Override
+  protected org.apache.thrift.protocol.TStruct getStructDesc() {
+    return STRUCT_DESC;
+  }
+
+  @Override
+  protected _Fields enumForId(short id) {
+    return _Fields.findByThriftIdOrThrow(id);
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+
+  public String getFoo() {
+    if (getSetField() == _Fields.FOO) {
+      return (String)getFieldValue();
+    } else {
+      throw new RuntimeException("Cannot get field 'foo' because union is currently set to
" + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setFoo(String value) {
+    if (value == null) throw new NullPointerException();
+    setField_ = _Fields.FOO;
+    value_ = value;
+  }
+
+  public String getBar() {
+    if (getSetField() == _Fields.BAR) {
+      return (String)getFieldValue();
+    } else {
+      throw new RuntimeException("Cannot get field 'bar' because union is currently set to
" + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setBar(String value) {
+    if (value == null) throw new NullPointerException();
+    setField_ = _Fields.BAR;
+    value_ = value;
+  }
+
+  public boolean isSetFoo() {
+    return setField_ == _Fields.FOO;
+  }
+
+
+  public boolean isSetBar() {
+    return setField_ == _Fields.BAR;
+  }
+
+
+  public boolean equals(Object other) {
+    if (other instanceof FooOrBar) {
+      return equals((FooOrBar)other);
+    } else {
+      return false;
+    }
+  }
+
+  public boolean equals(FooOrBar other) {
+    return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());
+  }
+
+  @Override
+  public int compareTo(FooOrBar other) {
+    int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());
+    if (lastComparison == 0) {
+      return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
+    }
+    return lastComparison;
+  }
+
+
+  /**
+   * If you'd like this to perform more respectably, use the hashcode generator option.
+   */
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  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);
+    }
+  }
+
+
+}

Propchange: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Test.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Test.java?rev=1598159&r1=1598158&r2=1598159&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Test.java (original)
+++ avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Test.java Wed May
28 22:19:54 2014
@@ -36,6 +36,7 @@ public class Test implements org.apache.
   private static final org.apache.thrift.protocol.TField SET_FIELD_FIELD_DESC = new org.apache.thrift.protocol.TField("setField",
org.apache.thrift.protocol.TType.SET, (short)11);
   private static final org.apache.thrift.protocol.TField ENUM_FIELD_FIELD_DESC = new org.apache.thrift.protocol.TField("enumField",
org.apache.thrift.protocol.TType.I32, (short)12);
   private static final org.apache.thrift.protocol.TField STRUCT_FIELD_FIELD_DESC = new org.apache.thrift.protocol.TField("structField",
org.apache.thrift.protocol.TType.STRUCT, (short)13);
+  private static final org.apache.thrift.protocol.TField FOO_OR_BAR_FIELD_DESC = new org.apache.thrift.protocol.TField("fooOrBar",
org.apache.thrift.protocol.TType.STRUCT, (short)14);
 
   private boolean boolField; // required
   private byte byteField; // required
@@ -50,6 +51,7 @@ public class Test implements org.apache.
   private Set<Integer> setField; // required
   private E enumField; // required
   private Nested structField; // required
+  private FooOrBar fooOrBar; // 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 {
@@ -69,7 +71,8 @@ public class Test implements org.apache.
      * @see E
      */
     ENUM_FIELD((short)12, "enumField"),
-    STRUCT_FIELD((short)13, "structField");
+    STRUCT_FIELD((short)13, "structField"),
+    FOO_OR_BAR((short)14, "fooOrBar");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -110,6 +113,8 @@ public class Test implements org.apache.
           return ENUM_FIELD;
         case 13: // STRUCT_FIELD
           return STRUCT_FIELD;
+        case 14: // FOO_OR_BAR
+          return FOO_OR_BAR;
         default:
           return null;
       }
@@ -191,6 +196,8 @@ public class Test implements org.apache.
         new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM,
E.class)));
     tmpMap.put(_Fields.STRUCT_FIELD, new org.apache.thrift.meta_data.FieldMetaData("structField",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
Nested.class)));
+    tmpMap.put(_Fields.FOO_OR_BAR, new org.apache.thrift.meta_data.FieldMetaData("fooOrBar",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
FooOrBar.class)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Test.class, metaDataMap);
   }
@@ -209,7 +216,8 @@ public class Test implements org.apache.
     List<Integer> listField,
     Set<Integer> setField,
     E enumField,
-    Nested structField)
+    Nested structField,
+    FooOrBar fooOrBar)
   {
     this();
     this.boolField = boolField;
@@ -228,6 +236,7 @@ public class Test implements org.apache.
     this.setField = setField;
     this.enumField = enumField;
     this.structField = structField;
+    this.fooOrBar = fooOrBar;
   }
 
   /**
@@ -284,6 +293,9 @@ public class Test implements org.apache.
     if (other.isSetStructField()) {
       this.structField = new Nested(other.structField);
     }
+    if (other.isSetFooOrBar()) {
+      this.fooOrBar = new FooOrBar(other.fooOrBar);
+    }
   }
 
   public Test deepCopy() {
@@ -311,6 +323,7 @@ public class Test implements org.apache.
     this.setField = null;
     this.enumField = null;
     this.structField = null;
+    this.fooOrBar = null;
   }
 
   public boolean isBoolField() {
@@ -664,6 +677,29 @@ public class Test implements org.apache.
     }
   }
 
+  public FooOrBar getFooOrBar() {
+    return this.fooOrBar;
+  }
+
+  public void setFooOrBar(FooOrBar fooOrBar) {
+    this.fooOrBar = fooOrBar;
+  }
+
+  public void unsetFooOrBar() {
+    this.fooOrBar = null;
+  }
+
+  /** Returns true if field fooOrBar is set (has been assigned a value) and false otherwise
*/
+  public boolean isSetFooOrBar() {
+    return this.fooOrBar != null;
+  }
+
+  public void setFooOrBarIsSet(boolean value) {
+    if (!value) {
+      this.fooOrBar = null;
+    }
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case BOOL_FIELD:
@@ -770,6 +806,14 @@ public class Test implements org.apache.
       }
       break;
 
+    case FOO_OR_BAR:
+      if (value == null) {
+        unsetFooOrBar();
+      } else {
+        setFooOrBar((FooOrBar)value);
+      }
+      break;
+
     }
   }
 
@@ -814,6 +858,9 @@ public class Test implements org.apache.
     case STRUCT_FIELD:
       return getStructField();
 
+    case FOO_OR_BAR:
+      return getFooOrBar();
+
     }
     throw new IllegalStateException();
   }
@@ -851,6 +898,8 @@ public class Test implements org.apache.
       return isSetEnumField();
     case STRUCT_FIELD:
       return isSetStructField();
+    case FOO_OR_BAR:
+      return isSetFooOrBar();
     }
     throw new IllegalStateException();
   }
@@ -985,6 +1034,15 @@ public class Test implements org.apache.
         return false;
     }
 
+    boolean this_present_fooOrBar = true && this.isSetFooOrBar();
+    boolean that_present_fooOrBar = true && that.isSetFooOrBar();
+    if (this_present_fooOrBar || that_present_fooOrBar) {
+      if (!(this_present_fooOrBar && that_present_fooOrBar))
+        return false;
+      if (!this.fooOrBar.equals(that.fooOrBar))
+        return false;
+    }
+
     return true;
   }
 
@@ -1131,6 +1189,16 @@ public class Test implements org.apache.
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetFooOrBar()).compareTo(typedOther.isSetFooOrBar());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetFooOrBar()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fooOrBar, typedOther.fooOrBar);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -1278,6 +1346,14 @@ public class Test implements org.apache.
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
           }
           break;
+        case 14: // FOO_OR_BAR
+          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
+            this.fooOrBar = new FooOrBar();
+            this.fooOrBar.read(iprot);
+          } else { 
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
         default:
           org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
       }
@@ -1370,6 +1446,11 @@ public class Test implements org.apache.
       this.structField.write(oprot);
       oprot.writeFieldEnd();
     }
+    if (this.fooOrBar != null) {
+      oprot.writeFieldBegin(FOO_OR_BAR_FIELD_DESC);
+      this.fooOrBar.write(oprot);
+      oprot.writeFieldEnd();
+    }
     oprot.writeFieldStop();
     oprot.writeStructEnd();
   }
@@ -1462,6 +1543,14 @@ public class Test implements org.apache.
       sb.append(this.structField);
     }
     first = false;
+    if (!first) sb.append(", ");
+    sb.append("fooOrBar:");
+    if (this.fooOrBar == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.fooOrBar);
+    }
+    first = false;
     sb.append(")");
     return sb.toString();
   }

Modified: avro/trunk/lang/java/thrift/src/test/thrift/test.thrift
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/thrift/test.thrift?rev=1598159&r1=1598158&r2=1598159&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/thrift/test.thrift (original)
+++ avro/trunk/lang/java/thrift/src/test/thrift/test.thrift Wed May 28 22:19:54 2014
@@ -28,6 +28,12 @@ struct Nested {
   1: i32 x
 }
 
+union FooOrBar {
+  1: string foo;
+  2: string bar;
+}
+
+
 // contains each primitive type
 struct Test {
   1: bool boolField
@@ -43,6 +49,7 @@ struct Test {
  11: set<i32> setField
  12: E enumField
  13: Nested structField
+ 14: FooOrBar fooOrBar
 }
 
 exception Error {



Mime
View raw message