[
https://issues.apache.org/jira/browse/CALCITE-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14230351#comment-14230351
]
Vladimir Sitnikov commented on CALCITE-501:
-------------------------------------------
{quote} indexed access via a map){quote}
The hard part is if you have {{Map<String, Employee>}} you have no idea what is
there in the key.
I am not sure if we want to invent some set of annotations.
Not sure if we want to support subset of
[JPA|http://stackoverflow.com/questions/21816983/jpa-hibernate-map-of-collections-using-mapkeycolumn]
or
[JDO|http://www.datanucleus.org/products/datanucleus/jdo/annotations.html#Key]
relevant annotations either.
{quote}The idea is that there should be rules that know about the various
access paths into a collection (full scan, range scan of a sorted collection,
indexed access via a map) {quote}
Am I right
{{org.apache.calcite.plan.RelOptRuleCall#transformTo(org.apache.calcite.rel.RelNode,
java.util.Map<org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode>)}}
allows to produce multiple equivalent {{RelNodes}} in the same rule execution?
If that works, I thing a single rule that matches
{{LogicalFilter(TableScan(table=emps))}} and produces all the suitable scans
will work.
So {{LogicalFilter(name=A and empno=B, TableScan(table=emps))}} would be
transformed to {{LogicalFilter(name==A and empno==B,
TableAccessByRowid(table=emps, IndexScan(name==A, empsByName)))}} and
{{LogicalFilter(name==A and empno==B, TableAccessByRowid(table=emps,
IndexScan(empno==B, empsByEmpno)))}}.
{quote}And we could extend the Table interface to declare the table's sort
order. {quote}
The sort order of "TableAccessByRowid" depends on the index used.
However, if it comes to "the order of rows out of plain scan",
{{org.apache.calcite.schema.Statistic}} might be better place ({{getRowCount}},
{{isKey}} are there)
> Implement indexed access paths in ReflectiveSchema
> --------------------------------------------------
>
> Key: CALCITE-501
> URL: https://issues.apache.org/jira/browse/CALCITE-501
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.0.0-incubating
> Reporter: Vladimir Sitnikov
> Assignee: Julian Hyde
>
> {{ReflectiveSchema}} is not able to perform indexed scan of a particular
> collection.
> It would be nice if it could find rows by a given key.
> This would demonstrate the way to implement indexed access path in Calcite:
> rules, filter matching.
> The sketch API can be as follows:
> {code:java}
> public static class CatchallSchema {
> public final Employee[] employees = {
> new Employee(1, 10, "A", 0f, null),
> new Employee(2, 10, "Ab", 0f, null),
> new Employee(3, 10, "Abc", 0f, null),
> new Employee(4, 10, "Abd", 0f, null),
> };
> // Return the data
> public Employee[] findEmployeesByName(String name);
> // or
> // List of indices into "employees" collection
> public int[] findEmployeesByName(String name);
> }
> {code}
> Alternative solution is to treat {{Map/SortedMap}} somehow in a special way.
> {code:java}
> // When Filter(name=?, Scan) can be transformed to MapGet(name=?)
> public Map<String, Employee> employees;
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)