/**
  * Process re-index for a given variant state and class
  *
  * @param LoggerInterface $logger
  * @param SolrIndex $indexInstance
  * @param array $state Variant state
  * @param string $class
  * @param bool $includeSubclasses
  * @param int $batchSize
  * @param string $taskName
  */
 protected function processVariant(LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $includeSubclasses, $batchSize, $taskName)
 {
     // Set state
     SearchVariant::activate_state($state);
     // Count records
     $query = $class::get();
     if (!$includeSubclasses) {
         $query = $query->filter('ClassName', $class);
     }
     $total = $query->count();
     // Skip this variant if nothing to process, or if there are no records
     if ($total == 0 || $indexInstance->variantStateExcluded($state)) {
         // Remove all records in the current state, since there are no groups to process
         $logger->info("Clearing all records of type {$class} in the current state: " . json_encode($state));
         $this->clearRecords($indexInstance, $class);
         return;
     }
     // For each group, run processing
     $groups = (int) (($total + $batchSize - 1) / $batchSize);
     for ($group = 0; $group < $groups; $group++) {
         $this->processGroup($logger, $indexInstance, $state, $class, $groups, $group, $taskName);
     }
 }