/**
* Will rebuild a table, repairing indices and re-serialising content
*
* The end result will be:
* - new inverse indices will be created
* - changes to serialisation will be updated on all entities
* - added/removed fields will be updated on all entities
*
* @param string $class_name
* @param int $batch_size
*/
public function rebuild($class_name, $batch_size = 100)
{
$this->maintenanceOperation(function () use($class_name, $batch_size) {
$metadata = $this->entity_manager->getMapper()->getEntityMetadata($class_name);
$this->logger->info("Rebuilding `" . $metadata->getTableName() . "`..");
$records = $this->entity_manager->indexedQuery(new IndexedQuery($class_name, ['@id' => '*']), false);
$this->logger->info(number_format($records->count()) . ' records to rebuild, ' . number_format($batch_size) . ' at a time');
$ts = microtime(true);
$this->rebuildRecords($records, $metadata, $batch_size);
$delta = microtime(true) - $ts;
$this->logger->info("Rebuild of `" . $metadata->getTableName() . "` completed in " . number_format($delta, 2) . " seconds");
});
}