You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by Matt Burgess <ma...@apache.org> on 2016/08/08 23:39:31 UTC

Unions of Maps

Hello all,

I'm using Hive 1.2.1, and let's say I have the following type info
(code simplified):

typeInfo = TypeInfoUtils.getTypeInfoFromTypeString("uniontype<map<string,float>,map<string,int>>")

I can get the appropriate ObjectInspectors:

oi = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(typeInfo)

map1oi = oi.getObjectInspectors().get(0)

map2oi = oi.getObjectInspectors().get(1)

I'm trying to fill a map (actually a MapWritable, I'm converting these
to ORC).  Now let's say I'm given a Map object. How would I
programmatically tell which one of the union "entries" is the right
one to use? Do I just try the put() command and if it fails, try the
next ObjectInspector? Do I try to get the Class of the key/value and
recursively try to build an "output object" that way? Or am I missing
a better way to resolve the correct union type against the incoming
object?

Thank you in advance,
Matt