@Override // The evaluate() method. The input is passed in as an array of DeferredObjects, so that // computation is not wasted on deserializing them if they're not actually used public Object evaluate(DeferredObject[] arguments) throws HiveException { Object obj = arguments[0].get(); return serde.serializeField(obj, inOi); }
static public void initialize() throws Exception { instance = new JsonSerDe(); Configuration conf = null; Properties tbl = new Properties(); tbl.setProperty(serdeConstants.LIST_COLUMNS, "one,two,three,four,five"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "boolean,float,array<string>,string,timestamp"); instance.initialize(conf, tbl); }
/** * Test of getSerializedClass method, of class JsonSerDe. */ @Test public void testGetSerializedClass() throws Exception { JsonSerDe instance = new JsonSerDe(); initialize(instance); System.out.println("getSerializedClass"); Class expResult = Text.class; Class result = instance.getSerializedClass(); assertEquals(expResult, result); }
@Test public void testDeserializePartialFieldSet() throws Exception { Writable w = new Text("{\"missing\":\"whocares\",\"one\":true,\"three\":[\"red\",\"yellow\",[\"blue\",\"azure\",\"cobalt\",\"teal\"],\"orange\"],\"two\":19.5,\"four\":\"poop\"}"); JsonSerDe instance = new JsonSerDe(); initialize(instance); JSONObject result = (JSONObject) instance.deserialize(w); assertEquals(result.get("four"),"poop"); assertTrue( result.get("three") instanceof JSONArray); assertTrue( ((JSONArray)result.get("three")).get(0) instanceof String ); assertEquals( ((JSONArray)result.get("three")).get(0),"red"); }
public void initialize2(JsonSerDe instance) throws Exception { System.out.println("initialize"); Configuration conf = null; Properties tbl = new Properties(); tbl.setProperty(serdeConstants.LIST_COLUMNS, "one,two,three,four,five"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "boolean,float,array<string>,string,string"); instance.initialize(conf, tbl); }
@Before public void setUp() throws Exception { initialize(); }
@Before public void setUp() throws Exception { initialize(); }
@Before public void setUp() throws Exception { initialize(); }
@Before public void setUp() throws Exception { initialize(); }
@Before public void setUp() throws Exception { initialize(); }
@Before public void setUp() throws Exception { initialize(); }
@Before public void setUp() throws Exception { initialize(); }
static public void initialize() throws Exception { instance = new JsonSerDe(); Configuration conf = null; Properties tbl = new Properties(); // from google video API tbl.setProperty(serdeConstants.LIST_COLUMNS, "country,languages,religions"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "string,array<string>,array<string>".toLowerCase()); instance.initialize(conf, tbl); }
public void initialize(JsonSerDe instance) throws Exception { System.out.println("initialize"); Configuration conf = null; Properties tbl = new Properties(); tbl.setProperty(serdeConstants.LIST_COLUMNS, "one,two,three,four"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "boolean,float,array<string>,string"); instance.initialize(conf, tbl); }
/** * Serializes a Union */ private Object serializeUnion(Object obj, UnionObjectInspector oi) { if(obj == null) return null; return serializeField(obj, oi.getObjectInspectors().get(oi.getTag(obj))); }
static public void initialize() throws Exception { instance = new JsonSerDe(); Configuration conf = null; Properties tbl = new Properties(); // from google video API tbl.setProperty(serdeConstants.LIST_COLUMNS, "country,languages,religions"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "string,string,map<string,string>".toLowerCase()); instance.initialize(conf, tbl); }
public void initialize(JsonSerDe instance) throws Exception { System.out.println("initialize"); Configuration conf = null; Properties tbl = new Properties(); tbl.setProperty(serdeConstants.LIST_COLUMNS, "one"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "string"); instance.initialize(conf, tbl); }
public JsonSerDe getMappedSerde() throws SerDeException { System.out.println("testMapping"); JsonSerDe serde = new JsonSerDe(); Configuration conf = null; Properties tbl = new Properties(); tbl.setProperty(serdeConstants.LIST_COLUMNS, "one,two,three,four,ts"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "boolean,float,array<string>,string,int"); // this means, we call it ts but in data it's 'timestamp' tbl.setProperty("mapping.ts", "timestamp"); serde.initialize(conf, tbl); return serde; }
static public void initialize() throws Exception { instance = new JsonSerDe(); Configuration conf = null; Properties tbl = new Properties(); // from google video API tbl.setProperty(serdeConstants.LIST_COLUMNS, "country,stuff"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "string,uniontype<int,double,array<string>,struct<a:int,b:string>,string>".toLowerCase()); instance.initialize(conf, tbl); }
public JsonSerDe getNumericSerde() throws SerDeException { System.out.println("testMapping"); JsonSerDe serde = new JsonSerDe(); Configuration conf = null; Properties tbl = new Properties(); tbl.setProperty(serdeConstants.LIST_COLUMNS, "cboolean,ctinyint,csmallint,cint,cbigint,cfloat,cdouble"); tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, "boolean,tinyint,smallint,int,bigint,float,double"); serde.initialize(conf, tbl); return serde; }