| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\ArchiveProcessor; |
|
|
| |
| |
| |
| |
| class Record |
| { |
| public const TYPE_NUMERIC = 'numeric'; |
| public const TYPE_BLOB = 'blob'; |
|
|
| |
| |
| |
| private $type; |
|
|
| |
| |
| |
| private $name; |
|
|
| |
| |
| |
| private $plugin = null; |
|
|
| |
| |
| |
| private $columnToSortByBeforeTruncation; |
|
|
| |
| |
| |
| private $maxRowsInTable; |
|
|
| |
| |
| |
| private $maxRowsInSubtable; |
|
|
| |
| |
| |
| private $countOfRecordName = null; |
|
|
| |
| |
| |
| private $countOfRecordNameIsRecursive = false; |
|
|
| |
| |
| |
| private $countOfRecordNameIsForLeafs = false; |
|
|
| |
| |
| |
| private $columnToRenameAfterAggregation = null; |
|
|
| |
| |
| |
| private $blobColumnAggregationOps = null; |
|
|
| |
| |
| |
| private $multiplePeriodTransform = null; |
|
|
| |
| |
| |
| private $aggregatedRecordTransform = null; |
|
|
| |
| |
| |
| private $builtFromFlatRecord = null; |
|
|
| |
| |
| |
| private $flatToHierarchyPathCallback = null; |
|
|
| |
| |
| |
| private $legacyHierarchyToFlatReducerCallback = null; |
|
|
| public static function make($type, $name) |
| { |
| $record = new Record(); |
| $record->setType($type); |
| $record->setName($name); |
| return $record; |
| } |
|
|
| public function setPlugin(?string $plugin): Record |
| { |
| $this->plugin = $plugin; |
| return $this; |
| } |
|
|
| public function setName(string $name): Record |
| { |
| if (!preg_match('/^[a-zA-Z0-9_-]+$/', $name)) { |
| throw new \Exception('Invalid record name: ' . $name . '. Only alphanumeric characters, hyphens and underscores are allowed.'); |
| } |
|
|
| $this->name = $name; |
| return $this; |
| } |
|
|
| |
| |
| |
| |
| public function setColumnToSortByBeforeTruncation($columnToSortByBeforeTruncation) |
| { |
| $this->columnToSortByBeforeTruncation = $columnToSortByBeforeTruncation; |
| return $this; |
| } |
|
|
| public function setMaxRowsInTable(?int $maxRowsInTable): Record |
| { |
| $this->maxRowsInTable = $maxRowsInTable; |
| return $this; |
| } |
|
|
| public function setMaxRowsInSubtable(?int $maxRowsInSubtable): Record |
| { |
| $this->maxRowsInSubtable = $maxRowsInSubtable; |
| return $this; |
| } |
|
|
| public function getPlugin(): ?string |
| { |
| return $this->plugin; |
| } |
|
|
| public function getName(): string |
| { |
| return $this->name; |
| } |
|
|
| |
| |
| |
| public function getColumnToSortByBeforeTruncation() |
| { |
| return $this->columnToSortByBeforeTruncation; |
| } |
|
|
| public function getMaxRowsInTable(): ?int |
| { |
| return $this->maxRowsInTable; |
| } |
|
|
| public function getMaxRowsInSubtable(): ?int |
| { |
| return $this->maxRowsInSubtable; |
| } |
|
|
| public function setType(string $type): Record |
| { |
| $this->type = $type; |
| return $this; |
| } |
|
|
| public function getType(): string |
| { |
| return $this->type; |
| } |
|
|
| public function setIsCountOfBlobRecordRows(string $dependentRecordName, bool $isRecursive = false): Record |
| { |
| $this->countOfRecordName = $dependentRecordName; |
| $this->countOfRecordNameIsRecursive = $isRecursive; |
| return $this; |
| } |
|
|
| public function setIsCountOfBlobRecordLeafRows(string $dependentRecordName): Record |
| { |
| $this->countOfRecordName = $dependentRecordName; |
| $this->countOfRecordNameIsForLeafs = true; |
| return $this; |
| } |
|
|
| public function getCountOfRecordName(): ?string |
| { |
| return $this->countOfRecordName; |
| } |
|
|
| public function getCountOfRecordNameIsRecursive(): bool |
| { |
| return $this->countOfRecordNameIsRecursive; |
| } |
|
|
| public function getCountOfRecordNameIsForLeafs(): bool |
| { |
| return $this->countOfRecordNameIsForLeafs; |
| } |
|
|
| |
| |
| |
| public function setColumnToRenameAfterAggregation(?array $columnToRenameAfterAggregation): Record |
| { |
| $this->columnToRenameAfterAggregation = $columnToRenameAfterAggregation; |
| return $this; |
| } |
|
|
| |
| |
| |
| public function getColumnToRenameAfterAggregation(): ?array |
| { |
| return $this->columnToRenameAfterAggregation; |
| } |
|
|
| |
| |
| |
| public function setBlobColumnAggregationOps(?array $blobColumnAggregationOps): Record |
| { |
| $this->blobColumnAggregationOps = $blobColumnAggregationOps; |
| return $this; |
| } |
|
|
| |
| |
| |
| public function getBlobColumnAggregationOps(): ?array |
| { |
| return $this->blobColumnAggregationOps; |
| } |
|
|
| public function setMultiplePeriodTransform(?callable $multiplePeriodTransform): Record |
| { |
| $this->multiplePeriodTransform = $multiplePeriodTransform; |
| return $this; |
| } |
|
|
| public function getMultiplePeriodTransform(): ?callable |
| { |
| return $this->multiplePeriodTransform; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public function setAggregatedRecordTransform(?callable $transform): Record |
| { |
| if (null !== $transform && $this->type !== self::TYPE_BLOB) { |
| throw new \InvalidArgumentException('setAggregatedRecordTransform() can only be used with blob records.'); |
| } |
|
|
| $this->aggregatedRecordTransform = $transform; |
| return $this; |
| } |
|
|
| public function getAggregatedRecordTransform(): ?callable |
| { |
| return $this->aggregatedRecordTransform; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public function setBuiltFromFlatRecord( |
| string $flatRecordName, |
| callable $flatToHierarchyPathCallback, |
| ?callable $legacyHierarchyToFlatReducerCallback = null |
| ): Record { |
| if ($this->type !== self::TYPE_BLOB) { |
| throw new \InvalidArgumentException('setBuiltFromFlatRecord() can only be used with blob records.'); |
| } |
|
|
| if (!preg_match('/^[a-zA-Z0-9_-]+$/', $flatRecordName)) { |
| throw new \InvalidArgumentException('Invalid flat record name: ' . $flatRecordName); |
| } |
|
|
| $this->builtFromFlatRecord = $flatRecordName; |
| $this->flatToHierarchyPathCallback = $flatToHierarchyPathCallback; |
| $this->legacyHierarchyToFlatReducerCallback = $legacyHierarchyToFlatReducerCallback; |
|
|
| return $this; |
| } |
|
|
| public function getBuiltFromFlatRecord(): ?string |
| { |
| return $this->builtFromFlatRecord; |
| } |
|
|
| |
| |
| |
| public function getFlatToHierarchyPathCallback(): ?callable |
| { |
| return $this->flatToHierarchyPathCallback; |
| } |
|
|
| |
| |
| |
| public function getLegacyHierarchyToFlatReducerCallback(): ?callable |
| { |
| return $this->legacyHierarchyToFlatReducerCallback; |
| } |
| } |
|
|