Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-7016

Allow mixing token and partition key restrictions

    XMLWordPrintableJSON

    Details

    • Severity:
      Low

      Description

      select ... where token(k) < x and token(k) >= y and k in (a,b) allow filtering;

      This fails on 2.0.6: can't restrict k by more than one relation.

      In the context of map/reduce (hence the token range) I want to map over only a subset of the keys (hence the 'in'). Pushing the 'in' filter down to cql is substantially cheaper than pulling all rows to the client and then discarding most of them.

      Currently this is possible only if the hadoop integration code is altered to apply the AND on the client side and use cql that contains only the resulting filtered 'in' set. The problem is not hadoop specific though, so IMO it should really be solved in cql not the hadoop integration code.

      Most restrictions on cql syntax seem to exist to prevent unduly expensive queries. This one seems to be doing the opposite.

      Edit: on further thought and with reference to the code in SelectStatement$RawStatement, it seems to me that token(k) and k should be considered distinct entities for the purposes of processing restrictions. That is, no restriction on the token should conflict with a restriction on the raw key. That way any monolithic query in terms of k and be decomposed into parallel chunks over the token range for the purposes of map/reduce processing simply by appending a 'and where token(k)...' clause to the exiting 'where k ...'.

        Attachments

        1. CASSANDRA-7016.txt
          21 kB
          Benjamin Lerer
        2. CASSANDRA-7016-V2.txt
          21 kB
          Benjamin Lerer
        3. CASSANDRA-7016-V3.txt
          27 kB
          Benjamin Lerer
        4. CASSANDRA-7016-V4-trunk.txt
          29 kB
          Benjamin Lerer
        5. CASSANDRA-7016-V5-trunk.txt
          31 kB
          Benjamin Lerer

          Issue Links

            Activity

              People

              • Assignee:
                blerer Benjamin Lerer
                Reporter:
                jhalliday Jonathan Halliday
                Authors:
                Benjamin Lerer
                Reviewers:
                Tom Hobbs
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: