Java Code Examples for org.apache.pig.data.DataType#toTuple()
The following examples show how to use
org.apache.pig.data.DataType#toTuple() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDataModel.java From spork with Apache License 2.0 | 5 votes |
@Test(expected = ExecException.class) public void testTupleConversionErr() throws Exception { List list = new ArrayList(); try { DataType.toTuple(list); } catch (ExecException ee) { assertEquals(1071, ee.getErrorCode()); throw ee; } }
Example 2
Source File: TestDataModel.java From spork with Apache License 2.0 | 5 votes |
@Test(expected = ExecException.class) public void testTupleConversionErr1() throws Exception { DataByteArray ba = new DataByteArray("hello world"); try { DataType.toTuple(ba); } catch (ExecException ee) { assertEquals(1071, ee.getErrorCode()); throw ee; } }
Example 3
Source File: TupleFromBag.java From datafu with Apache License 2.0 | 5 votes |
@Override public void accumulate(Tuple tinput) throws IOException { if (result == null) { try{ DataBag samples = (DataBag) tinput.get(0); int index = ((Number)tinput.get(1)).intValue(); for (Tuple tuple : samples) { if(tupleIndex == index){ result = tuple; return; } tupleIndex++; } } catch (Exception e){ // no logging was done in the original class, and I preserve this behavior // however, an exception would have caused null to be returned. // instead, I silently continue and attempt to reach the desired index } if (defaultResult == null && tinput.size() == 3){ defaultResult = DataType.toTuple(tinput.get(2)); } } }