You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Jean-Nicolas Boulay Desjardins <jn...@gmail.com> on 2011/06/28 21:06:35 UTC

Problem with PHPCassa accessing Indexes

Hi,

I am having problem accessing data via an index with PHPCassa. I have
var_dump() the results:

array(6) { ["birthdate"]=> int(3546927995491989807) ["email"]=>
string(20) "jnbdzjnbdz@gmail.com" ["firstname"]=> string(12)
"Jean-Nicolas" ["lastname"]=> string(17) "Boulay Desjardins"
["password"]=> string(8) "password" ["username"]=> string(5) "jnbdz" }

object(cassandra_IndexExpression)#76 (3) { ["column_name"]=> string(5)
"email" ["op"]=> int(0) ["value"]=> string(20) "jnbdzjnbdz@gmail.com"
}

object(cassandra_IndexClause)#77 (3) { ["expressions"]=> array(1) {
[0]=> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=>
string(5) "email" ["op"]=> int(0) ["value"]=> string(20)
"jnbdzjnbdz@gmail.com" } } ["start_key"]=> string(0) "" ["count"]=>
int(100) }

Here is the code:

$columnFamily = CASSANDRA::selectColumnFamily('Users');

                $this->selectUser = $columnFamily->get('jnbdz');

                var_dump($this->selectUser);

                echo '<br/>';
                echo '<br/>';

                $index_exp =
CassandraUtil::create_index_expression('email',
'jnbdzjnbdz@gmail.com');
var_dump($index_exp);
                $index_clause =
CassandraUtil::create_index_clause(array($index_exp));
echo '<br/>';
echo '<br/>';
var_dump($index_clause);
                $rows = $column_family->get_indexed_slices($index_clause);
echo '<br/>';
echo '<br/>';
var_dump($rows);
                var_dump($row);

Thanks in advance for any help

Re: Problem with PHPCassa accessing Indexes

Posted by Tyler Hobbs <ty...@datastax.com>.
The output of 'describe keyspace' would be useful for figuring this
out, at well.

