use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory.getStandardStructObjectInspector in project hive by apache.
the class MapJoinTestDescription method computeDerived.
public void computeDerived() {
bigTableColumnNamesList = Arrays.asList(bigTableColumnNames);
bigTableKeyColumnNames = new String[bigTableKeyColumnNums.length];
bigTableKeyTypeInfos = new TypeInfo[bigTableKeyColumnNums.length];
for (int i = 0; i < bigTableKeyColumnNums.length; i++) {
bigTableKeyColumnNames[i] = bigTableColumnNames[bigTableKeyColumnNums[i]];
bigTableKeyTypeInfos[i] = bigTableTypeInfos[bigTableKeyColumnNums[i]];
}
smallTableValueColumnNamesList = Arrays.asList(smallTableValueColumnNames);
bigTableObjectInspectors = new ObjectInspector[bigTableTypeInfos.length];
for (int i = 0; i < bigTableTypeInfos.length; i++) {
bigTableObjectInspectors[i] = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector((PrimitiveTypeInfo) bigTableTypeInfos[i]);
}
bigTableObjectInspectorsList = Arrays.asList(bigTableObjectInspectors);
smallTableObjectInspectors = new ObjectInspector[smallTableValueTypeInfos.length];
smallTablePrimitiveCategories = new PrimitiveCategory[smallTableValueTypeInfos.length];
smallTableValuePrimitiveTypeInfos = new PrimitiveTypeInfo[smallTableValueTypeInfos.length];
for (int i = 0; i < smallTableValueTypeInfos.length; i++) {
PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) smallTableValueTypeInfos[i];
smallTableObjectInspectors[i] = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(primitiveTypeInfo);
smallTablePrimitiveCategories[i] = primitiveTypeInfo.getPrimitiveCategory();
smallTableValuePrimitiveTypeInfos[i] = primitiveTypeInfo;
}
smallTableObjectInspectorsList = Arrays.asList(smallTableObjectInspectors);
bigTableStandardObjectInspector = ObjectInspectorFactory.getStandardStructObjectInspector(bigTableColumnNamesList, Arrays.asList((ObjectInspector[]) bigTableObjectInspectors));
smallTableStandardObjectInspector = ObjectInspectorFactory.getStandardStructObjectInspector(smallTableValueColumnNamesList, Arrays.asList((ObjectInspector[]) smallTableObjectInspectors));
inputObjectInspectors = new ObjectInspector[] { bigTableStandardObjectInspector, smallTableStandardObjectInspector };
int outputLength = bigTableRetainColumnNums.length + smallTableRetainKeyColumnNums.length + smallTableRetainValueColumnNums.length;
outputColumnNames = createOutputColumnNames(outputLength);
outputTypeInfos = new TypeInfo[outputLength];
int outputIndex = 0;
for (int i = 0; i < bigTableRetainColumnNums.length; i++) {
outputTypeInfos[outputIndex++] = bigTableTypeInfos[bigTableRetainColumnNums[i]];
}
// }
for (int i = 0; i < smallTableRetainValueColumnNums.length; i++) {
outputTypeInfos[outputIndex++] = smallTableValueTypeInfos[smallTableRetainValueColumnNums[i]];
}
outputObjectInspectors = new ObjectInspector[outputLength];
for (int i = 0; i < outputLength; i++) {
PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) outputTypeInfos[i];
outputObjectInspectors[i] = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(primitiveTypeInfo);
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory.getStandardStructObjectInspector in project hive by apache.
the class DataBuilder method createRows.
/**
* returns the InspectableObject array the builder methods
* helped to assemble.
* @return InspectableObject array (objects that have data coupled with
* and object inspector )
*/
public InspectableObject[] createRows() {
InspectableObject[] toReturn = new InspectableObject[this.rows.size()];
for (int i = 0; i < toReturn.length; i++) {
toReturn[i] = new InspectableObject();
toReturn[i].o = rows.get(i);
toReturn[i].oi = ObjectInspectorFactory.getStandardStructObjectInspector(this.columnNames, this.columnTypes);
}
return toReturn;
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory.getStandardStructObjectInspector in project hive by apache.
the class TestGenericUDFExtractUnionValueConverter method convertStruct.
@Test
public void convertStruct() {
ObjectInspector inspector = ObjectInspectorFactory.getStandardStructObjectInspector(Arrays.asList("foo"), Arrays.<ObjectInspector>asList(unionObjectInspector));
Object value = Arrays.asList(union);
@SuppressWarnings("unchecked") List<Object> result = (List<Object>) underTest.convert(value, inspector);
assertThat(result.size(), is(1));
assertThat(result.get(0), is((Object) Arrays.asList("foo", null)));
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory.getStandardStructObjectInspector in project hive by apache.
the class InternalUtil method createStructObjectInspector.
static StructObjectInspector createStructObjectInspector(HCatSchema outputSchema) throws IOException {
if (outputSchema == null) {
throw new IOException("Invalid output schema specified");
}
List<ObjectInspector> fieldInspectors = new ArrayList<ObjectInspector>();
List<String> fieldNames = new ArrayList<String>();
for (HCatFieldSchema hcatFieldSchema : outputSchema.getFields()) {
TypeInfo type = TypeInfoUtils.getTypeInfoFromTypeString(hcatFieldSchema.getTypeString());
fieldNames.add(hcatFieldSchema.getName());
fieldInspectors.add(getObjectInspector(type));
}
StructObjectInspector structInspector = ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldInspectors);
return structInspector;
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory.getStandardStructObjectInspector in project hive by apache.
the class DynamicPartitionPruner method prunePartitionSingleSource.
@VisibleForTesting
protected void prunePartitionSingleSource(String source, SourceInfo si) throws HiveException {
if (si.skipPruning.get()) {
// in this case we've determined that there's too much data
// to prune dynamically.
LOG.info("Skip pruning on " + source + ", column " + si.columnName);
return;
}
Set<Object> values = si.values;
String columnName = si.columnName;
if (LOG.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Pruning ");
sb.append(columnName);
sb.append(" with ");
for (Object value : values) {
sb.append(value == null ? null : value.toString());
sb.append(", ");
}
LOG.debug(sb.toString());
}
ObjectInspector oi = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getPrimitiveTypeInfo(si.columnType));
Converter converter = ObjectInspectorConverters.getConverter(PrimitiveObjectInspectorFactory.javaStringObjectInspector, oi);
StructObjectInspector soi = ObjectInspectorFactory.getStandardStructObjectInspector(Collections.singletonList(columnName), Collections.singletonList(oi));
@SuppressWarnings("rawtypes") ExprNodeEvaluator eval = ExprNodeEvaluatorFactory.get(si.partKey);
eval.initialize(soi);
applyFilterToPartitions(converter, eval, columnName, values);
}
Aggregations