public void testInspectorFromTypeInfo() { TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString("struct<c1:boolean,c2:tinyint" + ",c3:smallint,c4:int,c5:bigint,c6:float,c7:double,c8:binary," + "c9:string,c10:struct<c1:int>,c11:map<int,int>,c12:uniontype<int>" + ",c13:array<timestamp>>"); StructObjectInspector inspector = (StructObjectInspector) OrcStruct.createObjectInspector(typeInfo); Assert.Equal("struct<c1:boolean,c2:tinyint,c3:smallint,c4:int,c5:" + "bigint,c6:float,c7:double,c8:binary,c9:string,c10:struct<" + "c1:int>,c11:map<int,int>,c12:uniontype<int>,c13:array<timestamp>>", inspector.getTypeName()); Assert.Equal(null, inspector.getAllStructFieldRefs()[0].getFieldComment()); Assert.Equal(null, inspector.getStructFieldRef("UNKNOWN")); OrcStruct s1 = new OrcStruct(13); for (int i = 0; i < 13; ++i) { s1.setFieldValue(i, i); } List <object> list = new List <object> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; Assert.Equal(list, inspector.getStructFieldsDataAsList(s1)); ListObjectInspector listOI = (ListObjectInspector) inspector.getAllStructFieldRefs()[12].getFieldObjectInspector(); Assert.Equal(ObjectInspectorCategory.LIST, listOI.getCategory()); Assert.Equal(10, listOI.getListElement(list, 10)); Assert.Equal(null, listOI.getListElement(list, -1)); Assert.Equal(null, listOI.getListElement(list, 13)); Assert.Equal(13, listOI.getListLength(list)); Dictionary <object, object> map = new Dictionary <object, object>() { { 1, 2 }, { 2, 4 }, { 3, 6 }, }; MapObjectInspector mapOI = (MapObjectInspector) inspector.getAllStructFieldRefs()[10].getFieldObjectInspector(); Assert.Equal(3, mapOI.getMapSize(map)); Assert.Equal(4, mapOI.getMapValueElement(map, 2)); }
public override List <object> getStructFieldsDataAsList(object data) { return(wrapped.getStructFieldsDataAsList(data)); }