Java Code Examples for org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory#writableIntObjectInspector()

The following examples show how to use org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory#writableIntObjectInspector() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
*
* Initialize HiveUDF and create object inspectors. It requires that the argument length is = 1 and that the ObjectInspector of arguments[0] is of type StructObjectInspector
*
* @param arguments array of length 1 containing one StructObjectInspector
*
* @return ObjectInspector that is able to parse the result of the evaluate method of the UDF (BinaryWritable)
*
* @throws org.apache.hadoop.hive.ql.exec.UDFArgumentException in case the first argument is not of StructObjectInspector
* @throws org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException in case the number of arguments is != 1
*
*/

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
	if (arguments==null) {
      		throw new UDFArgumentLengthException("bitcoinTransactionHash only takes one argument: Struct<BitcoinTransaction> ");
	}
  	if (arguments.length != 1) {
      		throw new UDFArgumentLengthException("bitcoinTransactionHash only takes one argument: Struct<BitcoinTransaction> ");
	}
	if (!(arguments[0] instanceof StructObjectInspector)) { 
		throw new UDFArgumentException("first argument must be a Struct containing a BitcoinTransaction");
	}
	this.soi = (StructObjectInspector)arguments[0];
	// these are only used for bitcointransaction structs exported to other formats, such as ORC
	this.wboi = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
	this.wioi = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
	this.wloi = PrimitiveObjectInspectorFactory.writableLongObjectInspector;
	this.hdoi = PrimitiveObjectInspectorFactory.javaHiveDecimalObjectInspector;
	// the UDF returns the hash value of a BitcoinTransaction as byte array
	return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
}
 
Example 2
/**
*
* Initialize HiveUDF and create object inspectors. It requires that the argument length is = 1 and that the ObjectInspector of arguments[0] is of type StructObjectInspector
*
* @param arguments array of length 1 containing one StructObjectInspector
*
* @return ObjectInspector that is able to parse the result of the evaluate method of the UDF (BinaryWritable)
*
* @throws org.apache.hadoop.hive.ql.exec.UDFArgumentException in case the first argument is not of StructObjectInspector
* @throws org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException in case the number of arguments is != 1
*
*/

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
	if (arguments==null) {
      		throw new UDFArgumentLengthException("bitcoinTransactionHash only takes one argument: Struct<BitcoinTransaction> ");
	}
  	if (arguments.length != 1) {
      		throw new UDFArgumentLengthException("bitcoinTransactionHash only takes one argument: Struct<BitcoinTransaction> ");
	}
	if (!(arguments[0] instanceof StructObjectInspector)) { 
		throw new UDFArgumentException("first argument must be a Struct containing a BitcoinTransaction");
	}
	this.soi = (StructObjectInspector)arguments[0];
	// these are only used for bitcointransaction structs exported to other formats, such as ORC
	this.wboi = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
	this.wioi = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
	this.wloi = PrimitiveObjectInspectorFactory.writableLongObjectInspector;
	this.wbyoi = PrimitiveObjectInspectorFactory.writableByteObjectInspector;
	this.hdoi = PrimitiveObjectInspectorFactory.javaHiveDecimalObjectInspector;
	// the UDF returns the hash value of a BitcoinTransaction as byte array
	return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
}
 
Example 3
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 4 && argOIs.length != 5) {
        throw new UDFArgumentException("tree_predict_v1 takes 4 or 5 arguments");
    }

    this.modelTypeOI = HiveUtils.asIntegerOI(argOIs, 1);
    this.stringOI = HiveUtils.asStringOI(argOIs, 2);
    ListObjectInspector listOI = HiveUtils.asListOI(argOIs, 3);
    this.featureListOI = listOI;
    ObjectInspector elemOI = listOI.getListElementObjectInspector();
    this.featureElemOI = HiveUtils.asDoubleCompatibleOI(elemOI);

    boolean classification = false;
    if (argOIs.length == 5) {
        classification = HiveUtils.getConstBoolean(argOIs, 4);
    }
    this.classification = classification;

    if (classification) {
        return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    } else {
        return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    }
}
 
