cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Stupp (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CASSANDRA-7396) Allow selecting Map key, List index
Date Fri, 08 Apr 2016 14:23:25 GMT

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

Robert Stupp updated CASSANDRA-7396:
------------------------------------
    Status: Patch Available  (was: In Progress)

[Branch|https://github.com/apache/cassandra/compare/trunk...snazy:7396-coll-slice]
[utests|http://cassci.datastax.com/view/Dev/view/snazy/job/snazy-7396-coll-slice-testall/lastSuccessfulBuild/]
[dtests|http://cassci.datastax.com/view/Dev/view/snazy/job/snazy-7396-coll-slice-dtest/lastSuccessfulBuild/]

It allows single element and slice selections on sets, maps and lists - both frozen and non-frozen
ones.

Syntax for single element selections is {{collection_column\[element_term\]}}.
Syntax for slice selections is {{collection_column\[from_term..to_term\]}}. Either {{from_term}}
or {{to_term}} can be omitted to make either one unbounded.
All kinds of terms are allowed - including bind markers and function calls. Single element
and slice selections can also be passed to functions/aggregates.
The resulting type of any element or slice selection is the same as the collection type. For
example, {{set_column\[element\]}} will return a set (not a boolean).

Non-frozen collections (complex data) except lists are treated special. It uses {{ColumnFilter}}
to filter only those values, that are within the bounds of the slice(s).

{{CollectionSerializer.serializeForNativeProtocol}} (moved from {{CollectionType}}) now takes
additional parameters to prevent superfluous serialization - this works for non-frozen lists,
too.
{{CollectionSerializer.reserializeForNativeProtocol}} performs similar work for frozen types.

{{SelectStatement}} tries to use one {{ColumnFilter}} instance for all executions of a (prepared)
statement. In case the terms for the element/slice sub-selection are dynamic ones (bound parameters,
function calls), a new {{ColumnFilter}} needs to be created for each execution in order to
benefit from its select/slice capabilities.

The new class {{SelectionRestriction}} is used as a descriptor of column element/slice/full
selections. Each individual selection has its own {{SelectionRestriction}} instance.

{{Term.Raw}} got a new function {{isConstant}}, which is needed to determine whether a {{SelectionRestriction}}
refers to a constant/literal value.

Some {{Selector}} methods now take {{QueryOptions}} instead of {{int protocolVersion}}, which
is needed to resolve bound variables and functions for element/slice bounds.

{{Selection}} now distinguishes between {{ByteBuffer}}s and {{ComplexColumnData}}. The {{ComplexColumnData}}
is used to use the “raw” cells for collection select/slice before these get serialized.
That {{ComplexColumnData}} is then passed to {{CollectionSerializer}}.

One maybe annoying thing in the syntax is the use of two dots to separate slice bounds. Given
a {{map<int,text>}} and doing a slice selection like {{SELECT col\[1..5\]}} will result
in a parser failure, because it interprets {{1.}} as the start of a floating point literal
and then complains about the 2nd dot. Workaround is to put a space between ({{SELECT col\[1
.. 5\]}}). I thought about using {{:}} as a separator, but that is the start of a bind parameter.
{{-}} is already “occupied” by negative numeric values. {{;}} is the end of a statement.
Using a keyword like {{TO}} makes unbounded slice queried look a bit awkward ({{SELECT col\[
TO 5\]}} or {{SELECT col\[5 TO \]}}.

> Allow selecting Map key, List index
> -----------------------------------
>
>                 Key: CASSANDRA-7396
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7396
>             Project: Cassandra
>          Issue Type: New Feature
>          Components: CQL
>            Reporter: Jonathan Ellis
>            Assignee: Robert Stupp
>              Labels: cql
>             Fix For: 3.x
>
>         Attachments: 7396_unit_tests.txt
>
>
> Allow "SELECT map['key]" and "SELECT list[index]."  (Selecting a UDT subfield is already
supported.)



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

Mime
View raw message