You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Andrew Hust (JIRA)" <ji...@apache.org> on 2015/09/03 17:12:47 UTC

[jira] [Commented] (CASSANDRA-7771) Allow multiple 2ndary index on the same column

    [ https://issues.apache.org/jira/browse/CASSANDRA-7771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14729220#comment-14729220 ] 

Andrew Hust commented on CASSANDRA-7771:
----------------------------------------

When creating separate indexes on both the key and value of a map column the ddl for the table in cqlsh only contains the index on the value.  Both indexes are functional and queries return expected results.  When querying metadata from the python driver (3.0.0a2) both indexes are present and using the function as_cql_query produces the correct ddl.  This might just be an out of date python lib in cqlsh.

Tested on C*: {{66b0e1d7889d0858753c6e364e77d86fe278eee4}}

Can be reproduced with the following shell commands and ccm:
{code}
ccm remove 2i_test
ccm create -n 1 -v git:cassandra-3.0 -s 2i_test
ccm start

cat << EOF | ccm node1 cqlsh
CREATE KEYSPACE index_test_ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
USE index_test_ks;
CREATE TABLE tbl1 (id uuid primary key, ds map<text, int>, c1 int);
INSERT INTO tbl1 (id, ds, c1) values (uuid(), {'foo': 1, 'bar': 2}, 1);
INSERT INTO tbl1 (id, ds, c1) values (uuid(), {'faz': 1, 'baz': 2}, 2);
CREATE INDEX ix_tbl1_map_values ON tbl1(ds);
CREATE INDEX ix_tbl1_map_keys ON tbl1(keys(ds));

SELECT * FROM tbl1 where ds contains 1;
SELECT * FROM tbl1 where ds contains key 'foo';

// *******
// DDL only has ix_tbl1_map_values present
// *******
DESC TABLE tbl1;

// *******
// system_schema.indexes is correct
// *******
SELECT * FROM system_schema.indexes;
EOF
ccm stop
{code}

Example output:
{code}
CREATE TABLE index_test_ks.tbl1 (
    id uuid PRIMARY KEY,
    c1 int,
    ds map<text, int>
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';
CREATE INDEX ix_tbl1_map_values ON index_test_ks.tbl1 (ds);


 keyspace_name | table_name | index_name         | index_type | options              | target_columns | target_type
---------------+------------+--------------------+------------+----------------------+----------------+-------------
 index_test_ks |       tbl1 |   ix_tbl1_map_keys | COMPOSITES |   {'index_keys': ''} |         {'ds'} |      COLUMN
 index_test_ks |       tbl1 | ix_tbl1_map_values | COMPOSITES | {'index_values': ''} |         {'ds'} |      COLUMN
{code}

> Allow multiple 2ndary index on the same column
> ----------------------------------------------
>
>                 Key: CASSANDRA-7771
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7771
>             Project: Cassandra
>          Issue Type: New Feature
>            Reporter: Sylvain Lebresne
>            Assignee: Sam Tunnicliffe
>              Labels: client-impacting
>             Fix For: 3.0 beta 1
>
>
> Currently, the code assumes that we'll only have one 2ndary index per column. This has been reasonable so far but stop being it with CASSANDRA-6382 (you might want to index multiple fields of the same UDT column) and CASSANDRA-7458 (you may want to have one "normal" index an multiple functional index for the same column). So we should consider removing that assumption in the code, which is mainly 2 places:
> # in the schema: each ColumnDefinition only has infos for one index. This part should probably be tackled in CASSANDRA-6717 so I'm marking this issue as a follow-up of CASSANDRA-6717.
> # in the 2ndary index API: this is the part I'm suggesting we fix in this issue.



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