/** * Loads an entire columnfamily by keyid * @param string $keyID optional row key * @param bool $colAutoCreate create columns in the object instance which have not been defined * @param int $consistencyLevel cassandra consistency level * @return bool loaded OK */ public function load($keyID = NULL, $consistencyLevel = NULL) { if ($keyID === NULL) { $keyID = $this->getKeyID(); } $ok = $this->pathOK($keyID); $this->setLoaded(FALSE); if ($ok) { $autoCreate = $this->getAutoCreate(); $predicate = new cassandra_SlicePredicate(); // if autocreate is turned on, get latest limited everything if ($autoCreate) { $predicate->slice_range = new cassandra_SliceRange(); $predicate->slice_range->start = ''; $predicate->slice_range->finish = ''; $predicate->slice_range->count = $this->getLimit(); $predicate->slice_range->reversed = TRUE; $result = PandraCore::getCFSlice($this->getKeySpace(), $keyID, new cassandra_ColumnParent(array('column_family' => $this->getName())), $predicate, PandraCore::getConsistency($consistencyLevel)); // otherwise by defined columns (slice query) } else { $predicate->column_names = $this->getColumnNames(); $result = PandraCore::getCFSliceMulti($this->getKeySpace(), array($keyID), new cassandra_ColumnParent(array('column_family' => $this->getName())), $predicate, PandraCore::getConsistency($consistencyLevel)); $result = $result[$keyID]; } if ($result !== NULL) { // Clean slate $this->destroyColumns(); $this->destroyErrors(); $this->init(); // Try populating $this->setLoaded($this->populate($result, $autoCreate)); // If we're loaded, use a new key if ($this->isLoaded()) { $this->setKeyID($keyID); } } else { $this->registerError(PandraCore::$lastError); } } return $ok && $this->isLoaded(); }
public function extract($popType = self::POPULATE_MODEL) { // Check we have everything if ($this->pathOK()) { $result = NULL; // Cache hit? if ($this->cacheRetrieve($result)) { return $this->hydrate($popType, $result); } // Graph Processing PandraLog::debug('processing graph'); if (!empty($this->_graph[self::CONTEXT_SUPERCOLUMN])) { } $preResult = PandraCore::getCFSliceMulti($this->_keySpace, $this->_keys, $this->_columnFamily); //public function getCFSliceMulti($keySpace, array $keyIDs, $columnFamilyName, $superColumnName = NULL, $columnNames = array(), $consistencyLevel = NULL) { // We've got a basic result set, so filter out what we don't want // Cache and populate if ($result !== NULL) { $this->cacheStore($result); return $this->hydrate($popType, $result); } } else { throw new RuntimeException('Missing Keys, Keyspace or ColumnFamily'); } return NULL; }
/** * Loads an entire columnfamily by keyid * @param string $keyID optional row key * @param int $consistencyLevel cassandra consistency level * @return bool loaded OK */ public function load($keyID = NULL, $consistencyLevel = NULL) { if ($keyID === NULL) { $keyID = $this->getKeyID(); } $ok = $this->pathOK($keyID); $this->setLoaded(FALSE); if ($ok) { $autoCreate = $this->getAutoCreate(); $predicate = new cassandra_SlicePredicate(); // if autocreate is turned on, get latest limited everything if ($autoCreate) { $predicate->slice_range = new cassandra_SliceRange(); $predicate->slice_range->start = ''; $predicate->slice_range->finish = ''; $predicate->slice_range->count = $this->getLimit(); $predicate->slice_range->reversed = TRUE; $result = PandraCore::getCFSlice($this->getKeySpace(), $keyID, new cassandra_ColumnParent(array('column_family' => $this->getName())), $predicate, PandraCore::getConsistency($consistencyLevel)); // otherwise by defined columns (slice query) } else { $predicate->column_names = $this->getColumnNames(); $result = PandraCore::getCFSliceMulti($this->getKeySpace(), array($keyID), new cassandra_ColumnParent(array('column_family' => $this->getName())), $predicate, PandraCore::getConsistency($consistencyLevel)); $result = $result[$keyID]; } if ($result !== NULL) { $this->init(); foreach ($result as $superColumn) { $sc = $superColumn->super_column; $newSuper = new PandraSuperColumn($this->typeConvert($sc->name, UUID::UUID_FMT_STR), NULL, NULL, $this, $this->getType()); if ($this->addSuper($newSuper)->populate($sc->columns, $autoCreate)) { $this->setLoaded(TRUE); } else { $this->setLoaded(FALSE); break; } } if ($this->isLoaded()) { $this->setKeyID($keyID); } } else { $this->registerError(PandraCore::$lastError); } } return $ok && $this->isLoaded(); }