Dear Wiki user, You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for change notification.
The "ClientExamples" page has been changed by MikeRoberts. The comment on this change is: add a batch_insert example. http://wiki.apache.org/cassandra/ClientExamples?action=diff&rev1=33&rev2=34 -------------------------------------------------- // Update the value to be inserted for the updated column Path $value = "24"; $client->insert($keyspace, $keyUserId, $columnPath, $value, $timestamp, $consistency_level); + + /* + * use batch_insert to insert a supercolumn and its children using the standard config + * builds the structure + * + * Super1 : { + * KeyName : { + * SuperColumnName : { + * foo : fooey value + * bar : bar like thing + * } + * } + */ + + // build columns to insert + $column1 = new cassandra_Column(); + $column1->name = 'foo'; + $column1->value = 'fooey value'; + $column1->timestamp = time(); + + $column2 = new cassandra_Column(); + $column2->name = 'bar'; + $column2->value = 'bar like thing'; + $column2->timestamp = time(); + + // build super column containing the columns + $super_column = new cassandra_SuperColumn(); + $super_column->name = 'SuperColumnName'; + $super_column->columns = array($column1, $column2); + + // create columnorsupercolumn holder class that batch_insert uses + $c_or_sc = new cassandra_ColumnOrSuperColumn(); + $c_or_sc->super_column = $super_column; + + // create the mutation (a map of ColumnFamily names to lists ColumnsOrSuperColumns objects + $mutation['Super1'] = array($c_or_sc); + + $client->batch_insert($keyspace, 'KeyName', $mutation, $consistency_level); /* Query for data */