Example 4
private ObjectInspector getObjectInspector(final TypeInfo typeInfo) {
    if (typeInfo.equals(TypeInfoFactory.doubleTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.booleanTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.floatTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.intTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.longTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.stringTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.timestampTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableTimestampObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.dateTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableDateObjectInspector;
    } else {
        throw new UnsupportedOperationException("Unknown field type: " + typeInfo);
    }
}
 
Example 5
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    // Check if two arguments were passed
    if (arguments.length != ARG_COUNT) {
        throw new UDFArgumentLengthException(
                "The function array_element_at(array, index) takes exactly " + ARG_COUNT + " arguments.");
    }

    // Check if ARRAY_IDX argument is of category LIST
    if (!arguments[ARRAY_IDX].getCategory().equals(ObjectInspector.Category.LIST)) {
        throw new UDFArgumentTypeException(ARRAY_IDX,
                "\"" + org.apache.hadoop.hive.serde.serdeConstants.LIST_TYPE_NAME + "\" "
                        + "expected at function array_element_at, but "
                        + "\"" + arguments[ARRAY_IDX].getTypeName() + "\" "
                        + "is found");
    }

    arrayOI = (ListObjectInspector) arguments[ARRAY_IDX];
    arrayElementOI = arrayOI.getListElementObjectInspector();
    indexOI = arguments[INDEX_IDX];

    ObjectInspector expectOI = PrimitiveObjectInspectorFactory.writableIntObjectInspector;

    // Check if index and expect are of same type
    if (!ObjectInspectorUtils.compareTypes(expectOI, indexOI)) {
        throw new UDFArgumentTypeException(INDEX_IDX,
                "\"" + expectOI.getTypeName() + "\""
                        + " expected at function array_element_at, but "
                        + "\"" + indexOI.getTypeName() + "\""
                        + " is found");
    }

    return arrayElementOI;
}
 
Example 6
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    // Check if two arguments were passed
    if (arguments.length != ARG_COUNT) {
        throw new UDFArgumentLengthException(
                "The function array_slice(array, start, length) takes exactly " + ARG_COUNT + " arguments.");
    }

    // Check if ARRAY_IDX argument is of category LIST
    if (!arguments[ARRAY_IDX].getCategory().equals(ObjectInspector.Category.LIST)) {
        throw new UDFArgumentTypeException(ARRAY_IDX,
                "\"" + org.apache.hadoop.hive.serde.serdeConstants.LIST_TYPE_NAME + "\" "
                        + "expected at function array_slice, but "
                        + "\"" + arguments[ARRAY_IDX].getTypeName() + "\" "
                        + "is found");
    }

    arrayOI = (ListObjectInspector) arguments[ARRAY_IDX];
    arrayElementOI = arrayOI.getListElementObjectInspector();

    ObjectInspector expectOI = PrimitiveObjectInspectorFactory.writableIntObjectInspector;

    // Check if value and expect are of same type
    for (int i = 1; i < 3; i++) {
        if (!ObjectInspectorUtils.compareTypes(expectOI, arguments[i])) {
            throw new UDFArgumentTypeException(i,
                    "\"" + expectOI.getTypeName() + "\""
                            + " expected at function array_slice, but "
                            + "\"" + arguments[i].getTypeName() + "\""
                            + " is found");
        }
    }

    return ObjectInspectorFactory.getStandardListObjectInspector(arrayElementOI);
}
 
Example 7
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
	if (arguments==null) {
     		throw new UDFArgumentLengthException("ethereumGetChainId only takes one argument: Struct<EthereumTransction> ");
	}
	if (arguments.length != 1) {
     		throw new UDFArgumentLengthException("ethereumGetChainId only takes one argument: Struct<EthereumTransction> ");
	}
	if (!(arguments[0] instanceof StructObjectInspector)) { 
	throw new UDFArgumentException("first argument must be a Struct containing a EthereumTransction");
	}
	this.ethereumUDFUtil=new EthereumUDFUtil((StructObjectInspector) arguments[0]);
	return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
}
 
Example 8
Source Project: incubator-hivemall   File: Lat2TileYUDF.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("_FUNC_ takes exactly 2 arguments: " + argOIs.length);
    }
    this.latOI = HiveUtils.asDoubleCompatibleOI(argOIs[0]);
    this.zoomOI = HiveUtils.asIntegerOI(argOIs[1]);

    this.result = new IntWritable();
    return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
}
 
