diff --git ql/src/test/queries/clientpositive/convert_enum_to_string.q ql/src/test/queries/clientpositive/convert_enum_to_string.q new file mode 100644 index 0000000..3dc4a6a --- /dev/null +++ ql/src/test/queries/clientpositive/convert_enum_to_string.q @@ -0,0 +1,10 @@ +-- Ensure Enum fields are converted to strings (instead of struct) + +create table convert_enum_to_string + partitioned by (b string) + row format serde "org.apache.hadoop.hive.serde2.thrift.ThriftDeserializer" + with serdeproperties ( + "serialization.class"="org.apache.hadoop.hive.serde2.thrift.test.MegaStruct", + "serialization.format"="org.apache.thrift.protocol.TBinaryProtocol"); + +describe convert_enum_to_string; diff --git ql/src/test/results/clientpositive/convert_enum_to_string.q.out ql/src/test/results/clientpositive/convert_enum_to_string.q.out new file mode 100644 index 0000000..6cf1931 --- /dev/null +++ ql/src/test/results/clientpositive/convert_enum_to_string.q.out @@ -0,0 +1,44 @@ +PREHOOK: query: -- Ensure Enum fields are converted to strings (instead of struct) + +create table convert_enum_to_string + partitioned by (b string) + row format serde "org.apache.hadoop.hive.serde2.thrift.ThriftDeserializer" + with serdeproperties ( + "serialization.class"="org.apache.hadoop.hive.serde2.thrift.test.MegaStruct", + "serialization.format"="org.apache.thrift.protocol.TBinaryProtocol") +PREHOOK: type: CREATETABLE +POSTHOOK: query: -- Ensure Enum fields are converted to strings (instead of struct) + +create table convert_enum_to_string + partitioned by (b string) + row format serde "org.apache.hadoop.hive.serde2.thrift.ThriftDeserializer" + with serdeproperties ( + "serialization.class"="org.apache.hadoop.hive.serde2.thrift.test.MegaStruct", + "serialization.format"="org.apache.thrift.protocol.TBinaryProtocol") +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@convert_enum_to_string +PREHOOK: query: describe convert_enum_to_string +PREHOOK: type: DESCTABLE +POSTHOOK: query: describe convert_enum_to_string +POSTHOOK: type: DESCTABLE +my_bool boolean from deserializer +my_byte tinyint from deserializer +my_16bit_int smallint from deserializer +my_32bit_int int from deserializer +my_64bit_int bigint from deserializer +my_double double from deserializer +my_string string from deserializer +my_binary struct from deserializer +my_string_string_map map from deserializer +my_string_enum_map map from deserializer +my_enum_string_map map from deserializer +my_enum_struct_map map> from deserializer +my_enum_stringlist_map map> from deserializer +my_enum_structlist_map map>> from deserializer +my_stringlist array from deserializer +my_structlist array> from deserializer +my_enumlist array from deserializer +my_stringset struct<> from deserializer +my_enumset struct<> from deserializer +my_structset struct<> from deserializer +b string diff --git serde/if/test/megastruct.thrift serde/if/test/megastruct.thrift new file mode 100644 index 0000000..91eb77e --- /dev/null +++ serde/if/test/megastruct.thrift @@ -0,0 +1,58 @@ +/** + * 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. + */ + +/** + * MetaStruct intends to stress test Hive's thrift support by having all + * sorts of crazy but valid field types. Please add new fields if you find + * a case that's not handled correctly. + */ + +namespace java org.apache.hadoop.hive.serde2.thrift.test + +enum MyEnum { + LLAMA = 1, + ALPACA = 2 +} + +struct MiniStruct { + 1: optional string my_string, + 2: optional MyEnum my_enum +} + +struct MegaStruct { + 1: optional bool my_bool, + 2: optional byte my_byte, + 3: optional i16 my_16bit_int, + 4: optional i32 my_32bit_int, + 5: optional i64 my_64bit_int, + 6: optional double my_double, + 7: optional string my_string, + 8: optional binary my_binary, + 9: optional map my_string_string_map, + 10: optional map my_string_enum_map, + 11: optional map my_enum_string_map, + 12: optional map my_enum_struct_map, + 13: optional map> my_enum_stringlist_map, + 14: optional map> my_enum_structlist_map, + 15: optional list my_stringlist, + 16: optional list my_structlist, + 17: optional list my_enumlist, + 18: optional set my_stringset, + 19: optional set my_enumset, + 20: optional set my_structset +} diff --git serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java new file mode 100644 index 0000000..7f470e0 --- /dev/null +++ serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java @@ -0,0 +1,2540 @@ +/** + * Autogenerated by Thrift Compiler (0.7.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + */ +package org.apache.hadoop.hive.serde2.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 MegaStruct implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("MegaStruct"); + + private static final org.apache.thrift.protocol.TField MY_BOOL_FIELD_DESC = new org.apache.thrift.protocol.TField("my_bool", org.apache.thrift.protocol.TType.BOOL, (short)1); + private static final org.apache.thrift.protocol.TField MY_BYTE_FIELD_DESC = new org.apache.thrift.protocol.TField("my_byte", org.apache.thrift.protocol.TType.BYTE, (short)2); + private static final org.apache.thrift.protocol.TField MY_16BIT_INT_FIELD_DESC = new org.apache.thrift.protocol.TField("my_16bit_int", org.apache.thrift.protocol.TType.I16, (short)3); + private static final org.apache.thrift.protocol.TField MY_32BIT_INT_FIELD_DESC = new org.apache.thrift.protocol.TField("my_32bit_int", org.apache.thrift.protocol.TType.I32, (short)4); + private static final org.apache.thrift.protocol.TField MY_64BIT_INT_FIELD_DESC = new org.apache.thrift.protocol.TField("my_64bit_int", org.apache.thrift.protocol.TType.I64, (short)5); + private static final org.apache.thrift.protocol.TField MY_DOUBLE_FIELD_DESC = new org.apache.thrift.protocol.TField("my_double", org.apache.thrift.protocol.TType.DOUBLE, (short)6); + private static final org.apache.thrift.protocol.TField MY_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("my_string", org.apache.thrift.protocol.TType.STRING, (short)7); + private static final org.apache.thrift.protocol.TField MY_BINARY_FIELD_DESC = new org.apache.thrift.protocol.TField("my_binary", org.apache.thrift.protocol.TType.STRING, (short)8); + private static final org.apache.thrift.protocol.TField MY_STRING_STRING_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("my_string_string_map", org.apache.thrift.protocol.TType.MAP, (short)9); + private static final org.apache.thrift.protocol.TField MY_STRING_ENUM_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("my_string_enum_map", org.apache.thrift.protocol.TType.MAP, (short)10); + private static final org.apache.thrift.protocol.TField MY_ENUM_STRING_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("my_enum_string_map", org.apache.thrift.protocol.TType.MAP, (short)11); + private static final org.apache.thrift.protocol.TField MY_ENUM_STRUCT_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("my_enum_struct_map", org.apache.thrift.protocol.TType.MAP, (short)12); + private static final org.apache.thrift.protocol.TField MY_ENUM_STRINGLIST_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("my_enum_stringlist_map", org.apache.thrift.protocol.TType.MAP, (short)13); + private static final org.apache.thrift.protocol.TField MY_ENUM_STRUCTLIST_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("my_enum_structlist_map", org.apache.thrift.protocol.TType.MAP, (short)14); + private static final org.apache.thrift.protocol.TField MY_STRINGLIST_FIELD_DESC = new org.apache.thrift.protocol.TField("my_stringlist", org.apache.thrift.protocol.TType.LIST, (short)15); + private static final org.apache.thrift.protocol.TField MY_STRUCTLIST_FIELD_DESC = new org.apache.thrift.protocol.TField("my_structlist", org.apache.thrift.protocol.TType.LIST, (short)16); + private static final org.apache.thrift.protocol.TField MY_ENUMLIST_FIELD_DESC = new org.apache.thrift.protocol.TField("my_enumlist", org.apache.thrift.protocol.TType.LIST, (short)17); + private static final org.apache.thrift.protocol.TField MY_STRINGSET_FIELD_DESC = new org.apache.thrift.protocol.TField("my_stringset", org.apache.thrift.protocol.TType.SET, (short)18); + private static final org.apache.thrift.protocol.TField MY_ENUMSET_FIELD_DESC = new org.apache.thrift.protocol.TField("my_enumset", org.apache.thrift.protocol.TType.SET, (short)19); + private static final org.apache.thrift.protocol.TField MY_STRUCTSET_FIELD_DESC = new org.apache.thrift.protocol.TField("my_structset", org.apache.thrift.protocol.TType.SET, (short)20); + + private boolean my_bool; // required + private byte my_byte; // required + private short my_16bit_int; // required + private int my_32bit_int; // required + private long my_64bit_int; // required + private double my_double; // required + private String my_string; // required + private ByteBuffer my_binary; // required + private Map my_string_string_map; // required + private Map my_string_enum_map; // required + private Map my_enum_string_map; // required + private Map my_enum_struct_map; // required + private Map> my_enum_stringlist_map; // required + private Map> my_enum_structlist_map; // required + private List my_stringlist; // required + private List my_structlist; // required + private List my_enumlist; // required + private Set my_stringset; // required + private Set my_enumset; // required + private Set my_structset; // 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 { + MY_BOOL((short)1, "my_bool"), + MY_BYTE((short)2, "my_byte"), + MY_16BIT_INT((short)3, "my_16bit_int"), + MY_32BIT_INT((short)4, "my_32bit_int"), + MY_64BIT_INT((short)5, "my_64bit_int"), + MY_DOUBLE((short)6, "my_double"), + MY_STRING((short)7, "my_string"), + MY_BINARY((short)8, "my_binary"), + MY_STRING_STRING_MAP((short)9, "my_string_string_map"), + MY_STRING_ENUM_MAP((short)10, "my_string_enum_map"), + MY_ENUM_STRING_MAP((short)11, "my_enum_string_map"), + MY_ENUM_STRUCT_MAP((short)12, "my_enum_struct_map"), + MY_ENUM_STRINGLIST_MAP((short)13, "my_enum_stringlist_map"), + MY_ENUM_STRUCTLIST_MAP((short)14, "my_enum_structlist_map"), + MY_STRINGLIST((short)15, "my_stringlist"), + MY_STRUCTLIST((short)16, "my_structlist"), + MY_ENUMLIST((short)17, "my_enumlist"), + MY_STRINGSET((short)18, "my_stringset"), + MY_ENUMSET((short)19, "my_enumset"), + MY_STRUCTSET((short)20, "my_structset"); + + private static final Map byName = new HashMap(); + + 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: // MY_BOOL + return MY_BOOL; + case 2: // MY_BYTE + return MY_BYTE; + case 3: // MY_16BIT_INT + return MY_16BIT_INT; + case 4: // MY_32BIT_INT + return MY_32BIT_INT; + case 5: // MY_64BIT_INT + return MY_64BIT_INT; + case 6: // MY_DOUBLE + return MY_DOUBLE; + case 7: // MY_STRING + return MY_STRING; + case 8: // MY_BINARY + return MY_BINARY; + case 9: // MY_STRING_STRING_MAP + return MY_STRING_STRING_MAP; + case 10: // MY_STRING_ENUM_MAP + return MY_STRING_ENUM_MAP; + case 11: // MY_ENUM_STRING_MAP + return MY_ENUM_STRING_MAP; + case 12: // MY_ENUM_STRUCT_MAP + return MY_ENUM_STRUCT_MAP; + case 13: // MY_ENUM_STRINGLIST_MAP + return MY_ENUM_STRINGLIST_MAP; + case 14: // MY_ENUM_STRUCTLIST_MAP + return MY_ENUM_STRUCTLIST_MAP; + case 15: // MY_STRINGLIST + return MY_STRINGLIST; + case 16: // MY_STRUCTLIST + return MY_STRUCTLIST; + case 17: // MY_ENUMLIST + return MY_ENUMLIST; + case 18: // MY_STRINGSET + return MY_STRINGSET; + case 19: // MY_ENUMSET + return MY_ENUMSET; + case 20: // MY_STRUCTSET + return MY_STRUCTSET; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __MY_BOOL_ISSET_ID = 0; + private static final int __MY_BYTE_ISSET_ID = 1; + private static final int __MY_16BIT_INT_ISSET_ID = 2; + private static final int __MY_32BIT_INT_ISSET_ID = 3; + private static final int __MY_64BIT_INT_ISSET_ID = 4; + private static final int __MY_DOUBLE_ISSET_ID = 5; + private BitSet __isset_bit_vector = new BitSet(6); + + 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.MY_BOOL, new org.apache.thrift.meta_data.FieldMetaData("my_bool", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.MY_BYTE, new org.apache.thrift.meta_data.FieldMetaData("my_byte", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BYTE))); + tmpMap.put(_Fields.MY_16BIT_INT, new org.apache.thrift.meta_data.FieldMetaData("my_16bit_int", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); + tmpMap.put(_Fields.MY_32BIT_INT, new org.apache.thrift.meta_data.FieldMetaData("my_32bit_int", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.MY_64BIT_INT, new org.apache.thrift.meta_data.FieldMetaData("my_64bit_int", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.MY_DOUBLE, new org.apache.thrift.meta_data.FieldMetaData("my_double", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE))); + tmpMap.put(_Fields.MY_STRING, new org.apache.thrift.meta_data.FieldMetaData("my_string", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.MY_BINARY, new org.apache.thrift.meta_data.FieldMetaData("my_binary", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); + tmpMap.put(_Fields.MY_STRING_STRING_MAP, new org.apache.thrift.meta_data.FieldMetaData("my_string_string_map", org.apache.thrift.TFieldRequirementType.OPTIONAL, + 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.MY_STRING_ENUM_MAP, new org.apache.thrift.meta_data.FieldMetaData("my_string_enum_map", org.apache.thrift.TFieldRequirementType.OPTIONAL, + 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.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, MyEnum.class)))); + tmpMap.put(_Fields.MY_ENUM_STRING_MAP, new org.apache.thrift.meta_data.FieldMetaData("my_enum_string_map", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, MyEnum.class), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.MY_ENUM_STRUCT_MAP, new org.apache.thrift.meta_data.FieldMetaData("my_enum_struct_map", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, MyEnum.class), + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, MiniStruct.class)))); + tmpMap.put(_Fields.MY_ENUM_STRINGLIST_MAP, new org.apache.thrift.meta_data.FieldMetaData("my_enum_stringlist_map", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, MyEnum.class), + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))))); + tmpMap.put(_Fields.MY_ENUM_STRUCTLIST_MAP, new org.apache.thrift.meta_data.FieldMetaData("my_enum_structlist_map", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, MyEnum.class), + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, MiniStruct.class))))); + tmpMap.put(_Fields.MY_STRINGLIST, new org.apache.thrift.meta_data.FieldMetaData("my_stringlist", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.MY_STRUCTLIST, new org.apache.thrift.meta_data.FieldMetaData("my_structlist", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, MiniStruct.class)))); + tmpMap.put(_Fields.MY_ENUMLIST, new org.apache.thrift.meta_data.FieldMetaData("my_enumlist", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, MyEnum.class)))); + tmpMap.put(_Fields.MY_STRINGSET, new org.apache.thrift.meta_data.FieldMetaData("my_stringset", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.MY_ENUMSET, new org.apache.thrift.meta_data.FieldMetaData("my_enumset", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, MyEnum.class)))); + tmpMap.put(_Fields.MY_STRUCTSET, new org.apache.thrift.meta_data.FieldMetaData("my_structset", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, MiniStruct.class)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(MegaStruct.class, metaDataMap); + } + + public MegaStruct() { + } + + /** + * Performs a deep copy on other. + */ + public MegaStruct(MegaStruct other) { + __isset_bit_vector.clear(); + __isset_bit_vector.or(other.__isset_bit_vector); + this.my_bool = other.my_bool; + this.my_byte = other.my_byte; + this.my_16bit_int = other.my_16bit_int; + this.my_32bit_int = other.my_32bit_int; + this.my_64bit_int = other.my_64bit_int; + this.my_double = other.my_double; + if (other.isSetMy_string()) { + this.my_string = other.my_string; + } + if (other.isSetMy_binary()) { + this.my_binary = org.apache.thrift.TBaseHelper.copyBinary(other.my_binary); +; + } + if (other.isSetMy_string_string_map()) { + Map __this__my_string_string_map = new HashMap(); + for (Map.Entry other_element : other.my_string_string_map.entrySet()) { + + String other_element_key = other_element.getKey(); + String other_element_value = other_element.getValue(); + + String __this__my_string_string_map_copy_key = other_element_key; + + String __this__my_string_string_map_copy_value = other_element_value; + + __this__my_string_string_map.put(__this__my_string_string_map_copy_key, __this__my_string_string_map_copy_value); + } + this.my_string_string_map = __this__my_string_string_map; + } + if (other.isSetMy_string_enum_map()) { + Map __this__my_string_enum_map = new HashMap(); + for (Map.Entry other_element : other.my_string_enum_map.entrySet()) { + + String other_element_key = other_element.getKey(); + MyEnum other_element_value = other_element.getValue(); + + String __this__my_string_enum_map_copy_key = other_element_key; + + MyEnum __this__my_string_enum_map_copy_value = other_element_value; + + __this__my_string_enum_map.put(__this__my_string_enum_map_copy_key, __this__my_string_enum_map_copy_value); + } + this.my_string_enum_map = __this__my_string_enum_map; + } + if (other.isSetMy_enum_string_map()) { + Map __this__my_enum_string_map = new HashMap(); + for (Map.Entry other_element : other.my_enum_string_map.entrySet()) { + + MyEnum other_element_key = other_element.getKey(); + String other_element_value = other_element.getValue(); + + MyEnum __this__my_enum_string_map_copy_key = other_element_key; + + String __this__my_enum_string_map_copy_value = other_element_value; + + __this__my_enum_string_map.put(__this__my_enum_string_map_copy_key, __this__my_enum_string_map_copy_value); + } + this.my_enum_string_map = __this__my_enum_string_map; + } + if (other.isSetMy_enum_struct_map()) { + Map __this__my_enum_struct_map = new HashMap(); + for (Map.Entry other_element : other.my_enum_struct_map.entrySet()) { + + MyEnum other_element_key = other_element.getKey(); + MiniStruct other_element_value = other_element.getValue(); + + MyEnum __this__my_enum_struct_map_copy_key = other_element_key; + + MiniStruct __this__my_enum_struct_map_copy_value = new MiniStruct(other_element_value); + + __this__my_enum_struct_map.put(__this__my_enum_struct_map_copy_key, __this__my_enum_struct_map_copy_value); + } + this.my_enum_struct_map = __this__my_enum_struct_map; + } + if (other.isSetMy_enum_stringlist_map()) { + Map> __this__my_enum_stringlist_map = new HashMap>(); + for (Map.Entry> other_element : other.my_enum_stringlist_map.entrySet()) { + + MyEnum other_element_key = other_element.getKey(); + List other_element_value = other_element.getValue(); + + MyEnum __this__my_enum_stringlist_map_copy_key = other_element_key; + + List __this__my_enum_stringlist_map_copy_value = new ArrayList(); + for (String other_element_value_element : other_element_value) { + __this__my_enum_stringlist_map_copy_value.add(other_element_value_element); + } + + __this__my_enum_stringlist_map.put(__this__my_enum_stringlist_map_copy_key, __this__my_enum_stringlist_map_copy_value); + } + this.my_enum_stringlist_map = __this__my_enum_stringlist_map; + } + if (other.isSetMy_enum_structlist_map()) { + Map> __this__my_enum_structlist_map = new HashMap>(); + for (Map.Entry> other_element : other.my_enum_structlist_map.entrySet()) { + + MyEnum other_element_key = other_element.getKey(); + List other_element_value = other_element.getValue(); + + MyEnum __this__my_enum_structlist_map_copy_key = other_element_key; + + List __this__my_enum_structlist_map_copy_value = new ArrayList(); + for (MiniStruct other_element_value_element : other_element_value) { + __this__my_enum_structlist_map_copy_value.add(new MiniStruct(other_element_value_element)); + } + + __this__my_enum_structlist_map.put(__this__my_enum_structlist_map_copy_key, __this__my_enum_structlist_map_copy_value); + } + this.my_enum_structlist_map = __this__my_enum_structlist_map; + } + if (other.isSetMy_stringlist()) { + List __this__my_stringlist = new ArrayList(); + for (String other_element : other.my_stringlist) { + __this__my_stringlist.add(other_element); + } + this.my_stringlist = __this__my_stringlist; + } + if (other.isSetMy_structlist()) { + List __this__my_structlist = new ArrayList(); + for (MiniStruct other_element : other.my_structlist) { + __this__my_structlist.add(new MiniStruct(other_element)); + } + this.my_structlist = __this__my_structlist; + } + if (other.isSetMy_enumlist()) { + List __this__my_enumlist = new ArrayList(); + for (MyEnum other_element : other.my_enumlist) { + __this__my_enumlist.add(other_element); + } + this.my_enumlist = __this__my_enumlist; + } + if (other.isSetMy_stringset()) { + Set __this__my_stringset = new HashSet(); + for (String other_element : other.my_stringset) { + __this__my_stringset.add(other_element); + } + this.my_stringset = __this__my_stringset; + } + if (other.isSetMy_enumset()) { + Set __this__my_enumset = new HashSet(); + for (MyEnum other_element : other.my_enumset) { + __this__my_enumset.add(other_element); + } + this.my_enumset = __this__my_enumset; + } + if (other.isSetMy_structset()) { + Set __this__my_structset = new HashSet(); + for (MiniStruct other_element : other.my_structset) { + __this__my_structset.add(new MiniStruct(other_element)); + } + this.my_structset = __this__my_structset; + } + } + + public MegaStruct deepCopy() { + return new MegaStruct(this); + } + + @Override + public void clear() { + setMy_boolIsSet(false); + this.my_bool = false; + setMy_byteIsSet(false); + this.my_byte = 0; + setMy_16bit_intIsSet(false); + this.my_16bit_int = 0; + setMy_32bit_intIsSet(false); + this.my_32bit_int = 0; + setMy_64bit_intIsSet(false); + this.my_64bit_int = 0; + setMy_doubleIsSet(false); + this.my_double = 0.0; + this.my_string = null; + this.my_binary = null; + this.my_string_string_map = null; + this.my_string_enum_map = null; + this.my_enum_string_map = null; + this.my_enum_struct_map = null; + this.my_enum_stringlist_map = null; + this.my_enum_structlist_map = null; + this.my_stringlist = null; + this.my_structlist = null; + this.my_enumlist = null; + this.my_stringset = null; + this.my_enumset = null; + this.my_structset = null; + } + + public boolean isMy_bool() { + return this.my_bool; + } + + public void setMy_bool(boolean my_bool) { + this.my_bool = my_bool; + setMy_boolIsSet(true); + } + + public void unsetMy_bool() { + __isset_bit_vector.clear(__MY_BOOL_ISSET_ID); + } + + /** Returns true if field my_bool is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_bool() { + return __isset_bit_vector.get(__MY_BOOL_ISSET_ID); + } + + public void setMy_boolIsSet(boolean value) { + __isset_bit_vector.set(__MY_BOOL_ISSET_ID, value); + } + + public byte getMy_byte() { + return this.my_byte; + } + + public void setMy_byte(byte my_byte) { + this.my_byte = my_byte; + setMy_byteIsSet(true); + } + + public void unsetMy_byte() { + __isset_bit_vector.clear(__MY_BYTE_ISSET_ID); + } + + /** Returns true if field my_byte is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_byte() { + return __isset_bit_vector.get(__MY_BYTE_ISSET_ID); + } + + public void setMy_byteIsSet(boolean value) { + __isset_bit_vector.set(__MY_BYTE_ISSET_ID, value); + } + + public short getMy_16bit_int() { + return this.my_16bit_int; + } + + public void setMy_16bit_int(short my_16bit_int) { + this.my_16bit_int = my_16bit_int; + setMy_16bit_intIsSet(true); + } + + public void unsetMy_16bit_int() { + __isset_bit_vector.clear(__MY_16BIT_INT_ISSET_ID); + } + + /** Returns true if field my_16bit_int is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_16bit_int() { + return __isset_bit_vector.get(__MY_16BIT_INT_ISSET_ID); + } + + public void setMy_16bit_intIsSet(boolean value) { + __isset_bit_vector.set(__MY_16BIT_INT_ISSET_ID, value); + } + + public int getMy_32bit_int() { + return this.my_32bit_int; + } + + public void setMy_32bit_int(int my_32bit_int) { + this.my_32bit_int = my_32bit_int; + setMy_32bit_intIsSet(true); + } + + public void unsetMy_32bit_int() { + __isset_bit_vector.clear(__MY_32BIT_INT_ISSET_ID); + } + + /** Returns true if field my_32bit_int is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_32bit_int() { + return __isset_bit_vector.get(__MY_32BIT_INT_ISSET_ID); + } + + public void setMy_32bit_intIsSet(boolean value) { + __isset_bit_vector.set(__MY_32BIT_INT_ISSET_ID, value); + } + + public long getMy_64bit_int() { + return this.my_64bit_int; + } + + public void setMy_64bit_int(long my_64bit_int) { + this.my_64bit_int = my_64bit_int; + setMy_64bit_intIsSet(true); + } + + public void unsetMy_64bit_int() { + __isset_bit_vector.clear(__MY_64BIT_INT_ISSET_ID); + } + + /** Returns true if field my_64bit_int is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_64bit_int() { + return __isset_bit_vector.get(__MY_64BIT_INT_ISSET_ID); + } + + public void setMy_64bit_intIsSet(boolean value) { + __isset_bit_vector.set(__MY_64BIT_INT_ISSET_ID, value); + } + + public double getMy_double() { + return this.my_double; + } + + public void setMy_double(double my_double) { + this.my_double = my_double; + setMy_doubleIsSet(true); + } + + public void unsetMy_double() { + __isset_bit_vector.clear(__MY_DOUBLE_ISSET_ID); + } + + /** Returns true if field my_double is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_double() { + return __isset_bit_vector.get(__MY_DOUBLE_ISSET_ID); + } + + public void setMy_doubleIsSet(boolean value) { + __isset_bit_vector.set(__MY_DOUBLE_ISSET_ID, value); + } + + public String getMy_string() { + return this.my_string; + } + + public void setMy_string(String my_string) { + this.my_string = my_string; + } + + public void unsetMy_string() { + this.my_string = null; + } + + /** Returns true if field my_string is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_string() { + return this.my_string != null; + } + + public void setMy_stringIsSet(boolean value) { + if (!value) { + this.my_string = null; + } + } + + public byte[] getMy_binary() { + setMy_binary(org.apache.thrift.TBaseHelper.rightSize(my_binary)); + return my_binary == null ? null : my_binary.array(); + } + + public ByteBuffer bufferForMy_binary() { + return my_binary; + } + + public void setMy_binary(byte[] my_binary) { + setMy_binary(my_binary == null ? (ByteBuffer)null : ByteBuffer.wrap(my_binary)); + } + + public void setMy_binary(ByteBuffer my_binary) { + this.my_binary = my_binary; + } + + public void unsetMy_binary() { + this.my_binary = null; + } + + /** Returns true if field my_binary is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_binary() { + return this.my_binary != null; + } + + public void setMy_binaryIsSet(boolean value) { + if (!value) { + this.my_binary = null; + } + } + + public int getMy_string_string_mapSize() { + return (this.my_string_string_map == null) ? 0 : this.my_string_string_map.size(); + } + + public void putToMy_string_string_map(String key, String val) { + if (this.my_string_string_map == null) { + this.my_string_string_map = new HashMap(); + } + this.my_string_string_map.put(key, val); + } + + public Map getMy_string_string_map() { + return this.my_string_string_map; + } + + public void setMy_string_string_map(Map my_string_string_map) { + this.my_string_string_map = my_string_string_map; + } + + public void unsetMy_string_string_map() { + this.my_string_string_map = null; + } + + /** Returns true if field my_string_string_map is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_string_string_map() { + return this.my_string_string_map != null; + } + + public void setMy_string_string_mapIsSet(boolean value) { + if (!value) { + this.my_string_string_map = null; + } + } + + public int getMy_string_enum_mapSize() { + return (this.my_string_enum_map == null) ? 0 : this.my_string_enum_map.size(); + } + + public void putToMy_string_enum_map(String key, MyEnum val) { + if (this.my_string_enum_map == null) { + this.my_string_enum_map = new HashMap(); + } + this.my_string_enum_map.put(key, val); + } + + public Map getMy_string_enum_map() { + return this.my_string_enum_map; + } + + public void setMy_string_enum_map(Map my_string_enum_map) { + this.my_string_enum_map = my_string_enum_map; + } + + public void unsetMy_string_enum_map() { + this.my_string_enum_map = null; + } + + /** Returns true if field my_string_enum_map is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_string_enum_map() { + return this.my_string_enum_map != null; + } + + public void setMy_string_enum_mapIsSet(boolean value) { + if (!value) { + this.my_string_enum_map = null; + } + } + + public int getMy_enum_string_mapSize() { + return (this.my_enum_string_map == null) ? 0 : this.my_enum_string_map.size(); + } + + public void putToMy_enum_string_map(MyEnum key, String val) { + if (this.my_enum_string_map == null) { + this.my_enum_string_map = new HashMap(); + } + this.my_enum_string_map.put(key, val); + } + + public Map getMy_enum_string_map() { + return this.my_enum_string_map; + } + + public void setMy_enum_string_map(Map my_enum_string_map) { + this.my_enum_string_map = my_enum_string_map; + } + + public void unsetMy_enum_string_map() { + this.my_enum_string_map = null; + } + + /** Returns true if field my_enum_string_map is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_enum_string_map() { + return this.my_enum_string_map != null; + } + + public void setMy_enum_string_mapIsSet(boolean value) { + if (!value) { + this.my_enum_string_map = null; + } + } + + public int getMy_enum_struct_mapSize() { + return (this.my_enum_struct_map == null) ? 0 : this.my_enum_struct_map.size(); + } + + public void putToMy_enum_struct_map(MyEnum key, MiniStruct val) { + if (this.my_enum_struct_map == null) { + this.my_enum_struct_map = new HashMap(); + } + this.my_enum_struct_map.put(key, val); + } + + public Map getMy_enum_struct_map() { + return this.my_enum_struct_map; + } + + public void setMy_enum_struct_map(Map my_enum_struct_map) { + this.my_enum_struct_map = my_enum_struct_map; + } + + public void unsetMy_enum_struct_map() { + this.my_enum_struct_map = null; + } + + /** Returns true if field my_enum_struct_map is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_enum_struct_map() { + return this.my_enum_struct_map != null; + } + + public void setMy_enum_struct_mapIsSet(boolean value) { + if (!value) { + this.my_enum_struct_map = null; + } + } + + public int getMy_enum_stringlist_mapSize() { + return (this.my_enum_stringlist_map == null) ? 0 : this.my_enum_stringlist_map.size(); + } + + public void putToMy_enum_stringlist_map(MyEnum key, List val) { + if (this.my_enum_stringlist_map == null) { + this.my_enum_stringlist_map = new HashMap>(); + } + this.my_enum_stringlist_map.put(key, val); + } + + public Map> getMy_enum_stringlist_map() { + return this.my_enum_stringlist_map; + } + + public void setMy_enum_stringlist_map(Map> my_enum_stringlist_map) { + this.my_enum_stringlist_map = my_enum_stringlist_map; + } + + public void unsetMy_enum_stringlist_map() { + this.my_enum_stringlist_map = null; + } + + /** Returns true if field my_enum_stringlist_map is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_enum_stringlist_map() { + return this.my_enum_stringlist_map != null; + } + + public void setMy_enum_stringlist_mapIsSet(boolean value) { + if (!value) { + this.my_enum_stringlist_map = null; + } + } + + public int getMy_enum_structlist_mapSize() { + return (this.my_enum_structlist_map == null) ? 0 : this.my_enum_structlist_map.size(); + } + + public void putToMy_enum_structlist_map(MyEnum key, List val) { + if (this.my_enum_structlist_map == null) { + this.my_enum_structlist_map = new HashMap>(); + } + this.my_enum_structlist_map.put(key, val); + } + + public Map> getMy_enum_structlist_map() { + return this.my_enum_structlist_map; + } + + public void setMy_enum_structlist_map(Map> my_enum_structlist_map) { + this.my_enum_structlist_map = my_enum_structlist_map; + } + + public void unsetMy_enum_structlist_map() { + this.my_enum_structlist_map = null; + } + + /** Returns true if field my_enum_structlist_map is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_enum_structlist_map() { + return this.my_enum_structlist_map != null; + } + + public void setMy_enum_structlist_mapIsSet(boolean value) { + if (!value) { + this.my_enum_structlist_map = null; + } + } + + public int getMy_stringlistSize() { + return (this.my_stringlist == null) ? 0 : this.my_stringlist.size(); + } + + public java.util.Iterator getMy_stringlistIterator() { + return (this.my_stringlist == null) ? null : this.my_stringlist.iterator(); + } + + public void addToMy_stringlist(String elem) { + if (this.my_stringlist == null) { + this.my_stringlist = new ArrayList(); + } + this.my_stringlist.add(elem); + } + + public List getMy_stringlist() { + return this.my_stringlist; + } + + public void setMy_stringlist(List my_stringlist) { + this.my_stringlist = my_stringlist; + } + + public void unsetMy_stringlist() { + this.my_stringlist = null; + } + + /** Returns true if field my_stringlist is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_stringlist() { + return this.my_stringlist != null; + } + + public void setMy_stringlistIsSet(boolean value) { + if (!value) { + this.my_stringlist = null; + } + } + + public int getMy_structlistSize() { + return (this.my_structlist == null) ? 0 : this.my_structlist.size(); + } + + public java.util.Iterator getMy_structlistIterator() { + return (this.my_structlist == null) ? null : this.my_structlist.iterator(); + } + + public void addToMy_structlist(MiniStruct elem) { + if (this.my_structlist == null) { + this.my_structlist = new ArrayList(); + } + this.my_structlist.add(elem); + } + + public List getMy_structlist() { + return this.my_structlist; + } + + public void setMy_structlist(List my_structlist) { + this.my_structlist = my_structlist; + } + + public void unsetMy_structlist() { + this.my_structlist = null; + } + + /** Returns true if field my_structlist is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_structlist() { + return this.my_structlist != null; + } + + public void setMy_structlistIsSet(boolean value) { + if (!value) { + this.my_structlist = null; + } + } + + public int getMy_enumlistSize() { + return (this.my_enumlist == null) ? 0 : this.my_enumlist.size(); + } + + public java.util.Iterator getMy_enumlistIterator() { + return (this.my_enumlist == null) ? null : this.my_enumlist.iterator(); + } + + public void addToMy_enumlist(MyEnum elem) { + if (this.my_enumlist == null) { + this.my_enumlist = new ArrayList(); + } + this.my_enumlist.add(elem); + } + + public List getMy_enumlist() { + return this.my_enumlist; + } + + public void setMy_enumlist(List my_enumlist) { + this.my_enumlist = my_enumlist; + } + + public void unsetMy_enumlist() { + this.my_enumlist = null; + } + + /** Returns true if field my_enumlist is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_enumlist() { + return this.my_enumlist != null; + } + + public void setMy_enumlistIsSet(boolean value) { + if (!value) { + this.my_enumlist = null; + } + } + + public int getMy_stringsetSize() { + return (this.my_stringset == null) ? 0 : this.my_stringset.size(); + } + + public java.util.Iterator getMy_stringsetIterator() { + return (this.my_stringset == null) ? null : this.my_stringset.iterator(); + } + + public void addToMy_stringset(String elem) { + if (this.my_stringset == null) { + this.my_stringset = new HashSet(); + } + this.my_stringset.add(elem); + } + + public Set getMy_stringset() { + return this.my_stringset; + } + + public void setMy_stringset(Set my_stringset) { + this.my_stringset = my_stringset; + } + + public void unsetMy_stringset() { + this.my_stringset = null; + } + + /** Returns true if field my_stringset is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_stringset() { + return this.my_stringset != null; + } + + public void setMy_stringsetIsSet(boolean value) { + if (!value) { + this.my_stringset = null; + } + } + + public int getMy_enumsetSize() { + return (this.my_enumset == null) ? 0 : this.my_enumset.size(); + } + + public java.util.Iterator getMy_enumsetIterator() { + return (this.my_enumset == null) ? null : this.my_enumset.iterator(); + } + + public void addToMy_enumset(MyEnum elem) { + if (this.my_enumset == null) { + this.my_enumset = new HashSet(); + } + this.my_enumset.add(elem); + } + + public Set getMy_enumset() { + return this.my_enumset; + } + + public void setMy_enumset(Set my_enumset) { + this.my_enumset = my_enumset; + } + + public void unsetMy_enumset() { + this.my_enumset = null; + } + + /** Returns true if field my_enumset is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_enumset() { + return this.my_enumset != null; + } + + public void setMy_enumsetIsSet(boolean value) { + if (!value) { + this.my_enumset = null; + } + } + + public int getMy_structsetSize() { + return (this.my_structset == null) ? 0 : this.my_structset.size(); + } + + public java.util.Iterator getMy_structsetIterator() { + return (this.my_structset == null) ? null : this.my_structset.iterator(); + } + + public void addToMy_structset(MiniStruct elem) { + if (this.my_structset == null) { + this.my_structset = new HashSet(); + } + this.my_structset.add(elem); + } + + public Set getMy_structset() { + return this.my_structset; + } + + public void setMy_structset(Set my_structset) { + this.my_structset = my_structset; + } + + public void unsetMy_structset() { + this.my_structset = null; + } + + /** Returns true if field my_structset is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_structset() { + return this.my_structset != null; + } + + public void setMy_structsetIsSet(boolean value) { + if (!value) { + this.my_structset = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case MY_BOOL: + if (value == null) { + unsetMy_bool(); + } else { + setMy_bool((Boolean)value); + } + break; + + case MY_BYTE: + if (value == null) { + unsetMy_byte(); + } else { + setMy_byte((Byte)value); + } + break; + + case MY_16BIT_INT: + if (value == null) { + unsetMy_16bit_int(); + } else { + setMy_16bit_int((Short)value); + } + break; + + case MY_32BIT_INT: + if (value == null) { + unsetMy_32bit_int(); + } else { + setMy_32bit_int((Integer)value); + } + break; + + case MY_64BIT_INT: + if (value == null) { + unsetMy_64bit_int(); + } else { + setMy_64bit_int((Long)value); + } + break; + + case MY_DOUBLE: + if (value == null) { + unsetMy_double(); + } else { + setMy_double((Double)value); + } + break; + + case MY_STRING: + if (value == null) { + unsetMy_string(); + } else { + setMy_string((String)value); + } + break; + + case MY_BINARY: + if (value == null) { + unsetMy_binary(); + } else { + setMy_binary((ByteBuffer)value); + } + break; + + case MY_STRING_STRING_MAP: + if (value == null) { + unsetMy_string_string_map(); + } else { + setMy_string_string_map((Map)value); + } + break; + + case MY_STRING_ENUM_MAP: + if (value == null) { + unsetMy_string_enum_map(); + } else { + setMy_string_enum_map((Map)value); + } + break; + + case MY_ENUM_STRING_MAP: + if (value == null) { + unsetMy_enum_string_map(); + } else { + setMy_enum_string_map((Map)value); + } + break; + + case MY_ENUM_STRUCT_MAP: + if (value == null) { + unsetMy_enum_struct_map(); + } else { + setMy_enum_struct_map((Map)value); + } + break; + + case MY_ENUM_STRINGLIST_MAP: + if (value == null) { + unsetMy_enum_stringlist_map(); + } else { + setMy_enum_stringlist_map((Map>)value); + } + break; + + case MY_ENUM_STRUCTLIST_MAP: + if (value == null) { + unsetMy_enum_structlist_map(); + } else { + setMy_enum_structlist_map((Map>)value); + } + break; + + case MY_STRINGLIST: + if (value == null) { + unsetMy_stringlist(); + } else { + setMy_stringlist((List)value); + } + break; + + case MY_STRUCTLIST: + if (value == null) { + unsetMy_structlist(); + } else { + setMy_structlist((List)value); + } + break; + + case MY_ENUMLIST: + if (value == null) { + unsetMy_enumlist(); + } else { + setMy_enumlist((List)value); + } + break; + + case MY_STRINGSET: + if (value == null) { + unsetMy_stringset(); + } else { + setMy_stringset((Set)value); + } + break; + + case MY_ENUMSET: + if (value == null) { + unsetMy_enumset(); + } else { + setMy_enumset((Set)value); + } + break; + + case MY_STRUCTSET: + if (value == null) { + unsetMy_structset(); + } else { + setMy_structset((Set)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case MY_BOOL: + return Boolean.valueOf(isMy_bool()); + + case MY_BYTE: + return Byte.valueOf(getMy_byte()); + + case MY_16BIT_INT: + return Short.valueOf(getMy_16bit_int()); + + case MY_32BIT_INT: + return Integer.valueOf(getMy_32bit_int()); + + case MY_64BIT_INT: + return Long.valueOf(getMy_64bit_int()); + + case MY_DOUBLE: + return Double.valueOf(getMy_double()); + + case MY_STRING: + return getMy_string(); + + case MY_BINARY: + return getMy_binary(); + + case MY_STRING_STRING_MAP: + return getMy_string_string_map(); + + case MY_STRING_ENUM_MAP: + return getMy_string_enum_map(); + + case MY_ENUM_STRING_MAP: + return getMy_enum_string_map(); + + case MY_ENUM_STRUCT_MAP: + return getMy_enum_struct_map(); + + case MY_ENUM_STRINGLIST_MAP: + return getMy_enum_stringlist_map(); + + case MY_ENUM_STRUCTLIST_MAP: + return getMy_enum_structlist_map(); + + case MY_STRINGLIST: + return getMy_stringlist(); + + case MY_STRUCTLIST: + return getMy_structlist(); + + case MY_ENUMLIST: + return getMy_enumlist(); + + case MY_STRINGSET: + return getMy_stringset(); + + case MY_ENUMSET: + return getMy_enumset(); + + case MY_STRUCTSET: + return getMy_structset(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case MY_BOOL: + return isSetMy_bool(); + case MY_BYTE: + return isSetMy_byte(); + case MY_16BIT_INT: + return isSetMy_16bit_int(); + case MY_32BIT_INT: + return isSetMy_32bit_int(); + case MY_64BIT_INT: + return isSetMy_64bit_int(); + case MY_DOUBLE: + return isSetMy_double(); + case MY_STRING: + return isSetMy_string(); + case MY_BINARY: + return isSetMy_binary(); + case MY_STRING_STRING_MAP: + return isSetMy_string_string_map(); + case MY_STRING_ENUM_MAP: + return isSetMy_string_enum_map(); + case MY_ENUM_STRING_MAP: + return isSetMy_enum_string_map(); + case MY_ENUM_STRUCT_MAP: + return isSetMy_enum_struct_map(); + case MY_ENUM_STRINGLIST_MAP: + return isSetMy_enum_stringlist_map(); + case MY_ENUM_STRUCTLIST_MAP: + return isSetMy_enum_structlist_map(); + case MY_STRINGLIST: + return isSetMy_stringlist(); + case MY_STRUCTLIST: + return isSetMy_structlist(); + case MY_ENUMLIST: + return isSetMy_enumlist(); + case MY_STRINGSET: + return isSetMy_stringset(); + case MY_ENUMSET: + return isSetMy_enumset(); + case MY_STRUCTSET: + return isSetMy_structset(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof MegaStruct) + return this.equals((MegaStruct)that); + return false; + } + + public boolean equals(MegaStruct that) { + if (that == null) + return false; + + boolean this_present_my_bool = true && this.isSetMy_bool(); + boolean that_present_my_bool = true && that.isSetMy_bool(); + if (this_present_my_bool || that_present_my_bool) { + if (!(this_present_my_bool && that_present_my_bool)) + return false; + if (this.my_bool != that.my_bool) + return false; + } + + boolean this_present_my_byte = true && this.isSetMy_byte(); + boolean that_present_my_byte = true && that.isSetMy_byte(); + if (this_present_my_byte || that_present_my_byte) { + if (!(this_present_my_byte && that_present_my_byte)) + return false; + if (this.my_byte != that.my_byte) + return false; + } + + boolean this_present_my_16bit_int = true && this.isSetMy_16bit_int(); + boolean that_present_my_16bit_int = true && that.isSetMy_16bit_int(); + if (this_present_my_16bit_int || that_present_my_16bit_int) { + if (!(this_present_my_16bit_int && that_present_my_16bit_int)) + return false; + if (this.my_16bit_int != that.my_16bit_int) + return false; + } + + boolean this_present_my_32bit_int = true && this.isSetMy_32bit_int(); + boolean that_present_my_32bit_int = true && that.isSetMy_32bit_int(); + if (this_present_my_32bit_int || that_present_my_32bit_int) { + if (!(this_present_my_32bit_int && that_present_my_32bit_int)) + return false; + if (this.my_32bit_int != that.my_32bit_int) + return false; + } + + boolean this_present_my_64bit_int = true && this.isSetMy_64bit_int(); + boolean that_present_my_64bit_int = true && that.isSetMy_64bit_int(); + if (this_present_my_64bit_int || that_present_my_64bit_int) { + if (!(this_present_my_64bit_int && that_present_my_64bit_int)) + return false; + if (this.my_64bit_int != that.my_64bit_int) + return false; + } + + boolean this_present_my_double = true && this.isSetMy_double(); + boolean that_present_my_double = true && that.isSetMy_double(); + if (this_present_my_double || that_present_my_double) { + if (!(this_present_my_double && that_present_my_double)) + return false; + if (this.my_double != that.my_double) + return false; + } + + boolean this_present_my_string = true && this.isSetMy_string(); + boolean that_present_my_string = true && that.isSetMy_string(); + if (this_present_my_string || that_present_my_string) { + if (!(this_present_my_string && that_present_my_string)) + return false; + if (!this.my_string.equals(that.my_string)) + return false; + } + + boolean this_present_my_binary = true && this.isSetMy_binary(); + boolean that_present_my_binary = true && that.isSetMy_binary(); + if (this_present_my_binary || that_present_my_binary) { + if (!(this_present_my_binary && that_present_my_binary)) + return false; + if (!this.my_binary.equals(that.my_binary)) + return false; + } + + boolean this_present_my_string_string_map = true && this.isSetMy_string_string_map(); + boolean that_present_my_string_string_map = true && that.isSetMy_string_string_map(); + if (this_present_my_string_string_map || that_present_my_string_string_map) { + if (!(this_present_my_string_string_map && that_present_my_string_string_map)) + return false; + if (!this.my_string_string_map.equals(that.my_string_string_map)) + return false; + } + + boolean this_present_my_string_enum_map = true && this.isSetMy_string_enum_map(); + boolean that_present_my_string_enum_map = true && that.isSetMy_string_enum_map(); + if (this_present_my_string_enum_map || that_present_my_string_enum_map) { + if (!(this_present_my_string_enum_map && that_present_my_string_enum_map)) + return false; + if (!this.my_string_enum_map.equals(that.my_string_enum_map)) + return false; + } + + boolean this_present_my_enum_string_map = true && this.isSetMy_enum_string_map(); + boolean that_present_my_enum_string_map = true && that.isSetMy_enum_string_map(); + if (this_present_my_enum_string_map || that_present_my_enum_string_map) { + if (!(this_present_my_enum_string_map && that_present_my_enum_string_map)) + return false; + if (!this.my_enum_string_map.equals(that.my_enum_string_map)) + return false; + } + + boolean this_present_my_enum_struct_map = true && this.isSetMy_enum_struct_map(); + boolean that_present_my_enum_struct_map = true && that.isSetMy_enum_struct_map(); + if (this_present_my_enum_struct_map || that_present_my_enum_struct_map) { + if (!(this_present_my_enum_struct_map && that_present_my_enum_struct_map)) + return false; + if (!this.my_enum_struct_map.equals(that.my_enum_struct_map)) + return false; + } + + boolean this_present_my_enum_stringlist_map = true && this.isSetMy_enum_stringlist_map(); + boolean that_present_my_enum_stringlist_map = true && that.isSetMy_enum_stringlist_map(); + if (this_present_my_enum_stringlist_map || that_present_my_enum_stringlist_map) { + if (!(this_present_my_enum_stringlist_map && that_present_my_enum_stringlist_map)) + return false; + if (!this.my_enum_stringlist_map.equals(that.my_enum_stringlist_map)) + return false; + } + + boolean this_present_my_enum_structlist_map = true && this.isSetMy_enum_structlist_map(); + boolean that_present_my_enum_structlist_map = true && that.isSetMy_enum_structlist_map(); + if (this_present_my_enum_structlist_map || that_present_my_enum_structlist_map) { + if (!(this_present_my_enum_structlist_map && that_present_my_enum_structlist_map)) + return false; + if (!this.my_enum_structlist_map.equals(that.my_enum_structlist_map)) + return false; + } + + boolean this_present_my_stringlist = true && this.isSetMy_stringlist(); + boolean that_present_my_stringlist = true && that.isSetMy_stringlist(); + if (this_present_my_stringlist || that_present_my_stringlist) { + if (!(this_present_my_stringlist && that_present_my_stringlist)) + return false; + if (!this.my_stringlist.equals(that.my_stringlist)) + return false; + } + + boolean this_present_my_structlist = true && this.isSetMy_structlist(); + boolean that_present_my_structlist = true && that.isSetMy_structlist(); + if (this_present_my_structlist || that_present_my_structlist) { + if (!(this_present_my_structlist && that_present_my_structlist)) + return false; + if (!this.my_structlist.equals(that.my_structlist)) + return false; + } + + boolean this_present_my_enumlist = true && this.isSetMy_enumlist(); + boolean that_present_my_enumlist = true && that.isSetMy_enumlist(); + if (this_present_my_enumlist || that_present_my_enumlist) { + if (!(this_present_my_enumlist && that_present_my_enumlist)) + return false; + if (!this.my_enumlist.equals(that.my_enumlist)) + return false; + } + + boolean this_present_my_stringset = true && this.isSetMy_stringset(); + boolean that_present_my_stringset = true && that.isSetMy_stringset(); + if (this_present_my_stringset || that_present_my_stringset) { + if (!(this_present_my_stringset && that_present_my_stringset)) + return false; + if (!this.my_stringset.equals(that.my_stringset)) + return false; + } + + boolean this_present_my_enumset = true && this.isSetMy_enumset(); + boolean that_present_my_enumset = true && that.isSetMy_enumset(); + if (this_present_my_enumset || that_present_my_enumset) { + if (!(this_present_my_enumset && that_present_my_enumset)) + return false; + if (!this.my_enumset.equals(that.my_enumset)) + return false; + } + + boolean this_present_my_structset = true && this.isSetMy_structset(); + boolean that_present_my_structset = true && that.isSetMy_structset(); + if (this_present_my_structset || that_present_my_structset) { + if (!(this_present_my_structset && that_present_my_structset)) + return false; + if (!this.my_structset.equals(that.my_structset)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(MegaStruct other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + MegaStruct typedOther = (MegaStruct)other; + + lastComparison = Boolean.valueOf(isSetMy_bool()).compareTo(typedOther.isSetMy_bool()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_bool()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_bool, typedOther.my_bool); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_byte()).compareTo(typedOther.isSetMy_byte()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_byte()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_byte, typedOther.my_byte); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_16bit_int()).compareTo(typedOther.isSetMy_16bit_int()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_16bit_int()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_16bit_int, typedOther.my_16bit_int); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_32bit_int()).compareTo(typedOther.isSetMy_32bit_int()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_32bit_int()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_32bit_int, typedOther.my_32bit_int); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_64bit_int()).compareTo(typedOther.isSetMy_64bit_int()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_64bit_int()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_64bit_int, typedOther.my_64bit_int); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_double()).compareTo(typedOther.isSetMy_double()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_double()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_double, typedOther.my_double); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_string()).compareTo(typedOther.isSetMy_string()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_string()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_string, typedOther.my_string); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_binary()).compareTo(typedOther.isSetMy_binary()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_binary()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_binary, typedOther.my_binary); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_string_string_map()).compareTo(typedOther.isSetMy_string_string_map()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_string_string_map()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_string_string_map, typedOther.my_string_string_map); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_string_enum_map()).compareTo(typedOther.isSetMy_string_enum_map()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_string_enum_map()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_string_enum_map, typedOther.my_string_enum_map); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_enum_string_map()).compareTo(typedOther.isSetMy_enum_string_map()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_enum_string_map()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_enum_string_map, typedOther.my_enum_string_map); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_enum_struct_map()).compareTo(typedOther.isSetMy_enum_struct_map()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_enum_struct_map()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_enum_struct_map, typedOther.my_enum_struct_map); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_enum_stringlist_map()).compareTo(typedOther.isSetMy_enum_stringlist_map()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_enum_stringlist_map()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_enum_stringlist_map, typedOther.my_enum_stringlist_map); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_enum_structlist_map()).compareTo(typedOther.isSetMy_enum_structlist_map()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_enum_structlist_map()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_enum_structlist_map, typedOther.my_enum_structlist_map); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_stringlist()).compareTo(typedOther.isSetMy_stringlist()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_stringlist()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_stringlist, typedOther.my_stringlist); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_structlist()).compareTo(typedOther.isSetMy_structlist()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_structlist()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_structlist, typedOther.my_structlist); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_enumlist()).compareTo(typedOther.isSetMy_enumlist()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_enumlist()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_enumlist, typedOther.my_enumlist); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_stringset()).compareTo(typedOther.isSetMy_stringset()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_stringset()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_stringset, typedOther.my_stringset); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_enumset()).compareTo(typedOther.isSetMy_enumset()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_enumset()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_enumset, typedOther.my_enumset); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_structset()).compareTo(typedOther.isSetMy_structset()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_structset()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_structset, typedOther.my_structset); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 1: // MY_BOOL + if (field.type == org.apache.thrift.protocol.TType.BOOL) { + this.my_bool = iprot.readBool(); + setMy_boolIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // MY_BYTE + if (field.type == org.apache.thrift.protocol.TType.BYTE) { + this.my_byte = iprot.readByte(); + setMy_byteIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // MY_16BIT_INT + if (field.type == org.apache.thrift.protocol.TType.I16) { + this.my_16bit_int = iprot.readI16(); + setMy_16bit_intIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 4: // MY_32BIT_INT + if (field.type == org.apache.thrift.protocol.TType.I32) { + this.my_32bit_int = iprot.readI32(); + setMy_32bit_intIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 5: // MY_64BIT_INT + if (field.type == org.apache.thrift.protocol.TType.I64) { + this.my_64bit_int = iprot.readI64(); + setMy_64bit_intIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 6: // MY_DOUBLE + if (field.type == org.apache.thrift.protocol.TType.DOUBLE) { + this.my_double = iprot.readDouble(); + setMy_doubleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 7: // MY_STRING + if (field.type == org.apache.thrift.protocol.TType.STRING) { + this.my_string = iprot.readString(); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 8: // MY_BINARY + if (field.type == org.apache.thrift.protocol.TType.STRING) { + this.my_binary = iprot.readBinary(); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 9: // MY_STRING_STRING_MAP + if (field.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin(); + this.my_string_string_map = new HashMap(2*_map0.size); + for (int _i1 = 0; _i1 < _map0.size; ++_i1) + { + String _key2; // required + String _val3; // required + _key2 = iprot.readString(); + _val3 = iprot.readString(); + this.my_string_string_map.put(_key2, _val3); + } + iprot.readMapEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 10: // MY_STRING_ENUM_MAP + if (field.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map4 = iprot.readMapBegin(); + this.my_string_enum_map = new HashMap(2*_map4.size); + for (int _i5 = 0; _i5 < _map4.size; ++_i5) + { + String _key6; // required + MyEnum _val7; // required + _key6 = iprot.readString(); + _val7 = MyEnum.findByValue(iprot.readI32()); + this.my_string_enum_map.put(_key6, _val7); + } + iprot.readMapEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 11: // MY_ENUM_STRING_MAP + if (field.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map8 = iprot.readMapBegin(); + this.my_enum_string_map = new HashMap(2*_map8.size); + for (int _i9 = 0; _i9 < _map8.size; ++_i9) + { + MyEnum _key10; // required + String _val11; // required + _key10 = MyEnum.findByValue(iprot.readI32()); + _val11 = iprot.readString(); + this.my_enum_string_map.put(_key10, _val11); + } + iprot.readMapEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 12: // MY_ENUM_STRUCT_MAP + if (field.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map12 = iprot.readMapBegin(); + this.my_enum_struct_map = new HashMap(2*_map12.size); + for (int _i13 = 0; _i13 < _map12.size; ++_i13) + { + MyEnum _key14; // required + MiniStruct _val15; // required + _key14 = MyEnum.findByValue(iprot.readI32()); + _val15 = new MiniStruct(); + _val15.read(iprot); + this.my_enum_struct_map.put(_key14, _val15); + } + iprot.readMapEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 13: // MY_ENUM_STRINGLIST_MAP + if (field.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map16 = iprot.readMapBegin(); + this.my_enum_stringlist_map = new HashMap>(2*_map16.size); + for (int _i17 = 0; _i17 < _map16.size; ++_i17) + { + MyEnum _key18; // required + List _val19; // required + _key18 = MyEnum.findByValue(iprot.readI32()); + { + org.apache.thrift.protocol.TList _list20 = iprot.readListBegin(); + _val19 = new ArrayList(_list20.size); + for (int _i21 = 0; _i21 < _list20.size; ++_i21) + { + String _elem22; // required + _elem22 = iprot.readString(); + _val19.add(_elem22); + } + iprot.readListEnd(); + } + this.my_enum_stringlist_map.put(_key18, _val19); + } + iprot.readMapEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 14: // MY_ENUM_STRUCTLIST_MAP + if (field.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map23 = iprot.readMapBegin(); + this.my_enum_structlist_map = new HashMap>(2*_map23.size); + for (int _i24 = 0; _i24 < _map23.size; ++_i24) + { + MyEnum _key25; // required + List _val26; // required + _key25 = MyEnum.findByValue(iprot.readI32()); + { + org.apache.thrift.protocol.TList _list27 = iprot.readListBegin(); + _val26 = new ArrayList(_list27.size); + for (int _i28 = 0; _i28 < _list27.size; ++_i28) + { + MiniStruct _elem29; // required + _elem29 = new MiniStruct(); + _elem29.read(iprot); + _val26.add(_elem29); + } + iprot.readListEnd(); + } + this.my_enum_structlist_map.put(_key25, _val26); + } + iprot.readMapEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 15: // MY_STRINGLIST + if (field.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list30 = iprot.readListBegin(); + this.my_stringlist = new ArrayList(_list30.size); + for (int _i31 = 0; _i31 < _list30.size; ++_i31) + { + String _elem32; // required + _elem32 = iprot.readString(); + this.my_stringlist.add(_elem32); + } + iprot.readListEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 16: // MY_STRUCTLIST + if (field.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list33 = iprot.readListBegin(); + this.my_structlist = new ArrayList(_list33.size); + for (int _i34 = 0; _i34 < _list33.size; ++_i34) + { + MiniStruct _elem35; // required + _elem35 = new MiniStruct(); + _elem35.read(iprot); + this.my_structlist.add(_elem35); + } + iprot.readListEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 17: // MY_ENUMLIST + if (field.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list36 = iprot.readListBegin(); + this.my_enumlist = new ArrayList(_list36.size); + for (int _i37 = 0; _i37 < _list36.size; ++_i37) + { + MyEnum _elem38; // required + _elem38 = MyEnum.findByValue(iprot.readI32()); + this.my_enumlist.add(_elem38); + } + iprot.readListEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 18: // MY_STRINGSET + if (field.type == org.apache.thrift.protocol.TType.SET) { + { + org.apache.thrift.protocol.TSet _set39 = iprot.readSetBegin(); + this.my_stringset = new HashSet(2*_set39.size); + for (int _i40 = 0; _i40 < _set39.size; ++_i40) + { + String _elem41; // required + _elem41 = iprot.readString(); + this.my_stringset.add(_elem41); + } + iprot.readSetEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 19: // MY_ENUMSET + if (field.type == org.apache.thrift.protocol.TType.SET) { + { + org.apache.thrift.protocol.TSet _set42 = iprot.readSetBegin(); + this.my_enumset = new HashSet(2*_set42.size); + for (int _i43 = 0; _i43 < _set42.size; ++_i43) + { + MyEnum _elem44; // required + _elem44 = MyEnum.findByValue(iprot.readI32()); + this.my_enumset.add(_elem44); + } + iprot.readSetEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 20: // MY_STRUCTSET + if (field.type == org.apache.thrift.protocol.TType.SET) { + { + org.apache.thrift.protocol.TSet _set45 = iprot.readSetBegin(); + this.my_structset = new HashSet(2*_set45.size); + for (int _i46 = 0; _i46 < _set45.size; ++_i46) + { + MiniStruct _elem47; // required + _elem47 = new MiniStruct(); + _elem47.read(iprot); + this.my_structset.add(_elem47); + } + iprot.readSetEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (isSetMy_bool()) { + oprot.writeFieldBegin(MY_BOOL_FIELD_DESC); + oprot.writeBool(this.my_bool); + oprot.writeFieldEnd(); + } + if (isSetMy_byte()) { + oprot.writeFieldBegin(MY_BYTE_FIELD_DESC); + oprot.writeByte(this.my_byte); + oprot.writeFieldEnd(); + } + if (isSetMy_16bit_int()) { + oprot.writeFieldBegin(MY_16BIT_INT_FIELD_DESC); + oprot.writeI16(this.my_16bit_int); + oprot.writeFieldEnd(); + } + if (isSetMy_32bit_int()) { + oprot.writeFieldBegin(MY_32BIT_INT_FIELD_DESC); + oprot.writeI32(this.my_32bit_int); + oprot.writeFieldEnd(); + } + if (isSetMy_64bit_int()) { + oprot.writeFieldBegin(MY_64BIT_INT_FIELD_DESC); + oprot.writeI64(this.my_64bit_int); + oprot.writeFieldEnd(); + } + if (isSetMy_double()) { + oprot.writeFieldBegin(MY_DOUBLE_FIELD_DESC); + oprot.writeDouble(this.my_double); + oprot.writeFieldEnd(); + } + if (this.my_string != null) { + if (isSetMy_string()) { + oprot.writeFieldBegin(MY_STRING_FIELD_DESC); + oprot.writeString(this.my_string); + oprot.writeFieldEnd(); + } + } + if (this.my_binary != null) { + if (isSetMy_binary()) { + oprot.writeFieldBegin(MY_BINARY_FIELD_DESC); + oprot.writeBinary(this.my_binary); + oprot.writeFieldEnd(); + } + } + if (this.my_string_string_map != null) { + if (isSetMy_string_string_map()) { + oprot.writeFieldBegin(MY_STRING_STRING_MAP_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, this.my_string_string_map.size())); + for (Map.Entry _iter48 : this.my_string_string_map.entrySet()) + { + oprot.writeString(_iter48.getKey()); + oprot.writeString(_iter48.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_string_enum_map != null) { + if (isSetMy_string_enum_map()) { + oprot.writeFieldBegin(MY_STRING_ENUM_MAP_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I32, this.my_string_enum_map.size())); + for (Map.Entry _iter49 : this.my_string_enum_map.entrySet()) + { + oprot.writeString(_iter49.getKey()); + oprot.writeI32(_iter49.getValue().getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_enum_string_map != null) { + if (isSetMy_enum_string_map()) { + oprot.writeFieldBegin(MY_ENUM_STRING_MAP_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRING, this.my_enum_string_map.size())); + for (Map.Entry _iter50 : this.my_enum_string_map.entrySet()) + { + oprot.writeI32(_iter50.getKey().getValue()); + oprot.writeString(_iter50.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_enum_struct_map != null) { + if (isSetMy_enum_struct_map()) { + oprot.writeFieldBegin(MY_ENUM_STRUCT_MAP_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, this.my_enum_struct_map.size())); + for (Map.Entry _iter51 : this.my_enum_struct_map.entrySet()) + { + oprot.writeI32(_iter51.getKey().getValue()); + _iter51.getValue().write(oprot); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_enum_stringlist_map != null) { + if (isSetMy_enum_stringlist_map()) { + oprot.writeFieldBegin(MY_ENUM_STRINGLIST_MAP_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.LIST, this.my_enum_stringlist_map.size())); + for (Map.Entry> _iter52 : this.my_enum_stringlist_map.entrySet()) + { + oprot.writeI32(_iter52.getKey().getValue()); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, _iter52.getValue().size())); + for (String _iter53 : _iter52.getValue()) + { + oprot.writeString(_iter53); + } + oprot.writeListEnd(); + } + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_enum_structlist_map != null) { + if (isSetMy_enum_structlist_map()) { + oprot.writeFieldBegin(MY_ENUM_STRUCTLIST_MAP_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.LIST, this.my_enum_structlist_map.size())); + for (Map.Entry> _iter54 : this.my_enum_structlist_map.entrySet()) + { + oprot.writeI32(_iter54.getKey().getValue()); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, _iter54.getValue().size())); + for (MiniStruct _iter55 : _iter54.getValue()) + { + _iter55.write(oprot); + } + oprot.writeListEnd(); + } + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_stringlist != null) { + if (isSetMy_stringlist()) { + oprot.writeFieldBegin(MY_STRINGLIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, this.my_stringlist.size())); + for (String _iter56 : this.my_stringlist) + { + oprot.writeString(_iter56); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_structlist != null) { + if (isSetMy_structlist()) { + oprot.writeFieldBegin(MY_STRUCTLIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.my_structlist.size())); + for (MiniStruct _iter57 : this.my_structlist) + { + _iter57.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_enumlist != null) { + if (isSetMy_enumlist()) { + oprot.writeFieldBegin(MY_ENUMLIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, this.my_enumlist.size())); + for (MyEnum _iter58 : this.my_enumlist) + { + oprot.writeI32(_iter58.getValue()); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_stringset != null) { + if (isSetMy_stringset()) { + oprot.writeFieldBegin(MY_STRINGSET_FIELD_DESC); + { + oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, this.my_stringset.size())); + for (String _iter59 : this.my_stringset) + { + oprot.writeString(_iter59); + } + oprot.writeSetEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_enumset != null) { + if (isSetMy_enumset()) { + oprot.writeFieldBegin(MY_ENUMSET_FIELD_DESC); + { + oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, this.my_enumset.size())); + for (MyEnum _iter60 : this.my_enumset) + { + oprot.writeI32(_iter60.getValue()); + } + oprot.writeSetEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.my_structset != null) { + if (isSetMy_structset()) { + oprot.writeFieldBegin(MY_STRUCTSET_FIELD_DESC); + { + oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, this.my_structset.size())); + for (MiniStruct _iter61 : this.my_structset) + { + _iter61.write(oprot); + } + oprot.writeSetEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("MegaStruct("); + boolean first = true; + + if (isSetMy_bool()) { + sb.append("my_bool:"); + sb.append(this.my_bool); + first = false; + } + if (isSetMy_byte()) { + if (!first) sb.append(", "); + sb.append("my_byte:"); + sb.append(this.my_byte); + first = false; + } + if (isSetMy_16bit_int()) { + if (!first) sb.append(", "); + sb.append("my_16bit_int:"); + sb.append(this.my_16bit_int); + first = false; + } + if (isSetMy_32bit_int()) { + if (!first) sb.append(", "); + sb.append("my_32bit_int:"); + sb.append(this.my_32bit_int); + first = false; + } + if (isSetMy_64bit_int()) { + if (!first) sb.append(", "); + sb.append("my_64bit_int:"); + sb.append(this.my_64bit_int); + first = false; + } + if (isSetMy_double()) { + if (!first) sb.append(", "); + sb.append("my_double:"); + sb.append(this.my_double); + first = false; + } + if (isSetMy_string()) { + if (!first) sb.append(", "); + sb.append("my_string:"); + if (this.my_string == null) { + sb.append("null"); + } else { + sb.append(this.my_string); + } + first = false; + } + if (isSetMy_binary()) { + if (!first) sb.append(", "); + sb.append("my_binary:"); + if (this.my_binary == null) { + sb.append("null"); + } else { + org.apache.thrift.TBaseHelper.toString(this.my_binary, sb); + } + first = false; + } + if (isSetMy_string_string_map()) { + if (!first) sb.append(", "); + sb.append("my_string_string_map:"); + if (this.my_string_string_map == null) { + sb.append("null"); + } else { + sb.append(this.my_string_string_map); + } + first = false; + } + if (isSetMy_string_enum_map()) { + if (!first) sb.append(", "); + sb.append("my_string_enum_map:"); + if (this.my_string_enum_map == null) { + sb.append("null"); + } else { + sb.append(this.my_string_enum_map); + } + first = false; + } + if (isSetMy_enum_string_map()) { + if (!first) sb.append(", "); + sb.append("my_enum_string_map:"); + if (this.my_enum_string_map == null) { + sb.append("null"); + } else { + sb.append(this.my_enum_string_map); + } + first = false; + } + if (isSetMy_enum_struct_map()) { + if (!first) sb.append(", "); + sb.append("my_enum_struct_map:"); + if (this.my_enum_struct_map == null) { + sb.append("null"); + } else { + sb.append(this.my_enum_struct_map); + } + first = false; + } + if (isSetMy_enum_stringlist_map()) { + if (!first) sb.append(", "); + sb.append("my_enum_stringlist_map:"); + if (this.my_enum_stringlist_map == null) { + sb.append("null"); + } else { + sb.append(this.my_enum_stringlist_map); + } + first = false; + } + if (isSetMy_enum_structlist_map()) { + if (!first) sb.append(", "); + sb.append("my_enum_structlist_map:"); + if (this.my_enum_structlist_map == null) { + sb.append("null"); + } else { + sb.append(this.my_enum_structlist_map); + } + first = false; + } + if (isSetMy_stringlist()) { + if (!first) sb.append(", "); + sb.append("my_stringlist:"); + if (this.my_stringlist == null) { + sb.append("null"); + } else { + sb.append(this.my_stringlist); + } + first = false; + } + if (isSetMy_structlist()) { + if (!first) sb.append(", "); + sb.append("my_structlist:"); + if (this.my_structlist == null) { + sb.append("null"); + } else { + sb.append(this.my_structlist); + } + first = false; + } + if (isSetMy_enumlist()) { + if (!first) sb.append(", "); + sb.append("my_enumlist:"); + if (this.my_enumlist == null) { + sb.append("null"); + } else { + sb.append(this.my_enumlist); + } + first = false; + } + if (isSetMy_stringset()) { + if (!first) sb.append(", "); + sb.append("my_stringset:"); + if (this.my_stringset == null) { + sb.append("null"); + } else { + sb.append(this.my_stringset); + } + first = false; + } + if (isSetMy_enumset()) { + if (!first) sb.append(", "); + sb.append("my_enumset:"); + if (this.my_enumset == null) { + sb.append("null"); + } else { + sb.append(this.my_enumset); + } + first = false; + } + if (isSetMy_structset()) { + if (!first) sb.append(", "); + sb.append("my_structset:"); + if (this.my_structset == null) { + sb.append("null"); + } else { + sb.append(this.my_structset); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bit_vector = new BitSet(1); + 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); + } + } + +} + diff --git serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MiniStruct.java serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MiniStruct.java new file mode 100644 index 0000000..b6852dc --- /dev/null +++ serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MiniStruct.java @@ -0,0 +1,415 @@ +/** + * Autogenerated by Thrift Compiler (0.7.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + */ +package org.apache.hadoop.hive.serde2.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 MiniStruct implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("MiniStruct"); + + private static final org.apache.thrift.protocol.TField MY_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("my_string", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField MY_ENUM_FIELD_DESC = new org.apache.thrift.protocol.TField("my_enum", org.apache.thrift.protocol.TType.I32, (short)2); + + private String my_string; // required + private MyEnum my_enum; // 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 { + MY_STRING((short)1, "my_string"), + /** + * + * @see MyEnum + */ + MY_ENUM((short)2, "my_enum"); + + private static final Map byName = new HashMap(); + + 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: // MY_STRING + return MY_STRING; + case 2: // MY_ENUM + return MY_ENUM; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.MY_STRING, new org.apache.thrift.meta_data.FieldMetaData("my_string", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.MY_ENUM, new org.apache.thrift.meta_data.FieldMetaData("my_enum", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, MyEnum.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(MiniStruct.class, metaDataMap); + } + + public MiniStruct() { + } + + /** + * Performs a deep copy on other. + */ + public MiniStruct(MiniStruct other) { + if (other.isSetMy_string()) { + this.my_string = other.my_string; + } + if (other.isSetMy_enum()) { + this.my_enum = other.my_enum; + } + } + + public MiniStruct deepCopy() { + return new MiniStruct(this); + } + + @Override + public void clear() { + this.my_string = null; + this.my_enum = null; + } + + public String getMy_string() { + return this.my_string; + } + + public void setMy_string(String my_string) { + this.my_string = my_string; + } + + public void unsetMy_string() { + this.my_string = null; + } + + /** Returns true if field my_string is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_string() { + return this.my_string != null; + } + + public void setMy_stringIsSet(boolean value) { + if (!value) { + this.my_string = null; + } + } + + /** + * + * @see MyEnum + */ + public MyEnum getMy_enum() { + return this.my_enum; + } + + /** + * + * @see MyEnum + */ + public void setMy_enum(MyEnum my_enum) { + this.my_enum = my_enum; + } + + public void unsetMy_enum() { + this.my_enum = null; + } + + /** Returns true if field my_enum is set (has been assigned a value) and false otherwise */ + public boolean isSetMy_enum() { + return this.my_enum != null; + } + + public void setMy_enumIsSet(boolean value) { + if (!value) { + this.my_enum = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case MY_STRING: + if (value == null) { + unsetMy_string(); + } else { + setMy_string((String)value); + } + break; + + case MY_ENUM: + if (value == null) { + unsetMy_enum(); + } else { + setMy_enum((MyEnum)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case MY_STRING: + return getMy_string(); + + case MY_ENUM: + return getMy_enum(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case MY_STRING: + return isSetMy_string(); + case MY_ENUM: + return isSetMy_enum(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof MiniStruct) + return this.equals((MiniStruct)that); + return false; + } + + public boolean equals(MiniStruct that) { + if (that == null) + return false; + + boolean this_present_my_string = true && this.isSetMy_string(); + boolean that_present_my_string = true && that.isSetMy_string(); + if (this_present_my_string || that_present_my_string) { + if (!(this_present_my_string && that_present_my_string)) + return false; + if (!this.my_string.equals(that.my_string)) + return false; + } + + boolean this_present_my_enum = true && this.isSetMy_enum(); + boolean that_present_my_enum = true && that.isSetMy_enum(); + if (this_present_my_enum || that_present_my_enum) { + if (!(this_present_my_enum && that_present_my_enum)) + return false; + if (!this.my_enum.equals(that.my_enum)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(MiniStruct other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + MiniStruct typedOther = (MiniStruct)other; + + lastComparison = Boolean.valueOf(isSetMy_string()).compareTo(typedOther.isSetMy_string()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_string()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_string, typedOther.my_string); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMy_enum()).compareTo(typedOther.isSetMy_enum()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMy_enum()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.my_enum, typedOther.my_enum); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 1: // MY_STRING + if (field.type == org.apache.thrift.protocol.TType.STRING) { + this.my_string = iprot.readString(); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // MY_ENUM + if (field.type == org.apache.thrift.protocol.TType.I32) { + this.my_enum = MyEnum.findByValue(iprot.readI32()); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.my_string != null) { + if (isSetMy_string()) { + oprot.writeFieldBegin(MY_STRING_FIELD_DESC); + oprot.writeString(this.my_string); + oprot.writeFieldEnd(); + } + } + if (this.my_enum != null) { + if (isSetMy_enum()) { + oprot.writeFieldBegin(MY_ENUM_FIELD_DESC); + oprot.writeI32(this.my_enum.getValue()); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("MiniStruct("); + boolean first = true; + + if (isSetMy_string()) { + sb.append("my_string:"); + if (this.my_string == null) { + sb.append("null"); + } else { + sb.append(this.my_string); + } + first = false; + } + if (isSetMy_enum()) { + if (!first) sb.append(", "); + sb.append("my_enum:"); + if (this.my_enum == null) { + sb.append("null"); + } else { + sb.append(this.my_enum); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + +} + diff --git serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MyEnum.java serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MyEnum.java new file mode 100644 index 0000000..dc9fc8c --- /dev/null +++ serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MyEnum.java @@ -0,0 +1,44 @@ +/** + * Autogenerated by Thrift Compiler (0.7.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + */ +package org.apache.hadoop.hive.serde2.thrift.test; + + +import java.util.Map; +import java.util.HashMap; +import org.apache.thrift.TEnum; + +public enum MyEnum implements org.apache.thrift.TEnum { + LLAMA(1), + ALPACA(2); + + private final int value; + + private MyEnum(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static MyEnum findByValue(int value) { + switch (value) { + case 1: + return LLAMA; + case 2: + return ALPACA; + default: + return null; + } + } +} diff --git serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java index b21755e..0e39073 100644 --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java @@ -155,6 +155,12 @@ public final class ObjectInspectorFactory { .getTypeEntryFromPrimitiveWritableClass(c).primitiveCategory); } + // Enum class? + if (Enum.class.isAssignableFrom(c)) { + return PrimitiveObjectInspectorFactory + .getPrimitiveJavaObjectInspector(PrimitiveObjectInspector.PrimitiveCategory.STRING); + } + // Must be struct because List and Map need to be ParameterizedType assert (!List.class.isAssignableFrom(c)); assert (!Map.class.isAssignableFrom(c)); diff --git serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java index 921ce2b..be7c64a 100644 --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java @@ -32,12 +32,12 @@ public class JavaStringObjectInspector extends @Override public Text getPrimitiveWritableObject(Object o) { - return o == null ? null : new Text(((String) o)); + return o == null ? null : new Text(o.toString()); } @Override public String getPrimitiveJavaObject(Object o) { - return (String) o; + return o == null ? null : o.toString(); } @Override