You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "Wangpei (Peter)" <pe...@huawei.com> on 2011/03/24 05:17:35 UTC

result of get_indexed_slices() seems wrong

Hi,

This problem occurs when the clause has multi expression and a expression with operator other than EQ.
Is anyone meet the same problem?

I trace the code, and seen this at ColumnFamilyStore.satisfies() method:
            int v = data.getComparator().compare(column.value(), expression.value);
It seems when I need the type of column value here, it use the type of my column names which is UTF8Type, so give the wrong result.
To fix it, the expression needs a optional "comparator_type" attribute, then satisfies() can get the correct type to compare.
pls point out if I am wrong.



Re: result of get_indexed_slices() seems wrong

Posted by Jonathan Ellis <jb...@gmail.com>.
it's unusual but valid to have an expression on a column w/ no metadata.

2011/3/24 Wangpei (Peter) <pe...@huawei.com>:
> Thanks aaron.
>
> Maybe we need to do more check at ThriftValidation.validateIndexClauses(),
> add this:
>
>         Map<ByteBuffer, ColumnDefinition> colDefs =
> DatabaseDescriptor.getTableDefinition(keyspace).cfMetaData().get(columnFamily).getColumn_metadata();
>
>         for (IndexExpression expression : index_clause.expressions)
>
>         {
>
>             if (!colDefs.containsKey(expression.column_name))
>
>                 throw new InvalidRequestException("No column definition for
> " + expression.column_name);
>
>         }
>
>
>
>
>
> 发件人: aaron morton [mailto:aaron@thelastpickle.com]
> 发送时间: 2011年3月24日 12:24
> 收件人: user@cassandra.apache.org
> 主题: Re: result of get_indexed_slices() seems wrong
>
>
>
> Looks like this https://issues.apache.org/jira/browse/CASSANDRA-2347
>
>
>
> From this
> discussion http://www.mail-archive.com/user@cassandra.apache.org/msg11291.html
>
>
>
>
>
> Aaron
>
>
>
> On 24 Mar 2011, at 17:17, Wangpei (Peter) wrote:
>
> Hi,
>
>
>
> This problem occurs when the clause has multi expression and a expression
> with operator other than EQ.
>
> Is anyone meet the same problem?
>
>
>
> I trace the code, and seen this at ColumnFamilyStore.satisfies() method:
>
>             int v = data.getComparator().compare(column.value(),
> expression.value);
>
> It seems when I need the type of column value here, it use the type of my
> column names which is UTF8Type, so give the wrong result.
>
> To fix it, the expression needs a optional "comparator_type" attribute, then
> satisfies() can get the correct type to compare.
>
> pls point out if I am wrong.
>
>
>
>
>
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of DataStax, the source for professional Cassandra support
http://www.datastax.com

Re: result of get_indexed_slices() seems wrong

Posted by "Wangpei (Peter)" <pe...@huawei.com>.
Thanks aaron.
Maybe we need to do more check at ThriftValidation.validateIndexClauses(), add this:
        Map<ByteBuffer, ColumnDefinition> colDefs = DatabaseDescriptor.getTableDefinition(keyspace).cfMetaData().get(columnFamily).getColumn_metadata();
        for (IndexExpression expression : index_clause.expressions)
        {
            if (!colDefs.containsKey(expression.column_name))
                throw new InvalidRequestException("No column definition for " + expression.column_name);
        }


发件人: aaron morton [mailto:aaron@thelastpickle.com]
发送时间: 2011年3月24日 12:24
收件人: user@cassandra.apache.org
主题: Re: result of get_indexed_slices() seems wrong

Looks like this https://issues.apache.org/jira/browse/CASSANDRA-2347

From this discussion http://www.mail-archive.com/user@cassandra.apache.org/msg11291.html


Aaron

On 24 Mar 2011, at 17:17, Wangpei (Peter) wrote:


Hi,

This problem occurs when the clause has multi expression and a expression with operator other than EQ.
Is anyone meet the same problem?

I trace the code, and seen this at ColumnFamilyStore.satisfies() method:
            int v = data.getComparator().compare(column.value(), expression.value);
It seems when I need the type of column value here, it use the type of my column names which is UTF8Type, so give the wrong result.
To fix it, the expression needs a optional “comparator_type” attribute, then satisfies() can get the correct type to compare.
pls point out if I am wrong.




Re: result of get_indexed_slices() seems wrong

Posted by aaron morton <aa...@thelastpickle.com>.
Looks like this https://issues.apache.org/jira/browse/CASSANDRA-2347

From this discussion http://www.mail-archive.com/user@cassandra.apache.org/msg11291.html


Aaron

On 24 Mar 2011, at 17:17, Wangpei (Peter) wrote:

> Hi,
>  
> This problem occurs when the clause has multi expression and a expression with operator other than EQ.
> Is anyone meet the same problem?
>  
> I trace the code, and seen this at ColumnFamilyStore.satisfies() method:
>             int v = data.getComparator().compare(column.value(), expression.value);
> It seems when I need the type of column value here, it use the type of my column names which is UTF8Type, so give the wrong result.
> To fix it, the expression needs a optional “comparator_type” attribute, then satisfies() can get the correct type to compare.
> pls point out if I am wrong.
>  
>