cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Stupp (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-7970) JSON support for CQL
Date Wed, 11 Feb 2015 15:00:30 GMT


Robert Stupp commented on CASSANDRA-7970:

Beside some last points from my side. I’ve compared your branch against it’s origin in
trunk, since it does not merge without conflicts against current trunk - but that’s fine
for a ”quick look”.

* {{ColumnCondition.CollectionBound#valueAppliesTo}}, {{Lists.getElementsFromValue}}, {{Sets.getElementsFromValue}}
and {{Maps.Putter}} do similar things. Any chance to consolidate everything/most into a single
function/few functions?
* in {{Json#handleCaseSensitivity}} you can remove the two ArrayLists and the Map.put/remove
sequences when you iterate iterate over {{for (String mapKey : new HashSet(valueMap.keySet()))}}
* not sure, if you already have, but a unit test to test all combinations in {{Json#handleCaseSensitivity}}
would be great
* Can you remove {{Selection#validateSelectors}}? It’s unused.
* Can you extract a method for the two switch-statements at the end of {{ParsedInsert#prepareInternal}}?
* In {{SetType.fromJSONObject}} you could add a simple {{if (!buffers.add(…)) throw SomeMeaningfulDuplicateElementException}}
(and remove the size-check after the loop).
* in {{UserType.fromJSONObject}} you can safely replace {{buffers}} with an ordinary array

Regarding the JSON library: I’ve created CASSANDRA-8785 (software not maintained for many
years does feel right).

> JSON support for CQL
> --------------------
>                 Key: CASSANDRA-7970
>                 URL:
>             Project: Cassandra
>          Issue Type: New Feature
>          Components: API
>            Reporter: Jonathan Ellis
>            Assignee: Tyler Hobbs
>             Fix For: 3.0
>         Attachments: 7970-trunk-v1.txt
> JSON is popular enough that not supporting it is becoming a competitive weakness.  We
can add JSON support in a way that is compatible with our performance goals by *mapping* JSON
to an existing schema: one JSON documents maps to one CQL row.
> Thus, it is NOT a goal to support schemaless documents, which is a misfeature [1] [2]
[3].  Rather, it is to allow a convenient way to easily turn a JSON document from a service
or a user into a CQL row, with all the validation that entails.
> Since we are not looking to support schemaless documents, we will not be adding a JSON
data type (CASSANDRA-6833) a la postgresql.  Rather, we will map the JSON to UDT, collections,
and primitive CQL types.
> Here's how this might look:
> {code}
> CREATE TYPE address (
>   street text,
>   city text,
>   zip_code int,
>   phones set<text>
> );
> CREATE TABLE users (
>   id uuid PRIMARY KEY,
>   name text,
>   addresses map<text, address>
> );
> {‘id’: 4b856557-7153,
>    ‘name’: ‘jbellis’,
>    ‘address’: {“home”: {“street”: “123 Cassandra Dr”,
>                         “city”: “Austin”,
>                         “zip_code”: 78747,
>                         “phones”: [2101234567]}}};
> SELECT JSON id, address FROM users;
> {code}
> (We would also want to_json and from_json functions to allow mapping a single column's
worth of data.  These would not require extra syntax.)
> [1]
> [2]
> [3]

This message was sent by Atlassian JIRA

View raw message