On Tue, Jun 28, 2011 at 5:10 PM, Jean-Nicolas Boulay Desjardins
<jn...@gmail.com> wrote:
> Sorry, my mistake. The variable name was wrong. Weird, I did not get any errors.
>
> Thanks anyways.
>
> But I do Have a another question. When looking in cassandra-cli I did
> "get Users[jnbdz];" and I got:
>
> A long is exactly 8 bytes: 10
>
> And I don't get the data.
>
> Am I missing something?
>
> Thanks in advance.
>
> On Tue, Jun 28, 2011 at 6:00 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>> What does the ouput of 'describe keyspace <keyspaces>' show for the
>> keyspace the CF is in?
>>
>> On Tue, Jun 28, 2011 at 2:35 PM, Jean-Nicolas Boulay Desjardins
>> <jn...@gmail.com> wrote:
>>> Actually I am not getting any results from: get_indexed_slices()
>>>
>>> It seems my code dies at: $rows =
>>> $column_family->get_indexed_slices($index_clause);
>>>
>>> Because everything after that is echo is not shown on the page.
>>>
>>> Plus I don't get any errors.
>>>
>>> Any ideas?
>>>
>>> On Tue, Jun 28, 2011 at 3:23 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>>>> The result of get_indexed_slices() is an Iterator object, not an
>>>> array.  It doesn't look like you're treating it accordingly.
>>>>
>>>> See the bottom of this section for an example:
>>>> http://thobbs.github.com/phpcassa/tutorial.html#indexes
>>>>
>>>> On Tue, Jun 28, 2011 at 2:06 PM, Jean-Nicolas Boulay Desjardins
>>>> <jn...@gmail.com> wrote:
>>>>> Hi,
>>>>>
>>>>> I am having problem accessing data via an index with PHPCassa. I have
>>>>> var_dump() the results:
>>>>>
>>>>> array(6) { ["birthdate"]=> int(3546927995491989807) ["email"]=>
>>>>> string(20) "jnbdzjnbdz@gmail.com" ["firstname"]=> string(12)
>>>>> "Jean-Nicolas" ["lastname"]=> string(17) "Boulay Desjardins"
>>>>> ["password"]=> string(8) "password" ["username"]=> string(5) "jnbdz" }
>>>>>
>>>>> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=> string(5)
>>>>> "email" ["op"]=> int(0) ["value"]=> string(20) "jnbdzjnbdz@gmail.com"
>>>>> }
>>>>>
>>>>> object(cassandra_IndexClause)#77 (3) { ["expressions"]=> array(1) {
>>>>> [0]=> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=>
>>>>> string(5) "email" ["op"]=> int(0) ["value"]=> string(20)
>>>>> "jnbdzjnbdz@gmail.com" } } ["start_key"]=> string(0) "" ["count"]=>
>>>>> int(100) }
>>>>>
>>>>> Here is the code:
>>>>>
>>>>> $columnFamily = CASSANDRA::selectColumnFamily('Users');
>>>>>
>>>>>                 $this->selectUser = $columnFamily->get('jnbdz');
>>>>>
>>>>>                 var_dump($this->selectUser);
>>>>>
>>>>>                 echo '<br/>';
>>>>>                 echo '<br/>';
>>>>>
>>>>>                 $index_exp =
>>>>> CassandraUtil::create_index_expression('email',
>>>>> 'jnbdzjnbdz@gmail.com');
>>>>> var_dump($index_exp);
>>>>>                 $index_clause =
>>>>> CassandraUtil::create_index_clause(array($index_exp));
>>>>> echo '<br/>';
>>>>> echo '<br/>';
>>>>> var_dump($index_clause);
>>>>>                 $rows = $column_family->get_indexed_slices($index_clause);
>>>>> echo '<br/>';
>>>>> echo '<br/>';
>>>>> var_dump($rows);
>>>>>                 var_dump($row);
>>>>>
>>>>> Thanks in advance for any help
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Tyler Hobbs
>>>> Software Engineer, DataStax
>>>> Maintainer of the pycassa Cassandra Python client library
>>>>
>>>
>>>
>>>
>>> --
>>> Name / Nom: Boulay Desjardins, Jean-Nicolas
>>> Website / Site Web: www.jeannicolas.com
>>>
>>
>>
>>
>> --
>> Tyler Hobbs
>> Software Engineer, DataStax
>> Maintainer of the pycassa Cassandra Python client library
>>
>
>
>
> --
> Name / Nom: Boulay Desjardins, Jean-Nicolas
> Website / Site Web: www.jeannicolas.com
>



-- 
Tyler Hobbs
Software Engineer, DataStax
Maintainer of the pycassa Cassandra Python client library

Re: Problem with PHPCassa accessing Indexes

Posted by Jean-Nicolas Boulay Desjardins <jn...@gmail.com>.
Sorry, my mistake. The variable name was wrong. Weird, I did not get any errors.

Thanks anyways.

But I do Have a another question. When looking in cassandra-cli I did
"get Users[jnbdz];" and I got:

A long is exactly 8 bytes: 10

And I don't get the data.

Am I missing something?

Thanks in advance.

