本文整理匯總了Java中org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.getPrimitiveJavaObject方法的典型用法代碼示例。如果您正苦於以下問題:Java PrimitiveObjectInspector.getPrimitiveJavaObject方法的具體用法?Java PrimitiveObjectInspector.getPrimitiveJavaObject怎麽用?Java PrimitiveObjectInspector.getPrimitiveJavaObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector
的用法示例。
在下文中一共展示了PrimitiveObjectInspector.getPrimitiveJavaObject方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
DeferredObject jsonDeferredObject = arguments[0];
String json = null;
if (jsonOI.getCategory() == Category.STRUCT){
//StructObjectInspector structOI = (StructObjectInspector)jsonOI;
// TODO support structs
} else {
PrimitiveObjectInspector primOI = (PrimitiveObjectInspector)jsonOI;
json = (String)primOI.getPrimitiveJavaObject(jsonDeferredObject.get());
}
try {
OGCGeometry ogcGeom = OGCGeometry.fromGeoJson(json);
return GeometryUtils.geometryToEsriShapeBytesWritable(ogcGeom);
} catch (Exception e) {
LogUtils.Log_InvalidText(LOG, json);
}
return null;
}
示例2: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
DeferredObject jsonDeferredObject = arguments[0];
String json = null;
if (jsonOI.getCategory() == Category.STRUCT){
//StructObjectInspector structOI = (StructObjectInspector)jsonOI;
// TODO support structs
} else {
PrimitiveObjectInspector primOI = (PrimitiveObjectInspector)jsonOI;
json = (String)primOI.getPrimitiveJavaObject(jsonDeferredObject.get());
}
try {
OGCGeometry ogcGeom = OGCGeometry.fromJson(json);
return GeometryUtils.geometryToEsriShapeBytesWritable(ogcGeom);
} catch (Exception e) {
}
return null;
}
示例3: testSimpleXmlMap
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public void testSimpleXmlMap() throws SerDeException {
XmlSerDe xmlSerDe = new XmlSerDe();
Configuration configuration = new Configuration();
Properties properties = new Properties();
properties.put(LIST_COLUMNS, "test");
properties.put(LIST_COLUMN_TYPES, "map<string,string>");
properties.setProperty("column.xpath.test", "//*[contains(name(),'test')]");
xmlSerDe.initialize(configuration, properties);
Text text = new Text();
text.set("<root><test1>string1</test1><test2>string2</test2></root>");
Object o = xmlSerDe.deserialize(text);
XmlStructObjectInspector structInspector = ((XmlStructObjectInspector) xmlSerDe.getObjectInspector());
StructField structField = structInspector.getStructFieldRef("test");
Object data = structInspector.getStructFieldData(o, structField);
XmlMapObjectInspector fieldInspector = (XmlMapObjectInspector) structField.getFieldObjectInspector();
Map map = fieldInspector.getMap(data);
PrimitiveObjectInspector valueObjectInspector = (PrimitiveObjectInspector) fieldInspector.getMapValueObjectInspector();
String test = (String) valueObjectInspector.getPrimitiveJavaObject(map.get("test1"));
assertEquals("string1", test);
}
示例4: deparseObject
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
public static Object deparseObject(Object field, ObjectInspector fieldOI) throws SerDeException {
switch(fieldOI.getCategory()) {
case PRIMITIVE: {
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) fieldOI;
return oi.getPrimitiveJavaObject(field);
}
case LIST: {
ListObjectInspector listOI = (ListObjectInspector) fieldOI;
List<?> elements = listOI.getList(field);
List<Object> list = new ArrayList<Object>(elements.size());
ObjectInspector elemOI = listOI.getListElementObjectInspector();
for(Object elem : elements) {
Object o = deparseObject(elem, elemOI);
list.add(o);
}
return list;
}
default:
throw new SerDeException("Unexpected fieldOI: " + fieldOI);
}
}
示例5: loadValues
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
private static void loadValues(Object2ObjectMap<Object, Object> map, File file,
PrimitiveObjectInspector keyOI, PrimitiveObjectInspector valueOI) throws IOException,
SerDeException {
if (!file.exists()) {
return;
}
if (!file.getName().endsWith(".crc")) {
if (file.isDirectory()) {
for (File f : file.listFiles()) {
loadValues(map, f, keyOI, valueOI);
}
} else {
LazySimpleSerDe serde = HiveUtils.getKeyValueLineSerde(keyOI, valueOI);
StructObjectInspector lineOI = (StructObjectInspector) serde.getObjectInspector();
StructField keyRef = lineOI.getStructFieldRef("key");
StructField valueRef = lineOI.getStructFieldRef("value");
PrimitiveObjectInspector keyRefOI = (PrimitiveObjectInspector) keyRef.getFieldObjectInspector();
PrimitiveObjectInspector valueRefOI = (PrimitiveObjectInspector) valueRef.getFieldObjectInspector();
BufferedReader reader = null;
try {
reader = HadoopUtils.getBufferedReader(file);
String line;
while ((line = reader.readLine()) != null) {
Text lineText = new Text(line);
Object lineObj = serde.deserialize(lineText);
List<Object> fields = lineOI.getStructFieldsDataAsList(lineObj);
Object f0 = fields.get(0);
Object f1 = fields.get(1);
Object k = keyRefOI.getPrimitiveJavaObject(f0);
Object v = valueRefOI.getPrimitiveWritableObject(valueRefOI.copyObject(f1));
map.put(k, v);
}
} finally {
IOUtils.closeQuietly(reader);
}
}
}
}
示例6: deparseObject
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
public static Object deparseObject(Object field, ObjectInspector fieldOI)
throws SerDeException {
switch (fieldOI.getCategory()) {
case PRIMITIVE: {
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) fieldOI;
return oi.getPrimitiveJavaObject(field);
}
//Kudu doesnt support LIST or MAP based data types
default:
throw new SerDeException("Unexpected fieldOI: " + fieldOI);
}
}
示例7: generateJsonFromWritable
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
private void generateJsonFromWritable(Writable value, int fieldIndex, String label,
PrimitiveObjectInspector poi, JsonGenerator jsonGen)
throws JsonProcessingException, IOException {
Object prim = poi.getPrimitiveJavaObject(value);
if (prim instanceof java.util.Date) {
long epoch = ((java.util.Date)prim).getTime();
long offset = prim instanceof java.sql.Timestamp ? 0 : tz.getOffset(epoch);
jsonGen.writeObjectField(label, epoch - offset); // UTC
} else {
jsonGen.writeObjectField(label, prim);
}
}
示例8: getPrimaryFromOrc
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
public static Object getPrimaryFromOrc(Object obj, PrimitiveObjectInspector poi) {
Object result = null;
if (obj == null) {
return result;
}
switch (poi.getPrimitiveCategory()) {
case FLOAT:
case DOUBLE:
case BOOLEAN:
case INT:
case LONG:
case STRING:
result = poi.getPrimitiveJavaObject(obj);
break;
case CHAR:
result = ((HiveChar)poi.getPrimitiveJavaObject(obj)).getValue();
break;
case VARCHAR:
result = ((HiveVarchar)poi.getPrimitiveJavaObject(obj)).getValue();
break;
case BYTE:
result = (int)(Byte)poi.getPrimitiveJavaObject(obj);
break;
case SHORT:
result = (int)(Short)poi.getPrimitiveJavaObject(obj);
break;
case BINARY:
BytesWritable bw = (BytesWritable) obj;
// Make a copy
result = new DataByteArray(bw.getBytes(), 0, bw.getLength());
break;
case TIMESTAMP:
java.sql.Timestamp origTimeStamp = (java.sql.Timestamp)poi.getPrimitiveJavaObject(obj);
result = new DateTime(origTimeStamp.getTime());
break;
case DATE:
java.sql.Date origDate = (java.sql.Date)poi.getPrimitiveJavaObject(obj);
result = new DateTime(origDate.getTime());
break;
case DECIMAL:
org.apache.hadoop.hive.common.type.HiveDecimal origDecimal =
(org.apache.hadoop.hive.common.type.HiveDecimal)poi.getPrimitiveJavaObject(obj);
result = origDecimal.bigDecimalValue();
break;
default:
throw new IllegalArgumentException("Unknown primitive type " +
(poi).getPrimitiveCategory());
}
return result;
}
示例9: toString
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
private String toString(String columnName, Object data, PrimitiveObjectInspector primitiveObjectInspector)
throws SerDeException {
Object primitiveJavaObject = primitiveObjectInspector.getPrimitiveJavaObject(data);
return toString(columnName, primitiveJavaObject);
}
示例10: extractValue
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
/**
* Override this if it takes more than a cast to convert Hive value into the sketch update type U
* @param data Hive value object
* @param valueInspector PrimitiveObjectInspector for the value
* @return extracted value
* @throws HiveException if anything goes wrong
*/
public U extractValue(final Object data, final PrimitiveObjectInspector valueInspector)
throws HiveException {
@SuppressWarnings("unchecked")
final U value = (U) valueInspector.getPrimitiveJavaObject(data);
return value;
}
示例11: deparsePrimitive
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
/**
* Deparses a primitive type.
*
* @param obj - Hive object to deparse
* @param oi - ObjectInspector for the object
* @return - A deparsed object
*/
private Object deparsePrimitive(Object obj, PrimitiveObjectInspector primOI) {
return primOI.getPrimitiveJavaObject(obj);
}
示例12: deparsePrimitive
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
/**
* Deparses a primitive type.
*
* @param obj - Hive object to deparse
* @param primOI - ObjectInspector for the object
* @return - A deparsed object
*/
private Object deparsePrimitive(Object obj, PrimitiveObjectInspector primOI) {
return primOI.getPrimitiveJavaObject(obj);
}
示例13: deparsePrimitive
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
/**
* Deparses a primitive type.
*
* @param obj
* - Hive object to deparse
* @param oi
* - ObjectInspector for the object
* @return - A deparsed object
*/
private Object deparsePrimitive(final Object obj,
final PrimitiveObjectInspector primOI) {
return primOI.getPrimitiveJavaObject(obj);
}