diff options
author | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-05-31 11:36:25 +0400 |
---|---|---|
committer | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-05-31 11:36:25 +0400 |
commit | 6abbacb9575087161ade571de2b0ad373b03d115 (patch) | |
tree | 4da27e6b31ffc2f62e0cb0b7ee2cecfd15de2c22 /core/TablePartitioning.php | |
parent | cbc929d0e6a10337c29c3459048611c23a2d2d65 (diff) |
Refactored archive data querying code. Removed tree-like data structure from Piwik_Archive, added memory optimizations for archiving (not storing archive processing instances), added optimization for querying data indexed by site + date, added ability to select multiple blobs/metrics at once (from different plugins), added optimization to Piwik_ArchiveProcessing_Period where numerics/records are selected all at once instead of one at a time.
Also added data access layer object for archive querying code, allowed anonymous function objects to be used as DataTable filters, and removed 'timestamp' DataTable metadata.
Diffstat (limited to 'core/TablePartitioning.php')
-rw-r--r-- | core/TablePartitioning.php | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/core/TablePartitioning.php b/core/TablePartitioning.php index 40bcec40d0..b3341940ba 100644 --- a/core/TablePartitioning.php +++ b/core/TablePartitioning.php @@ -97,6 +97,9 @@ abstract class Piwik_TablePartitioning */ class Piwik_TablePartitioning_Monthly extends Piwik_TablePartitioning { + private static $blobArchiveTable = null; + private static $numericArchiveTable = null; + public function __construct($tableName) { parent::__construct($tableName); @@ -107,24 +110,29 @@ class Piwik_TablePartitioning_Monthly extends Piwik_TablePartitioning $config = Piwik_Config::getInstance(); return $config->database['tables_prefix'] . $this->tableName . "_" . date("Y_m", $this->timestamp); } - -} - -/** - * - * @package Piwik - * @subpackage Piwik_TablePartitioning - */ -class Piwik_TablePartitioning_Daily extends Piwik_TablePartitioning -{ - public function __construct($tableName) + + /** + * Creates archive_blob & archive_numeric tables for a period if they don't + * already exist. + * + * @param Piwik_Period $periodInMonth + */ + public static function createArchiveTablesIfAbsent($periodInMonth) { - parent::__construct($tableName); + $timestamp = $periodInMonth->getDateStart()->getTimestamp(); + + self::$blobArchiveTable->setTimestamp($timestamp); + self::$blobArchiveTable->getTableName(); + + self::$numericArchiveTable->setTimestamp($timestamp); + self::$numericArchiveTable->getTableName(); } - - protected function generateTableName() + + public static function init() { - $config = Piwik_Config::getInstance(); - return $config->database['tables_prefix'] . $this->tableName . "_" . date("Y_m_d", $this->timestamp); + self::$blobArchiveTable = new Piwik_TablePartitioning_Monthly('archive_blob'); + self::$numericArchiveTable = new Piwik_TablePartitioning_Monthly('archive_numeric'); } } + +Piwik_TablePartitioning_Monthly::init(); |