| 146 | import org.junit.Test; |
| 147 | |
| 148 | public class TestBuiltin { |
| 149 | private static final Log LOG = LogFactory.getLog(TestBuiltin.class); |
| 150 | private static PigServer pigServer; |
| 151 | private static Properties properties; |
| 152 | private static MiniGenericCluster cluster; |
| 153 | |
| 154 | private TupleFactory tupleFactory = TupleFactory.getInstance(); |
| 155 | private BagFactory bagFactory = DefaultBagFactory.getInstance(); |
| 156 | |
| 157 | private static Tuple NULL_INPUT_TUPLE; |
| 158 | |
| 159 | // some inputs |
| 160 | private static Integer[] intInput = { 3, 1, 2, 4, 5, 7, null, 6, 8, 9, 10 }; |
| 161 | private static Long[] intAsLong = { 3L, 1L, 2L, 4L, 5L, 7L, null, 6L, 8L, 9L, 10L }; |
| 162 | |
| 163 | private static Long[] longInput = { 145769183483345L, null, 4345639849L, 3435543121L, 2L, 5L, 9L, 7L, 8L, 6L, 10L }; |
| 164 | |
| 165 | private static Float[] floatInput = { 10.4f, 2.35f, 3.099f, null, 4.08495f, 5.350f, 6.78f, 7.0f, 8.0f, 9.0f, 0.09f }; |
| 166 | private static Double[] floatAsDouble = { 10.4, 2.35, 3.099, null, 4.08495, 5.350, 6.78, 7.0, 8.0, 9.0, 0.09 }; |
| 167 | |
| 168 | private static Double[] doubleInput = { 5.5673910, 121.0, 3.0, 0.000000834593, 1.0, 6.0, 7.0, 8.0, 9.0, 10.0, null }; |
| 169 | |
| 170 | private static BigDecimal[] bigDecimalInput = {BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN, new BigDecimal("99999999999999977.9999999999999999999999999999999999999999")}; |
| 171 | private static BigInteger[] bigIntegerInput = {BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN, new BigInteger("999999999998888888887777777777777744444488888889999999999977")}; |
| 172 | |
| 173 | private static String[] ba = { "7", "2", "3", null, "4", "5", "6", "1", "8", "9", "10"}; |
| 174 | private static Double[] baAsDouble = { 7.0, 2.0, 3.0, null, 4.0, 5.0, 6.0, 1.0, 8.0, 9.0, 10.0}; |
| 175 | |
| 176 | private static String[] stringInput = {"unit", "test", null, "input", "string"}; |
| 177 | private static DataByteArray[] ByteArrayInput = Util.toDataByteArrays(ba); |
| 178 | |
| 179 | private static DateTime[] datetimeInput = {new DateTime("2009-01-07T01:07:02.000Z"), new DateTime("2008-10-09T01:07:02.000Z"), null, new DateTime("2014-12-25T11:11:11.000Z"), new DateTime("2009-01-07T01:07:02.000Z")}; |
| 180 | |
| 181 | // The HashMaps below are used to set up the appropriate EvalFunc, |
| 182 | // the allowed input and expected output for the different aggregate functions |
| 183 | // which have different implementations for different input types |
| 184 | // This way rather than quickly exploding the test cases (one per input type |
| 185 | // per aggregate), all cases for a given aggregate stage are handled |
| 186 | // in one test case in a loop |
| 187 | |
| 188 | // A mapping between name of Aggregate function to its corresponding EvalFunc object |
| 189 | private static HashMap<String, EvalFunc<?>> evalFuncMap = new HashMap<String, EvalFunc<?>>(); |
| 190 | |
| 191 | // A mapping between a type name (example: "Integer") and a tuple containing |
| 192 | // a bag of inputs of that type |
| 193 | private static HashMap<String, Tuple> inputMap = new HashMap<String, Tuple>(); |
| 194 | |
| 195 | // A mapping between a type name (example: "Integer") and tuples containing |
| 196 | // a bag of inputs of that type for accumulator functions |
| 197 | private static HashMap<String, Tuple[]> inputMapForAccumulate = new HashMap<String, Tuple[]>(); |
| 198 | |
| 199 | // A mapping between name of Aggregate function and the input type of its |
| 200 | // argument |
| 201 | private static HashMap<String, String> allowedInput = new HashMap<String, String>(); |
| 202 | |
| 203 | // A mapping between name of Aggregate function and the output value (based on the |
| 204 | // inputs above) |
| 205 | private static HashMap<String, Object> expectedMap = new HashMap<String, Object>(); |
nothing calls this directly
no test coverage detected