Пример #1
0
            public OrcUnionObjectInspector(UnionTypeInfo info)
            {
                List <TypeInfo> unionChildren = info.getAllUnionObjectTypeInfos();

                this.children = new List <ObjectInspector>(unionChildren.Count);
                foreach (TypeInfo child in info.getAllUnionObjectTypeInfos())
                {
                    this.children.Add(OrcStruct.createObjectInspector(child));
                }
            }
Пример #2
0
        public static TypeDescription convertTypeInfo(TypeInfo info)
        {
            switch (info.getCategory())
            {
            case ObjectInspectorCategory.PRIMITIVE:
            {
                PrimitiveTypeInfo pinfo = (PrimitiveTypeInfo)info;
                switch (pinfo.getPrimitiveCategory())
                {
                case PrimitiveCategory.BOOLEAN:
                    return(TypeDescription.createBoolean());

                case PrimitiveCategory.BYTE:
                    return(TypeDescription.createByte());

                case PrimitiveCategory.SHORT:
                    return(TypeDescription.createShort());

                case PrimitiveCategory.INT:
                    return(TypeDescription.createInt());

                case PrimitiveCategory.LONG:
                    return(TypeDescription.createLong());

                case PrimitiveCategory.FLOAT:
                    return(TypeDescription.createFloat());

                case PrimitiveCategory.DOUBLE:
                    return(TypeDescription.createDouble());

                case PrimitiveCategory.STRING:
                    return(TypeDescription.createString());

                case PrimitiveCategory.DATE:
                    return(TypeDescription.createDate());

                case PrimitiveCategory.TIMESTAMP:
                    return(TypeDescription.createTimestamp());

                case PrimitiveCategory.BINARY:
                    return(TypeDescription.createBinary());

                case PrimitiveCategory.DECIMAL:
                {
                    DecimalTypeInfo dinfo = (DecimalTypeInfo)pinfo;
                    return(TypeDescription.createDecimal()
                           .withScale(dinfo.scale())
                           .withPrecision(dinfo.precision()));
                }

                case PrimitiveCategory.VARCHAR:
                {
                    BaseCharTypeInfo cinfo = (BaseCharTypeInfo)pinfo;
                    return(TypeDescription.createVarchar()
                           .withMaxLength(cinfo.getLength()));
                }

                case PrimitiveCategory.CHAR:
                {
                    BaseCharTypeInfo cinfo = (BaseCharTypeInfo)pinfo;
                    return(TypeDescription.createChar()
                           .withMaxLength(cinfo.getLength()));
                }

                default:
                    throw new ArgumentException("ORC doesn't handle primitive" +
                                                " category " + pinfo.getPrimitiveCategory());
                }
            }

            case ObjectInspectorCategory.LIST:
            {
                ListTypeInfo linfo = (ListTypeInfo)info;
                return(TypeDescription.createList
                           (convertTypeInfo(linfo.getListElementTypeInfo())));
            }

            case ObjectInspectorCategory.MAP:
            {
                MapTypeInfo minfo = (MapTypeInfo)info;
                return(TypeDescription.createMap
                           (convertTypeInfo(minfo.getMapKeyTypeInfo()),
                           convertTypeInfo(minfo.getMapValueTypeInfo())));
            }

            case ObjectInspectorCategory.UNION:
            {
                UnionTypeInfo   minfo  = (UnionTypeInfo)info;
                TypeDescription result = TypeDescription.createUnion();
                foreach (TypeInfo child in minfo.getAllUnionObjectTypeInfos())
                {
                    result.addUnionChild(convertTypeInfo(child));
                }
                return(result);
            }

            case ObjectInspectorCategory.STRUCT:
            {
                StructTypeInfo  sinfo  = (StructTypeInfo)info;
                TypeDescription result = TypeDescription.createStruct();
                foreach (string fieldName in sinfo.getAllStructFieldNames())
                {
                    result.addField(fieldName,
                                    convertTypeInfo(sinfo.getStructFieldTypeInfo(fieldName)));
                }
                return(result);
            }

            default:
                throw new ArgumentException("ORC doesn't handle " +
                                            info.getCategory());
            }
        }
Пример #3
0
 public OrcUnionObjectInspector(UnionTypeInfo info)
 {
     List<TypeInfo> unionChildren = info.getAllUnionObjectTypeInfos();
     this.children = new List<ObjectInspector>(unionChildren.Count);
     foreach (TypeInfo child in info.getAllUnionObjectTypeInfos())
     {
         this.children.Add(OrcStruct.createObjectInspector(child));
     }
 }