[
https://issues.apache.org/jira/browse/CASSANDRA-7372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14027114#comment-14027114
]
Mikhail Stepura edited comment on CASSANDRA-7372 at 6/10/14 10:08 PM:
----------------------------------------------------------------------
bq. Why do we end up with an empty composite there?
Well, we have no {{columnRestrictions}} (in SelectStatement) in that case, so
{{CompositesSearcher.makePrefix()}} has to deal with {{SliceQueryFilter(EMPTY,
EMPTY)}}.
{{makePrefix}} handles only the situation where {{key}} is empty, returning an
empty composite, and dtests cover exactly this use-case (no restriction on a
partition key) :
https://github.com/riptano/cassandra-dtest/blob/master/cql_tests.py#L3521
{code}
//1. works because CompositesSearcher.makePrefix handles the empty key. This is
covered by dtests
SELECT * FROM products WHERE categories CONTAINS 'lmn';
//2. IndexOutOfBoundsException. Fails to create the startPrefix at
CompositesSearcher.getIndexedIterator
SELECT * FROM products WHERE account = 'test' AND categories CONTAINS 'lmn';
//3. IndexOutOfBoundsException. Fails to create the endPrefix at
CompositesSearcher.getIndexedIterator
SELECT * FROM products WHERE account = 'test' AND id > 6 AND categories
CONTAINS 'lmn';
//4. Works fine
SELECT * FROM products WHERE account = 'test' AND id > 6 AND id < 1000 AND
categories CONTAINS 'lmn';
{code}
was (Author: mishail):
bq. Why do we end up with an empty composite there?
Well, we have no {{columnRestrictions}} (in SelectStatement) in that case, so
{{CompositesSearcher.makePrefix()}} has to deal with {{SliceQueryFilter(EMPTY,
EMPTY)}}.
{{makePrefix}} handles only the situation where {{key}} is empty, returning an
empty composite, and dtests cover exactly this use-case (no restriction on a
partition key) :
https://github.com/riptano/cassandra-dtest/blob/master/cql_tests.py#L3521
{code}
//1. works because CompositesSearcher.makePrefix handles the empty key
SELECT * FROM products WHERE categories CONTAINS 'lmn';
//2. IndexOutOfBoundsException. Fails to create the startPrefix at
CompositesSearcher.getIndexedIterator
SELECT * FROM products WHERE account = 'test' AND categories CONTAINS 'lmn';
//3. IndexOutOfBoundsException. Fails to create the endPrefix at
CompositesSearcher.getIndexedIterator
SELECT * FROM products WHERE account = 'test' AND id > 6 AND categories
CONTAINS 'lmn';
//4. Works fine
SELECT * FROM products WHERE account = 'test' AND id > 6 AND id < 1000 AND
categories CONTAINS 'lmn';
{code}
> Exception when querying a composite-keyed table with a collection index
> -----------------------------------------------------------------------
>
> Key: CASSANDRA-7372
> URL: https://issues.apache.org/jira/browse/CASSANDRA-7372
> Project: Cassandra
> Issue Type: Bug
> Reporter: Ghais Issa
> Fix For: 2.1.0
>
> Attachments: CASSANDRA-2.1-7372-v2.patch
>
>
> Given the following schema:
> {code}
> CREATE TABLE products (
> account text,
> id int,
> categories set<text>,
> PRIMARY KEY (account, id)
> );
> CREATE INDEX cat_index ON products(categories);
> {code}
> The following query fails with an exception
> {code}
> SELECT * FROM products WHERE account = 'xyz' AND categories CONTAINS 'lmn';
> errors={}, last_host=127.0.0.1
> {code}
> The exception in cassandra's log is:
> {code}
> WARN 17:01:49 Uncaught exception on thread
> Thread[SharedPool-Worker-2,5,main]: {}
> java.lang.RuntimeException: java.lang.IndexOutOfBoundsException
> at
> org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2015)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> ~[na:1.7.0_25]
> at
> org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:162)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:103)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]
> Caused by: java.lang.IndexOutOfBoundsException: null
> at
> org.apache.cassandra.db.composites.Composites$EmptyComposite.get(Composites.java:60)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.db.index.composites.CompositesIndexOnCollectionKey.makeIndexColumnPrefix(CompositesIndexOnCollectionKey.java:78)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.db.index.composites.CompositesSearcher.makePrefix(CompositesSearcher.java:82)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.db.index.composites.CompositesSearcher.getIndexedIterator(CompositesSearcher.java:116)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.db.index.composites.CompositesSearcher.search(CompositesSearcher.java:68)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.db.index.SecondaryIndexManager.search(SecondaryIndexManager.java:589)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.db.ColumnFamilyStore.search(ColumnFamilyStore.java:2060)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.db.RangeSliceCommand.executeLocally(RangeSliceCommand.java:131)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.service.StorageProxy$LocalRangeSliceRunnable.runMayThrow(StorageProxy.java:1368)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> at
> org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2011)
> ~[apache-cassandra-2.1.0-rc1.jar:2.1.0-rc1]
> ... 4 common frames omitted
> {code}
> The following query however works
> {code}
> SELECT * FROM products WHERE categories CONTAINS 'lmn';
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)