Created
February 22, 2017 06:10
-
-
Save anonymous/dba4d3f0e6e28cdc0c947aab61d8a851 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.hadoop.hive.ql.exec.UDF; | |
public class FindMaxDelayType extends UDF { | |
public enum DelayTypes {carrier,weather,nas,security,late_aircraft} | |
public String evaluate(double carrier, double weather, double nas, double security, double late_aircraft) { | |
double currentMax = carrier; | |
int index = 0; | |
if(weather > currentMax) { | |
currentMax = weather; | |
index = 1; | |
} | |
if(nas > currentMax) { | |
currentMax = nas; | |
index = 2; | |
} | |
if(security > currentMax) { | |
currentMax = security; | |
index = 3; | |
} | |
if(late_aircraft > currentMax) { | |
currentMax = late_aircraft; | |
index = 4; | |
} | |
return DelayTypes.values()[index].name(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment