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

DOAN DuyHai commented on CASSANDRA-11538:
-----------------------------------------

Ok to make it clearer

For static column index (*RegularColumnIndex*):

{code:java}
    public CBuilder buildIndexClusteringPrefix(ByteBuffer partitionKey,
                                               ClusteringPrefix prefix,
                                               CellPath path)
    {
        CBuilder builder = CBuilder.create(getIndexComparator());
        builder.add(partitionKey);
        for (int i = 0; i < prefix.size(); i++)
            builder.add(prefix.get(i));

        // Note: if indexing a static column, prefix will be 
Clustering.STATIC_CLUSTERING
        // so the Clustering obtained from builder::build will contain a value 
for only
        // the partition key. At query time though, this is all that's needed 
as the entire
        // base table partition should be returned for any mathching index 
entry.
        return builder;
    }
{code}

For partition component index (*PartitionKeyIndex*):


{code:java}
    public CBuilder buildIndexClusteringPrefix(ByteBuffer partitionKey,
                                               ClusteringPrefix prefix,
                                               CellPath path)
    {
        CBuilder builder = CBuilder.create(getIndexComparator());
        builder.add(partitionKey);
        for (int i = 0; i < prefix.size(); i++)
            builder.add(prefix.get(i));
        return builder;
    }
{code}

As you can see, for static column index, we only store the singleton 
*Clustering.STATIC_CLUSTERING* because it is sufficient. However, the source 
code for partition component index stores all the clustering values for each 
row, which is not necessary since we only need the full partition key to access 
the complete partition.

> Give secondary index on partition column the same treatment as static column
> ----------------------------------------------------------------------------
>
>                 Key: CASSANDRA-11538
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11538
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: CQL
>         Environment: Cassandra 3.4
>            Reporter: DOAN DuyHai
>            Priority: Minor
>
> For index on static column, in the index table we store:
> - partition key = base table static column value
> - clustering =  base table complete partition key (as a single value)
> The way we handle index on partition column is different, we store:
> - partition key = base table partition column value
> - clustering 1 = base table complete partition key (as a single value)
> - clustering 2 ... N+1 = N clustering values of the base table
> It is more consistent to give partition column index the same treatment as 
> the one for static column



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

Reply via email to