Search in sources :

Example 1 with MockSplit

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);
}
Also used : Optional(java.util.Optional) ConstantExpression(io.prestosql.spi.relation.ConstantExpression) ArrayList(java.util.ArrayList) RowExpression(io.prestosql.spi.relation.RowExpression) Duration(io.airlift.units.Duration) MockSplit(io.prestosql.utils.MockSplit) SqlStageExecution(io.prestosql.execution.SqlStageExecution) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) CatalogName(io.prestosql.spi.connector.CatalogName) Split(io.prestosql.metadata.Split) MockSplit(io.prestosql.utils.MockSplit) SplitSource(io.prestosql.split.SplitSource) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test)

Aggregations

Duration (io.airlift.units.Duration)1 SqlStageExecution (io.prestosql.execution.SqlStageExecution)1 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)1 Split (io.prestosql.metadata.Split)1 HetuMetaStoreManager (io.prestosql.metastore.HetuMetaStoreManager)1 CatalogName (io.prestosql.spi.connector.CatalogName)1 ConstantExpression (io.prestosql.spi.relation.ConstantExpression)1 RowExpression (io.prestosql.spi.relation.RowExpression)1 VariableReferenceExpression (io.prestosql.spi.relation.VariableReferenceExpression)1 SplitSource (io.prestosql.split.SplitSource)1 MockSplit (io.prestosql.utils.MockSplit)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Test (org.testng.annotations.Test)1