Java Code Examples for org.apache.calcite.plan.hep.HepPlanner#registerMetadataProviders()

The following examples show how to use org.apache.calcite.plan.hep.HepPlanner#registerMetadataProviders() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Programs.java    From Bats with Apache License 2.0 6 votes vote down vote up
/** Creates a program that executes a {@link HepProgram}. */
public static Program of(final HepProgram hepProgram, final boolean noDag,
    final RelMetadataProvider metadataProvider) {
  return (planner, rel, requiredOutputTraits, materializations, lattices) -> {
    final HepPlanner hepPlanner = new HepPlanner(hepProgram,
        null, noDag, null, RelOptCostImpl.FACTORY);

    List<RelMetadataProvider> list = new ArrayList<>();
    if (metadataProvider != null) {
      list.add(metadataProvider);
    }
    hepPlanner.registerMetadataProviders(list);
    RelMetadataProvider plannerChain =
        ChainedRelMetadataProvider.of(list);
    rel.getCluster().setMetadataProvider(plannerChain);

    hepPlanner.setRoot(rel);
    return hepPlanner.findBestExp();
  };
}
 
Example 2
Source File: Programs.java    From calcite with Apache License 2.0 6 votes vote down vote up
/** Creates a program that executes a {@link HepProgram}. */
public static Program of(final HepProgram hepProgram, final boolean noDag,
    final RelMetadataProvider metadataProvider) {
  return (planner, rel, requiredOutputTraits, materializations, lattices) -> {
    final HepPlanner hepPlanner = new HepPlanner(hepProgram,
        null, noDag, null, RelOptCostImpl.FACTORY);

    List<RelMetadataProvider> list = new ArrayList<>();
    if (metadataProvider != null) {
      list.add(metadataProvider);
    }
    hepPlanner.registerMetadataProviders(list);
    for (RelOptMaterialization materialization : materializations) {
      hepPlanner.addMaterialization(materialization);
    }
    for (RelOptLattice lattice : lattices) {
      hepPlanner.addLattice(lattice);
    }
    RelMetadataProvider plannerChain =
        ChainedRelMetadataProvider.of(list);
    rel.getCluster().setMetadataProvider(plannerChain);

    hepPlanner.setRoot(rel);
    return hepPlanner.findBestExp();
  };
}