@Test public void testBucketedTableDoubleFloat() throws Exception { ConnectorTableHandle tableHandle = getTableHandle(tableBucketedDoubleFloat); List<ConnectorColumnHandle> columnHandles = ImmutableList.copyOf(metadata.getColumnHandles(tableHandle).values()); Map<String, Integer> columnIndex = indexColumns(columnHandles); assertTableIsBucketed(tableHandle); ImmutableMap<ConnectorColumnHandle, Comparable<?>> bindings = ImmutableMap.<ConnectorColumnHandle, Comparable<?>>builder() .put(columnHandles.get(columnIndex.get("t_float")), 406.1000061035156) .put(columnHandles.get(columnIndex.get("t_double")), 407.2) .build(); // floats and doubles are not supported, so we should see all splits ConnectorPartitionResult partitionResult = splitManager.getPartitions(tableHandle, TupleDomain.withFixedValues(bindings)); List<ConnectorSplit> splits = getAllSplits(splitManager.getPartitionSplits(tableHandle, partitionResult.getPartitions())); assertEquals(splits.size(), 32); int count = 0; for (ConnectorSplit split : splits) { try (RecordCursor cursor = recordSetProvider.getRecordSet(split, columnHandles).cursor()) { while (cursor.advanceNextPosition()) { count++; } } } assertEquals(count, 300); }
@Test public void testBucketedTableBigintBoolean() throws Exception { ConnectorTableHandle tableHandle = getTableHandle(tableBucketedBigintBoolean); List<ConnectorColumnHandle> columnHandles = ImmutableList.copyOf(metadata.getColumnHandles(tableHandle).values()); Map<String, Integer> columnIndex = indexColumns(columnHandles); assertTableIsBucketed(tableHandle); String testString = "textfile test"; // This needs to match one of the rows where t_string is not empty or null, and where t_bigint // is not null // (i.e. (testBigint - 604) % 19 > 1 and (testBigint - 604) % 13 != 0) Long testBigint = 608L; Boolean testBoolean = true; ImmutableMap<ConnectorColumnHandle, Comparable<?>> bindings = ImmutableMap.<ConnectorColumnHandle, Comparable<?>>builder() .put(columnHandles.get(columnIndex.get("t_string")), utf8Slice(testString)) .put(columnHandles.get(columnIndex.get("t_bigint")), testBigint) .put(columnHandles.get(columnIndex.get("t_boolean")), testBoolean) .build(); ConnectorPartitionResult partitionResult = splitManager.getPartitions(tableHandle, TupleDomain.withFixedValues(bindings)); List<ConnectorSplit> splits = getAllSplits(splitManager.getPartitionSplits(tableHandle, partitionResult.getPartitions())); assertEquals(splits.size(), 1); boolean rowFound = false; try (RecordCursor cursor = recordSetProvider.getRecordSet(splits.get(0), columnHandles).cursor()) { while (cursor.advanceNextPosition()) { if (testString.equals(cursor.getSlice(columnIndex.get("t_string")).toStringUtf8()) && testBigint == cursor.getLong(columnIndex.get("t_bigint")) && testBoolean == cursor.getBoolean(columnIndex.get("t_boolean"))) { rowFound = true; break; } } assertTrue(rowFound); } }
@Test public void testBucketedTableStringInt() throws Exception { ConnectorTableHandle tableHandle = getTableHandle(tableBucketedStringInt); List<ConnectorColumnHandle> columnHandles = ImmutableList.copyOf(metadata.getColumnHandles(tableHandle).values()); Map<String, Integer> columnIndex = indexColumns(columnHandles); assertTableIsBucketed(tableHandle); String testString = "sequencefile test"; Long testInt = 413L; Long testSmallint = 412L; // Reverse the order of bindings as compared to bucketing order ImmutableMap<ConnectorColumnHandle, Comparable<?>> bindings = ImmutableMap.<ConnectorColumnHandle, Comparable<?>>builder() .put(columnHandles.get(columnIndex.get("t_int")), testInt) .put(columnHandles.get(columnIndex.get("t_string")), utf8Slice(testString)) .put(columnHandles.get(columnIndex.get("t_smallint")), testSmallint) .build(); ConnectorPartitionResult partitionResult = splitManager.getPartitions(tableHandle, TupleDomain.withFixedValues(bindings)); List<ConnectorSplit> splits = getAllSplits(splitManager.getPartitionSplits(tableHandle, partitionResult.getPartitions())); assertEquals(splits.size(), 1); boolean rowFound = false; try (RecordCursor cursor = recordSetProvider.getRecordSet(splits.get(0), columnHandles).cursor()) { while (cursor.advanceNextPosition()) { if (testString.equals(cursor.getSlice(columnIndex.get("t_string")).toStringUtf8()) && testInt == cursor.getLong(columnIndex.get("t_int")) && testSmallint == cursor.getLong(columnIndex.get("t_smallint"))) { rowFound = true; } } assertTrue(rowFound); } }