當前位置: 首頁>>代碼示例>>Java>>正文


Java PrimitiveObjectInspector.getPrimitiveJavaObject方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Esri,項目名稱:spatial-framework-for-hadoop,代碼行數:25,代碼來源:ST_GeomFromGeoJson.java

示例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;
}
 
開發者ID:Esri,項目名稱:spatial-framework-for-hadoop,代碼行數:26,代碼來源:ST_GeomFromJson.java

示例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);
}
 
開發者ID:dvasilen,項目名稱:Hive-XML-SerDe,代碼行數:22,代碼來源:ObjectInspectorTest.java

示例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);
    }
}
 
開發者ID:myui,項目名稱:HiveJdbcStorageHandler,代碼行數:22,代碼來源:HiveJdbcBridgeUtils.java

示例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);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-hivemall,代碼行數:40,代碼來源:DistributedCacheLookupUDF.java

示例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);
    }
}
 
開發者ID:BimalTandel,項目名稱:HiveKudu-Handler,代碼行數:15,代碼來源:HiveKuduBridgeUtils.java

示例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);
	}
}
 
開發者ID:Esri,項目名稱:spatial-framework-for-hadoop,代碼行數:13,代碼來源:BaseJsonSerDe.java

示例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;
}
 
開發者ID:sigmoidanalytics,項目名稱:spork,代碼行數:51,代碼來源:OrcUtils.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:6,代碼來源:BlurSerializer.java

示例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;
}
 
開發者ID:DataSketches,項目名稱:sketches-hive,代碼行數:14,代碼來源:DataToSketchUDAF.java

示例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);
}
 
開發者ID:scaleoutsoftware,項目名稱:hServer,代碼行數:11,代碼來源:JsonSerDe.java

示例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);
}
 
開發者ID:micmiu,項目名稱:bigdata-tutorial,代碼行數:11,代碼來源:JSONCDHSerDe.java

示例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);
}
 
開發者ID:jaibeermalik,項目名稱:searchanalytics-bigdata,代碼行數:14,代碼來源:JSONSerDe.java


注:本文中的org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.getPrimitiveJavaObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。