On Tue, Jun 28, 2011 at 6:00 PM, Tyler Hobbs <ty...@datastax.com> wrote:
> What does the ouput of 'describe keyspace <keyspaces>' show for the
> keyspace the CF is in?
>
> On Tue, Jun 28, 2011 at 2:35 PM, Jean-Nicolas Boulay Desjardins
> <jn...@gmail.com> wrote:
>> Actually I am not getting any results from: get_indexed_slices()
>>
>> It seems my code dies at: $rows =
>> $column_family->get_indexed_slices($index_clause);
>>
>> Because everything after that is echo is not shown on the page.
>>
>> Plus I don't get any errors.
>>
>> Any ideas?
>>
>> On Tue, Jun 28, 2011 at 3:23 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>>> The result of get_indexed_slices() is an Iterator object, not an
>>> array.  It doesn't look like you're treating it accordingly.
>>>
>>> See the bottom of this section for an example:
>>> http://thobbs.github.com/phpcassa/tutorial.html#indexes
>>>
>>> On Tue, Jun 28, 2011 at 2:06 PM, Jean-Nicolas Boulay Desjardins
>>> <jn...@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> I am having problem accessing data via an index with PHPCassa. I have
>>>> var_dump() the results:
>>>>
>>>> array(6) { ["birthdate"]=> int(3546927995491989807) ["email"]=>
>>>> string(20) "jnbdzjnbdz@gmail.com" ["firstname"]=> string(12)
>>>> "Jean-Nicolas" ["lastname"]=> string(17) "Boulay Desjardins"
>>>> ["password"]=> string(8) "password" ["username"]=> string(5) "jnbdz" }
>>>>
>>>> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=> string(5)
>>>> "email" ["op"]=> int(0) ["value"]=> string(20) "jnbdzjnbdz@gmail.com"
>>>> }
>>>>
>>>> object(cassandra_IndexClause)#77 (3) { ["expressions"]=> array(1) {
>>>> [0]=> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=>
>>>> string(5) "email" ["op"]=> int(0) ["value"]=> string(20)
>>>> "jnbdzjnbdz@gmail.com" } } ["start_key"]=> string(0) "" ["count"]=>
>>>> int(100) }
>>>>
>>>> Here is the code:
>>>>
>>>> $columnFamily = CASSANDRA::selectColumnFamily('Users');
>>>>
>>>>                 $this->selectUser = $columnFamily->get('jnbdz');
>>>>
>>>>                 var_dump($this->selectUser);
>>>>
>>>>                 echo '<br/>';
>>>>                 echo '<br/>';
>>>>
>>>>                 $index_exp =
>>>> CassandraUtil::create_index_expression('email',
>>>> 'jnbdzjnbdz@gmail.com');
>>>> var_dump($index_exp);
>>>>                 $index_clause =
>>>> CassandraUtil::create_index_clause(array($index_exp));
>>>> echo '<br/>';
>>>> echo '<br/>';
>>>> var_dump($index_clause);
>>>>                 $rows = $column_family->get_indexed_slices($index_clause);
>>>> echo '<br/>';
>>>> echo '<br/>';
>>>> var_dump($rows);
>>>>                 var_dump($row);
>>>>
>>>> Thanks in advance for any help
>>>>
>>>
>>>
>>>
>>> --
>>> Tyler Hobbs
>>> Software Engineer, DataStax
>>> Maintainer of the pycassa Cassandra Python client library
>>>
>>
>>
>>
>> --
>> Name / Nom: Boulay Desjardins, Jean-Nicolas
>> Website / Site Web: www.jeannicolas.com
>>
>
>
>
> --
> Tyler Hobbs
> Software Engineer, DataStax
> Maintainer of the pycassa Cassandra Python client library
>



-- 
Name / Nom: Boulay Desjardins, Jean-Nicolas
Website / Site Web: www.jeannicolas.com

Re: Problem with PHPCassa accessing Indexes

Posted by Tyler Hobbs <ty...@datastax.com>.
What does the ouput of 'describe keyspace <keyspaces>' show for the
keyspace the CF is in?

