001 /* 002 * Copyright (c) 2007-2014 Concurrent, Inc. All Rights Reserved. 003 * 004 * Project and contact information: http://www.cascading.org/ 005 * 006 * This file is part of the Cascading project. 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020 021 package cascading.operation.aggregator; 022 023 import java.beans.ConstructorProperties; 024 025 import cascading.operation.Aggregator; 026 import cascading.tuple.Fields; 027 028 /** 029 * Class Max is an {@link Aggregator} that returns the maximum value encountered in the current group. 030 * <p/> 031 * This class assumes the argument values is a {@link Number}, or a {@link String} representation of a number. 032 * <p/> 033 * See {@link MaxValue} to find the max of any {@link Comparable} type. 034 */ 035 @Deprecated 036 public class Max extends ExtremaBase 037 { 038 /** Field FIELD_NAME */ 039 public static final String FIELD_NAME = "max"; 040 041 /** Constructs a new instance that returns the maximum value encountered in the field name "max". */ 042 public Max() 043 { 044 super( 1, new Fields( FIELD_NAME ) ); 045 } 046 047 /** 048 * Constructs a new instance that returns the maximum value encountered in the given fieldDeclaration field name. 049 * 050 * @param fieldDeclaration of type Fields 051 */ 052 @ConstructorProperties({"fieldDeclaration"}) 053 public Max( Fields fieldDeclaration ) 054 { 055 super( 1, fieldDeclaration ); 056 } 057 058 /** 059 * Constructs a new instance that returns the maximum value encountered in the given fieldDeclaration field name. 060 * Any argument matching an ignoredValue won't be compared. 061 * 062 * @param fieldDeclaration of type Fields 063 * @param ignoreValues of type Object... 064 */ 065 @ConstructorProperties({"fieldDeclaration", "ignoreValues"}) 066 public Max( Fields fieldDeclaration, Object... ignoreValues ) 067 { 068 super( fieldDeclaration, ignoreValues ); 069 } 070 071 @Override 072 protected boolean compare( Number lhs, Number rhs ) 073 { 074 return lhs.doubleValue() < rhs.doubleValue(); 075 } 076 077 @Override 078 protected double getInitialValue() 079 { 080 return Double.NEGATIVE_INFINITY; 081 } 082 }