@SuppressWarnings("deprecation") public static MapJoinKey read(Output output, MapJoinObjectSerDeContext context, Writable writable) throws SerDeException, HiveException { AbstractSerDe serde = context.getSerDe(); Object obj = serde.deserialize(writable); MapJoinKeyObject result = new MapJoinKeyObject(); result.read(serde.getObjectInspector(), obj); return result; }
public static MapJoinKey readFromRow(Output output, MapJoinKey key, Object[] keyObject, List<ObjectInspector> keyFieldsOI, boolean mayReuseKey) throws HiveException { MapJoinKeyObject result = mayReuseKey ? (MapJoinKeyObject)key : new MapJoinKeyObject(); result.readFromRow(keyObject, keyFieldsOI); return result; }
public static MapJoinKey readFromVector(Output output, MapJoinKey key, Object[] keyObject, List<ObjectInspector> keyOIs, boolean mayReuseKey) throws HiveException { MapJoinKeyObject result = mayReuseKey ? (MapJoinKeyObject)key : new MapJoinKeyObject(); result.setKeyObjects(keyObject); return result; }
static MapJoinKeyObject serde(MapJoinKeyObject key, String columns, String types) throws Exception { MapJoinKeyObject result = new MapJoinKeyObject(); ByteArrayInputStream bais; ObjectInputStream in; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); LazyBinarySerDe serde = new LazyBinarySerDe(); Properties props = new Properties(); props.put(serdeConstants.LIST_COLUMNS, columns); props.put(serdeConstants.LIST_COLUMN_TYPES, types); SerDeUtils.initializeSerDe(serde, null, props, null); MapJoinObjectSerDeContext context = new MapJoinObjectSerDeContext(serde, false); key.write(context, out); out.close(); bais = new ByteArrayInputStream(baos.toByteArray()); in = new ObjectInputStream(bais); result.read(context, in, new BytesWritable()); return result; }
public void read(MapJoinObjectSerDeContext context, ObjectInputStream in, Writable container) throws IOException, SerDeException { container.readFields(in); read(context, container); }
@Test public void testEqualityHashCode() throws Exception { MapJoinKeyObject key1 = new MapJoinKeyObject(new String[] {"key"}); MapJoinKeyObject key2 = new MapJoinKeyObject(new String[] {"key"}); Utilities.testEquality(key1, key2); key1 = new MapJoinKeyObject(new Object[] {148, null}); key2 = new MapJoinKeyObject(new Object[] {148, null}); Utilities.testEquality(key1, key2); key1 = new MapJoinKeyObject(new Object[] {null, "key1"}); key2 = new MapJoinKeyObject(new Object[] {null, "key2"}); Assert.assertFalse(key1.equals(key2)); } @Test
@Test public void testSerialization() throws Exception { MapJoinKeyObject key1 = new MapJoinKeyObject(new Object[] {new Text("field0"), null, new Text("field2")}); MapJoinKeyObject key2 = Utilities.serde(key1, "f0,f1,f2", "string,string,string"); Utilities.testEquality(key1, key2); } }
static void testEquality(MapJoinKeyObject key1, MapJoinKeyObject key2) { Assert.assertEquals(key1.hashCode(), key2.hashCode()); Assert.assertEquals(key1, key2); Assert.assertEquals(key1.getKeyLength(), key2.getKeyLength()); Assert.assertTrue(key1.equals(key2)); }
public void read(MapJoinObjectSerDeContext context, ObjectInputStream in, Writable container) throws IOException, SerDeException { container.readFields(in); read(context, container); }
@Before public void setup() throws Exception { key = new MapJoinKeyObject(KEY); rowContainer = new MapJoinEagerRowContainer(); rowContainer.addRow(VALUE); baos = new ByteArrayOutputStream(); out = new ObjectOutputStream(baos); LazyBinarySerDe keySerde = new LazyBinarySerDe(); Properties keyProps = new Properties(); keyProps.put(serdeConstants.LIST_COLUMNS, "v1"); keyProps.put(serdeConstants.LIST_COLUMN_TYPES, "string"); SerDeUtils.initializeSerDe(keySerde, null, keyProps, null); LazyBinarySerDe valueSerde = new LazyBinarySerDe(); Properties valueProps = new Properties(); valueProps.put(serdeConstants.LIST_COLUMNS, "v1"); valueProps.put(serdeConstants.LIST_COLUMN_TYPES, "string"); SerDeUtils.initializeSerDe(valueSerde, null, keyProps, null); containerSerde = new MapJoinTableContainerSerDe( new MapJoinObjectSerDeContext(keySerde, false), new MapJoinObjectSerDeContext(valueSerde, false)); container = new HashMapWrapper(); }
@SuppressWarnings("deprecation") public static MapJoinKey read(Output output, MapJoinObjectSerDeContext context, Writable writable) throws SerDeException, HiveException { AbstractSerDe serde = context.getSerDe(); Object obj = serde.deserialize(writable); MapJoinKeyObject result = new MapJoinKeyObject(); result.read(serde.getObjectInspector(), obj); return result; }
public static MapJoinKey readFromRow(Output output, MapJoinKey key, Object[] keyObject, List<ObjectInspector> keyFieldsOI, boolean mayReuseKey) throws HiveException { MapJoinKeyObject result = mayReuseKey ? (MapJoinKeyObject)key : new MapJoinKeyObject(); result.readFromRow(keyObject, keyFieldsOI); return result; }
public static MapJoinKey readFromVector(Output output, MapJoinKey key, Object[] keyObject, List<ObjectInspector> keyOIs, boolean mayReuseKey) throws HiveException { MapJoinKeyObject result = mayReuseKey ? (MapJoinKeyObject)key : new MapJoinKeyObject(); result.setKeyObjects(keyObject); return result; }
public void read(MapJoinObjectSerDeContext context, Writable container) throws SerDeException { read(context.getSerDe().getObjectInspector(), context.getSerDe().deserialize(container)); }
private void loadNormal(MapJoinPersistableTableContainer container, ObjectInputStream in, Writable keyContainer, Writable valueContainer) throws Exception { int numKeys = in.readInt(); for (int keyIndex = 0; keyIndex < numKeys; keyIndex++) { MapJoinKeyObject key = new MapJoinKeyObject(); key.read(keyContext, in, keyContainer); if (container.get(key) == null) { container.put(key, new MapJoinEagerRowContainer()); } MapJoinEagerRowContainer values = (MapJoinEagerRowContainer) container.get(key); values.read(valueContext, in, valueContainer); container.put(key, values); } }
currentKey[keyIndex] = joinKeys[alias].get(keyIndex).evaluate(row); MapJoinKeyObject key = new MapJoinKeyObject(); key.readFromRow(currentKey, joinKeysObjectInspectors[alias]);
public static MapJoinKey readFromVector(Output output, MapJoinKey key, Object[] keyObject, List<ObjectInspector> keyOIs, boolean mayReuseKey) throws HiveException { MapJoinKeyObject result = mayReuseKey ? (MapJoinKeyObject)key : new MapJoinKeyObject(); result.setKeyObjects(keyObject); return result; }
public void read(MapJoinObjectSerDeContext context, Writable container) throws SerDeException { read(context.getSerDe().getObjectInspector(), context.getSerDe().deserialize(container)); }
private void loadNormal(MapJoinPersistableTableContainer container, ObjectInputStream in, Writable keyContainer, Writable valueContainer) throws Exception { int numKeys = in.readInt(); for (int keyIndex = 0; keyIndex < numKeys; keyIndex++) { MapJoinKeyObject key = new MapJoinKeyObject(); key.read(keyContext, in, keyContainer); if (container.get(key) == null) { container.put(key, new MapJoinEagerRowContainer()); } MapJoinEagerRowContainer values = (MapJoinEagerRowContainer) container.get(key); values.read(valueContext, in, valueContainer); container.put(key, values); } }
currentKey[keyIndex] = joinKeys[alias].get(keyIndex).evaluate(row); MapJoinKeyObject key = new MapJoinKeyObject(); key.readFromRow(currentKey, joinKeysObjectInspectors[alias]);