On Tue, Jun 28, 2011 at 2:35 PM, Jean-Nicolas Boulay Desjardins
<jn...@gmail.com> wrote:
> Actually I am not getting any results from: get_indexed_slices()
>
> It seems my code dies at: $rows =
> $column_family->get_indexed_slices($index_clause);
>
> Because everything after that is echo is not shown on the page.
>
> Plus I don't get any errors.
>
> Any ideas?
>
> On Tue, Jun 28, 2011 at 3:23 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>> The result of get_indexed_slices() is an Iterator object, not an
>> array.  It doesn't look like you're treating it accordingly.
>>
>> See the bottom of this section for an example:
>> http://thobbs.github.com/phpcassa/tutorial.html#indexes
>>
>> On Tue, Jun 28, 2011 at 2:06 PM, Jean-Nicolas Boulay Desjardins
>> <jn...@gmail.com> wrote:
>>> Hi,
>>>
>>> I am having problem accessing data via an index with PHPCassa. I have
>>> var_dump() the results:
>>>
>>> array(6) { ["birthdate"]=> int(3546927995491989807) ["email"]=>
>>> string(20) "jnbdzjnbdz@gmail.com" ["firstname"]=> string(12)
>>> "Jean-Nicolas" ["lastname"]=> string(17) "Boulay Desjardins"
>>> ["password"]=> string(8) "password" ["username"]=> string(5) "jnbdz" }
>>>
>>> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=> string(5)
>>> "email" ["op"]=> int(0) ["value"]=> string(20) "jnbdzjnbdz@gmail.com"
>>> }
>>>
>>> object(cassandra_IndexClause)#77 (3) { ["expressions"]=> array(1) {
>>> [0]=> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=>
>>> string(5) "email" ["op"]=> int(0) ["value"]=> string(20)
>>> "jnbdzjnbdz@gmail.com" } } ["start_key"]=> string(0) "" ["count"]=>
>>> int(100) }
>>>
>>> Here is the code:
>>>
>>> $columnFamily = CASSANDRA::selectColumnFamily('Users');
>>>
>>>                 $this->selectUser = $columnFamily->get('jnbdz');
>>>
>>>                 var_dump($this->selectUser);
>>>
>>>                 echo '<br/>';
>>>                 echo '<br/>';
>>>
>>>                 $index_exp =
>>> CassandraUtil::create_index_expression('email',
>>> 'jnbdzjnbdz@gmail.com');
>>> var_dump($index_exp);
>>>                 $index_clause =
>>> CassandraUtil::create_index_clause(array($index_exp));
>>> echo '<br/>';
>>> echo '<br/>';
>>> var_dump($index_clause);
>>>                 $rows = $column_family->get_indexed_slices($index_clause);
>>> echo '<br/>';
>>> echo '<br/>';
>>> var_dump($rows);
>>>                 var_dump($row);
>>>
>>> Thanks in advance for any help
>>>
>>
>>
>>
>> --
>> Tyler Hobbs
>> Software Engineer, DataStax
>> Maintainer of the pycassa Cassandra Python client library
>>
>
>
>
> --
> Name / Nom: Boulay Desjardins, Jean-Nicolas
> Website / Site Web: www.jeannicolas.com
>



-- 
Tyler Hobbs
Software Engineer, DataStax
Maintainer of the pycassa Cassandra Python client library

Re: Problem with PHPCassa accessing Indexes

Posted by Jean-Nicolas Boulay Desjardins <jn...@gmail.com>.
Actually I am not getting any results from: get_indexed_slices()

It seems my code dies at: $rows =
$column_family->get_indexed_slices($index_clause);

Because everything after that is echo is not shown on the page.

Plus I don't get any errors.

Any ideas?

