Property | Type | Description | |
---|---|---|---|
$currentId | integer | Id assigned to the DataTable, used to lookup the table using the DataTable_Manager | |
$depthLevel | integer | Current depth level of this data table 0 is the parent data table | |
$disabledFilters | array | List of disabled filter names eg 'Limit' or 'Sort' | |
$enableRecursiveFilters | boolean | When the table and all subtables are loaded, this flag will be set to true to ensure filters are applied to all subtables | |
$enableRecursiveSort | boolean | Defaults to false for performance reasons (most of the time we don't need recursive sorting so we save a looping over the dataTable) | |
$indexNotUpToDate | boolean | This flag is set to false once we modify the table in a way that outdates the index | |
$maximumAllowedRows | integer | If adding more rows is attempted, the extra rows get summed to the summary row. | |
$queuedFilters | array | List of BaseFilter queued to this table | |
$rebuildIndexContinuously | boolean | This is to optimize and not rebuild the full Index in the case where we add row, getRowFromLabel, addRow, getRowFromLabel thousands of times. | |
$rows | Array of Row | ||
$rowsCountBeforeLimitFilter | integer | We keep track of the number of rows before applying the LIMIT filter that deletes some rows | |
$rowsIndexByLabel | array | ||
$summaryRow | |||
$tableSortedBy | string | Column name of last time the table was sorted |
Method | Description | |
---|---|---|
__clone ( ) | Clone. Called when cloning the datatable. We need to make sure to create a new datatableId. | |
__construct ( ) | Constructor. Creates an empty DataTable. | |
__destruct ( ) | Destructor. Makes sure DataTable memory will be cleaned up. | |
__sleep ( ) | ||
__toString ( ) : string | Returns a string representation of this DataTable for convenient viewing. | |
addDataTable ( |
Sums a DataTable to this one. | |
addRow ( |
Adds a row to this table. | |
addRowFromArray ( array $row ) | Adds a new row from an array. | |
addRowFromSimpleArray ( array $row ) | Adds a new row a from an array of column values. | |
addRowsFromArray ( array $array ) | Adds multiple rows from an array. | |
addRowsFromSerializedArray ( string $serialized ) | Adds a set of rows from a serialized DataTable string. | |
addRowsFromSimpleArray ( array $array ) | Adds multiple rows from an array containing arrays of column values. | |
addSummaryRow ( |
Sets the summary row. | |
applyQueuedFilters ( ) | Applies all filters that were previously queued to the table. See {@link queueFilter()} for more information. | |
clearQueuedFilters ( ) | Unsets all queued filters. | |
deleteColumn ( string $name ) | Delete a column by name in every row. This change is NOT applied recursively to all subtables. | |
deleteColumns ( array $names, boolean $deleteRecursiveInSubtables = false ) | Deletes several columns by name in every row. | |
deleteRow ( integer $id ) | Deletes a row by ID. | |
deleteRows ( array $rowIds ) | Deletes a set of rows by ID. | |
deleteRowsOffset ( integer $offset, integer | null $limit = null ) : integer | Deletes rows from $offset to $offset + $limit. | |
disableFilter ( string $className ) | Disable a specific filter to run on this DataTable in case you have already applied this filter or if you will handle this filter manually by using a custom filter. Be aware if you disable a given filter, that filter won't be ever executed. Even if another filter calls this filter on the DataTable. | |
disableRecursiveFilters ( ) | ||
enableRecursiveFilters ( ) | Enables recursive filtering. If this method is called then the {@link filter()} method will apply filters to every subtable in addition to this instance. | |
enableRecursiveSort ( ) | Enables recursive sorting. If this method is called {@link sort()} will also sort all subtables. | |
filter ( string | Closur\Closure $className, array $parameters = [] ) | Applies a filter to this datatable. | |
filterSubtables ( string | Closur\Closure $className, array $parameters = [] ) | Applies a filter to all subtables but not to this datatable. | |
fromSerializedArray ( string $data ) : |
Creates a new DataTable instance from a serialized DataTable string. | |
getAllTableMetadata ( ) : array | Returns all table metadata. | |
getColumn ( string $name ) : array | Returns an array containing all column values for the requested column. | |
getColumns ( ) : array | Returns the names of every column this DataTable contains. This method will return the columns of the first row with data and will assume they occur in every other row as well. | |
getColumnsStartingWith ( string $namePrefix ) : array | Returns an array containing all column values of columns whose name starts with $name. | |
getEmptyClone ( boolean $keepFilters = true ) : |
Returns an empty DataTable with the same metadata and queued filters as $this one. | |
getFirstRow ( ) : |
Returns the first row of the DataTable. | |
getId ( ) : integer | Returns the DataTable ID. | |
getIterator ( ) : ArrayIterator | |
||
getLastRow ( ) : |
Returns the last row of the DataTable. If there is a summary row, it will always be considered the last row. | |
getMetadata ( string $name ) : mixed | false | Returns metadata by name. | |
getRowFromId ( integer $id ) : |
Returns a row by ID. The ID is either the index of the row or {@link ID_SUMMARY_ROW}. | |
getRowFromIdSubDataTable ( integer $idSubTable ) : |
Returns the row that has a subtable with ID matching $idSubtable. | |
getRowFromLabel ( string $label ) : |
Returns the Row whose 'label' column is equal to $label. | |
getRowIdFromLabel ( string $label ) : integer | Returns the row id for the row whose 'label' column is equal to $label. | |
getRows ( ) : |
Returns the array of Rows. | |
getRowsCount ( ) : integer | Returns the number of rows in the table including the summary row. | |
getRowsCountRecursive ( ) : integer | Returns the number of rows in the entire DataTable hierarchy. This is the number of rows in this DataTable summed with the row count of each descendant subtable. | |
getRowsCountWithoutSummaryRow ( ) | ||
getRowsMetadata ( string $name ) : array | Returns an array containing the requested metadata value of each row. | |
getRowsWithoutSummaryRow ( ) | ||
getSerialized ( integer $maximumRowsInDataTable = null, integer $maximumRowsInSubDataTable = null, string $columnToSortByBeforeTruncation = null ) : array | Serializes an entire DataTable hierarchy and returns the array of serialized DataTables. | |
getSortedByColumnName ( ) : false | string | Returns the name of the column this table was sorted by (if any). | |
isEqual ( |
Returns true if both DataTable instances are exactly the same. | |
isSortRecursiveEnabled ( ) | ||
makeFromIndexedArray ( array $array, array | null $subtablePerLabel = null ) : |
Rewrites the input $array | |
makeFromSimpleArray ( array $array ) : |
Returns a new DataTable created with data from a 'simple' array. | |
mergeSubtables ( string | boolean $labelColumn = false, boolean $useMetadataColumn = false ) : |
Returns a new DataTable in which the rows of this table are replaced with the aggregatated rows of all its subtables. | |
offsetExists ( $offset ) | ||
offsetGet ( $offset ) | ||
offsetSet ( $offset, $value ) | ||
offsetUnset ( $offset ) | ||
queueFilter ( string | Closur\Closure $className, array $parameters = [] ) | Adds a filter and a list of parameters to the list of queued filters. These filters will be executed when {@link applyQueuedFilters()} is called. | |
queueFilterSubtables ( string | Closur\Closure $className, array $parameters = [] ) | Adds a filter and a list of parameters to the list of queued filters of all subtables. These filters will be executed when {@link applyQueuedFilters()} is called. | |
rebuildIndex ( ) | Rebuilds the index used to lookup a row by label | |
renameColumn ( string $oldName, string $newName ) | Rename a column in every row. This change is applied recursively to all subtables. | |
setAllTableMetadata ( $metadata ) | Sets metadata, erasing existing values. | |
setLabelsHaveChanged ( ) | ||
setMaximumAllowedRows ( integer $maximumAllowedRows ) | Sets the maximum number of rows allowed in this datatable (including the summary row). If adding more then the allowed number of rows is attempted, the extra rows are summed to the summary row. | |
setMaximumDepthLevelAllowedAtLeast ( integer $atLeastLevel ) | Sets the maximum depth level to at least a certain value. If the current value is greater than $atLeastLevel, the maximum nesting level is not changed. | |
setMetadata ( string $name, mixed $value ) | Sets a metadata value by name. | |
setMetadataValues ( array $values ) | Sets several metadata values by name. | |
setRows ( $rows ) | ||
setTableSortedBy ( $column ) | ||
sort ( string $functionCallback, string $columnSortedBy ) | Sorts the DataTable rows using the supplied callback function. | |
walkPath ( array $path, array | boolean $missingRowColumns = false, integer $maxSubtableRows ) : array | Traverses a DataTable tree using an array of labels and returns the row it finds or false if it cannot find one. The number of path segments that were successfully walked is also returned. |
Method | Description | |
---|---|---|
aggregateRowFromSimpleTable ( $row ) | ||
aggregateRowWithLabel ( |
Aggregates the $row columns to this table. |
Method | Description | |
---|---|---|
unserializeRows ( string $serialized ) : array | It is faster to unserialize existing serialized Row instances to "Piwik_DataTable_SerializedRow" and access the $row->c property than implementing a "__wakeup" method in the Row instance to map the "$row->c" to $row->columns etc. We're talking here about 15% faster reports aggregation in some cases. To be concrete: We have a test where Archiving a year takes 1700 seconds with "__wakeup" and 1400 seconds with this method. Yes, it takes 300 seconds to wake up millions of rows. We should be able to remove this code here end 2015 and use the "__wakeup" way by then. |
public __clone ( ) |
public __destruct ( ) |
public __toString ( ) : string | ||
return | string |
public addDataTable ( |
||
$tableToSum |
public addRow ( |
||
$row | ||
return | `$row` or the summary row if we're at the maximum number of rows. |
public addRowFromArray ( array $row ) | ||
$row | array | eg. `array(Row::COLUMNS => array('visits' => 13, 'test' => 'toto'), Row::METADATA => array('mymetadata' => 'myvalue'))` |
public addRowFromSimpleArray ( array $row ) | ||
$row | array | eg. `array('name' => 'google analytics', 'license' => 'commercial')` |
public addRowsFromArray ( array $array ) | ||
$array | array | Array with the following structure array( // row1 array( Row::COLUMNS => array( col1_name => value1, col2_name => value2, ...), Row::METADATA => array( metadata1_name => value1, ...), // see Row ), // row2 array( ... ), ) |
public addRowsFromSerializedArray ( string $serialized ) | ||
$serialized | string | A string with the format of a string in the array returned by {@link serialize()}. |
public addRowsFromSimpleArray ( array $array ) | ||
$array | array | Array with the following structure: array( array( col1_name => valueA, col2_name => valueC, ...), array( col1_name => valueB, col2_name => valueD, ...), ) |
public addSummaryRow ( |
||
$row | ||
return | Returns `$row`. |
protected aggregateRowWithLabel ( |
||
$row |
public applyQueuedFilters ( ) |
public deleteColumn ( string $name ) | ||
$name | string | Column name to delete. |
public deleteColumns ( array $names, boolean $deleteRecursiveInSubtables = false ) | ||
$names | array | List of column names to delete. |
$deleteRecursiveInSubtables | boolean | Whether to apply this change to all subtables or not. |
public deleteRows ( array $rowIds ) | ||
$rowIds | array | The list of row IDs to delete. |
public disableFilter ( string $className ) | ||
$className | string | eg 'Limit' or 'Sort'. Passing a `Closure` or an `array($class, $methodName)` is not supported yet. We check for exact match. So if you disable 'Limit' and call `->filter('Limit')` this filter won't be executed. If you call `->filter('Piwik\DataTable\Filter\Limit')` that filter will be executed. See it as a feature. |
public enableRecursiveFilters ( ) |
public enableRecursiveSort ( ) |
public filter ( string | Closur\Closure $className, array $parameters = [] ) | ||
$className | string | Closur\Closure | Class name, eg. `"Sort"` or "Piwik\DataTable\Filters\Sort"`. If no namespace is supplied, `Piwik\DataTable\BaseFilter` is assumed. This parameter can also be a closure that takes a DataTable as its first parameter. |
$parameters | array | Array of extra parameters to pass to the filter. |
public filterSubtables ( string | Closur\Closure $className, array $parameters = [] ) | ||
$className | string | Closur\Closure | Class name, eg. `"Sort"` or "Piwik\DataTable\Filters\Sort"`. If no namespace is supplied, `Piwik\DataTable\BaseFilter` is assumed. This parameter can also be a closure that takes a DataTable as its first parameter. |
$parameters | array | Array of extra parameters to pass to the filter. |
public static fromSerializedArray ( string $data ) : |
||
$data | string | |
return |
public getAllTableMetadata ( ) : array | ||
return | array |
public getColumns ( ) : array | ||
return | array | Array of string column names. |
public getColumnsStartingWith ( string $namePrefix ) : array | ||
$namePrefix | string | The column name prefix. |
return | array | The array of column values. |
public getEmptyClone ( boolean $keepFilters = true ) : |
||
$keepFilters | boolean | Whether to pass the queued filter list to the new DataTable or not. |
return |
public getFirstRow ( ) : |
||
return | The first row or `false` if it cannot be found. |
public getIterator ( ) : ArrayIterator | |
||
return | ArrayIterator | |
public getLastRow ( ) : |
||
return | The last row or `false` if it cannot be found. |
public getMetadata ( string $name ) : mixed | false | ||
$name | string | The metadata name. |
return | mixed | false | The metadata value or `false` if it cannot be found. |
public getRowFromId ( integer $id ) : |
||
$id | integer | The row ID. |
return | The Row or false if not found. |
public getRowFromIdSubDataTable ( integer $idSubTable ) : |
||
$idSubTable | integer | The subtable ID. |
return | The row or false if not found |
public getRowFromLabel ( string $label ) : |
||
$label | string | `'label'` column value to look for. |
return | The row if found, `false` if otherwise. |
public getRowIdFromLabel ( string $label ) : integer | ||
$label | string | `'label'` column value to look for. |
return | integer | The row ID. |
public getRows ( ) : |
||
return |
public getRowsCount ( ) : integer | ||
return | integer |
public getRowsCountRecursive ( ) : integer | ||
return | integer |
public getRowsMetadata ( string $name ) : array | ||
$name | string | The metadata column to return. |
return | array |
public getSerialized ( integer $maximumRowsInDataTable = null, integer $maximumRowsInSubDataTable = null, string $columnToSortByBeforeTruncation = null ) : array | ||
$maximumRowsInDataTable | integer | If not null, defines the maximum number of rows allowed in the serialized DataTable. |
$maximumRowsInSubDataTable | integer | If not null, defines the maximum number of rows allowed in serialized subtables. |
$columnToSortByBeforeTruncation | string | The column to sort by before truncating, eg, `Metrics::INDEX_NB_VISITS`. |
return | array | The array of serialized DataTables: array( // this DataTable (the root) 0 => 'eghuighahgaueytae78yaet7yaetae', // a subtable 1 => 'gaegae gh gwrh guiwh uigwhuige', // another subtable 2 => 'gqegJHUIGHEQjkgneqjgnqeugUGEQHGUHQE', // etc. ); |
public getSortedByColumnName ( ) : false | string | ||
return | false | string | The sorted column name or false if none. |
public static makeFromSimpleArray ( array $array ) : |
||
$array | array | |
return |
public mergeSubtables ( string | boolean $labelColumn = false, boolean $useMetadataColumn = false ) : |
||
$labelColumn | string | boolean | If supplied the label of the parent row will be added to a new column in each subtable row. If set to, `'label'` each subtable row's label will be prepended w/ the parent row's label. So `'child_label'` becomes `'parent_label - child_label'`. |
$useMetadataColumn | boolean | If true and if `$labelColumn` is supplied, the parent row's label will be added as metadata and not a new column. |
return |
public queueFilter ( string | Closur\Closure $className, array $parameters = [] ) | ||
$className | string | Closur\Closure | The class name of the filter, eg. `'Limit'`. |
$parameters | array | The parameters to give to the filter, eg. `array($offset, $limit)` for the Limit filter. |
public queueFilterSubtables ( string | Closur\Closure $className, array $parameters = [] ) | ||
$className | string | Closur\Closure | The class name of the filter, eg. `'Limit'`. |
$parameters | array | The parameters to give to the filter, eg. `array($offset, $limit)` for the Limit filter. |
public rebuildIndex ( ) |
public renameColumn ( string $oldName, string $newName ) | ||
$oldName | string | Old column name. |
$newName | string | New column name. |
public setAllTableMetadata ( $metadata ) |
public setMaximumAllowedRows ( integer $maximumAllowedRows ) | ||
$maximumAllowedRows | integer | If `0`, the maximum number of rows is unset. |
public static setMaximumDepthLevelAllowedAtLeast ( integer $atLeastLevel ) | ||
$atLeastLevel | integer |
public setMetadata ( string $name, mixed $value ) | ||
$name | string | The metadata name. |
$value | mixed |
public setMetadataValues ( array $values ) | ||
$values | array | Array mapping metadata names with metadata values. |
public walkPath ( array $path, array | boolean $missingRowColumns = false, integer $maxSubtableRows ) : array | ||
$path | array | The path to walk. An array of label values. The first element refers to a row in this DataTable, the second in a subtable of the first row, the third a subtable of the second row, etc. |
$missingRowColumns | array | boolean | The default columns to use when creating new rows. If this parameter is supplied, new rows will be created for path labels that cannot be found. |
$maxSubtableRows | integer | The maximum number of allowed rows in new subtables. New subtables are only created if `$missingRowColumns` is provided. |
return | array | First element is the found row or `false`. Second element is the number of path segments walked. If a row is found, this will be == to `count($path)`. Otherwise, it will be the index of the path segment that we could not find. |
protected int $currentId | ||
return | integer |
protected int $depthLevel | ||
return | integer |
protected array $disabledFilters | ||
return | array |
protected bool $enableRecursiveFilters | ||
return | boolean |
protected bool $enableRecursiveSort | ||
return | boolean |
protected bool $indexNotUpToDate | ||
return | boolean |
protected int $maximumAllowedRows | ||
return | integer |
protected array $queuedFilters | ||
return | array |
protected bool $rebuildIndexContinuously | ||
return | boolean |
protected Row[],Piwik\DataTable $rows | ||
return |
protected int $rowsCountBeforeLimitFilter | ||
return | integer |
protected string $tableSortedBy | ||
return | string |