cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Pittier <jordan.pitt...@gmail.com>
Subject Re: batch_mutate - PHP
Date Tue, 27 Apr 2010 22:01:27 GMT
Hi,
Here is a working example :

    $mutation_map = array("$key"=>array("Standard1" => array()));
    for($column_name=0; $column_name<$options['numcolumns']; $column_name++)
    {
      $column = new cassandra_Column(array('name' => "$column_name", 'value'
=> 'put your data here', 'timestamp' => time()));
      $c_or_sc = new cassandra_ColumnOrSuperColumn(array('column' =>
$column));
      $mutation = new cassandra_mutation(array('column_or_supercolumn' =>
$c_or_sc));
      $mutation_map["$key"]["Standard1"][] = $mutation;
    }
    $client->batch_mutate('Keyspace1', $mutation_map,
cassandra_ConsistencyLevel::ONE);

Hope it helps.

Jordan

On Tue, Apr 27, 2010 at 11:26 PM, Ken McCarthy <
kmccarthy@gridironsoftware.com> wrote:

> Any examples on how to set up the mutation_map ?
>
> The best I can figure out is:
>
> array(1) {
>   ["195f224d2e8d15d215726590754e3ff3"]=>
>   array(1) {
>     ["time"]=>
>     array(8) {
>       [0]=>
>       object(cassandra_Mutation)#18 (2) {
>         ["column_or_supercolumn"]=>
>         object(cassandra_ColumnOrSuperColumn)#19 (2) {
>           ["column"]=>
>           object(cassandra_Column)#20 (3) {
>             ["name"]=>
>             string(4) "user"
>             ["value"]=>
>             string(9) "memymo"
>             ["timestamp"]=>
>             int(1272399957)
>           }
>           ["super_column"]=>
>           NULL
>         }
>         ["deletion"]=>
>         NULL
>       }
>
> ........
>
>       [7]=>
>       object(cassandra_Mutation)#39 (2) {
>         ["column_or_supercolumn"]=>
>         object(cassandra_ColumnOrSuperColumn)#40 (2) {
>           ["column"]=>
>           object(cassandra_Column)#41 (3) {
>             ["name"]=>
>             string(8) "interval"
>             ["value"]=>
>             float(5)
>             ["timestamp"]=>
>             int(1272399957)
>           }
>           ["super_column"]=>
>           NULL
>         }
>         ["deletion"]=>
>         NULL
>       }
>     }
>   }
> }
>
>
> TException:  Error: Bad type in structure.
>
> Thanks.
>

Mime
View raw message