On Tue, Jun 28, 2011 at 3:23 PM, Tyler Hobbs <ty...@datastax.com> wrote:
> The result of get_indexed_slices() is an Iterator object, not an
> array.  It doesn't look like you're treating it accordingly.
>
> See the bottom of this section for an example:
> http://thobbs.github.com/phpcassa/tutorial.html#indexes
>
> On Tue, Jun 28, 2011 at 2:06 PM, Jean-Nicolas Boulay Desjardins
> <jn...@gmail.com> wrote:
>> Hi,
>>
>> I am having problem accessing data via an index with PHPCassa. I have
>> var_dump() the results:
>>
>> array(6) { ["birthdate"]=> int(3546927995491989807) ["email"]=>
>> string(20) "jnbdzjnbdz@gmail.com" ["firstname"]=> string(12)
>> "Jean-Nicolas" ["lastname"]=> string(17) "Boulay Desjardins"
>> ["password"]=> string(8) "password" ["username"]=> string(5) "jnbdz" }
>>
>> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=> string(5)
>> "email" ["op"]=> int(0) ["value"]=> string(20) "jnbdzjnbdz@gmail.com"
>> }
>>
>> object(cassandra_IndexClause)#77 (3) { ["expressions"]=> array(1) {
>> [0]=> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=>
>> string(5) "email" ["op"]=> int(0) ["value"]=> string(20)
>> "jnbdzjnbdz@gmail.com" } } ["start_key"]=> string(0) "" ["count"]=>
>> int(100) }
>>
>> Here is the code:
>>
>> $columnFamily = CASSANDRA::selectColumnFamily('Users');
>>
>>                 $this->selectUser = $columnFamily->get('jnbdz');
>>
>>                 var_dump($this->selectUser);
>>
>>                 echo '<br/>';
>>                 echo '<br/>';
>>
>>                 $index_exp =
>> CassandraUtil::create_index_expression('email',
>> 'jnbdzjnbdz@gmail.com');
>> var_dump($index_exp);
>>                 $index_clause =
>> CassandraUtil::create_index_clause(array($index_exp));
>> echo '<br/>';
>> echo '<br/>';
>> var_dump($index_clause);
>>                 $rows = $column_family->get_indexed_slices($index_clause);
>> echo '<br/>';
>> echo '<br/>';
>> var_dump($rows);
>>                 var_dump($row);
>>
>> Thanks in advance for any help
>>
>
>
>
> --
> Tyler Hobbs
> Software Engineer, DataStax
> Maintainer of the pycassa Cassandra Python client library
>



-- 
Name / Nom: Boulay Desjardins, Jean-Nicolas
Website / Site Web: www.jeannicolas.com

Re: Problem with PHPCassa accessing Indexes

Posted by Tyler Hobbs <ty...@datastax.com>.
The result of get_indexed_slices() is an Iterator object, not an
array.  It doesn't look like you're treating it accordingly.

See the bottom of this section for an example:
http://thobbs.github.com/phpcassa/tutorial.html#indexes

On Tue, Jun 28, 2011 at 2:06 PM, Jean-Nicolas Boulay Desjardins
<jn...@gmail.com> wrote:
> Hi,
>
> I am having problem accessing data via an index with PHPCassa. I have
> var_dump() the results:
>
> array(6) { ["birthdate"]=> int(3546927995491989807) ["email"]=>
> string(20) "jnbdzjnbdz@gmail.com" ["firstname"]=> string(12)
> "Jean-Nicolas" ["lastname"]=> string(17) "Boulay Desjardins"
> ["password"]=> string(8) "password" ["username"]=> string(5) "jnbdz" }
>
> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=> string(5)
> "email" ["op"]=> int(0) ["value"]=> string(20) "jnbdzjnbdz@gmail.com"
> }
>
> object(cassandra_IndexClause)#77 (3) { ["expressions"]=> array(1) {
> [0]=> object(cassandra_IndexExpression)#76 (3) { ["column_name"]=>
> string(5) "email" ["op"]=> int(0) ["value"]=> string(20)
> "jnbdzjnbdz@gmail.com" } } ["start_key"]=> string(0) "" ["count"]=>
> int(100) }
>
> Here is the code:
>
> $columnFamily = CASSANDRA::selectColumnFamily('Users');
>
>                 $this->selectUser = $columnFamily->get('jnbdz');
>
>                 var_dump($this->selectUser);
>
>                 echo '<br/>';
>                 echo '<br/>';
>
>                 $index_exp =
> CassandraUtil::create_index_expression('email',
> 'jnbdzjnbdz@gmail.com');
> var_dump($index_exp);
>                 $index_clause =
> CassandraUtil::create_index_clause(array($index_exp));
> echo '<br/>';
> echo '<br/>';
> var_dump($index_clause);
>                 $rows = $column_family->get_indexed_slices($index_clause);
> echo '<br/>';
> echo '<br/>';
> var_dump($rows);
>                 var_dump($row);
>
> Thanks in advance for any help
>



-- 
Tyler Hobbs
Software Engineer, DataStax
Maintainer of the pycassa Cassandra Python client library