Пример #1
0
 /**
  * Save this column family and any modified columns to Cassandra
  * @param cassandra_ColumnPath $columnPath
  * @param int $consistencyLevel Cassandra consistency level
  * @return bool save ok
  */
 public function save($consistencyLevel = NULL)
 {
     $ok = $this->pathOK();
     if ($ok) {
         if ($this->getDelete()) {
             $columnPath = new cassandra_ColumnPath();
             $columnPath->column_family = $this->getName();
             $ok = PandraCore::deleteColumnPath($this->getKeySpace(), $this->getKeyID(), $columnPath, NULL, PandraCore::getConsistency($consistencyLevel));
             if (!$ok) {
                 $this->registerError(PandraCore::$lastError);
             }
         } else {
             // @todo have this use thrift batch_insert method in core
             $modifiedColumns = $this->getModifiedColumns();
             foreach ($modifiedColumns as &$cObj) {
                 if (!$cObj->save(PandraCore::getConsistency($consistencyLevel))) {
                     $this->registerError($cObj->getLastError());
                     return FALSE;
                 }
             }
             $ok = TRUE;
         }
         if ($ok) {
             $this->reset();
         }
     }
     return $ok;
 }
Пример #2
0
 public function save($consistencyLevel = NULL)
 {
     if (!$this->isModified()) {
         return FALSE;
     }
     $ok = FALSE;
     // Deletes the entire columnfamily by key
     if ($this->isDeleted()) {
         $columnPath = new cassandra_ColumnPath();
         $columnPath->column_family = $this->getName();
         $ok = PandraCore::deleteColumnPath($this->getKeySpace(), $this->keyID, $columnPath, time(), PandraCore::getConsistency($consistencyLevel));
         if (!$ok) {
             $this->registerError(PandraCore::$lastError);
         }
     } else {
         foreach ($this->_columns as $colName => $superColumn) {
             $ok = $superColumn->save();
             if (!$ok) {
                 $this->registerError(PandraCore::$lastError);
                 break;
             }
         }
     }
     return $ok;
 }
Пример #3
0
 /**
  * Save all columns in this loaded columnfamily
  * @return void
  */
 public function save($consistencyLevel = NULL)
 {
     if (!$this->isModified()) {
         return FALSE;
     }
     $ok = $this->pathOK();
     if ($ok) {
         if ($this->getDelete()) {
             $columnPath = new cassandra_ColumnPath();
             $columnPath->column_family = $this->getColumnFamilyName();
             $columnPath->super_column = $this->getName();
             $ok = PandraCore::deleteColumnPath($this->getKeySpace(), $this->getKeyID(), $columnPath, NULL, PandraCore::getConsistency($consistencyLevel));
         } else {
             $this->bindTimeModifiedColumns();
             $ok = PandraCore::saveSuperColumn($this->getKeySpace(), $this->getKeyID(), array($this->getColumnFamilyName()), array($this->getName() => $this->getModifiedColumns()), PandraCore::getConsistency($consistencyLevel));
         }
         if ($ok) {
             $this->reset();
         } else {
             $this->registerError(PandraCore::$lastError);
         }
     }
     return $ok;
 }
Пример #4
0
 /**
  * Save this column family and any modified columns to Cassandra
  * @param cassandra_ColumnPath $columnPath
  * @param int $consistencyLevel Cassandra consistency level
  * @return bool save ok
  */
 public function save($consistencyLevel = NULL)
 {
     $this->checkCFState();
     $ok = FALSE;
     if ($this->getDelete()) {
         $columnPath = new cassandra_ColumnPath();
         $columnPath->column_family = $this->getName();
         $ok = PandraCore::deleteColumnPath($this->getKeySpace(), $this->keyID, $columnPath, time());
         if (!$ok) {
             $this->registerError(PandraCore::$lastError);
         }
     } else {
         foreach ($this->_columns as &$cObj) {
             if (!$cObj->isModified()) {
                 continue;
             }
             if (!$cObj->save($this->keyID, $this->getKeySpace(), $this->getName(), PandraCore::getConsistency($consistencyLevel))) {
                 $this->registerError($cObj->getLastError());
                 return FALSE;
             }
         }
         $ok = TRUE;
     }
     if ($ok) {
         $this->reset();
     }
     return $ok;
 }
Пример #5
0
 /**
  * Saves this individual column path
  * @param string $keyID row key
  * @param sring $keySpace key space
  * @param string $columnFamily column family name
  * @param int $consistencyLevel cassandra save consistency level
  * @return bool save ok
  */
 public function save($keyID, $keySpace, $columnFamily, $consistencyLevel = NULL)
 {
     if (!$this->isModified()) {
         return TRUE;
     }
     // Build the column path for modifying this individual column
     $columnPath = new cassandra_ColumnPath();
     $columnPath->column_family = $columnFamily;
     $columnPath->column = $this->name;
     $ok = FALSE;
     if ($this->_delete) {
         $ok = PandraCore::deleteColumnPath($keySpace, $keyID, $columnPath, $this->bindTime(), PandraCore::getConsistency($consistencyLevel));
     } else {
         $ok = PandraCore::saveColumnPath($keySpace, $keyID, $columnPath, $this->callback === NULL ? $this->value : $this->callbackvalue(), $this->bindTime(), PandraCore::getConsistency($consistencyLevel));
     }
     if (!$ok) {
         if (empty(PandraCore::$errors)) {
             $errorStr = 'Unkown Error';
         } else {
             $errorStr = PandraCore::$errors;
         }
         $this->registerError($errorStr);
     }
     if ($ok) {
         $this->reset();
     }
     return $ok;
 }
Пример #6
0
 /**
  * Saves this individual column path, where a parent has been set (setParent()) keyid, keyspace, columnfamily or supercolumn
  * will be inherited for the save.
  * @return bool save ok
  */
 public function save($consistencyLevel = NULL)
 {
     if (!$this->isModified()) {
         $this->registerError("Column " . $this->name . " is not modified");
         return FALSE;
     }
     // Build the column path for modifying this individual column
     $columnPath = new cassandra_ColumnPath();
     $columnPath->column_family = $this->getColumnFamilyName();
     $columnPath->super_column = $this->getSuperColumnName();
     $columnPath->column = $this->getName();
     $ok = FALSE;
     if ($this->isDeleted()) {
         $ok = PandraCore::deleteColumnPath($this->getKeySpace(), $this->getKeyID(), $columnPath, $this->bindTime(), PandraCore::getConsistency($consistencyLevel));
     } else {
         $ok = PandraCore::saveColumnPath($this->getKeySpace(), $this->getKeyID(), $columnPath, $this->callbackvalue(), $this->bindTime(), PandraCore::getConsistency($consistencyLevel));
     }
     if (!$ok) {
         if (empty(PandraCore::$lastError)) {
             $errorStr = 'Unknown Error';
         } else {
             $errorStr = PandraCore::$lastError;
         }
         $this->registerError($errorStr);
     }
     if ($ok) {
         $this->reset();
     }
     return $ok;
 }