Example 9
Source Project: incubator-hivemall   File: Lon2TileXUDF.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("_FUNC_ takes exactly 2 arguments: " + argOIs.length);
    }
    this.lonOI = HiveUtils.asDoubleCompatibleOI(argOIs[0]);
    this.zoomOI = HiveUtils.asIntegerOI(argOIs[1]);

    this.result = new IntWritable();
    return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
}
 
Example 10
Source Project: incubator-hivemall   File: ArgminUDF.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 1) {
        throw new UDFArgumentException("argmin takes exactly one argument: " + argOIs.length);
    }
    this.listOI = HiveUtils.asListOI(argOIs[0]);
    this.elemOI = HiveUtils.asPrimitiveObjectInspector(listOI.getListElementObjectInspector());

    this.result = new IntWritable();

    return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
}
 
Example 11
Source Project: incubator-hivemall   File: ArgmaxUDF.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 1) {
        throw new UDFArgumentException("argmax takes exactly one argument: " + argOIs.length);
    }
    this.listOI = HiveUtils.asListOI(argOIs[0]);
    this.elemOI = HiveUtils.asPrimitiveObjectInspector(listOI.getListElementObjectInspector());

    this.result = new IntWritable();

    return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
}
 
Example 12
@Override
public ObjectInspector init(Mode mode, ObjectInspector[] parameters) throws HiveException {
    assert (parameters.length == 1);
    super.init(mode, parameters);
    // initialize input
    if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {// from original data
        this.inputListOI = (ListObjectInspector) parameters[0];
        this.inputListElemOI =
                HiveUtils.asDoubleCompatibleOI(inputListOI.getListElementObjectInspector());
    } else {// from partial aggregation
        StructObjectInspector soi = (StructObjectInspector) parameters[0];
        this.internalMergeOI = soi;
        this.sizeField = soi.getStructFieldRef("size");
        this.sumField = soi.getStructFieldRef("sum");
        this.countField = soi.getStructFieldRef("count");
        this.sizeOI = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
        this.sumOI = ObjectInspectorFactory.getStandardListObjectInspector(
            PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
        this.countOI = ObjectInspectorFactory.getStandardListObjectInspector(
            PrimitiveObjectInspectorFactory.writableLongObjectInspector);
    }

    // initialize output
    final ObjectInspector outputOI;
    if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {// terminatePartial
        outputOI = internalMergeOI();
    } else {// terminate
        outputOI = ObjectInspectorFactory.getStandardListObjectInspector(
            PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
    }
    return outputOI;
}
 
Example 13
private ObjectInspector getObjectInspector(final TypeInfo typeInfo) {
  if (typeInfo.equals(TypeInfoFactory.doubleTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.booleanTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.floatTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.intTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.longTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.stringTypeInfo)) {
    return ParquetPrimitiveInspectorFactory.parquetStringInspector;
  } else if (typeInfo.getCategory().equals(Category.STRUCT)) {
    return new ArrayWritableObjectInspector((StructTypeInfo) typeInfo);
  } else if (typeInfo.getCategory().equals(Category.LIST)) {
    final TypeInfo subTypeInfo = ((ListTypeInfo) typeInfo).getListElementTypeInfo();
    return new ParquetHiveArrayInspector(getObjectInspector(subTypeInfo));
  } else if (typeInfo.getCategory().equals(Category.MAP)) {
    final TypeInfo keyTypeInfo = ((MapTypeInfo) typeInfo).getMapKeyTypeInfo();
    final TypeInfo valueTypeInfo = ((MapTypeInfo) typeInfo).getMapValueTypeInfo();
    if (keyTypeInfo.equals(TypeInfoFactory.stringTypeInfo) || keyTypeInfo.equals(TypeInfoFactory.byteTypeInfo)
            || keyTypeInfo.equals(TypeInfoFactory.shortTypeInfo)) {
      return new DeepParquetHiveMapInspector(getObjectInspector(keyTypeInfo), getObjectInspector(valueTypeInfo));
    } else {
      return new StandardParquetHiveMapInspector(getObjectInspector(keyTypeInfo), getObjectInspector(valueTypeInfo));
    }
  } else if (typeInfo.equals(TypeInfoFactory.timestampTypeInfo)) {
    throw new UnsupportedOperationException("timestamp not implemented yet");
  } else if (typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
    return ParquetPrimitiveInspectorFactory.parquetByteInspector;
  } else if (typeInfo.equals(TypeInfoFactory.shortTypeInfo)) {
    return ParquetPrimitiveInspectorFactory.parquetShortInspector;
  } else {
    throw new IllegalArgumentException("Unknown field info: " + typeInfo);
  }

}
 
Example 14
public static ObjectInspector createWritableObjectInspector(int columnId,
                                             List<OrcProto.Type> types){
  OrcProto.Type type = types.get(columnId);
  switch (type.getKind()) {
    case FLOAT:
      return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
    case DOUBLE:
      return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    case BOOLEAN:
      return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
    case BYTE:
      return PrimitiveObjectInspectorFactory.writableByteObjectInspector;
    case SHORT:
      return PrimitiveObjectInspectorFactory.writableShortObjectInspector;
    case INT:
      return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    case LONG:
      return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
    case BINARY:
      return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
    case STRING:
      return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    case TIMESTAMP:
      return PrimitiveObjectInspectorFactory.javaTimestampObjectInspector;
    case STRUCT:
      return new OrcStruct.OrcStructInspector(columnId, types);
    case UNION:
      return new OrcUnion.OrcUnionObjectInspector(columnId, types);
    case MAP:
      return new OrcStruct.OrcMapObjectInspector(columnId, types);
    case LIST:
      return new OrcStruct.OrcListObjectInspector(columnId, types);
    default:
      throw new UnsupportedOperationException("Unknown type " +
        type.getKind());
  }
}
 
Example 15
public static ObjectInspector craeteObjectInspectorFromTypeInfo( final TypeInfo typeInfo ){
  switch ( typeInfo.getCategory() ){
    case STRUCT:
      return new MDSStructObjectInspector( (StructTypeInfo)typeInfo );
    case MAP:
      return new MDSMapObjectInspector( (MapTypeInfo)typeInfo );
    case LIST:
      return new MDSListObjectInspector( (ListTypeInfo)typeInfo );
    case UNION:
      UnionTypeInfo unionTypeInfo = (UnionTypeInfo)typeInfo;
      List<ObjectInspector> unionList = new ArrayList<ObjectInspector>();
      for( TypeInfo childTypeInfo : unionTypeInfo.getAllUnionObjectTypeInfos() ){
        unionList.add( craeteObjectInspectorFromTypeInfo( childTypeInfo ) );
      }
      return ObjectInspectorFactory.getStandardUnionObjectInspector( unionList );
    case PRIMITIVE:
      PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo)typeInfo;
      switch( primitiveTypeInfo.getPrimitiveCategory() ){
        case STRING:
          return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
        case BINARY:
          return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
        case BOOLEAN:
          return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
        case BYTE:
          return PrimitiveObjectInspectorFactory.writableByteObjectInspector;
        case DOUBLE:
          return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
        case FLOAT:
          return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
        case INT:
          return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
        case LONG:
          return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
        case SHORT:
          return PrimitiveObjectInspectorFactory.writableShortObjectInspector;

        case DATE:
        case DECIMAL:
        case TIMESTAMP:
        case VOID:
        default:
        throw new UnsupportedOperationException( "Unknown primitive category " + primitiveTypeInfo.getPrimitiveCategory() );
      }
    default:
      throw new UnsupportedOperationException( "Unknown category " + typeInfo.getCategory() );
  }
}
 
Example 16
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentLengthException("Specify two arguments :" + argOIs.length);
    }

    if (HiveUtils.isListOI(argOIs[0]) && HiveUtils.isMapOI(argOIs[1])) {
        // feature_binning(array<features::string> features, map<string, array<number>> quantiles_map)

        if (!HiveUtils.isStringOI(
            ((ListObjectInspector) argOIs[0]).getListElementObjectInspector())) {
            throw new UDFArgumentTypeException(0,
                "Only array<string> type argument can be accepted but "
                        + argOIs[0].getTypeName() + " was passed as `features`");
        }
        featuresOI = HiveUtils.asListOI(argOIs[0]);
        featureOI = HiveUtils.asStringOI(featuresOI.getListElementObjectInspector());

        quantilesMapOI = HiveUtils.asMapOI(argOIs[1]);
        if (!HiveUtils.isStringOI(quantilesMapOI.getMapKeyObjectInspector())
                || !HiveUtils.isListOI(quantilesMapOI.getMapValueObjectInspector())
                || !HiveUtils.isNumberOI(
                    ((ListObjectInspector) quantilesMapOI.getMapValueObjectInspector()).getListElementObjectInspector())) {
            throw new UDFArgumentTypeException(1,
                "Only map<string, array<number>> type argument can be accepted but "
                        + argOIs[1].getTypeName() + " was passed as `quantiles_map`");
        }
        keyOI = HiveUtils.asStringOI(quantilesMapOI.getMapKeyObjectInspector());
        quantilesOI = HiveUtils.asListOI(quantilesMapOI.getMapValueObjectInspector());
        quantileOI =
                HiveUtils.asDoubleCompatibleOI(quantilesOI.getListElementObjectInspector());

        multiple = true;

        return ObjectInspectorFactory.getStandardListObjectInspector(
            PrimitiveObjectInspectorFactory.writableStringObjectInspector);
    } else if (HiveUtils.isPrimitiveOI(argOIs[0]) && HiveUtils.isListOI(argOIs[1])) {
        // feature_binning(number weight, array<number> quantiles)

        weightOI = HiveUtils.asDoubleCompatibleOI(argOIs[0]);

        quantilesOI = HiveUtils.asListOI(argOIs[1]);
        if (!HiveUtils.isNumberOI(quantilesOI.getListElementObjectInspector())) {
            throw new UDFArgumentTypeException(1,
                "Only array<number> type argument can be accepted but "
                        + argOIs[1].getTypeName() + " was passed as `quantiles`");
        }
        quantileOI =
                HiveUtils.asDoubleCompatibleOI(quantilesOI.getListElementObjectInspector());

        multiple = false;

        return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    } else {
        throw new UDFArgumentTypeException(0,
            "Only <array<features::string>, map<string, array<number>>> "
                    + "or <number, array<number>> type arguments can be accepted but <"
                    + argOIs[0].getTypeName() + ", " + argOIs[1].getTypeName()
                    + "> was passed.");
    }
}
 
