/** * Constructor MaxBy creates a new MaxBy instance. Use this constructor when used with a {@link AggregateBy} * instance. * * @param valueField of type Fields * @param maxField of type Fields */ @ConstructorProperties({"valueField", "maxField"}) public MaxBy( Fields valueField, Fields maxField ) { super( valueField, new MaxPartials( maxField ), new MaxValue( maxField ) ); }
/** * Constructor MaxBy creates a new MaxBy instance. * * @param name of type String * @param pipes of type Pipe[] * @param groupingFields of type Fields * @param valueField of type Fields * @param maxField of type Fields * @param threshold of type int */ @ConstructorProperties({"name", "pipes", "groupingFields", "valueField", "maxField", "threshold"}) public MaxBy( String name, Pipe[] pipes, Fields groupingFields, Fields valueField, Fields maxField, int threshold ) { super( name, pipes, groupingFields, valueField, new MaxPartials( maxField ), new MaxValue( maxField ), threshold ); } }
@Test public void testMaxValue() { Aggregator aggregator = new MaxValue(); Tuple[] arguments = new Tuple[]{new Tuple( new Double( 1.0 ) ), new Tuple( new Double( 3.0 ) ), new Tuple( new Double( 2.0 ) ), new Tuple( new Double( 4.0 ) ), new Tuple( new Double( -5.0 ) )}; Fields resultFields = new Fields( "field" ); TupleListCollector resultEntryCollector = invokeAggregator( aggregator, arguments, resultFields ); Tuple tuple = resultEntryCollector.iterator().next(); assertEquals( "got expected value after aggregate", 4.0, tuple.getDouble( 0 ), 0.0d ); }
@Test public void testMaxValueNonNumber() { Aggregator aggregator = new MaxValue(); Tuple[] arguments = new Tuple[]{new Tuple( 'a' ), new Tuple( 'b' ), new Tuple( 'c' ), new Tuple( 'd' ), new Tuple( 'e' )}; Fields resultFields = new Fields( "field" ); TupleListCollector resultEntryCollector = invokeAggregator( aggregator, arguments, resultFields ); Tuple tuple = resultEntryCollector.iterator().next(); assertEquals( "got expected value after aggregate", 'e', tuple.getChar( 0 ) ); }
Pipe merge = new HashJoin( "join", Pipe.pipes( left, right ), fields, Fields.size( 4 ), new InnerJoin() ); merge = new Every( merge, new MaxValue() );
Pipe merge = new HashJoin( "join", Pipe.pipes( left, right ), fields, Fields.size( 4 ), new InnerJoin() ); merge = new Every( merge, new MaxValue() );