org.apache.hadoop.hive.serde2.objectinspector.SettableListObjectInspector Java Examples

The following examples show how to use org.apache.hadoop.hive.serde2.objectinspector.SettableListObjectInspector. 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
Source File: HiveArray.java    From transport with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void add(StdData e) {
  if (_listObjectInspector instanceof SettableListObjectInspector) {
    SettableListObjectInspector settableListObjectInspector = (SettableListObjectInspector) _listObjectInspector;
    int originalSize = size();
    settableListObjectInspector.resize(_object, originalSize + 1);
    settableListObjectInspector.set(_object, originalSize,
        ((HiveData) e).getUnderlyingDataForObjectInspector(_elementObjectInspector));
    _isObjectModified = true;
  } else {
    throw new RuntimeException("Attempt to modify an immutable Hive object of type: "
        + _listObjectInspector.getClass());
  }
}
 
Example #2
Source File: CacheableObjectInspectorConverters.java    From transport with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a converter that converts objects from one OI to another OI. The
 * returned (converted) object does not belong to the converter. Hence once convertor can be used
 * multiple times within one eval invocation.
 */
public Converter getConverter(ObjectInspector inputOI, ObjectInspector outputOI) {
  // If the inputOI is the same as the outputOI, just return an
  // IdentityConverter.
  if (inputOI.equals(outputOI)) {
    return new ObjectInspectorConverters.IdentityConverter();
  }
  Converter c = getConverterFromCache(inputOI, outputOI);
  if (c != null) {
    return c;
  }
  switch (outputOI.getCategory()) {
    case PRIMITIVE:
      return getConverter((PrimitiveObjectInspector) inputOI, (PrimitiveObjectInspector) outputOI);
    case STRUCT:
      c = new StructConverter(inputOI, (SettableStructObjectInspector) outputOI);
      break;
    case LIST:
      c = new ListConverter(inputOI, (SettableListObjectInspector) outputOI);
      break;
    case MAP:
      c = new MapConverter(inputOI, (SettableMapObjectInspector) outputOI);
      break;
    default:
      throw new UnsupportedOperationException(
          "Hive internal error: conversion of " + inputOI.getTypeName() + " to " + outputOI.getTypeName()
              + " not supported yet.");
  }
  cacheConverter(inputOI, outputOI, c);
  return c;
}
 
Example #3
Source File: CacheableObjectInspectorConverters.java    From transport with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ListConverter(ObjectInspector inputOI, SettableListObjectInspector outputOI) {
  if (inputOI instanceof ListObjectInspector) {
    this.inputOI = (ListObjectInspector) inputOI;
    this.outputOI = outputOI;
    inputElementOI = this.inputOI.getListElementObjectInspector();
    outputElementOI = outputOI.getListElementObjectInspector();
    elementConverter = getConverter(inputElementOI, outputElementOI);
  } else if (!(inputOI instanceof VoidObjectInspector)) {
    throw new UnsupportedOperationException(
        "Hive internal error: conversion of " + inputOI.getTypeName() + " to " + outputOI.getTypeName()
            + "not supported yet.");
  }
}