You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by gu...@apache.org on 2014/09/16 00:46:49 UTC
svn commit: r1625176 [9/9] - in /hive/branches/cbo: ./
common/src/java/org/apache/hadoop/hive/common/
common/src/java/org/apache/hadoop/hive/conf/
contrib/src/test/results/clientpositive/ data/conf/tez/ data/files/
itests/hive-unit/src/test/java/org/ap...
Modified: hive/branches/cbo/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java (original)
+++ hive/branches/cbo/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java Mon Sep 15 22:46:44 2014
@@ -40,6 +40,10 @@ public class Complex implements org.apac
private static final org.apache.thrift.protocol.TField L_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("lString", org.apache.thrift.protocol.TType.LIST, (short)4);
private static final org.apache.thrift.protocol.TField LINT_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("lintString", org.apache.thrift.protocol.TType.LIST, (short)5);
private static final org.apache.thrift.protocol.TField M_STRING_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("mStringString", org.apache.thrift.protocol.TType.MAP, (short)6);
+ private static final org.apache.thrift.protocol.TField ATTRIBUTES_FIELD_DESC = new org.apache.thrift.protocol.TField("attributes", org.apache.thrift.protocol.TType.MAP, (short)7);
+ private static final org.apache.thrift.protocol.TField UNION_FIELD1_FIELD_DESC = new org.apache.thrift.protocol.TField("unionField1", org.apache.thrift.protocol.TType.STRUCT, (short)8);
+ private static final org.apache.thrift.protocol.TField UNION_FIELD2_FIELD_DESC = new org.apache.thrift.protocol.TField("unionField2", org.apache.thrift.protocol.TType.STRUCT, (short)9);
+ private static final org.apache.thrift.protocol.TField UNION_FIELD3_FIELD_DESC = new org.apache.thrift.protocol.TField("unionField3", org.apache.thrift.protocol.TType.STRUCT, (short)10);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -53,6 +57,10 @@ public class Complex implements org.apac
private List<String> lString; // required
private List<IntString> lintString; // required
private Map<String,String> mStringString; // required
+ private Map<String,Map<String,Map<String,PropValueUnion>>> attributes; // required
+ private PropValueUnion unionField1; // required
+ private PropValueUnion unionField2; // required
+ private PropValueUnion unionField3; // 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 {
@@ -61,7 +69,11 @@ public class Complex implements org.apac
LINT((short)3, "lint"),
L_STRING((short)4, "lString"),
LINT_STRING((short)5, "lintString"),
- M_STRING_STRING((short)6, "mStringString");
+ M_STRING_STRING((short)6, "mStringString"),
+ ATTRIBUTES((short)7, "attributes"),
+ UNION_FIELD1((short)8, "unionField1"),
+ UNION_FIELD2((short)9, "unionField2"),
+ UNION_FIELD3((short)10, "unionField3");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -88,6 +100,14 @@ public class Complex implements org.apac
return LINT_STRING;
case 6: // M_STRING_STRING
return M_STRING_STRING;
+ case 7: // ATTRIBUTES
+ return ATTRIBUTES;
+ case 8: // UNION_FIELD1
+ return UNION_FIELD1;
+ case 9: // UNION_FIELD2
+ return UNION_FIELD2;
+ case 10: // UNION_FIELD3
+ return UNION_FIELD3;
default:
return null;
}
@@ -150,6 +170,20 @@ public class Complex implements org.apac
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+ tmpMap.put(_Fields.ATTRIBUTES, new org.apache.thrift.meta_data.FieldMetaData("attributes", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
+ new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
+ new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PropValueUnion.class))))));
+ tmpMap.put(_Fields.UNION_FIELD1, new org.apache.thrift.meta_data.FieldMetaData("unionField1", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PropValueUnion.class)));
+ tmpMap.put(_Fields.UNION_FIELD2, new org.apache.thrift.meta_data.FieldMetaData("unionField2", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PropValueUnion.class)));
+ tmpMap.put(_Fields.UNION_FIELD3, new org.apache.thrift.meta_data.FieldMetaData("unionField3", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PropValueUnion.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Complex.class, metaDataMap);
}
@@ -163,7 +197,11 @@ public class Complex implements org.apac
List<Integer> lint,
List<String> lString,
List<IntString> lintString,
- Map<String,String> mStringString)
+ Map<String,String> mStringString,
+ Map<String,Map<String,Map<String,PropValueUnion>>> attributes,
+ PropValueUnion unionField1,
+ PropValueUnion unionField2,
+ PropValueUnion unionField3)
{
this();
this.aint = aint;
@@ -173,6 +211,10 @@ public class Complex implements org.apac
this.lString = lString;
this.lintString = lintString;
this.mStringString = mStringString;
+ this.attributes = attributes;
+ this.unionField1 = unionField1;
+ this.unionField2 = unionField2;
+ this.unionField3 = unionField3;
}
/**
@@ -220,6 +262,52 @@ public class Complex implements org.apac
}
this.mStringString = __this__mStringString;
}
+ if (other.isSetAttributes()) {
+ Map<String,Map<String,Map<String,PropValueUnion>>> __this__attributes = new HashMap<String,Map<String,Map<String,PropValueUnion>>>();
+ for (Map.Entry<String, Map<String,Map<String,PropValueUnion>>> other_element : other.attributes.entrySet()) {
+
+ String other_element_key = other_element.getKey();
+ Map<String,Map<String,PropValueUnion>> other_element_value = other_element.getValue();
+
+ String __this__attributes_copy_key = other_element_key;
+
+ Map<String,Map<String,PropValueUnion>> __this__attributes_copy_value = new HashMap<String,Map<String,PropValueUnion>>();
+ for (Map.Entry<String, Map<String,PropValueUnion>> other_element_value_element : other_element_value.entrySet()) {
+
+ String other_element_value_element_key = other_element_value_element.getKey();
+ Map<String,PropValueUnion> other_element_value_element_value = other_element_value_element.getValue();
+
+ String __this__attributes_copy_value_copy_key = other_element_value_element_key;
+
+ Map<String,PropValueUnion> __this__attributes_copy_value_copy_value = new HashMap<String,PropValueUnion>();
+ for (Map.Entry<String, PropValueUnion> other_element_value_element_value_element : other_element_value_element_value.entrySet()) {
+
+ String other_element_value_element_value_element_key = other_element_value_element_value_element.getKey();
+ PropValueUnion other_element_value_element_value_element_value = other_element_value_element_value_element.getValue();
+
+ String __this__attributes_copy_value_copy_value_copy_key = other_element_value_element_value_element_key;
+
+ PropValueUnion __this__attributes_copy_value_copy_value_copy_value = new PropValueUnion(other_element_value_element_value_element_value);
+
+ __this__attributes_copy_value_copy_value.put(__this__attributes_copy_value_copy_value_copy_key, __this__attributes_copy_value_copy_value_copy_value);
+ }
+
+ __this__attributes_copy_value.put(__this__attributes_copy_value_copy_key, __this__attributes_copy_value_copy_value);
+ }
+
+ __this__attributes.put(__this__attributes_copy_key, __this__attributes_copy_value);
+ }
+ this.attributes = __this__attributes;
+ }
+ if (other.isSetUnionField1()) {
+ this.unionField1 = new PropValueUnion(other.unionField1);
+ }
+ if (other.isSetUnionField2()) {
+ this.unionField2 = new PropValueUnion(other.unionField2);
+ }
+ if (other.isSetUnionField3()) {
+ this.unionField3 = new PropValueUnion(other.unionField3);
+ }
}
public Complex deepCopy() {
@@ -235,6 +323,10 @@ public class Complex implements org.apac
this.lString = null;
this.lintString = null;
this.mStringString = null;
+ this.attributes = null;
+ this.unionField1 = null;
+ this.unionField2 = null;
+ this.unionField3 = null;
}
public int getAint() {
@@ -430,6 +522,109 @@ public class Complex implements org.apac
}
}
+ public int getAttributesSize() {
+ return (this.attributes == null) ? 0 : this.attributes.size();
+ }
+
+ public void putToAttributes(String key, Map<String,Map<String,PropValueUnion>> val) {
+ if (this.attributes == null) {
+ this.attributes = new HashMap<String,Map<String,Map<String,PropValueUnion>>>();
+ }
+ this.attributes.put(key, val);
+ }
+
+ public Map<String,Map<String,Map<String,PropValueUnion>>> getAttributes() {
+ return this.attributes;
+ }
+
+ public void setAttributes(Map<String,Map<String,Map<String,PropValueUnion>>> attributes) {
+ this.attributes = attributes;
+ }
+
+ public void unsetAttributes() {
+ this.attributes = null;
+ }
+
+ /** Returns true if field attributes is set (has been assigned a value) and false otherwise */
+ public boolean isSetAttributes() {
+ return this.attributes != null;
+ }
+
+ public void setAttributesIsSet(boolean value) {
+ if (!value) {
+ this.attributes = null;
+ }
+ }
+
+ public PropValueUnion getUnionField1() {
+ return this.unionField1;
+ }
+
+ public void setUnionField1(PropValueUnion unionField1) {
+ this.unionField1 = unionField1;
+ }
+
+ public void unsetUnionField1() {
+ this.unionField1 = null;
+ }
+
+ /** Returns true if field unionField1 is set (has been assigned a value) and false otherwise */
+ public boolean isSetUnionField1() {
+ return this.unionField1 != null;
+ }
+
+ public void setUnionField1IsSet(boolean value) {
+ if (!value) {
+ this.unionField1 = null;
+ }
+ }
+
+ public PropValueUnion getUnionField2() {
+ return this.unionField2;
+ }
+
+ public void setUnionField2(PropValueUnion unionField2) {
+ this.unionField2 = unionField2;
+ }
+
+ public void unsetUnionField2() {
+ this.unionField2 = null;
+ }
+
+ /** Returns true if field unionField2 is set (has been assigned a value) and false otherwise */
+ public boolean isSetUnionField2() {
+ return this.unionField2 != null;
+ }
+
+ public void setUnionField2IsSet(boolean value) {
+ if (!value) {
+ this.unionField2 = null;
+ }
+ }
+
+ public PropValueUnion getUnionField3() {
+ return this.unionField3;
+ }
+
+ public void setUnionField3(PropValueUnion unionField3) {
+ this.unionField3 = unionField3;
+ }
+
+ public void unsetUnionField3() {
+ this.unionField3 = null;
+ }
+
+ /** Returns true if field unionField3 is set (has been assigned a value) and false otherwise */
+ public boolean isSetUnionField3() {
+ return this.unionField3 != null;
+ }
+
+ public void setUnionField3IsSet(boolean value) {
+ if (!value) {
+ this.unionField3 = null;
+ }
+ }
+
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case AINT:
@@ -480,6 +675,38 @@ public class Complex implements org.apac
}
break;
+ case ATTRIBUTES:
+ if (value == null) {
+ unsetAttributes();
+ } else {
+ setAttributes((Map<String,Map<String,Map<String,PropValueUnion>>>)value);
+ }
+ break;
+
+ case UNION_FIELD1:
+ if (value == null) {
+ unsetUnionField1();
+ } else {
+ setUnionField1((PropValueUnion)value);
+ }
+ break;
+
+ case UNION_FIELD2:
+ if (value == null) {
+ unsetUnionField2();
+ } else {
+ setUnionField2((PropValueUnion)value);
+ }
+ break;
+
+ case UNION_FIELD3:
+ if (value == null) {
+ unsetUnionField3();
+ } else {
+ setUnionField3((PropValueUnion)value);
+ }
+ break;
+
}
}
@@ -503,6 +730,18 @@ public class Complex implements org.apac
case M_STRING_STRING:
return getMStringString();
+ case ATTRIBUTES:
+ return getAttributes();
+
+ case UNION_FIELD1:
+ return getUnionField1();
+
+ case UNION_FIELD2:
+ return getUnionField2();
+
+ case UNION_FIELD3:
+ return getUnionField3();
+
}
throw new IllegalStateException();
}
@@ -526,6 +765,14 @@ public class Complex implements org.apac
return isSetLintString();
case M_STRING_STRING:
return isSetMStringString();
+ case ATTRIBUTES:
+ return isSetAttributes();
+ case UNION_FIELD1:
+ return isSetUnionField1();
+ case UNION_FIELD2:
+ return isSetUnionField2();
+ case UNION_FIELD3:
+ return isSetUnionField3();
}
throw new IllegalStateException();
}
@@ -597,6 +844,42 @@ public class Complex implements org.apac
return false;
}
+ boolean this_present_attributes = true && this.isSetAttributes();
+ boolean that_present_attributes = true && that.isSetAttributes();
+ if (this_present_attributes || that_present_attributes) {
+ if (!(this_present_attributes && that_present_attributes))
+ return false;
+ if (!this.attributes.equals(that.attributes))
+ return false;
+ }
+
+ boolean this_present_unionField1 = true && this.isSetUnionField1();
+ boolean that_present_unionField1 = true && that.isSetUnionField1();
+ if (this_present_unionField1 || that_present_unionField1) {
+ if (!(this_present_unionField1 && that_present_unionField1))
+ return false;
+ if (!this.unionField1.equals(that.unionField1))
+ return false;
+ }
+
+ boolean this_present_unionField2 = true && this.isSetUnionField2();
+ boolean that_present_unionField2 = true && that.isSetUnionField2();
+ if (this_present_unionField2 || that_present_unionField2) {
+ if (!(this_present_unionField2 && that_present_unionField2))
+ return false;
+ if (!this.unionField2.equals(that.unionField2))
+ return false;
+ }
+
+ boolean this_present_unionField3 = true && this.isSetUnionField3();
+ boolean that_present_unionField3 = true && that.isSetUnionField3();
+ if (this_present_unionField3 || that_present_unionField3) {
+ if (!(this_present_unionField3 && that_present_unionField3))
+ return false;
+ if (!this.unionField3.equals(that.unionField3))
+ return false;
+ }
+
return true;
}
@@ -634,6 +917,26 @@ public class Complex implements org.apac
if (present_mStringString)
builder.append(mStringString);
+ boolean present_attributes = true && (isSetAttributes());
+ builder.append(present_attributes);
+ if (present_attributes)
+ builder.append(attributes);
+
+ boolean present_unionField1 = true && (isSetUnionField1());
+ builder.append(present_unionField1);
+ if (present_unionField1)
+ builder.append(unionField1);
+
+ boolean present_unionField2 = true && (isSetUnionField2());
+ builder.append(present_unionField2);
+ if (present_unionField2)
+ builder.append(unionField2);
+
+ boolean present_unionField3 = true && (isSetUnionField3());
+ builder.append(present_unionField3);
+ if (present_unionField3)
+ builder.append(unionField3);
+
return builder.toHashCode();
}
@@ -705,6 +1008,46 @@ public class Complex implements org.apac
return lastComparison;
}
}
+ lastComparison = Boolean.valueOf(isSetAttributes()).compareTo(typedOther.isSetAttributes());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetAttributes()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.attributes, typedOther.attributes);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetUnionField1()).compareTo(typedOther.isSetUnionField1());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetUnionField1()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.unionField1, typedOther.unionField1);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetUnionField2()).compareTo(typedOther.isSetUnionField2());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetUnionField2()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.unionField2, typedOther.unionField2);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetUnionField3()).compareTo(typedOther.isSetUnionField3());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetUnionField3()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.unionField3, typedOther.unionField3);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -768,6 +1111,38 @@ public class Complex implements org.apac
sb.append(this.mStringString);
}
first = false;
+ if (!first) sb.append(", ");
+ sb.append("attributes:");
+ if (this.attributes == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.attributes);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("unionField1:");
+ if (this.unionField1 == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.unionField1);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("unionField2:");
+ if (this.unionField2 == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.unionField2);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("unionField3:");
+ if (this.unionField3 == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.unionField3);
+ }
+ first = false;
sb.append(")");
return sb.toString();
}
@@ -832,13 +1207,13 @@ public class Complex implements org.apac
case 3: // LINT
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
- org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
- struct.lint = new ArrayList<Integer>(_list0.size);
- for (int _i1 = 0; _i1 < _list0.size; ++_i1)
+ org.apache.thrift.protocol.TList _list18 = iprot.readListBegin();
+ struct.lint = new ArrayList<Integer>(_list18.size);
+ for (int _i19 = 0; _i19 < _list18.size; ++_i19)
{
- int _elem2; // required
- _elem2 = iprot.readI32();
- struct.lint.add(_elem2);
+ int _elem20; // required
+ _elem20 = iprot.readI32();
+ struct.lint.add(_elem20);
}
iprot.readListEnd();
}
@@ -850,13 +1225,13 @@ public class Complex implements org.apac
case 4: // L_STRING
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
- org.apache.thrift.protocol.TList _list3 = iprot.readListBegin();
- struct.lString = new ArrayList<String>(_list3.size);
- for (int _i4 = 0; _i4 < _list3.size; ++_i4)
+ org.apache.thrift.protocol.TList _list21 = iprot.readListBegin();
+ struct.lString = new ArrayList<String>(_list21.size);
+ for (int _i22 = 0; _i22 < _list21.size; ++_i22)
{
- String _elem5; // required
- _elem5 = iprot.readString();
- struct.lString.add(_elem5);
+ String _elem23; // required
+ _elem23 = iprot.readString();
+ struct.lString.add(_elem23);
}
iprot.readListEnd();
}
@@ -868,14 +1243,14 @@ public class Complex implements org.apac
case 5: // LINT_STRING
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
- org.apache.thrift.protocol.TList _list6 = iprot.readListBegin();
- struct.lintString = new ArrayList<IntString>(_list6.size);
- for (int _i7 = 0; _i7 < _list6.size; ++_i7)
+ org.apache.thrift.protocol.TList _list24 = iprot.readListBegin();
+ struct.lintString = new ArrayList<IntString>(_list24.size);
+ for (int _i25 = 0; _i25 < _list24.size; ++_i25)
{
- IntString _elem8; // required
- _elem8 = new IntString();
- _elem8.read(iprot);
- struct.lintString.add(_elem8);
+ IntString _elem26; // required
+ _elem26 = new IntString();
+ _elem26.read(iprot);
+ struct.lintString.add(_elem26);
}
iprot.readListEnd();
}
@@ -887,15 +1262,15 @@ public class Complex implements org.apac
case 6: // M_STRING_STRING
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
- org.apache.thrift.protocol.TMap _map9 = iprot.readMapBegin();
- struct.mStringString = new HashMap<String,String>(2*_map9.size);
- for (int _i10 = 0; _i10 < _map9.size; ++_i10)
+ org.apache.thrift.protocol.TMap _map27 = iprot.readMapBegin();
+ struct.mStringString = new HashMap<String,String>(2*_map27.size);
+ for (int _i28 = 0; _i28 < _map27.size; ++_i28)
{
- String _key11; // required
- String _val12; // required
- _key11 = iprot.readString();
- _val12 = iprot.readString();
- struct.mStringString.put(_key11, _val12);
+ String _key29; // required
+ String _val30; // optional
+ _key29 = iprot.readString();
+ _val30 = iprot.readString();
+ struct.mStringString.put(_key29, _val30);
}
iprot.readMapEnd();
}
@@ -904,6 +1279,78 @@ public class Complex implements org.apac
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
+ case 7: // ATTRIBUTES
+ if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
+ {
+ org.apache.thrift.protocol.TMap _map31 = iprot.readMapBegin();
+ struct.attributes = new HashMap<String,Map<String,Map<String,PropValueUnion>>>(2*_map31.size);
+ for (int _i32 = 0; _i32 < _map31.size; ++_i32)
+ {
+ String _key33; // required
+ Map<String,Map<String,PropValueUnion>> _val34; // optional
+ _key33 = iprot.readString();
+ {
+ org.apache.thrift.protocol.TMap _map35 = iprot.readMapBegin();
+ _val34 = new HashMap<String,Map<String,PropValueUnion>>(2*_map35.size);
+ for (int _i36 = 0; _i36 < _map35.size; ++_i36)
+ {
+ String _key37; // required
+ Map<String,PropValueUnion> _val38; // optional
+ _key37 = iprot.readString();
+ {
+ org.apache.thrift.protocol.TMap _map39 = iprot.readMapBegin();
+ _val38 = new HashMap<String,PropValueUnion>(2*_map39.size);
+ for (int _i40 = 0; _i40 < _map39.size; ++_i40)
+ {
+ String _key41; // required
+ PropValueUnion _val42; // optional
+ _key41 = iprot.readString();
+ _val42 = new PropValueUnion();
+ _val42.read(iprot);
+ _val38.put(_key41, _val42);
+ }
+ iprot.readMapEnd();
+ }
+ _val34.put(_key37, _val38);
+ }
+ iprot.readMapEnd();
+ }
+ struct.attributes.put(_key33, _val34);
+ }
+ iprot.readMapEnd();
+ }
+ struct.setAttributesIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 8: // UNION_FIELD1
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.unionField1 = new PropValueUnion();
+ struct.unionField1.read(iprot);
+ struct.setUnionField1IsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 9: // UNION_FIELD2
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.unionField2 = new PropValueUnion();
+ struct.unionField2.read(iprot);
+ struct.setUnionField2IsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 10: // UNION_FIELD3
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.unionField3 = new PropValueUnion();
+ struct.unionField3.read(iprot);
+ struct.setUnionField3IsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@@ -929,9 +1376,9 @@ public class Complex implements org.apac
oprot.writeFieldBegin(LINT_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.lint.size()));
- for (int _iter13 : struct.lint)
+ for (int _iter43 : struct.lint)
{
- oprot.writeI32(_iter13);
+ oprot.writeI32(_iter43);
}
oprot.writeListEnd();
}
@@ -941,9 +1388,9 @@ public class Complex implements org.apac
oprot.writeFieldBegin(L_STRING_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.lString.size()));
- for (String _iter14 : struct.lString)
+ for (String _iter44 : struct.lString)
{
- oprot.writeString(_iter14);
+ oprot.writeString(_iter44);
}
oprot.writeListEnd();
}
@@ -953,9 +1400,9 @@ public class Complex implements org.apac
oprot.writeFieldBegin(LINT_STRING_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.lintString.size()));
- for (IntString _iter15 : struct.lintString)
+ for (IntString _iter45 : struct.lintString)
{
- _iter15.write(oprot);
+ _iter45.write(oprot);
}
oprot.writeListEnd();
}
@@ -965,15 +1412,59 @@ public class Complex implements org.apac
oprot.writeFieldBegin(M_STRING_STRING_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.mStringString.size()));
- for (Map.Entry<String, String> _iter16 : struct.mStringString.entrySet())
+ for (Map.Entry<String, String> _iter46 : struct.mStringString.entrySet())
{
- oprot.writeString(_iter16.getKey());
- oprot.writeString(_iter16.getValue());
+ oprot.writeString(_iter46.getKey());
+ oprot.writeString(_iter46.getValue());
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
+ if (struct.attributes != null) {
+ oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
+ {
+ oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.MAP, struct.attributes.size()));
+ for (Map.Entry<String, Map<String,Map<String,PropValueUnion>>> _iter47 : struct.attributes.entrySet())
+ {
+ oprot.writeString(_iter47.getKey());
+ {
+ oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.MAP, _iter47.getValue().size()));
+ for (Map.Entry<String, Map<String,PropValueUnion>> _iter48 : _iter47.getValue().entrySet())
+ {
+ oprot.writeString(_iter48.getKey());
+ {
+ oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, _iter48.getValue().size()));
+ for (Map.Entry<String, PropValueUnion> _iter49 : _iter48.getValue().entrySet())
+ {
+ oprot.writeString(_iter49.getKey());
+ _iter49.getValue().write(oprot);
+ }
+ oprot.writeMapEnd();
+ }
+ }
+ oprot.writeMapEnd();
+ }
+ }
+ oprot.writeMapEnd();
+ }
+ oprot.writeFieldEnd();
+ }
+ if (struct.unionField1 != null) {
+ oprot.writeFieldBegin(UNION_FIELD1_FIELD_DESC);
+ struct.unionField1.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ if (struct.unionField2 != null) {
+ oprot.writeFieldBegin(UNION_FIELD2_FIELD_DESC);
+ struct.unionField2.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ if (struct.unionField3 != null) {
+ oprot.writeFieldBegin(UNION_FIELD3_FIELD_DESC);
+ struct.unionField3.write(oprot);
+ oprot.writeFieldEnd();
+ }
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@@ -1010,7 +1501,19 @@ public class Complex implements org.apac
if (struct.isSetMStringString()) {
optionals.set(5);
}
- oprot.writeBitSet(optionals, 6);
+ if (struct.isSetAttributes()) {
+ optionals.set(6);
+ }
+ if (struct.isSetUnionField1()) {
+ optionals.set(7);
+ }
+ if (struct.isSetUnionField2()) {
+ optionals.set(8);
+ }
+ if (struct.isSetUnionField3()) {
+ optionals.set(9);
+ }
+ oprot.writeBitSet(optionals, 10);
if (struct.isSetAint()) {
oprot.writeI32(struct.aint);
}
@@ -1020,46 +1523,79 @@ public class Complex implements org.apac
if (struct.isSetLint()) {
{
oprot.writeI32(struct.lint.size());
- for (int _iter17 : struct.lint)
+ for (int _iter50 : struct.lint)
{
- oprot.writeI32(_iter17);
+ oprot.writeI32(_iter50);
}
}
}
if (struct.isSetLString()) {
{
oprot.writeI32(struct.lString.size());
- for (String _iter18 : struct.lString)
+ for (String _iter51 : struct.lString)
{
- oprot.writeString(_iter18);
+ oprot.writeString(_iter51);
}
}
}
if (struct.isSetLintString()) {
{
oprot.writeI32(struct.lintString.size());
- for (IntString _iter19 : struct.lintString)
+ for (IntString _iter52 : struct.lintString)
{
- _iter19.write(oprot);
+ _iter52.write(oprot);
}
}
}
if (struct.isSetMStringString()) {
{
oprot.writeI32(struct.mStringString.size());
- for (Map.Entry<String, String> _iter20 : struct.mStringString.entrySet())
+ for (Map.Entry<String, String> _iter53 : struct.mStringString.entrySet())
{
- oprot.writeString(_iter20.getKey());
- oprot.writeString(_iter20.getValue());
+ oprot.writeString(_iter53.getKey());
+ oprot.writeString(_iter53.getValue());
+ }
+ }
+ }
+ if (struct.isSetAttributes()) {
+ {
+ oprot.writeI32(struct.attributes.size());
+ for (Map.Entry<String, Map<String,Map<String,PropValueUnion>>> _iter54 : struct.attributes.entrySet())
+ {
+ oprot.writeString(_iter54.getKey());
+ {
+ oprot.writeI32(_iter54.getValue().size());
+ for (Map.Entry<String, Map<String,PropValueUnion>> _iter55 : _iter54.getValue().entrySet())
+ {
+ oprot.writeString(_iter55.getKey());
+ {
+ oprot.writeI32(_iter55.getValue().size());
+ for (Map.Entry<String, PropValueUnion> _iter56 : _iter55.getValue().entrySet())
+ {
+ oprot.writeString(_iter56.getKey());
+ _iter56.getValue().write(oprot);
+ }
+ }
+ }
+ }
}
}
}
+ if (struct.isSetUnionField1()) {
+ struct.unionField1.write(oprot);
+ }
+ if (struct.isSetUnionField2()) {
+ struct.unionField2.write(oprot);
+ }
+ if (struct.isSetUnionField3()) {
+ struct.unionField3.write(oprot);
+ }
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, Complex struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
- BitSet incoming = iprot.readBitSet(6);
+ BitSet incoming = iprot.readBitSet(10);
if (incoming.get(0)) {
struct.aint = iprot.readI32();
struct.setAintIsSet(true);
@@ -1070,59 +1606,112 @@ public class Complex implements org.apac
}
if (incoming.get(2)) {
{
- org.apache.thrift.protocol.TList _list21 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32());
- struct.lint = new ArrayList<Integer>(_list21.size);
- for (int _i22 = 0; _i22 < _list21.size; ++_i22)
+ org.apache.thrift.protocol.TList _list57 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32());
+ struct.lint = new ArrayList<Integer>(_list57.size);
+ for (int _i58 = 0; _i58 < _list57.size; ++_i58)
{
- int _elem23; // required
- _elem23 = iprot.readI32();
- struct.lint.add(_elem23);
+ int _elem59; // required
+ _elem59 = iprot.readI32();
+ struct.lint.add(_elem59);
}
}
struct.setLintIsSet(true);
}
if (incoming.get(3)) {
{
- org.apache.thrift.protocol.TList _list24 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
- struct.lString = new ArrayList<String>(_list24.size);
- for (int _i25 = 0; _i25 < _list24.size; ++_i25)
+ org.apache.thrift.protocol.TList _list60 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+ struct.lString = new ArrayList<String>(_list60.size);
+ for (int _i61 = 0; _i61 < _list60.size; ++_i61)
{
- String _elem26; // required
- _elem26 = iprot.readString();
- struct.lString.add(_elem26);
+ String _elem62; // required
+ _elem62 = iprot.readString();
+ struct.lString.add(_elem62);
}
}
struct.setLStringIsSet(true);
}
if (incoming.get(4)) {
{
- org.apache.thrift.protocol.TList _list27 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
- struct.lintString = new ArrayList<IntString>(_list27.size);
- for (int _i28 = 0; _i28 < _list27.size; ++_i28)
+ org.apache.thrift.protocol.TList _list63 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+ struct.lintString = new ArrayList<IntString>(_list63.size);
+ for (int _i64 = 0; _i64 < _list63.size; ++_i64)
{
- IntString _elem29; // required
- _elem29 = new IntString();
- _elem29.read(iprot);
- struct.lintString.add(_elem29);
+ IntString _elem65; // required
+ _elem65 = new IntString();
+ _elem65.read(iprot);
+ struct.lintString.add(_elem65);
}
}
struct.setLintStringIsSet(true);
}
if (incoming.get(5)) {
{
- org.apache.thrift.protocol.TMap _map30 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
- struct.mStringString = new HashMap<String,String>(2*_map30.size);
- for (int _i31 = 0; _i31 < _map30.size; ++_i31)
+ org.apache.thrift.protocol.TMap _map66 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+ struct.mStringString = new HashMap<String,String>(2*_map66.size);
+ for (int _i67 = 0; _i67 < _map66.size; ++_i67)
{
- String _key32; // required
- String _val33; // required
- _key32 = iprot.readString();
- _val33 = iprot.readString();
- struct.mStringString.put(_key32, _val33);
+ String _key68; // required
+ String _val69; // optional
+ _key68 = iprot.readString();
+ _val69 = iprot.readString();
+ struct.mStringString.put(_key68, _val69);
}
}
struct.setMStringStringIsSet(true);
}
+ if (incoming.get(6)) {
+ {
+ org.apache.thrift.protocol.TMap _map70 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.MAP, iprot.readI32());
+ struct.attributes = new HashMap<String,Map<String,Map<String,PropValueUnion>>>(2*_map70.size);
+ for (int _i71 = 0; _i71 < _map70.size; ++_i71)
+ {
+ String _key72; // required
+ Map<String,Map<String,PropValueUnion>> _val73; // optional
+ _key72 = iprot.readString();
+ {
+ org.apache.thrift.protocol.TMap _map74 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.MAP, iprot.readI32());
+ _val73 = new HashMap<String,Map<String,PropValueUnion>>(2*_map74.size);
+ for (int _i75 = 0; _i75 < _map74.size; ++_i75)
+ {
+ String _key76; // required
+ Map<String,PropValueUnion> _val77; // optional
+ _key76 = iprot.readString();
+ {
+ org.apache.thrift.protocol.TMap _map78 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+ _val77 = new HashMap<String,PropValueUnion>(2*_map78.size);
+ for (int _i79 = 0; _i79 < _map78.size; ++_i79)
+ {
+ String _key80; // required
+ PropValueUnion _val81; // optional
+ _key80 = iprot.readString();
+ _val81 = new PropValueUnion();
+ _val81.read(iprot);
+ _val77.put(_key80, _val81);
+ }
+ }
+ _val73.put(_key76, _val77);
+ }
+ }
+ struct.attributes.put(_key72, _val73);
+ }
+ }
+ struct.setAttributesIsSet(true);
+ }
+ if (incoming.get(7)) {
+ struct.unionField1 = new PropValueUnion();
+ struct.unionField1.read(iprot);
+ struct.setUnionField1IsSet(true);
+ }
+ if (incoming.get(8)) {
+ struct.unionField2 = new PropValueUnion();
+ struct.unionField2.read(iprot);
+ struct.setUnionField2IsSet(true);
+ }
+ if (incoming.get(9)) {
+ struct.unionField3 = new PropValueUnion();
+ struct.unionField3.read(iprot);
+ struct.setUnionField3IsSet(true);
+ }
}
}
Modified: hive/branches/cbo/serde/src/gen/thrift/gen-py/complex/ttypes.py
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/gen/thrift/gen-py/complex/ttypes.py?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/gen/thrift/gen-py/complex/ttypes.py (original)
+++ hive/branches/cbo/serde/src/gen/thrift/gen-py/complex/ttypes.py Mon Sep 15 22:46:44 2014
@@ -17,6 +17,156 @@ except:
+class PropValueUnion:
+ """
+ Attributes:
+ - intValue
+ - longValue
+ - stringValue
+ - doubleValue
+ - flag
+ - lString
+ - unionMStringString
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.I32, 'intValue', None, None, ), # 1
+ (2, TType.I64, 'longValue', None, None, ), # 2
+ (3, TType.STRING, 'stringValue', None, None, ), # 3
+ (4, TType.DOUBLE, 'doubleValue', None, None, ), # 4
+ (5, TType.BOOL, 'flag', None, None, ), # 5
+ (6, TType.LIST, 'lString', (TType.STRING,None), None, ), # 6
+ (7, TType.MAP, 'unionMStringString', (TType.STRING,None,TType.STRING,None), None, ), # 7
+ )
+
+ def __init__(self, intValue=None, longValue=None, stringValue=None, doubleValue=None, flag=None, lString=None, unionMStringString=None,):
+ self.intValue = intValue
+ self.longValue = longValue
+ self.stringValue = stringValue
+ self.doubleValue = doubleValue
+ self.flag = flag
+ self.lString = lString
+ self.unionMStringString = unionMStringString
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.I32:
+ self.intValue = iprot.readI32();
+ else:
+ iprot.skip(ftype)
+ elif fid == 2:
+ if ftype == TType.I64:
+ self.longValue = iprot.readI64();
+ else:
+ iprot.skip(ftype)
+ elif fid == 3:
+ if ftype == TType.STRING:
+ self.stringValue = iprot.readString();
+ else:
+ iprot.skip(ftype)
+ elif fid == 4:
+ if ftype == TType.DOUBLE:
+ self.doubleValue = iprot.readDouble();
+ else:
+ iprot.skip(ftype)
+ elif fid == 5:
+ if ftype == TType.BOOL:
+ self.flag = iprot.readBool();
+ else:
+ iprot.skip(ftype)
+ elif fid == 6:
+ if ftype == TType.LIST:
+ self.lString = []
+ (_etype3, _size0) = iprot.readListBegin()
+ for _i4 in xrange(_size0):
+ _elem5 = iprot.readString();
+ self.lString.append(_elem5)
+ iprot.readListEnd()
+ else:
+ iprot.skip(ftype)
+ elif fid == 7:
+ if ftype == TType.MAP:
+ self.unionMStringString = {}
+ (_ktype7, _vtype8, _size6 ) = iprot.readMapBegin()
+ for _i10 in xrange(_size6):
+ _key11 = iprot.readString();
+ _val12 = iprot.readString();
+ self.unionMStringString[_key11] = _val12
+ iprot.readMapEnd()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('PropValueUnion')
+ if self.intValue is not None:
+ oprot.writeFieldBegin('intValue', TType.I32, 1)
+ oprot.writeI32(self.intValue)
+ oprot.writeFieldEnd()
+ if self.longValue is not None:
+ oprot.writeFieldBegin('longValue', TType.I64, 2)
+ oprot.writeI64(self.longValue)
+ oprot.writeFieldEnd()
+ if self.stringValue is not None:
+ oprot.writeFieldBegin('stringValue', TType.STRING, 3)
+ oprot.writeString(self.stringValue)
+ oprot.writeFieldEnd()
+ if self.doubleValue is not None:
+ oprot.writeFieldBegin('doubleValue', TType.DOUBLE, 4)
+ oprot.writeDouble(self.doubleValue)
+ oprot.writeFieldEnd()
+ if self.flag is not None:
+ oprot.writeFieldBegin('flag', TType.BOOL, 5)
+ oprot.writeBool(self.flag)
+ oprot.writeFieldEnd()
+ if self.lString is not None:
+ oprot.writeFieldBegin('lString', TType.LIST, 6)
+ oprot.writeListBegin(TType.STRING, len(self.lString))
+ for iter13 in self.lString:
+ oprot.writeString(iter13)
+ oprot.writeListEnd()
+ oprot.writeFieldEnd()
+ if self.unionMStringString is not None:
+ oprot.writeFieldBegin('unionMStringString', TType.MAP, 7)
+ oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.unionMStringString))
+ for kiter14,viter15 in self.unionMStringString.items():
+ oprot.writeString(kiter14)
+ oprot.writeString(viter15)
+ oprot.writeMapEnd()
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ return
+
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
+
class IntString:
"""
Attributes:
@@ -110,6 +260,10 @@ class Complex:
- lString
- lintString
- mStringString
+ - attributes
+ - unionField1
+ - unionField2
+ - unionField3
"""
thrift_spec = (
@@ -120,15 +274,23 @@ class Complex:
(4, TType.LIST, 'lString', (TType.STRING,None), None, ), # 4
(5, TType.LIST, 'lintString', (TType.STRUCT,(IntString, IntString.thrift_spec)), None, ), # 5
(6, TType.MAP, 'mStringString', (TType.STRING,None,TType.STRING,None), None, ), # 6
+ (7, TType.MAP, 'attributes', (TType.STRING,None,TType.MAP,(TType.STRING,None,TType.MAP,(TType.STRING,None,TType.STRUCT,(PropValueUnion, PropValueUnion.thrift_spec)))), None, ), # 7
+ (8, TType.STRUCT, 'unionField1', (PropValueUnion, PropValueUnion.thrift_spec), None, ), # 8
+ (9, TType.STRUCT, 'unionField2', (PropValueUnion, PropValueUnion.thrift_spec), None, ), # 9
+ (10, TType.STRUCT, 'unionField3', (PropValueUnion, PropValueUnion.thrift_spec), None, ), # 10
)
- def __init__(self, aint=None, aString=None, lint=None, lString=None, lintString=None, mStringString=None,):
+ def __init__(self, aint=None, aString=None, lint=None, lString=None, lintString=None, mStringString=None, attributes=None, unionField1=None, unionField2=None, unionField3=None,):
self.aint = aint
self.aString = aString
self.lint = lint
self.lString = lString
self.lintString = lintString
self.mStringString = mStringString
+ self.attributes = attributes
+ self.unionField1 = unionField1
+ self.unionField2 = unionField2
+ self.unionField3 = unionField3
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
@@ -152,45 +314,87 @@ class Complex:
elif fid == 3:
if ftype == TType.LIST:
self.lint = []
- (_etype3, _size0) = iprot.readListBegin()
- for _i4 in xrange(_size0):
- _elem5 = iprot.readI32();
- self.lint.append(_elem5)
+ (_etype19, _size16) = iprot.readListBegin()
+ for _i20 in xrange(_size16):
+ _elem21 = iprot.readI32();
+ self.lint.append(_elem21)
iprot.readListEnd()
else:
iprot.skip(ftype)
elif fid == 4:
if ftype == TType.LIST:
self.lString = []
- (_etype9, _size6) = iprot.readListBegin()
- for _i10 in xrange(_size6):
- _elem11 = iprot.readString();
- self.lString.append(_elem11)
+ (_etype25, _size22) = iprot.readListBegin()
+ for _i26 in xrange(_size22):
+ _elem27 = iprot.readString();
+ self.lString.append(_elem27)
iprot.readListEnd()
else:
iprot.skip(ftype)
elif fid == 5:
if ftype == TType.LIST:
self.lintString = []
- (_etype15, _size12) = iprot.readListBegin()
- for _i16 in xrange(_size12):
- _elem17 = IntString()
- _elem17.read(iprot)
- self.lintString.append(_elem17)
+ (_etype31, _size28) = iprot.readListBegin()
+ for _i32 in xrange(_size28):
+ _elem33 = IntString()
+ _elem33.read(iprot)
+ self.lintString.append(_elem33)
iprot.readListEnd()
else:
iprot.skip(ftype)
elif fid == 6:
if ftype == TType.MAP:
self.mStringString = {}
- (_ktype19, _vtype20, _size18 ) = iprot.readMapBegin()
- for _i22 in xrange(_size18):
- _key23 = iprot.readString();
- _val24 = iprot.readString();
- self.mStringString[_key23] = _val24
+ (_ktype35, _vtype36, _size34 ) = iprot.readMapBegin()
+ for _i38 in xrange(_size34):
+ _key39 = iprot.readString();
+ _val40 = iprot.readString();
+ self.mStringString[_key39] = _val40
+ iprot.readMapEnd()
+ else:
+ iprot.skip(ftype)
+ elif fid == 7:
+ if ftype == TType.MAP:
+ self.attributes = {}
+ (_ktype42, _vtype43, _size41 ) = iprot.readMapBegin()
+ for _i45 in xrange(_size41):
+ _key46 = iprot.readString();
+ _val47 = {}
+ (_ktype49, _vtype50, _size48 ) = iprot.readMapBegin()
+ for _i52 in xrange(_size48):
+ _key53 = iprot.readString();
+ _val54 = {}
+ (_ktype56, _vtype57, _size55 ) = iprot.readMapBegin()
+ for _i59 in xrange(_size55):
+ _key60 = iprot.readString();
+ _val61 = PropValueUnion()
+ _val61.read(iprot)
+ _val54[_key60] = _val61
+ iprot.readMapEnd()
+ _val47[_key53] = _val54
+ iprot.readMapEnd()
+ self.attributes[_key46] = _val47
iprot.readMapEnd()
else:
iprot.skip(ftype)
+ elif fid == 8:
+ if ftype == TType.STRUCT:
+ self.unionField1 = PropValueUnion()
+ self.unionField1.read(iprot)
+ else:
+ iprot.skip(ftype)
+ elif fid == 9:
+ if ftype == TType.STRUCT:
+ self.unionField2 = PropValueUnion()
+ self.unionField2.read(iprot)
+ else:
+ iprot.skip(ftype)
+ elif fid == 10:
+ if ftype == TType.STRUCT:
+ self.unionField3 = PropValueUnion()
+ self.unionField3.read(iprot)
+ else:
+ iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
@@ -212,32 +416,60 @@ class Complex:
if self.lint is not None:
oprot.writeFieldBegin('lint', TType.LIST, 3)
oprot.writeListBegin(TType.I32, len(self.lint))
- for iter25 in self.lint:
- oprot.writeI32(iter25)
+ for iter62 in self.lint:
+ oprot.writeI32(iter62)
oprot.writeListEnd()
oprot.writeFieldEnd()
if self.lString is not None:
oprot.writeFieldBegin('lString', TType.LIST, 4)
oprot.writeListBegin(TType.STRING, len(self.lString))
- for iter26 in self.lString:
- oprot.writeString(iter26)
+ for iter63 in self.lString:
+ oprot.writeString(iter63)
oprot.writeListEnd()
oprot.writeFieldEnd()
if self.lintString is not None:
oprot.writeFieldBegin('lintString', TType.LIST, 5)
oprot.writeListBegin(TType.STRUCT, len(self.lintString))
- for iter27 in self.lintString:
- iter27.write(oprot)
+ for iter64 in self.lintString:
+ iter64.write(oprot)
oprot.writeListEnd()
oprot.writeFieldEnd()
if self.mStringString is not None:
oprot.writeFieldBegin('mStringString', TType.MAP, 6)
oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.mStringString))
- for kiter28,viter29 in self.mStringString.items():
- oprot.writeString(kiter28)
- oprot.writeString(viter29)
+ for kiter65,viter66 in self.mStringString.items():
+ oprot.writeString(kiter65)
+ oprot.writeString(viter66)
+ oprot.writeMapEnd()
+ oprot.writeFieldEnd()
+ if self.attributes is not None:
+ oprot.writeFieldBegin('attributes', TType.MAP, 7)
+ oprot.writeMapBegin(TType.STRING, TType.MAP, len(self.attributes))
+ for kiter67,viter68 in self.attributes.items():
+ oprot.writeString(kiter67)
+ oprot.writeMapBegin(TType.STRING, TType.MAP, len(viter68))
+ for kiter69,viter70 in viter68.items():
+ oprot.writeString(kiter69)
+ oprot.writeMapBegin(TType.STRING, TType.STRUCT, len(viter70))
+ for kiter71,viter72 in viter70.items():
+ oprot.writeString(kiter71)
+ viter72.write(oprot)
+ oprot.writeMapEnd()
+ oprot.writeMapEnd()
oprot.writeMapEnd()
oprot.writeFieldEnd()
+ if self.unionField1 is not None:
+ oprot.writeFieldBegin('unionField1', TType.STRUCT, 8)
+ self.unionField1.write(oprot)
+ oprot.writeFieldEnd()
+ if self.unionField2 is not None:
+ oprot.writeFieldBegin('unionField2', TType.STRUCT, 9)
+ self.unionField2.write(oprot)
+ oprot.writeFieldEnd()
+ if self.unionField3 is not None:
+ oprot.writeFieldBegin('unionField3', TType.STRUCT, 10)
+ self.unionField3.write(oprot)
+ oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
Modified: hive/branches/cbo/serde/src/gen/thrift/gen-rb/complex_types.rb
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/gen/thrift/gen-rb/complex_types.rb?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/gen/thrift/gen-rb/complex_types.rb (original)
+++ hive/branches/cbo/serde/src/gen/thrift/gen-rb/complex_types.rb Mon Sep 15 22:46:44 2014
@@ -6,6 +6,65 @@
require 'thrift'
+class PropValueUnion < ::Thrift::Union
+ include ::Thrift::Struct_Union
+ class << self
+ def intValue(val)
+ PropValueUnion.new(:intValue, val)
+ end
+
+ def longValue(val)
+ PropValueUnion.new(:longValue, val)
+ end
+
+ def stringValue(val)
+ PropValueUnion.new(:stringValue, val)
+ end
+
+ def doubleValue(val)
+ PropValueUnion.new(:doubleValue, val)
+ end
+
+ def flag(val)
+ PropValueUnion.new(:flag, val)
+ end
+
+ def lString(val)
+ PropValueUnion.new(:lString, val)
+ end
+
+ def unionMStringString(val)
+ PropValueUnion.new(:unionMStringString, val)
+ end
+ end
+
+ INTVALUE = 1
+ LONGVALUE = 2
+ STRINGVALUE = 3
+ DOUBLEVALUE = 4
+ FLAG = 5
+ LSTRING = 6
+ UNIONMSTRINGSTRING = 7
+
+ FIELDS = {
+ INTVALUE => {:type => ::Thrift::Types::I32, :name => 'intValue', :optional => true},
+ LONGVALUE => {:type => ::Thrift::Types::I64, :name => 'longValue', :optional => true},
+ STRINGVALUE => {:type => ::Thrift::Types::STRING, :name => 'stringValue', :optional => true},
+ DOUBLEVALUE => {:type => ::Thrift::Types::DOUBLE, :name => 'doubleValue', :optional => true},
+ FLAG => {:type => ::Thrift::Types::BOOL, :name => 'flag', :optional => true},
+ LSTRING => {:type => ::Thrift::Types::LIST, :name => 'lString', :element => {:type => ::Thrift::Types::STRING}},
+ UNIONMSTRINGSTRING => {:type => ::Thrift::Types::MAP, :name => 'unionMStringString', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
+ }
+
+ def struct_fields; FIELDS; end
+
+ def validate
+ raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
+ end
+
+ ::Thrift::Union.generate_accessors self
+end
+
class IntString
include ::Thrift::Struct, ::Thrift::Struct_Union
MYINT = 1
@@ -34,6 +93,10 @@ class Complex
LSTRING = 4
LINTSTRING = 5
MSTRINGSTRING = 6
+ ATTRIBUTES = 7
+ UNIONFIELD1 = 8
+ UNIONFIELD2 = 9
+ UNIONFIELD3 = 10
FIELDS = {
AINT => {:type => ::Thrift::Types::I32, :name => 'aint'},
@@ -41,7 +104,11 @@ class Complex
LINT => {:type => ::Thrift::Types::LIST, :name => 'lint', :element => {:type => ::Thrift::Types::I32}},
LSTRING => {:type => ::Thrift::Types::LIST, :name => 'lString', :element => {:type => ::Thrift::Types::STRING}},
LINTSTRING => {:type => ::Thrift::Types::LIST, :name => 'lintString', :element => {:type => ::Thrift::Types::STRUCT, :class => ::IntString}},
- MSTRINGSTRING => {:type => ::Thrift::Types::MAP, :name => 'mStringString', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
+ MSTRINGSTRING => {:type => ::Thrift::Types::MAP, :name => 'mStringString', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
+ ATTRIBUTES => {:type => ::Thrift::Types::MAP, :name => 'attributes', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRUCT, :class => ::PropValueUnion}}}},
+ UNIONFIELD1 => {:type => ::Thrift::Types::STRUCT, :name => 'unionField1', :class => ::PropValueUnion},
+ UNIONFIELD2 => {:type => ::Thrift::Types::STRUCT, :name => 'unionField2', :class => ::PropValueUnion},
+ UNIONFIELD3 => {:type => ::Thrift::Types::STRUCT, :name => 'unionField3', :class => ::PropValueUnion}
}
def struct_fields; FIELDS; end
Modified: hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java (original)
+++ hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java Mon Sep 15 22:46:44 2014
@@ -26,10 +26,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import org.apache.thrift.TUnion;
/**
* ObjectInspectorFactory is the primary way to create new ObjectInspector
@@ -111,7 +113,8 @@ public final class ObjectInspectorFactor
if (t instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) t;
// List?
- if (List.class.isAssignableFrom((Class<?>) pt.getRawType())) {
+ if (List.class.isAssignableFrom((Class<?>) pt.getRawType()) ||
+ Set.class.isAssignableFrom((Class<?>) pt.getRawType())) {
return getStandardListObjectInspector(getReflectionObjectInspector(pt
.getActualTypeArguments()[0], options));
}
@@ -172,7 +175,7 @@ public final class ObjectInspectorFactor
oi = new ReflectionStructObjectInspector();
break;
case THRIFT:
- oi = new ThriftStructObjectInspector();
+ oi = TUnion.class.isAssignableFrom(c) ? new ThriftUnionObjectInspector() : new ThriftStructObjectInspector();
break;
case PROTOCOL_BUFFERS:
oi = new ProtocolBuffersStructObjectInspector();
@@ -181,20 +184,13 @@ public final class ObjectInspectorFactor
throw new RuntimeException(ObjectInspectorFactory.class.getName()
+ ": internal error.");
}
+
// put it into the cache BEFORE it is initialized to make sure we can catch
// recursive types.
objectInspectorCache.put(t, oi);
- Field[] fields = ObjectInspectorUtils.getDeclaredNonStaticFields(c);
- ArrayList<ObjectInspector> structFieldObjectInspectors = new ArrayList<ObjectInspector>(
- fields.length);
- for (int i = 0; i < fields.length; i++) {
- if (!oi.shouldIgnoreField(fields[i].getName())) {
- structFieldObjectInspectors.add(getReflectionObjectInspector(fields[i]
- .getGenericType(), options));
- }
- }
- oi.init(c, structFieldObjectInspectors);
+ oi.init(c, options);
return oi;
+
}
static ConcurrentHashMap<ObjectInspector, StandardListObjectInspector> cachedStandardListObjectInspector =
Modified: hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ReflectionStructObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ReflectionStructObjectInspector.java?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ReflectionStructObjectInspector.java (original)
+++ hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ReflectionStructObjectInspector.java Mon Sep 15 22:46:44 2014
@@ -44,6 +44,7 @@ public class ReflectionStructObjectInspe
public static class MyField implements StructField {
protected int fieldID;
protected Field field;
+
protected ObjectInspector fieldObjectInspector;
protected MyField() {
@@ -116,12 +117,13 @@ public class ReflectionStructObjectInspe
* The reason that this method is not recursive by itself is because we want
* to allow recursive types.
*/
- void init(Class<?> objectClass,
- List<ObjectInspector> structFieldObjectInspectors) {
- assert (!List.class.isAssignableFrom(objectClass));
- assert (!Map.class.isAssignableFrom(objectClass));
+ protected void init(Class<?> objectClass,
+ ObjectInspectorFactory.ObjectInspectorOptions options) {
+ verifyObjectClassType(objectClass);
this.objectClass = objectClass;
+ final List<? extends ObjectInspector> structFieldObjectInspectors = extractFieldObjectInspectors(objectClass, options);
+
Field[] reflectionFields = ObjectInspectorUtils
.getDeclaredNonStaticFields(objectClass);
fields = new ArrayList<MyField>(structFieldObjectInspectors.size());
@@ -205,4 +207,23 @@ public class ReflectionStructObjectInspe
return struct;
}
+ protected List<? extends ObjectInspector> extractFieldObjectInspectors(Class<?> clazz,
+ ObjectInspectorFactory.ObjectInspectorOptions options) {
+ Field[] fields = ObjectInspectorUtils.getDeclaredNonStaticFields(clazz);
+ ArrayList<ObjectInspector> structFieldObjectInspectors = new ArrayList<ObjectInspector>(
+ fields.length);
+ for (int i = 0; i < fields.length; i++) {
+ if (!shouldIgnoreField(fields[i].getName())) {
+ structFieldObjectInspectors.add(ObjectInspectorFactory.getReflectionObjectInspector(fields[i]
+ .getGenericType(), options));
+ }
+ }
+ return structFieldObjectInspectors;
+ }
+
+
+ protected void verifyObjectClassType(Class<?> objectClass) {
+ assert (!List.class.isAssignableFrom(objectClass));
+ assert (!Map.class.isAssignableFrom(objectClass));
+ }
}
Modified: hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/StandardListObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/StandardListObjectInspector.java?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/StandardListObjectInspector.java (original)
+++ hive/branches/cbo/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/StandardListObjectInspector.java Mon Sep 15 22:46:44 2014
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.serde2.ob
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
/**
* DefaultListObjectInspector works on list data that is stored as a Java List
@@ -53,52 +54,64 @@ public class StandardListObjectInspector
}
// with data
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public Object getListElement(Object data, int index) {
if (data == null) {
return null;
}
- // We support both List<Object> and Object[]
+ // We support List<Object>, Set<Object> and Object[]
// so we have to do differently.
- boolean isArray = ! (data instanceof List);
- if (isArray) {
- Object[] list = (Object[]) data;
- if (index < 0 || index >= list.length) {
- return null;
- }
- return list[index];
- } else {
- List<?> list = (List<?>) data;
- if (index < 0 || index >= list.size()) {
- return null;
+ if (! (data instanceof List)) {
+ if (! (data instanceof Set)) {
+ Object[] list = (Object[]) data;
+ if (index < 0 || index >= list.length) {
+ return null;
+ }
+ return list[index];
+ } else {
+ data = new ArrayList((Set<?>) data);
}
- return list.get(index);
}
+ List<?> list = (List<?>) data;
+ if (index < 0 || index >= list.size()) {
+ return null;
+ }
+ return list.get(index);
}
public int getListLength(Object data) {
if (data == null) {
return -1;
}
- // We support both List<Object> and Object[]
+ // We support List<Object>, Set<Object> and Object[]
// so we have to do differently.
- boolean isArray = ! (data instanceof List);
- if (isArray) {
- Object[] list = (Object[]) data;
- return list.length;
+ if (! (data instanceof List)) {
+ if (! (data instanceof Set)) {
+ Object[] list = (Object[]) data;
+ return list.length;
+ } else {
+ Set<?> set = (Set<?>) data;
+ return set.size();
+ }
} else {
List<?> list = (List<?>) data;
return list.size();
}
}
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public List<?> getList(Object data) {
if (data == null) {
return null;
}
- // We support both List<Object> and Object[]
+ // We support List<Object>, Set<Object> and Object[]
// so we have to do differently.
if (! (data instanceof List)) {
- data = java.util.Arrays.asList((Object[]) data);
+ if (! (data instanceof Set)) {
+ data = java.util.Arrays.asList((Object[]) data);
+ } else {
+ data = new ArrayList((Set<?>) data);
+ }
}
List<?> list = (List<?>) data;
return list;
Modified: hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorUtils.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorUtils.java?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorUtils.java (original)
+++ hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorUtils.java Mon Sep 15 22:46:44 2014
@@ -46,7 +46,7 @@ public class TestObjectInspectorUtils ex
StructObjectInspector soi = (StructObjectInspector) ObjectInspectorUtils
.getStandardObjectInspector(oi1);
List<? extends StructField> fields = soi.getAllStructFieldRefs();
- assertEquals(6, fields.size());
+ assertEquals(10, fields.size());
assertEquals(fields.get(0), soi.getStructFieldRef("aint"));
// null
@@ -75,7 +75,7 @@ public class TestObjectInspectorUtils ex
assertEquals(c4, soi.getStructFieldData(c, fields.get(4)));
assertNull(soi.getStructFieldData(c, fields.get(5)));
ArrayList<Object> cfields = new ArrayList<Object>();
- for (int i = 0; i < 6; i++) {
+ for (int i = 0; i < 10; i++) {
cfields.add(soi.getStructFieldData(c, fields.get(i)));
}
assertEquals(cfields, soi.getStructFieldsDataAsList(c));
Modified: hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestThriftObjectInspectors.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestThriftObjectInspectors.java?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestThriftObjectInspectors.java (original)
+++ hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestThriftObjectInspectors.java Mon Sep 15 22:46:44 2014
@@ -19,7 +19,9 @@ package org.apache.hadoop.hive.serde2.ob
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import junit.framework.TestCase;
@@ -27,6 +29,7 @@ import org.apache.hadoop.hive.serde2.obj
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.thrift.test.Complex;
import org.apache.hadoop.hive.serde2.thrift.test.IntString;
+import org.apache.hadoop.hive.serde2.thrift.test.SetIntString;
/**
* TestThriftObjectInspectors.
@@ -49,7 +52,7 @@ public class TestThriftObjectInspectors
assertEquals(Category.STRUCT, oi1.getCategory());
StructObjectInspector soi = (StructObjectInspector) oi1;
List<? extends StructField> fields = soi.getAllStructFieldRefs();
- assertEquals(6, fields.size());
+ assertEquals(10, fields.size());
assertEquals(fields.get(0), soi.getStructFieldRef("aint"));
// null
@@ -68,6 +71,10 @@ public class TestThriftObjectInspectors
List<IntString> c4 = new ArrayList<IntString>();
c.setLintString(c4);
c.setMStringString(null);
+ c.setAttributes(null);
+ c.setUnionField1(null);
+ c.setUnionField2(null);
+ c.setUnionField3(null);
assertEquals(1, soi.getStructFieldData(c, fields.get(0)));
assertEquals("test", soi.getStructFieldData(c, fields.get(1)));
@@ -75,8 +82,13 @@ public class TestThriftObjectInspectors
assertEquals(c3, soi.getStructFieldData(c, fields.get(3)));
assertEquals(c4, soi.getStructFieldData(c, fields.get(4)));
assertNull(soi.getStructFieldData(c, fields.get(5)));
+ assertNull(soi.getStructFieldData(c, fields.get(6)));
+ assertNull(soi.getStructFieldData(c, fields.get(7)));
+ assertNull(soi.getStructFieldData(c, fields.get(8)));
+ assertNull(soi.getStructFieldData(c, fields.get(9)));
+
ArrayList<Object> cfields = new ArrayList<Object>();
- for (int i = 0; i < 6; i++) {
+ for (int i = 0; i < 10; i++) {
cfields.add(soi.getStructFieldData(c, fields.get(i)));
}
assertEquals(cfields, soi.getStructFieldsDataAsList(c));
@@ -109,4 +121,70 @@ public class TestThriftObjectInspectors
throw e;
}
}
+
+ @SuppressWarnings("unchecked")
+ public void testThriftSetObjectInspector() throws Throwable {
+
+ try {
+ ObjectInspector oi1 = ObjectInspectorFactory
+ .getReflectionObjectInspector(SetIntString.class,
+ ObjectInspectorFactory.ObjectInspectorOptions.THRIFT);
+ ObjectInspector oi2 = ObjectInspectorFactory
+ .getReflectionObjectInspector(SetIntString.class,
+ ObjectInspectorFactory.ObjectInspectorOptions.THRIFT);
+ assertEquals(oi1, oi2);
+
+ // metadata
+ assertEquals(Category.STRUCT, oi1.getCategory());
+ StructObjectInspector soi = (StructObjectInspector) oi1;
+ List<? extends StructField> fields = soi.getAllStructFieldRefs();
+ assertEquals(2, fields.size());
+ assertEquals(fields.get(0), soi.getStructFieldRef("sIntString"));
+ assertEquals(fields.get(1), soi.getStructFieldRef("aString"));
+
+ // null
+ for (int i = 0; i < fields.size(); i++) {
+ assertNull(soi.getStructFieldData(null, fields.get(i)));
+ }
+
+ // real object
+ IntString s1 = new IntString();
+ s1.setMyint(1);
+ s1.setMyString("test");
+ s1.setUnderscore_int(2);
+
+ Set<IntString> set1 = new HashSet<IntString>();
+ set1.add(s1);
+
+ SetIntString s = new SetIntString();
+ s.setSIntString(set1);
+ s.setAString("setString");
+
+ assertEquals(set1, soi.getStructFieldData(s, fields.get(0)));
+ assertEquals("setString", soi.getStructFieldData(s, fields.get(1)));
+
+ // sub fields
+ assertEquals(
+ ObjectInspectorFactory
+ .getStandardListObjectInspector(ObjectInspectorFactory
+ .getReflectionObjectInspector(IntString.class,
+ ObjectInspectorFactory.ObjectInspectorOptions.THRIFT)),
+ fields.get(0).getFieldObjectInspector());
+ assertEquals(PrimitiveObjectInspectorFactory.javaStringObjectInspector,
+ fields.get(1).getFieldObjectInspector());
+
+ // compare set fields
+ ListObjectInspector loi = (ListObjectInspector) fields.get(0).getFieldObjectInspector();
+ assertEquals(1, loi.getListLength(set1));
+ List<IntString> list = (List<IntString>) loi.getList(set1);
+ assertEquals(1, list.size());
+ s1 = (IntString) loi.getListElement(list, 0);
+ assertEquals(1, s1.getMyint());
+ assertEquals("test", s1.getMyString());
+ assertEquals(2, s1.getUnderscore_int());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
}
Modified: hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/thrift_test/CreateSequenceFile.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/thrift_test/CreateSequenceFile.java?rev=1625176&r1=1625175&r2=1625176&view=diff
==============================================================================
--- hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/thrift_test/CreateSequenceFile.java (original)
+++ hive/branches/cbo/serde/src/test/org/apache/hadoop/hive/serde2/thrift_test/CreateSequenceFile.java Mon Sep 15 22:46:44 2014
@@ -19,6 +19,7 @@
package org.apache.hadoop.hive.serde2.thrift_test;
import java.util.ArrayList;
+import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
@@ -28,6 +29,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.serde2.ByteStream;
import org.apache.hadoop.hive.serde2.thrift.test.Complex;
import org.apache.hadoop.hive.serde2.thrift.test.IntString;
+import org.apache.hadoop.hive.serde2.thrift.test.PropValueUnion;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.Writable;
@@ -125,16 +127,23 @@ public final class CreateSequenceFile {
islist.add(new IntString(i * i, "" + i * i * i, i));
HashMap<String, String> hash = new HashMap<String, String>();
hash.put("key_" + i, "value_" + i);
+ Map<String, Map<String, Map<String,PropValueUnion>>> unionMap = new HashMap<String, Map<String, Map<String,PropValueUnion>>>();
+ Map<String, Map<String, PropValueUnion>> erMap = new HashMap<String, Map<String, PropValueUnion>>();
+ Map<String, PropValueUnion> attrMap = new HashMap<String, PropValueUnion>();
+
+ erMap.put("erVal" + i, attrMap);
+ attrMap.put("value_" + i, PropValueUnion.doubleValue(1.0));
+ unionMap.put("key_" + i, erMap);
Complex complex = new Complex(rand.nextInt(), "record_"
- + (new Integer(i)).toString(), alist, slist, islist, hash);
+ + (new Integer(i)).toString(), alist, slist, islist, hash, unionMap, PropValueUnion.stringValue("test" + i), PropValueUnion.unionMStringString(hash), PropValueUnion.lString(slist));
Writable value = serializer.serialize(complex);
writer.append(key, value);
}
// Add an all-null record
- Complex complex = new Complex(0, null, null, null, null, null);
+ Complex complex = new Complex(0, null, null, null, null, null, null, null, null, null);
Writable value = serializer.serialize(complex);
writer.append(key, value);