kallaspriit / Cassandra-PHP-Client-Library

Cassandra PHP-based client library for managing and querying your Cassandra cluster
http://cassandra-php-client-library.com
103 stars 25 forks source link

Cannot getWhere using other Operator, except Equality #29

Open anhphuong opened 11 years ago

anhphuong commented 11 years ago

Hi, I have an problem when I try to get data by Operator Greater & Less than.

First, I use this code: $aged24 = $cassandra->cf ( 'user' )->getWhere ( array ( array ( 'age', Cassandra::OP_EQ, 24 ) ) ); echo 'Users 24:

' . print_r ( $aged24->getAll(), true ) . '

';

The result OK, it showed: Array ( [jane.doe] => Array ( [age] => 24 [email] => jane@doe.com [name] => Jane Doe ) )

But, when I want get Greater, I changed code to: $aged20plus = $cassandra->cf ( 'user' )->getWhere ( array ( array ( 'age', Cassandra::OP_GT, 20 ) ) ); echo 'Users 20+:

' . print_r ( $aged20plus->getAll(), true ) . '

';

The result have Exception: "Failed calling "get_indexed_slices" the maximum of 5 times"

Please help me solve this problem. Thanks so much ^_^

kallaspriit commented 11 years ago

Are you using order-preserving partitioner?

anhphuong commented 11 years ago

Thanks so much for your care, kallaspriit :D I don't understand mush about your question. I only tried run "example.php", and then I add new code for purpose Select list of data where age greater than 20 (at example.php, it only have code to Select where age equal 24 year)

kallaspriit commented 11 years ago

Some useful reading on the topic:

http://ria101.wordpress.com/2010/02/22/cassandra-randompartitioner-vs-orderpreservingpartitioner/ http://www.datastax.com/docs/1.1/cluster_architecture/partitioning http://wiki.apache.org/cassandra/StorageConfiguration

anhphuong commented 11 years ago

so, are you sure this problem is about Cassandra Server config ?

kallaspriit commented 11 years ago

Most likely, the example.php includes a comparison OP too that is commented out because it does not work with default config.

anhphuong commented 11 years ago

Hi kallaspriit,

Thanks a lot for your help :D

I try open file cassandra.yaml follow your guide, then change the line: partitioner: org.apache.cassandra.dht.Murmur3Partitioner to partitioner: org.apache.cassandra.dht.OrderPreservingPartitioner

Then, I restart Cassandra.

I try run my code (php) again, it still had above problem :(

So, what's wrong I missed ?

anhphuong commented 11 years ago

Hi kallaspriit,

I try uncomment this line:

$usersAZ = $cassandra->cf ( 'user' )->getKeyRange ( 'a', 'z' ); print_r ( $usersAZ->getAll (), true );

The result show OK like that: Array (

[jane.doe] => Array
    (
        [age] => 24
        [email] => jane@doe.com
        [name] => Jane Doe
    )

[john] => Array
    (
        [age] => 34
        [email] => john@smith.com
        [name] => John Smith
    )

)

But, my code: $aged20plus = $cassandra->cf ( 'user' )->getWhere ( array ( array ( 'age', Cassandra::OP_GT, 20 ) ) ); print_r ( $aged20plus->getAll(), true );

Still show Exception: "Failed calling "get_indexed_slices" the maximum of 5 times" :(

pawankukreja01 commented 11 months ago

The error message you’re seeing indicates that the Cassandra driver has failed to retrieve the data you requested. This could be due to a number of reasons, such as network connectivity issues, incorrect configuration settings, or a bug in the driver itself.

it seems that this error message is often caused by a timeout issue. You might want to try increasing the timeout value in your code and see if that resolves the issue. Alternatively, you could try optimizing your query by adding an index on the ‘age’ column 1.