/** * Constructor MinBy creates a new MinBy instance. Use this constructor when used with a {@link cascading.pipe.assembly.AggregateBy} * instance. * * @param valueField of type Fields * @param minField of type Fields */ @ConstructorProperties({"valueField", "minField"}) public MinBy( Fields valueField, Fields minField ) { super( valueField, new MinPartials( minField ), new MinValue( minField ) ); }
/** * Constructor MinBy creates a new MinBy instance. * * @param name of type String * @param pipes of type Pipe[] * @param groupingFields of type Fields * @param valueField of type Fields * @param minField of type Fields * @param threshold of type int */ @ConstructorProperties({"name", "pipes", "groupingFields", "valueField", "minField", "threshold"}) public MinBy( String name, Pipe[] pipes, Fields groupingFields, Fields valueField, Fields minField, int threshold ) { super( name, pipes, groupingFields, valueField, new MinPartials( minField ), new MinValue( minField ), threshold ); } }
@Test public void testMinValue() { Aggregator aggregator = new MinValue(); 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", -5.0, tuple.getDouble( 0 ), 0.0d ); }
@Test public void testMinValueNonNumber() { Aggregator aggregator = new MinValue(); 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", 'a', tuple.getChar( 0 ) ); } }