@Override public boolean source( FlowProcess<? extends Configuration> flowProcess, SourceCall<Object[], RecordReader> sourceCall ) throws IOException { Tuple key = (Tuple) sourceCall.getContext()[ 0 ]; Tuple value = (Tuple) sourceCall.getContext()[ 1 ]; boolean result = sourceCall.getInput().next( key, value ); if( !result ) return false; TupleEntry entry = sourceCall.getIncomingEntry(); if( entry.hasTypes() ) entry.setCanonicalTuple( value ); else entry.setTuple( value ); return true; }
@Override public boolean source( FlowProcess<? extends Configuration> flowProcess, SourceCall<Object[], RecordReader> sourceCall ) throws IOException { Tuple key = (Tuple) sourceCall.getContext()[ 0 ]; Tuple value = (Tuple) sourceCall.getContext()[ 1 ]; boolean result = sourceCall.getInput().next( key, value ); if( !result ) return false; TupleEntry entry = sourceCall.getIncomingEntry(); if( entry.hasTypes() ) entry.setCanonicalTuple( value ); else entry.setTuple( value ); return true; }
@Test public void testSetCanonicalNull() { TupleEntry entryA = new TupleEntry( new Fields( "a", "b", "c" ), new Tuple( "a", "b", "c" ) ); entryA.setCanonicalTuple( null ); assertTrue( entryA.getTuple() == null ); }
public void complete( FlowProcess flowProcess, AggregatorCall aggregatorCall ) { TupleEntry result; if( aggregatorCall.getDeclaredFields().isUnknown() ) result = new TupleEntry( Fields.size( value[ 0 ].size() ), Tuple.size( value[ 0 ].size() ) ); else result = new TupleEntry( aggregatorCall.getDeclaredFields(), Tuple.size( aggregatorCall.getDeclaredFields().size() ) ); for( int i = 0; i < duplicates; i++ ) { for( Tuple tuple : value ) { try { result.setCanonicalTuple( tuple ); } catch( Exception exception ) { // value is a string, but the the test declared a numeric type result.setCanonicalTuple( Tuple.size( value[ 0 ].size(), -99 ) ); } aggregatorCall.getOutputCollector().add( result ); } } } }
expected.setString( 4, Long.toString( date.getTime() ) ); results.setCanonicalTuple( expected );
public void operate( FlowProcess flowProcess, FunctionCall<Integer> functionCall ) { if( value == null ) throwIntentionalException(); try { if( functionCall.getContext() == failon ) throw new RuntimeException( "function failed intentionally on tuple number: " + failon ); } finally { functionCall.setContext( functionCall.getContext() + 1 ); } TupleEntry result; if( functionCall.getDeclaredFields().isUnknown() ) result = new TupleEntry( Fields.size( value.size() ), Tuple.size( value.size() ) ); else result = new TupleEntry( functionCall.getDeclaredFields(), Tuple.size( functionCall.getDeclaredFields().size() ) ); try { result.setCanonicalTuple( value ); } catch( Exception exception ) { // value is a string, but the the test declared a numeric type result.setCanonicalTuple( Tuple.size( value.size(), -99 ) ); } functionCall.getOutputCollector().add( result ); }