private <K, V> void runTest(String testOrcFileName, Type type, ExpectedValuesBuilder<K, V> expectedValuesBuilder) throws Exception { runTest(testOrcFileName, type, type, expectedValuesBuilder); }
private <K, V> void runTest(String testOrcFileName, Type keyType, Type valueType, ExpectedValuesBuilder<K, V> expectedValuesBuilder) throws Exception { List<Map<K, V>> expectedValues = expectedValuesBuilder.build(); runTest(testOrcFileName, keyType, valueType, expectedValues, false, false); runTest(testOrcFileName, keyType, valueType, expectedValues, true, false); runTest(testOrcFileName, keyType, valueType, expectedValues, false, true); }
@Test public void testInteger() throws Exception { runTest("test_flat_map/flat_map_int.dwrf", IntegerType.INTEGER, ExpectedValuesBuilder.get(Function.identity())); }
@Test public void testShort() throws Exception { runTest("test_flat_map/flat_map_short.dwrf", SmallintType.SMALLINT, ExpectedValuesBuilder.get(Integer::shortValue)); }
@Test public void testList() throws Exception { runTest( "test_flat_map/flat_map_list.dwrf", IntegerType.INTEGER, LIST_TYPE, ExpectedValuesBuilder.get(Function.identity(), TestFlatMap::intToList)); }
@Test public void testByte() throws Exception { runTest("test_flat_map/flat_map_byte.dwrf", TinyintType.TINYINT, ExpectedValuesBuilder.get(Integer::byteValue)); }
@Test public void testShort() throws Exception { runTest("test_flat_map/flat_map_short.dwrf", SmallintType.SMALLINT, ExpectedValuesBuilder.get(Integer::shortValue)); }
@Test public void testLong() throws Exception { runTest("test_flat_map/flat_map_long.dwrf", BigintType.BIGINT, ExpectedValuesBuilder.get(Integer::longValue)); }
@Test public void testBoolean() throws Exception { runTest("test_flat_map/flat_map_boolean.dwrf", IntegerType.INTEGER, BooleanType.BOOLEAN, ExpectedValuesBuilder.get(Function.identity(), TestFlatMap::intToBoolean)); }
@Test public void testFloat() throws Exception { runTest("test_flat_map/flat_map_float.dwrf", IntegerType.INTEGER, RealType.REAL, ExpectedValuesBuilder.get(Function.identity(), Float::valueOf)); }
@Test public void testStringWithNull() throws Exception { runTest("test_flat_map/flat_map_string_with_null.dwrf", VarcharType.VARCHAR, ExpectedValuesBuilder.get(i -> Integer.toString(i)).setNullValuesFrequency(SOME)); }
@Test public void testDoubleWithNull() throws Exception { runTest("test_flat_map/flat_map_double_with_null.dwrf", IntegerType.INTEGER, DoubleType.DOUBLE, ExpectedValuesBuilder.get(Function.identity(), Double::valueOf).setNullValuesFrequency(SOME)); }
@Test public void testWithNulls() throws Exception { // A test case where some of the flat maps are null runTest( "test_flat_map/flat_map_some_null_maps.dwrf", IntegerType.INTEGER, ExpectedValuesBuilder.get(Function.identity()).setNullRowsFrequency(SOME)); }
@Test public void testWithAllNulls() throws Exception { // A test case where every flat map is null runTest( "test_flat_map/flat_map_all_null_maps.dwrf", IntegerType.INTEGER, ExpectedValuesBuilder.get(Function.identity()).setNullRowsFrequency(ALL)); }
@Test public void testStructWithNull() throws Exception { runTest( "test_flat_map/flat_map_struct_with_null.dwrf", IntegerType.INTEGER, STRUCT_TYPE, ExpectedValuesBuilder.get(Function.identity(), TestFlatMap::intToList).setNullValuesFrequency(SOME)); }
@Test public void testWithAllMaps() throws Exception { // A test case where all of the flat maps are empty runTest( "test_flat_map/flat_map_all_empty_maps.dwrf", IntegerType.INTEGER, ExpectedValuesBuilder.get(Function.identity()).setEmptyMapsFrequency(ALL)); }
@Test public void testBooleanWithNull() throws Exception { runTest("test_flat_map/flat_map_boolean_with_null.dwrf", IntegerType.INTEGER, BooleanType.BOOLEAN, ExpectedValuesBuilder.get(Function.identity(), TestFlatMap::intToBoolean).setNullValuesFrequency(SOME)); }
@Test public void testWithEmptyMaps() throws Exception { // A test case where some of the flat maps are empty runTest( "test_flat_map/flat_map_some_empty_maps.dwrf", IntegerType.INTEGER, ExpectedValuesBuilder.get(Function.identity()).setEmptyMapsFrequency(SOME)); }
@Test public void testFloatWithNull() throws Exception { runTest("test_flat_map/flat_map_float_with_null.dwrf", IntegerType.INTEGER, RealType.REAL, ExpectedValuesBuilder.get(Function.identity(), Float::valueOf).setNullValuesFrequency(SOME)); }
@Test public void testByteWithNull() throws Exception { runTest("test_flat_map/flat_map_byte_with_null.dwrf", TinyintType.TINYINT, ExpectedValuesBuilder.get(Integer::byteValue).setNullValuesFrequency(SOME)); }