Skip to content
Permalink
Browse files

Revert "Table: moved caching related functionality to separate classes (

#185)"

This reverts commit a561254.
  • Loading branch information...
dg committed Apr 16, 2019
1 parent cf962df commit 8b6230de10ce3821bc223a063ef458b189195a60
@@ -68,7 +68,7 @@ public function __toString()
public function toArray(): array
{
$this->reloadAllColumns();
$this->accessColumn(null);
return $this->data;
}
@@ -204,7 +204,7 @@ public function delete(): int
public function getIterator(): \Iterator
{
$this->reloadAllColumns();
$this->accessColumn(null);
return new \ArrayIterator($this->data);
}
@@ -308,10 +308,14 @@ public function __unset($key)
/**
* @internal
*/
public function accessColumn(string $key, bool $selectColumn = true): bool
public function accessColumn($key, bool $selectColumn = true): bool
{
if ($this->table->accessColumn($key, $selectColumn) && !$this->dataRefreshed) {
$this->refreshData();
if (!isset($this->table[$this->getSignature()])) {
throw new Nette\InvalidStateException("Database refetch failed; row with signature '{$this->getSignature()}' does not exist!");
}
$this->data = $this->table[$this->getSignature()]->data;
$this->dataRefreshed = true;
}
return isset($this->data[$key]) || array_key_exists($key, $this->data);
}
@@ -321,22 +325,4 @@ protected function removeAccessColumn(string $key): void
{
$this->table->removeAccessColumn($key);
}
protected function reloadAllColumns(): void
{
if ($this->table->reloadAllColumns() && !$this->dataRefreshed) {
$this->refreshData();
}
}
protected function refreshData(): void
{
if (!isset($this->table[$this->getSignature()])) {
throw new Nette\InvalidStateException("Database refetch failed; row with signature '{$this->getSignature()}' does not exist!");
}
$this->data = $this->table[$this->getSignature()]->data;
$this->dataRefreshed = true;
}
}

This file was deleted.

Oops, something went wrong.
@@ -20,12 +20,12 @@
*/
class GroupedSelection extends Selection
{
/** @var mixed current assigned referencing array */
public $refCacheCurrent;
/** @var Selection referenced table */
protected $refTable;
/** @var mixed current assigned referencing array */
protected $refCacheCurrent;
/** @var string grouping column name */
protected $column;
@@ -92,8 +92,7 @@ public function order(string $columns, ...$params)
*/
public function aggregation(string $function)
{
$selectQueryHash = $this->sqlBuilder->getSelectQueryHash($this->cache->getPreviousAccessedColumns());
$aggregation = &$this->getRefTable($refPath)->aggregation[$refPath . $function . $selectQueryHash];
$aggregation = &$this->getRefTable($refPath)->aggregation[$refPath . $function . $this->sqlBuilder->getSelectQueryHash($this->getPreviousAccessedColumns())];
if ($aggregation === null) {
$aggregation = [];
@@ -131,16 +130,16 @@ public function count(string $column = null): int
protected function execute(): void
{
if ($this->rows !== null) {
$this->cache->setObserveCache($this);
$this->observeCache = $this;
return;
}
$accessedColumns = $this->cache->getAccessedColumns();
$accessedColumns = $this->accessedColumns;
$this->loadRefCache();
if (!isset($this->refCacheCurrent['data'])) {
// we have not fetched any data yet => init accessedColumns by cached accessedColumns
$this->cache->setAccessedColumns($accessedColumns);
$this->accessedColumns = $accessedColumns;
$limit = $this->sqlBuilder->getLimit();
$rows = count($this->refTable->rows);
@@ -168,7 +167,7 @@ protected function execute(): void
$this->data = &$this->refCacheCurrent['data'][$this->active];
}
$this->cache->setObserveCache($this);
$this->observeCache = $this;
if ($this->data === null) {
$this->data = [];
} else {
@@ -195,9 +194,12 @@ protected function getRefTable(&$refPath): Selection
protected function loadRefCache(): void
{
$referencing = &$this->refCache->getReferencing($this->cache->getGeneralCacheKey());
$hash = $this->cache->loadFromRefCache($referencing);
$hash = $this->getSpecificCacheKey();
$referencing = &$this->refCache['referencing'][$this->getGeneralCacheKey()];
$this->observeCache = &$referencing['observeCache'];
$this->refCacheCurrent = &$referencing[$hash];
$this->accessedColumns = &$referencing[$hash]['accessed'];
$this->specificCacheKey = &$referencing[$hash]['specificCacheKey'];
$this->rows = &$referencing[$hash]['rows'];
if (isset($referencing[$hash]['data'][$this->active])) {

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 8b6230d

Please sign in to comment.
You can’t perform that action at this time.