Example 17
@Test
public void testWritableIntFeature() throws Exception {
    List<IntWritable> x = Arrays.asList(new IntWritable(111), new IntWritable(222));
    ObjectInspector featureOI = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    testFeature(x, featureOI, IntWritable.class, Integer.class);
}
 
Example 18
@Test
public void testWritableIntFeature() throws Exception {
    List<IntWritable> x = Arrays.asList(new IntWritable(111), new IntWritable(222));
    ObjectInspector featureOI = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    testFeature(x, featureOI, IntWritable.class, Integer.class);
}
 
Example 19
public static ObjectInspector createWritableObjectInspector(TypeInfo info) {
  switch (info.getCategory()) {
    case PRIMITIVE:
      switch (((PrimitiveTypeInfo) info).getPrimitiveCategory()) {
        case FLOAT:
          return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
        case DOUBLE:
          return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
        case BOOLEAN:
          return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
        case BYTE:
          return PrimitiveObjectInspectorFactory.writableByteObjectInspector;
        case SHORT:
          return PrimitiveObjectInspectorFactory.writableShortObjectInspector;
        case INT:
          return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
        case LONG:
          return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
        case BINARY:
          return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
        case STRING:
          return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
        case TIMESTAMP:
          return PrimitiveObjectInspectorFactory.javaTimestampObjectInspector;
        default:
          throw new IllegalArgumentException("Unknown primitive type " +
            ((PrimitiveTypeInfo) info).getPrimitiveCategory());
      }
    case STRUCT:
      return new OrcStruct.OrcStructInspector((StructTypeInfo) info);
    case UNION:
      return new OrcUnion.OrcUnionObjectInspector((UnionTypeInfo) info);
    case MAP:
      return new OrcStruct.OrcMapObjectInspector((MapTypeInfo) info);
    case LIST:
      return new OrcStruct.OrcListObjectInspector((ListTypeInfo) info);
    default:
      throw new IllegalArgumentException("Unknown type " +
        info.getCategory());
  }
}