cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samuel Klock (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CASSANDRA-8473) Secondary index support for key-value pairs in CQL3 maps
Date Thu, 18 Dec 2014 20:51:15 GMT

     [ https://issues.apache.org/jira/browse/CASSANDRA-8473?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Samuel Klock updated CASSANDRA-8473:
------------------------------------
    Attachment: trunk-8473-v3.txt
                cassandra-2.1-8473-v3.txt

Attaching new versions of the patch.  Details:

bq. Hmm, that error message indicates that the logic for frozen collections in {{toReceivers()}}
still isn't quite correct. (...)

Added a test targeting the error message.  Adjusted the logic in the trunk patch to make it
pass.

bq. (...) Frozen collections aren't tested with this method, and lists and sets only support
CONTAINS. So you could go ahead and simplify this whole method to reflect that. (...)

Done.  All of the {{switch}} logic has been removed except for the {{MAP}} case.

bq. I think this could replace the switch statement (although I haven't tested it): (...)

This worked with some minor adjustments to the logic.  I attempted to refactor it for clarity
at the expense of a little extra verbosity.  I also reverted the error message for unsupported
indexes on frozen collections to breaking {{FrozenCollectionsTest}}.

bq. I would be okay with a common abstract superclass. I agree that the abstraction doesn't
line up 100%.

Done via new class {{CompositesIndexIncludingCollectionKey}}.  Also: tweaked the code slightly
to address a compiler warning.

bq. My preference is still to stick with a 3.0 target. (...)

Before we close this question, can you give us a sense of what your concerns are and how we
might address them?  It's worth noting that we do have experience operating a couple of clusters
running 2.1.x releases that include variants of this patch, so we're confident that it doesn't
impact existing functionality.  Of course, our usage doesn't cover every possible case, but
we might be able to take some additional steps to improve your confidence in the proposed
implementation.

> Secondary index support for key-value pairs in CQL3 maps
> --------------------------------------------------------
>
>                 Key: CASSANDRA-8473
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8473
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Samuel Klock
>            Assignee: Samuel Klock
>             Fix For: 3.0
>
>         Attachments: cassandra-2.1-8473-actual-v1.txt, cassandra-2.1-8473-v2.txt, cassandra-2.1-8473-v3.txt,
cassandra-2.1-8473.txt, trunk-8473-v2.txt, trunk-8473-v3.txt
>
>
> CASSANDRA-4511 and CASSANDRA-6383 made substantial progress on secondary indexes on CQL3
maps, but support for a natural use case is still missing: queries to find rows with map columns
containing some key-value pair.  For example (from a comment on CASSANDRA-4511):
> {code:sql}
> SELECT * FROM main.users WHERE notify['email'] = true;
> {code}
> Cassandra should add support for this kind of index.  One option is to expose a CQL interface
like the following:
> * Creating an index:
> {code:sql}
> cqlsh:mykeyspace> CREATE TABLE mytable (key TEXT PRIMARY KEY, value MAP<TEXT, TEXT>);
> cqlsh:mykeyspace> CREATE INDEX ON mytable(ENTRIES(value));
> {code}
> * Querying the index:
> {code:sql}
> cqlsh:mykeyspace> INSERT INTO mytable (key, value) VALUES ('foo', {'a': '1', 'b':
'2', 'c': '3'});
> cqlsh:mykeyspace> INSERT INTO mytable (key, value) VALUES ('bar', {'a': '1', 'b':
'4'});
> cqlsh:mykeyspace> INSERT INTO mytable (key, value) VALUES ('baz', {'b': '4', 'c':
'3'});
> cqlsh:mykeyspace> SELECT * FROM mytable WHERE value['a'] = '1';
>  key | value
> -----+--------------------------------
>  bar |           {'a': '1', 'b': '4'}
>  foo | {'a': '1', 'b': '2', 'c': '3'}
> (2 rows)
> cqlsh:mykeyspace> SELECT * FROM mytable WHERE value['a'] = '1' AND value['b'] = '2'
ALLOW FILTERING;
>  key | value
> -----+--------------------------------
>  foo | {'a': '1', 'b': '2', 'c': '3'}
> (1 rows)
> cqlsh:mykeyspace> SELECT * FROM mytable WHERE value['b'] = '2' ALLOW FILTERING;
>  key | value                         
> -----+--------------------------------
>  foo | {'a': '1', 'b': '2', 'c': '3'}
> (1 rows)                             
> cqlsh:mykeyspace> SELECT * FROM mytable WHERE value['b'] = '4';
>  key | value
> -----+----------------------
>  bar | {'a': '1', 'b': '4'}
>  baz | {'b': '4', 'c': '3'}
> (2 rows)
> {code}
> A patch against the Cassandra-2.1 branch that implements this interface will be attached
to this issue shortly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message