> On Jun 4, 2015, at 2:54 PM, Jinfeng Ni <[email protected]> wrote:
>
> One question: Can RelBuilder allow to specify RelFactories directly, in
> stead of doing that in Context instance?
For the use case where you want a RelBuilder with a particular set of
factories, I recommend you create a RelProtoBuilder. We already have
public static final RelBuilder.ProtoRelBuilder DEFAULT_PROTO =
RelBuilder.proto(
Contexts.of(DEFAULT_PROJECT_FACTORY,
DEFAULT_FILTER_FACTORY,
DEFAULT_JOIN_FACTORY,
DEFAULT_SEMI_JOIN_FACTORY,
DEFAULT_SORT_FACTORY,
DEFAULT_AGGREGATE_FACTORY,
DEFAULT_SET_OP_FACTORY,
DEFAULT_VALUES_FACTORY,
DEFAULT_TABLE_SCAN_FACTORY));
You could create
public static final RelBuilder.ProtoRelBuilder DRILL_PROTO =
RelBuilder.proto(
Contexts.of(DRILL_PROJECT_FACTORY,
DRILL_FILTER_FACTORY,
DRILL_JOIN_FACTORY));
then when you need a RelBuilder, do
RelBuilder builder = DRILL_PROTO.create(cluster, schema);
I am loathe to add a constructor parameter to RelBuilder for each kind of
factory — 8 arguments is too many, and there will doubtless soon be 9 or 10.
Context is a convenient way of bundling those factories and other config
information. It doesn’t need to be the same Context as you are using for your
planner, by the way.
Julian