On Thu, Mar 13, 2014 at 12:12 PM, David Savage <davemssav...@gmail.com>wrote:

> Hi there,
>
> I'm experimenting using cassandra and have run across an error message
> which I need a little more information on.
>
> The use case I'm experimenting with is a series of document updates
> (documents being an arbitrary map of key value pairs), I would like to find
> the latest document updates after a specified time period. I don't want to
> store many copies of the documents (one per update) as the updates are
> often only to single keys in the map so that would involve a lot of
> duplicated data.
>
> The solution I've found that seems to fit best in terms of performance is
> to have two tables.
>
> One that has an event log of timeuuid -> docid and a second that stores
> the documents themselves stored by docid -> map<string, string>. I then run
> two queries, one to select ids that have changed after a certain time:
>
> SELECT id FROM eventlog WHERE timestamp>=minTimeuuid($minimumTime)
>
> and then a second to select the actual documents themselves
>
> SELECT id, data FROM documents WHERE id IN (0, 1, 2, 3, 4, 5, 6, 7...)
>
> However this then explodes on query with the error message:
>
> "Cannot restrict PRIMARY KEY part id by IN relation as a collection is
> selected by the query"
>
> Detective work lead me to these lines in
> org.apache.cassandra.cql3.statementsSelectStatement:
>
>                     // We only support IN for the last name and for
> compact storage so far
>                     // TODO: #3885 allows us to extend to non compact as
> well, but that remains to be done
>                     if (i != stmt.columnRestrictions.length - 1)
>                         throw new
> InvalidRequestException(String.format("PRIMARY KEY part %s cannot be
> restricted by IN relation", cname));
>                     else if (stmt.selectACollection())
>                         throw new
> InvalidRequestException(String.format("Cannot restrict PRIMARY KEY part %s
> by IN relation as a collection is selected by the query", cname));
>
> It seems like #3885 will allow support for the first IF block above, but I
> don't think it will allow the second, am I correct?
>

Right, #3885 is about the first one. Tbh, the 2nd limitation is kind of
historical and unless I'm forgetting something, we should be able to lift
that pretty easily. If you don't mind opening a JIRA ticket, I'll have a
look at removing said limitation.

--
Sylvain



>
> Any pointers on how I can work around this would be greatly appreciated.
>
> Kind regards,
>
> Dave
>

Reply via email to