original_string: public function addDataTable(DataTable $tableToSum)
      {
          if ($tableToSum instanceof Simple) {
              if ($tableToSum->getRowsCount() > 1) {
                  throw new Exception("Did not expect a Simple table with more than one row in addDataTable()");
              }
              $row = $tableToSum->getFirstRow();
              $this->aggregateRowFromSimpleTable($row);
          } else {
              $columnAggregationOps = $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
              foreach ($tableToSum->getRowsWithoutSummaryRow() as $row) {
                  $this->aggregateRowWithLabel($row, $columnAggregationOps);
              }
              // we do not use getRows() as this method might get called 100k times when aggregating many datatables and
              // this takes a lot of time.
              $row = $tableToSum->getRowFromId(DataTable::ID_SUMMARY_ROW);
              if ($row) {
                  $this->aggregateRowWithLabel($row, $columnAggregationOps);
              }
          }
      }
code: public function addDataTable(DataTable $tableToSum)
      {
          if ($tableToSum instanceof Simple) {
              if ($tableToSum->getRowsCount() > 1) {
                  throw new Exception("Did not expect a Simple table with more than one row in addDataTable()");
              }
              $row = $tableToSum->getFirstRow();
              $this->aggregateRowFromSimpleTable($row);
          } else {
              $columnAggregationOps = $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
              foreach ($tableToSum->getRowsWithoutSummaryRow() as $row) {
                  $this->aggregateRowWithLabel($row, $columnAggregationOps);
              }
              // we do not use getRows() as this method might get called 100k times when aggregating many datatables and
              // this takes a lot of time.
              $row = $tableToSum->getRowFromId(DataTable::ID_SUMMARY_ROW);
              if ($row) {
                  $this->aggregateRowWithLabel($row, $columnAggregationOps);
              }
          }
      }
code_tokens: public function addDataTable ( DataTable $ tableToSum ) { if ( $ tableToSum instanceof Simple ) { if ( $ tableToSum -> getRowsCount ( ) > 1 ) { throw new Exception ( "Did not expect a Simple table with more than one row in addDataTable()" ) ; } $ row = $ tableToSum -> getFirstRow ( ) ; $ this -> aggregateRowFromSimpleTable ( $ row ) ; } else { $ columnAggregationOps = $ this -> getMetadata ( self :: COLUMN_AGGREGATION_OPS_METADATA_NAME ) ; foreach ( $ tableToSum -> getRowsWithoutSummaryRow ( ) as $ row ) { $ this -> aggregateRowWithLabel ( $ row , $ columnAggregationOps ) ; } // we do not use getRows() as this method might get called 100k times when aggregating many datatables and // this takes a lot of time. $ row = $ tableToSum -> getRowFromId ( DataTable :: ID_SUMMARY_ROW ) ; if ( $ row ) { $ this -> aggregateRowWithLabel ( $ row , $ columnAggregationOps ) ; } } }
docstring: Sums a DataTable to this one.
  
  This method will sum rows that have the same label. If a row is found in `$tableToSum` whose
  label is not found in `$this`, the row will be added to `$this`.
  
  If the subtables for this table are loaded, they will be summed as well.
  
  Rows are summed together by summing individual columns. By default columns are summed by
  adding one column value to another. Some columns cannot be aggregated this way. In these
  cases, the {@link COLUMN_AGGREGATION_OPS_METADATA_NAME}
  metadata can be used to specify a different type of operation.
  
  @param \Piwik\DataTable $tableToSum
  @throws Exception
docstring_tokens: Sums a DataTable to this one .