当前位置: 首页>>代码示例>>Java>>正文


Java MapObjectInspector类代码示例

本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector的典型用法代码示例。如果您正苦于以下问题:Java MapObjectInspector类的具体用法?Java MapObjectInspector怎么用?Java MapObjectInspector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MapObjectInspector类属于org.apache.hadoop.hive.serde2.objectinspector包,在下文中一共展示了MapObjectInspector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isMonarchTypeSupported

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
public static boolean isMonarchTypeSupported(final ObjectInspector oi) {
  if (ObjectInspector.Category.PRIMITIVE.equals(oi.getCategory())) {
    /** handle primitive type definitions like decimal(20,20) or varchar(100) **/
    String typeStr = oi.getTypeName();
    final int argPos = typeStr.indexOf('(');
    if (argPos > 0) {
      typeStr = typeStr.substring(0, argPos);
    }
    return TYPE_HIVE_TO_MONARCH_MAP.containsKey(typeStr);
  } else if (oi instanceof ListObjectInspector) {
    ListObjectInspector loi = (ListObjectInspector)oi;
    return isMonarchTypeSupported(loi.getListElementObjectInspector());
  } else if (oi instanceof MapObjectInspector) {
    MapObjectInspector moi = (MapObjectInspector)oi;
    return isMonarchTypeSupported(moi.getMapKeyObjectInspector()) &&
      isMonarchTypeSupported(moi.getMapValueObjectInspector());
  } else if (oi instanceof StructObjectInspector) {
    return ((StructObjectInspector) oi).getAllStructFieldRefs().stream()
      .map(StructField::getFieldObjectInspector)
      .allMatch(MonarchPredicateHandler::isMonarchTypeSupported);
  } else if (oi instanceof UnionObjectInspector) {
    return ((UnionObjectInspector) oi).getObjectInspectors().stream()
      .allMatch(MonarchPredicateHandler::isMonarchTypeSupported);
  }
  return false;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:27,代码来源:MonarchPredicateHandler.java

示例2: kNNentries

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
@Nonnull
private static Int2ObjectMap<Int2FloatMap> kNNentries(@Nonnull final Object kNNiObj,
        @Nonnull final MapObjectInspector knnItemsOI,
        @Nonnull final PrimitiveObjectInspector knnItemsKeyOI,
        @Nonnull final MapObjectInspector knnItemsValueOI,
        @Nonnull final PrimitiveObjectInspector knnItemsValueKeyOI,
        @Nonnull final PrimitiveObjectInspector knnItemsValueValueOI,
        @Nullable Int2ObjectMap<Int2FloatMap> knnItems, @Nonnull final MutableInt nnzKNNi) {
    if (knnItems == null) {
        knnItems = new Int2ObjectOpenHashMap<>(1024);
    } else {
        knnItems.clear();
    }

    int numElementOfKNNItems = 0;
    for (Map.Entry<?, ?> entry : knnItemsOI.getMap(kNNiObj).entrySet()) {
        int user = PrimitiveObjectInspectorUtils.getInt(entry.getKey(), knnItemsKeyOI);
        Int2FloatMap ru = int2floatMap(knnItemsValueOI.getMap(entry.getValue()),
            knnItemsValueKeyOI, knnItemsValueValueOI);
        knnItems.put(user, ru);
        numElementOfKNNItems += ru.size();
    }

    nnzKNNi.setValue(numElementOfKNNItems);
    return knnItems;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:SlimUDTF.java

示例3: terminalOutputOI

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
@Nonnull
private static StructObjectInspector terminalOutputOI(
        @CheckForNull PrimitiveObjectInspector[] inputOIs) {
    Preconditions.checkNotNull(inputOIs);
    Preconditions.checkArgument(inputOIs.length >= 1, inputOIs.length);

    final List<String> fieldNames = new ArrayList<>(inputOIs.length);
    final List<ObjectInspector> fieldOIs = new ArrayList<>(inputOIs.length);
    for (int i = 0; i < inputOIs.length; i++) {
        fieldNames.add("f" + String.valueOf(i + 1));
        ObjectInspector keyOI = ObjectInspectorUtils.getStandardObjectInspector(
            inputOIs[i], ObjectInspectorCopyOption.WRITABLE);
        MapObjectInspector mapOI = ObjectInspectorFactory.getStandardMapObjectInspector(
            keyOI, PrimitiveObjectInspectorFactory.javaIntObjectInspector);
        fieldOIs.add(mapOI);
    }
    return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:19,代码来源:OnehotEncodingUDAF.java

示例4: initialize

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length != 2) {
        throw new UDFArgumentLengthException(
            "map_tail_n only takes 2 arguments: map<object, object>, int");
    }
    if (!(arguments[0] instanceof MapObjectInspector)) {
        throw new UDFArgumentException("The first argument must be a map");
    }
    this.mapObjectInspector = (MapObjectInspector) arguments[0];
    if (!(arguments[1] instanceof IntObjectInspector)) {
        throw new UDFArgumentException("The second argument must be an int");
    }
    this.intObjectInspector = (IntObjectInspector) arguments[1];

    ObjectInspector keyOI = ObjectInspectorUtils.getStandardObjectInspector(mapObjectInspector.getMapKeyObjectInspector());
    ObjectInspector valueOI = mapObjectInspector.getMapValueObjectInspector();

    return ObjectInspectorFactory.getStandardMapObjectInspector(keyOI, valueOI);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:21,代码来源:MapTailNUDF.java

示例5: hasDateType

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
static boolean hasDateType(ObjectInspector objectInspector)
{
    if (objectInspector instanceof PrimitiveObjectInspector) {
        PrimitiveObjectInspector primitiveInspector = (PrimitiveObjectInspector) objectInspector;
        return primitiveInspector.getPrimitiveCategory() == PrimitiveCategory.DATE;
    }
    if (objectInspector instanceof ListObjectInspector) {
        ListObjectInspector listInspector = (ListObjectInspector) objectInspector;
        return hasDateType(listInspector.getListElementObjectInspector());
    }
    if (objectInspector instanceof MapObjectInspector) {
        MapObjectInspector mapInspector = (MapObjectInspector) objectInspector;
        return hasDateType(mapInspector.getMapKeyObjectInspector()) ||
                hasDateType(mapInspector.getMapValueObjectInspector());
    }
    if (objectInspector instanceof StructObjectInspector) {
        for (StructField field : ((StructObjectInspector) objectInspector).getAllStructFieldRefs()) {
            if (hasDateType(field.getFieldObjectInspector())) {
                return true;
            }
        }
        return false;
    }
    throw new IllegalArgumentException("Unknown object inspector type " + objectInspector);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:DwrfRecordCursorProvider.java

示例6: deparseObject

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
/**
 * Deparse a Hive object into a Jackson-serializable object. This uses
 * the ObjectInspector to extract the column data.
 *
 * @param obj - Hive object to deparse
 * @param oi - ObjectInspector for the object
 * @return - A deparsed object
 */
private Object deparseObject(Object obj, ObjectInspector oi) {
    switch (oi.getCategory()) {
        case LIST:
            return deparseList(obj, (ListObjectInspector)oi);
        case MAP:
            return deparseMap(obj, (MapObjectInspector)oi);
        case PRIMITIVE:
            return deparsePrimitive(obj, (PrimitiveObjectInspector)oi);
        case STRUCT:
            return deparseStruct(obj, (StructObjectInspector)oi, false);
        case UNION:
            // Unsupported by JSON
        default:
            return null;
    }
}
 
开发者ID:scaleoutsoftware,项目名称:hServer,代码行数:25,代码来源:JsonSerDe.java

示例7: deparseObject

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
/**
 * Deparse a Hive object into a Jackson-serializable object. This uses
 * the ObjectInspector to extract the column data.
 *
 * @param obj - Hive object to deparse
 * @param oi  - ObjectInspector for the object
 * @return - A deparsed object
 */
private Object deparseObject(Object obj, ObjectInspector oi) {
	switch (oi.getCategory()) {
		case LIST:
			return deparseList(obj, (ListObjectInspector) oi);
		case MAP:
			return deparseMap(obj, (MapObjectInspector) oi);
		case PRIMITIVE:
			return deparsePrimitive(obj, (PrimitiveObjectInspector) oi);
		case STRUCT:
			return deparseStruct(obj, (StructObjectInspector) oi, false);
		case UNION:
			// Unsupported by JSON
		default:
			return null;
	}
}
 
开发者ID:micmiu,项目名称:bigdata-tutorial,代码行数:25,代码来源:JSONCDHSerDe.java

示例8: deparseObject

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
/**
 * Deparse a Hive object into a Jackson-serializable object. This uses the
 * ObjectInspector to extract the column data.
 *
 * @param obj
 *            - Hive object to deparse
 * @param oi
 *            - ObjectInspector for the object
 * @return - A deparsed object
 */
private Object deparseObject(final Object obj, final ObjectInspector oi) {
	switch (oi.getCategory()) {
	case PRIMITIVE:
		return deparsePrimitive(obj, (PrimitiveObjectInspector) oi);
	case LIST:
		return deparseList(obj, (ListObjectInspector) oi);
	case MAP:
		return deparseMap(obj, (MapObjectInspector) oi);
	case STRUCT:
		return deparseStruct(obj, (StructObjectInspector) oi, false);
	case UNION:
		// Unsupported by JSON
	default:
		return null;
	}
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:27,代码来源:JSONSerDe.java

示例9: initialize

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
@Override
public StructObjectInspector initialize(ObjectInspector[] args) throws UDFArgumentException {
  if (args.length != 1) {
    throw new UDFArgumentException("explode_map() takes only one argument");
  }

  if (args[0].getCategory() != ObjectInspector.Category.MAP) {
    throw new UDFArgumentException("explode_map() takes a map as a parameter");
  }
  mapOI = (MapObjectInspector) args[0];

  ArrayList<String> fieldNames = new ArrayList<String>();
  ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>();
  fieldNames.add("col1");
  fieldNames.add("col2");
  fieldOIs.add(mapOI.getMapKeyObjectInspector());
  fieldOIs.add(mapOI.getMapValueObjectInspector());
  return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames,
                                                                 fieldOIs);
}
 
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:21,代码来源:UDTFExplodeMap.java

示例10: initialize

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
    throws UDFArgumentException {

  mapOI = (MapObjectInspector)arguments[0];
  arrayOI = (ListObjectInspector)arguments[1];

  // Check map against key.
  ObjectInspector mapItemOI = mapOI.getMapKeyObjectInspector();

  ObjectInspector listItemOI = arrayOI.getListElementObjectInspector();

  if (!ObjectInspectorUtils.compareTypes(mapItemOI, listItemOI)) {
    throw new UDFArgumentException("Map key type (" + mapItemOI + ") must match " + 
                                   "list element type (" + listItemOI + ").");
  }

  return ObjectInspectorUtils.getStandardObjectInspector(mapOI,
            ObjectInspectorCopyOption.WRITABLE);
}
 
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:21,代码来源:UDFMapExclude.java

示例11: MapTreeWriter

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
MapTreeWriter(int columnId,
              ObjectInspector inspector,
              StreamFactory writer,
              boolean nullable, Configuration conf,
              boolean useVInts, boolean lowMemoryMode,
              MemoryEstimate memoryEstimate) throws IOException {
  super(columnId, inspector, writer, nullable, conf, useVInts, memoryEstimate);
  MapObjectInspector insp = (MapObjectInspector) inspector;
  childrenWriters = new TreeWriter[2];
  childrenWriters[0] =
    createTreeWriter(insp.getMapKeyObjectInspector(), writer, true, conf, useVInts,
        lowMemoryMode, memoryEstimate);
  childrenWriters[1] =
    createTreeWriter(insp.getMapValueObjectInspector(), writer, true, conf, useVInts,
        lowMemoryMode, memoryEstimate);
  lengths =
    new RunLengthIntegerWriter(writer.createStream(columnId,
        OrcProto.Stream.Kind.LENGTH), false, INT_BYTE_SIZE, useVInts);
  recordPosition(rowIndexPosition);
}
 
开发者ID:facebookarchive,项目名称:hive-dwrf,代码行数:21,代码来源:WriterImpl.java

示例12: write

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
@Override
void write(Object obj) throws IOException {
  long rawDataSize = 0;
  if (obj != null) {
    MapObjectInspector insp = (MapObjectInspector) inspector;
    // this sucks, but it will have to do until we can get a better
    // accessor in the MapObjectInspector.
    Map<?, ?> valueMap = insp.getMap(obj);
    // Don't use getMapSize(), it's inconsistent for some object inspectors
    int len = valueMap.size();
    lengths.write(len);
    for(Map.Entry<?, ?> entry: valueMap.entrySet()) {
      childrenWriters[0].write(entry.getKey());
      childrenWriters[1].write(entry.getValue());
      rawDataSize += childrenWriters[0].getRowRawDataSize();
      rawDataSize += childrenWriters[1].getRowRawDataSize();
    }
  }
  super.write(obj, rawDataSize);
}
 
开发者ID:facebookarchive,项目名称:hive-dwrf,代码行数:21,代码来源:WriterImpl.java

示例13: HiveMapParser

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
public HiveMapParser( final Object row , final MapObjectInspector mapObjectInspector ){
  this.row = row;
  this.mapObjectInspector = mapObjectInspector;
  childObjectInspector = mapObjectInspector.getMapValueObjectInspector();
  childConverter = HivePrimitiveConverterFactory.get( childObjectInspector );

  childHasParser = HiveParserFactory.hasParser( childObjectInspector );
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:9,代码来源:HiveMapParser.java

示例14: get

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
public static IParser get( final ObjectInspector objectInspector , final Object row ){

    switch( objectInspector.getCategory() ){
      case LIST:
        return new HiveListParser( row , (ListObjectInspector)objectInspector );
      case MAP:
        return new HiveMapParser( row , (MapObjectInspector)objectInspector );
      case STRUCT:
        return new HiveStructParser( row , (StructObjectInspector)objectInspector );
      case UNION:
      default:
        return new HiveNullParser();
    }
  }
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:15,代码来源:HiveParserFactory.java

示例15: get

import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector; //导入依赖的package包/类
public static IParser get( final ObjectInspector objectInspector , final Object row ){

    switch( objectInspector.getCategory() ){
      case LIST:
        return new OrcListParser( row , (ListObjectInspector)objectInspector );
      case MAP:
        return new OrcMapParser( row , (MapObjectInspector)objectInspector );
      case STRUCT:
        return new OrcStructParser( row , (StructObjectInspector)objectInspector );
      case UNION:
      default:
        return new OrcNullParser();
    }
  }
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:15,代码来源:OrcParserFactory.java


注:本文中的org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。