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 testList() throws Exception { runTest( "test_flat_map/flat_map_list.dwrf", IntegerType.INTEGER, LIST_TYPE, ExpectedValuesBuilder.get(Function.identity(), TestFlatMap::intToList)); }
@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 testShort() throws Exception { runTest("test_flat_map/flat_map_short.dwrf", SmallintType.SMALLINT, ExpectedValuesBuilder.get(Integer::shortValue)); }
@Test public void testInteger() throws Exception { runTest("test_flat_map/flat_map_int.dwrf", IntegerType.INTEGER, ExpectedValuesBuilder.get(Function.identity())); }
@Test public void testString() throws Exception { runTest("test_flat_map/flat_map_string.dwrf", VarcharType.VARCHAR, ExpectedValuesBuilder.get(i -> Integer.toString(i))); }
@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 testMap() throws Exception { runTest( "test_flat_map/flat_map_map.dwrf", IntegerType.INTEGER, MAP_TYPE, ExpectedValuesBuilder.get(Function.identity(), TestFlatMap::intToMap)); }
@Test public void testStruct() throws Exception { runTest( "test_flat_map/flat_map_struct.dwrf", IntegerType.INTEGER, STRUCT_TYPE, ExpectedValuesBuilder.get(Function.identity(), TestFlatMap::intToList)); }
@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 testBinary() throws Exception { runTest("test_flat_map/flat_map_binary.dwrf", VarbinaryType.VARBINARY, ExpectedValuesBuilder.get(i -> new SqlVarbinary(Integer.toString(i).getBytes(StandardCharsets.UTF_8)))); }
@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 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 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 testIntegerWithNull() throws Exception { runTest("test_flat_map/flat_map_int_with_null.dwrf", IntegerType.INTEGER, ExpectedValuesBuilder.get(Function.identity()).setNullValuesFrequency(SOME)); }
@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 testMapWithNull() throws Exception { runTest( "test_flat_map/flat_map_map_with_null.dwrf", IntegerType.INTEGER, MAP_TYPE, ExpectedValuesBuilder.get(Function.identity(), TestFlatMap::intToMap).setNullValuesFrequency(SOME)); }
@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 testByteWithNull() throws Exception { runTest("test_flat_map/flat_map_byte_with_null.dwrf", TinyintType.TINYINT, ExpectedValuesBuilder.get(Integer::byteValue).setNullValuesFrequency(SOME)); }