2012-01-11 61 views
1

您可以提供一個在phpcassa中的batch_mutate()函數的例子嗎?phpcassa cassandra批次突變

不能理解如何使用此功能,並沒有發現任何足夠的信息。

我也想知道如何與櫃檯提前使用

感謝。在櫃檯

回答

3

「刪除來自多個鍵的數據「:

function batch_remove($key=null, $columns=null, $super_column=null, $write_consistency_level=null) { 

    $timestamp = CassandraUtil::get_time(); 
    $deletion = new cassandra_Deletion(); 
    $deletion->timestamp = $timestamp; 

    if ($super_column !== null) $deletion->super_column = $this->pack_name($super_column, true); 
    else $deletion->super_column = null; 

    if ($columns !== null) { 
     $predicate = $this->create_slice_predicate($columns, '', '', false, self::DEFAULT_COLUMN_COUNT); 
     $deletion->predicate = $predicate; 
    } 

    $mutation = new cassandra_Mutation(); 
    $mutation->deletion = $deletion; 

    if (is_array($key) && count($key) >= 1) { 

     $mut_map = array(); 
     foreach($key as $v) { 
      $packed_key[$v] = $this->pack_key($v); 
      $mut_map[$v] = array($this->column_family => array($mutation)); 
     } 

     return $this->pool->call("batch_mutate", $mut_map, $this->wcl($write_consistency_level)); 

    } else return false; 

} 

//delete name1, name2, name3 from key1, key2 in a single call 
$column_family->batch_remove(array(key1, key2), array(name1, name2, name3)); 
+0

不確定這與所問的具體問題有什麼關係? – sdolgy 2012-02-03 18:00:33

2
  1. batch_mutate還沒有提供與PHPCassa:行動https://github.com/thobbs/phpcassa/issues/31
  2. batch_mutate,按照教程:http://thobbs.github.com/phpcassa/tutorial.html

「插入數據」:

$row1 = array('name1' => 'val1', 'name2' => 'val2'); 
$row2 = array('foo' => 'bar'); 
$column_family->batch_insert(array('row1' => $row1, 'row2' => $row2); 
+0

batch_remove作爲batch_insert工作嗎? $ column_family-> batch_remove(array($ row1,$ row2);? – Undrooleek 2012-01-31 13:43:45