Search in sources :

Example 1 with SpatialIndexBuilderOperatorFactory

use of com.facebook.presto.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory in project presto by prestodb.

the class TestSpatialJoinOperator method buildIndex.

private PagesSpatialIndexFactory buildIndex(DriverContext driverContext, SpatialPredicate spatialRelationshipTest, Optional<Integer> radiusChannel, Optional<Integer> partitionChannel, Optional<String> kdbTreeJson, Optional<InternalJoinFilterFunction> filterFunction, RowPagesBuilder buildPages) {
    Optional<JoinFilterFunctionCompiler.JoinFilterFunctionFactory> filterFunctionFactory = filterFunction.map(function -> (session, addresses, pages) -> new StandardJoinFilterFunction(function, addresses, pages));
    ValuesOperator.ValuesOperatorFactory valuesOperatorFactory = new ValuesOperator.ValuesOperatorFactory(0, new PlanNodeId("test"), buildPages.build());
    SpatialIndexBuilderOperatorFactory buildOperatorFactory = new SpatialIndexBuilderOperatorFactory(1, new PlanNodeId("test"), buildPages.getTypes(), Ints.asList(1), 0, radiusChannel, partitionChannel, spatialRelationshipTest, kdbTreeJson, filterFunctionFactory, 10_000, new TestingFactory(false));
    Driver driver = Driver.createDriver(driverContext, valuesOperatorFactory.createOperator(driverContext), buildOperatorFactory.createOperator(driverContext));
    PagesSpatialIndexFactory pagesSpatialIndexFactory = buildOperatorFactory.getPagesSpatialIndexFactory();
    ListenableFuture<PagesSpatialIndex> pagesSpatialIndex = pagesSpatialIndexFactory.createPagesSpatialIndex();
    while (!pagesSpatialIndex.isDone()) {
        driver.process();
    }
    // Release the spatial index reference
    pagesSpatialIndexFactory.probeOperatorFinished();
    runDriverInThread(executor, driver);
    return pagesSpatialIndexFactory;
}
Also used : SpatialIndexBuilderOperatorFactory(com.facebook.presto.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory) StandardJoinFilterFunction(com.facebook.presto.operator.StandardJoinFilterFunction) PagesSpatialIndex(com.facebook.presto.operator.PagesSpatialIndex) Driver(com.facebook.presto.operator.Driver) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) TestingFactory(com.facebook.presto.operator.PagesIndex.TestingFactory) ValuesOperator(com.facebook.presto.operator.ValuesOperator) PagesSpatialIndexFactory(com.facebook.presto.operator.PagesSpatialIndexFactory)

Aggregations

Driver (com.facebook.presto.operator.Driver)1 TestingFactory (com.facebook.presto.operator.PagesIndex.TestingFactory)1 PagesSpatialIndex (com.facebook.presto.operator.PagesSpatialIndex)1 PagesSpatialIndexFactory (com.facebook.presto.operator.PagesSpatialIndexFactory)1 SpatialIndexBuilderOperatorFactory (com.facebook.presto.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory)1 StandardJoinFilterFunction (com.facebook.presto.operator.StandardJoinFilterFunction)1 ValuesOperator (com.facebook.presto.operator.ValuesOperator)1 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)1