Join GitHub today
Use RexExecutor to evaluate projections and filters #198
I was asking on the mailing list if there is a way to use the existing code-generation infrastructure to evaluate projections and filters: https://groups.google.com/forum/#!topic/optiq-dev/-97ONPmDTB4.
This pull request contains my first approach to change the Rex* components to allow that.
My change includes the following:
I'm very happy about any feedback regarding my pull request. I know its certainly not the cleanest approach to implement this feature. But I didn't want to spend too much time working on it without any feedback. (Maybe adding something like a
I know that the pull request is a bit messed up (4 commits and I accidentally changed some code formattings while working with (/fighting against) the checkstyle plugin. Once I got feedback, I'll clean those things up and update the PR (using force push).
I like the general idea of what you are doing. It might help someone write an interpreter (i.e. implementations of
A further step could be to create an interpreter for a
Is it really what you want, to store data values in
That said, I'm OK with the idea of adding numbered slots into
Thanks for submitting an early draft for feedback. It's generally useful feature, and I think we can get this into a shape where I'd accept it.
I stumbled across the
Please give me a few days to rework the
I now think you're right to use RexInputRef. If you're implementing ProjectRel and FilterRel, then you'll want to access "fields of the incoming record", and that is precisely what RexInputRef is for.
I don't think you should add
Also, this isn't such a big deal, but I think we can avoid making changes to DataContext. Rather than storing all of the input fields in separately, we can store the array, and the array only needs to be accessed once. In your code:
RelDataType inputRowType; DataContext dataContext; Object slots = new Object[inputRowType.getFieldCount()]; dataContext.set("inputRecord", slots);
Inside generated code:
final DataContext root; Integer x = (Integer) ((Object) root.get("inputRecord")); Integer y = (Integer) ((Object) root.get("inputRecord")); Integer result = x + y;
and later we can optimize by generating
final Object slots = (Object) root.get("inputRecord");
Hi Julian, thank you very much for your guidance!
I would prefer to do the optimizations you've suggested at a later point since I'm still in a "prototyping" phase for my implementation and I want to focus on other parts of the implementation.