• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java AbstractPrimitiveObjectInspector类的典型用法和代码示例

java 1次浏览

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

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

示例1: serialize

点赞 2

import org.apache.hadoop.hive.serde2.objectinspector.primitive.AbstractPrimitiveObjectInspector; //导入依赖的package包/类
/**
 * Not use for SOLR search !
 */
@Override
public Writable serialize(final Object obj, final ObjectInspector inspector) throws SerDeException {
	final StructObjectInspector structInspector = (StructObjectInspector) inspector;
	final List<? extends StructField> fields = structInspector.getAllStructFieldRefs();
	if (fields.size() != colNames.size()) {
		throw new SerDeException(String.format(
				"Required %d columns, received %d.", colNames.size(),
				fields.size()));
	}
	
	cachedWritable.clear();
	for (int c = 0; c < fields.size(); c++) {
		StructField structField = fields.get(c);
		if (structField != null) {
			final Object field = structInspector.getStructFieldData(obj,fields.get(c));
			
			//TODO:currently only support hive primitive type
			final AbstractPrimitiveObjectInspector fieldOI = (AbstractPrimitiveObjectInspector)fields.get(c).getFieldObjectInspector();
			Writable value = (Writable)fieldOI.getPrimitiveWritableObject(field);
			log.debug(" value="+value);
			if (value == null) {
				if(PrimitiveCategory.STRING.equals(fieldOI.getPrimitiveCategory())){
					value = NullWritable.get();	
					//value = new Text("");
				}else{
					//TODO: now all treat as number
					value = new IntWritable(0);
				}
			}
			cachedWritable.put(new Text(colNames.get(c)), value);
		}
	}
	return cachedWritable;
}
 

开发者ID:vroyer,
项目名称:hive-solr-search,
代码行数:38,
代码来源:SolrSerDe.java

示例2: serialize

点赞 2

import org.apache.hadoop.hive.serde2.objectinspector.primitive.AbstractPrimitiveObjectInspector; //导入依赖的package包/类
@Override
public Writable serialize(final Object obj, final ObjectInspector inspector) throws SerDeException {
    final StructObjectInspector structInspector = (StructObjectInspector) inspector;
    final List<? extends StructField> fields = structInspector.getAllStructFieldRefs();
    if (fields.size() != columnNames.size()) {
        throw new SerDeException(String.format("Required %d columns, received %d.", columnNames.size(), fields.size()));
    }

    cachedWritable.clear();
    for (int c = 0; c < fieldCount; c++) {
        StructField structField = fields.get(c);
        if (structField != null) {
            final Object field = structInspector.getStructFieldData(obj, fields.get(c));

            // TODO:currently only support hive primitive type
            final AbstractPrimitiveObjectInspector fieldOI = (AbstractPrimitiveObjectInspector) fields.get(c).getFieldObjectInspector();

            Writable value = (Writable) fieldOI.getPrimitiveWritableObject(field);

            if (value == null) {
                if (PrimitiveCategory.STRING.equals(fieldOI.getPrimitiveCategory())) {
                    value = NullWritable.get();
                    // value = new Text("");
                } else {
                    // TODO: now all treat as number
                    value = new IntWritable(0);
                }
            }
            cachedWritable.put(new Text(columnNames.get(c)), value);
        }
    }
    return cachedWritable;
}
 

开发者ID:kernel164,
项目名称:hive-cassandra-dsc,
代码行数:34,
代码来源:Cql3SerDe.java

示例3: serialize

点赞 2

import org.apache.hadoop.hive.serde2.objectinspector.primitive.AbstractPrimitiveObjectInspector; //导入依赖的package包/类
@Override
public Writable serialize(final Object obj, final ObjectInspector inspector)
    throws SerDeException {

  final StructObjectInspector structInspector = (StructObjectInspector) inspector;
  final List<? extends StructField> fields = structInspector
      .getAllStructFieldRefs();
  if (fields.size() != columnNames.size()) {
    throw new SerDeException(String.format(
        "Required %d columns, received %d.", columnNames.size(),
        fields.size()));
  }

  cachedWritable.clear();
  for (int c = 0; c < fieldCount; c++) {
    StructField structField = fields.get(c);
    if (structField != null) {
      final Object field = structInspector.getStructFieldData(obj,
          structField);

      //TODO:currently only support hive primitive type
      final AbstractPrimitiveObjectInspector fieldOI = (AbstractPrimitiveObjectInspector)structField
          .getFieldObjectInspector();

      Writable value = (Writable)fieldOI.getPrimitiveWritableObject(field);

      if (value == null) {
        if(PrimitiveCategory.STRING.equals(fieldOI.getPrimitiveCategory())){
          value = NullWritable.get();
        }else{
          value = new IntWritable(0);
        }
      }
      cachedWritable.put(new Text(columnNames.get(c)), value);
    }
  }
  return cachedWritable;
}
 

开发者ID:amitjaspal,
项目名称:solr-storagehandler,
代码行数:39,
代码来源:SolrSerDe.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)