Task/Collect.php
public function collectComponentDataIncremental($job_list, &$results) {
    // Populate an array of incremental data that we collect for the given job
    // list, so array_merge() works.
    $incremental_data = array_fill_keys($this->collectorClassNames, []);

    // Keep track of any jobs which are the last for their collector, so we
    // know to write to the real storage file rather than temporary.
    $final_jobs = [];

    // Group the jobs by collector.
    $grouped_jobs = [];
    foreach ($job_list as $job) {
      $collector_class_name = $job['collector'];
      $grouped_jobs[$collector_class_name][] = $job;
    }

    // Pass each set of jobs to its respective collective.
    foreach ($grouped_jobs as $collector_class_name => $jobs) {
      $collector_helper = $this->getHelper($collector_class_name);

      $incremental_data[$collector_class_name] = $collector_helper->collect($jobs);

      $last_job = end($jobs);
      if (!empty($last_job['last'])) {
        $final_jobs[$collector_class_name] = TRUE;
      }
    }

    // Save the data for each collector.
    $storage = $this->environment->getStorage();
    foreach ($incremental_data as $collector_name => $collector_incremental_data) {
      // We have a key for every collector in $incremental_data, but have not
      // necessarily run jobs for that collector in this batch. Skip if empty.
      if (empty($collector_incremental_data)) {
        continue;
      }

      $collector_helper = $this->getHelper($collector_name);

      $storage_key = $collector_helper->getSaveDataKey();
      $temporary_storage_key = $storage_key . '_temporary';

      // Merge what we've just collected for this collector with what we've
      // collected on previous calls to this method.
      $data = $storage->retrieve($temporary_storage_key);

      $data = $collector_helper->mergeComponentData($data, $collector_incremental_data);

      if (isset($final_jobs[$collector_name])) {
        // We've done the final job for this collector. Store the data
        // accumulated so far into the permanent file, and clean up the
        // temporary file.
        $storage->store($storage_key, $data);
        $storage->delete($temporary_storage_key);

        // Add the count to the results.
        $collector_count = $collector_helper->getDataCount($data);
        $results[$collector_helper->getReportingKey()] = $collector_count;
      }
      else {
        $storage->store($temporary_storage_key, $data);
      }
    }
  }
public function collectComponentDataIncremental($job_list, &$results) {
    // Populate an array of incremental data that we collect for the given job
    // list, so array_merge() works.
    $incremental_data = array_fill_keys($this->collectorClassNames, []);

    // Keep track of any jobs which are the last for their collector, so we
    // know to write to the real storage file rather than temporary.
    $final_jobs = [];

    // Group the jobs by collector.
    $grouped_jobs = [];
    foreach ($job_list as $job) {
      $collector_class_name = $job['collector'];
      $grouped_jobs[$collector_class_name][] = $job;
    }

    // Pass each set of jobs to its respective collective.
    foreach ($grouped_jobs as $collector_class_name => $jobs) {
      $collector_helper = $this->getHelper($collector_class_name);

      $incremental_data[$collector_class_name] = $collector_helper->collect($jobs);

      $last_job = end($jobs);
      if (!empty($last_job['last'])) {
        $final_jobs[$collector_class_name] = TRUE;
      }
    }

    // Save the data for each collector.
    $storage = $this->environment->getStorage();
    foreach ($incremental_data as $collector_name => $collector_incremental_data) {
      // We have a key for every collector in $incremental_data, but have not
      // necessarily run jobs for that collector in this batch. Skip if empty.
      if (empty($collector_incremental_data)) {
        continue;
      }

      $collector_helper = $this->getHelper($collector_name);

      $storage_key = $collector_helper->getSaveDataKey();
      $temporary_storage_key = $storage_key . '_temporary';

      // Merge what we've just collected for this collector with what we've
      // collected on previous calls to this method.
      $data = $storage->retrieve($temporary_storage_key);

      $data = $collector_helper->mergeComponentData($data, $collector_incremental_data);

      if (isset($final_jobs[$collector_name])) {
        // We've done the final job for this collector. Store the data
        // accumulated so far into the permanent file, and clean up the
        // temporary file.
        $storage->store($storage_key, $data);
        $storage->delete($temporary_storage_key);

        // Add the count to the results.
        $collector_count = $collector_helper->getDataCount($data);
        $results[$collector_helper->getReportingKey()] = $collector_count;
      }
      else {
        $storage->store($temporary_storage_key, $data);
      }
    }
  }
public function collectComponentDataIncremental ( $ job_list , & $ results ) { // Populate an array of incremental data that we collect for the given job // list, so array_merge() works. $ incremental_data = array_fill_keys ( $ this -> collectorClassNames , [ ] ) ; // Keep track of any jobs which are the last for their collector, so we // know to write to the real storage file rather than temporary. $ final_jobs = [ ] ; // Group the jobs by collector. $ grouped_jobs = [ ] ; foreach ( $ job_list as $ job ) { $ collector_class_name = $ job [ 'collector' ] ; $ grouped_jobs [ $ collector_class_name ] [ ] = $ job ; } // Pass each set of jobs to its respective collective. foreach ( $ grouped_jobs as $ collector_class_name => $ jobs ) { $ collector_helper = $ this -> getHelper ( $ collector_class_name ) ; $ incremental_data [ $ collector_class_name ] = $ collector_helper -> collect ( $ jobs ) ; $ last_job = end ( $ jobs ) ; if ( ! empty ( $ last_job [ 'last' ] ) ) { $ final_jobs [ $ collector_class_name ] = TRUE ; } } // Save the data for each collector. $ storage = $ this -> environment -> getStorage ( ) ; foreach ( $ incremental_data as $ collector_name => $ collector_incremental_data ) { // We have a key for every collector in $incremental_data, but have not // necessarily run jobs for that collector in this batch. Skip if empty. if ( empty ( $ collector_incremental_data ) ) { continue ; } $ collector_helper = $ this -> getHelper ( $ collector_name ) ; $ storage_key = $ collector_helper -> getSaveDataKey ( ) ; $ temporary_storage_key = $ storage_key . '_temporary' ; // Merge what we've just collected for this collector with what we've // collected on previous calls to this method. $ data = $ storage -> retrieve ( $ temporary_storage_key ) ; $ data = $ collector_helper -> mergeComponentData ( $ data , $ collector_incremental_data ) ; if ( isset ( $ final_jobs [ $ collector_name ] ) ) { // We've done the final job for this collector. Store the data // accumulated so far into the permanent file, and clean up the // temporary file. $ storage -> store ( $ storage_key , $ data ) ; $ storage -> delete ( $ temporary_storage_key ) ; // Add the count to the results. $ collector_count = $ collector_helper -> getDataCount ( $ data ) ; $ results [ $ collector_helper -> getReportingKey ( ) ] = $ collector_count ; } else { $ storage -> store ( $ temporary_storage_key , $ data ) ; } } }
Perform a batch of incremental analysis.

@param array $job_list
A subset of the job list returned by getJobList().
@param array &$results
An array of results, passed by reference, into which an ongoing summary
of the analysis is set. Once all jobs have been passed into successive
calls of this method, this parameter will be identical to the return
value of collectComponentData().
Perform a batch of incremental analysis .