use of io.prestosql.utils.MockSplit in project hetu-core by openlookeng.
the class TestSplitFiltering method testGetFilteredSplit.
/**
* This test will not actually filter any splits since the indexes will not be found,
* instead it's just testing the flow. The actual filtering is tested in other classes.
*/
@Test
public void testGetFilteredSplit() {
PropertyService.setProperty(HetuConstant.FILTER_ENABLED, true);
PropertyService.setProperty(HetuConstant.INDEXSTORE_URI, "/tmp/hetu/indices");
PropertyService.setProperty(HetuConstant.INDEXSTORE_FILESYSTEM_PROFILE, "local-config-default");
PropertyService.setProperty(HetuConstant.FILTER_CACHE_TTL, new Duration(10, TimeUnit.MINUTES));
PropertyService.setProperty(HetuConstant.FILTER_CACHE_LOADING_DELAY, new Duration(5000, TimeUnit.MILLISECONDS));
PropertyService.setProperty(HetuConstant.FILTER_CACHE_LOADING_THREADS, 2L);
RowExpression expression = PlanBuilder.comparison(OperatorType.EQUAL, new VariableReferenceExpression("a", VarcharType.VARCHAR), new ConstantExpression(utf8Slice("test_value"), VarcharType.VARCHAR));
SqlStageExecution stage = TestUtil.getTestStage(expression);
List<Split> mockSplits = new ArrayList<>();
MockSplit mock = new MockSplit("hdfs://hacluster/AppData/BIProd/DWD/EVT/bogus_table/000000_0", 0, 10, 0);
MockSplit mock1 = new MockSplit("hdfs://hacluster/AppData/BIProd/DWD/EVT/bogus_table/000000_1", 0, 10, 0);
MockSplit mock2 = new MockSplit("hdfs://hacluster/AppData/BIProd/DWD/EVT/bogus_table/000001_0", 0, 10, 0);
MockSplit mock3 = new MockSplit("hdfs://hacluster/AppData/BIProd/DWD/EVT/bogus_table/000000_4", 0, 10, 0);
mockSplits.add(new Split(new CatalogName("bogus_catalog"), mock, Lifespan.taskWide()));
mockSplits.add(new Split(new CatalogName("bogus_catalog"), mock1, Lifespan.taskWide()));
mockSplits.add(new Split(new CatalogName("bogus_catalog"), mock2, Lifespan.taskWide()));
mockSplits.add(new Split(new CatalogName("bogus_catalog"), mock3, Lifespan.taskWide()));
SplitSource.SplitBatch nextSplits = new SplitSource.SplitBatch(mockSplits, true);
HeuristicIndexerManager indexerManager = new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager());
Pair<Optional<RowExpression>, Map<Symbol, ColumnHandle>> pair = SplitFiltering.getExpression(stage);
List<Split> filteredSplits = SplitFiltering.getFilteredSplit(pair.getFirst(), SplitFiltering.getFullyQualifiedName(stage), pair.getSecond(), nextSplits, indexerManager);
assertNotNull(filteredSplits);
assertEquals(filteredSplits.size(), 4);
}
Aggregations