Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BatchSizeCalculator.php
Go to the documentation of this file.
1 <?php
8 
13 {
17  private $batchRowsCount;
18 
22  private $estimators;
23 
27  private $batchSizeAdjusters;
28 
35  public function __construct(array $batchRowsCount, array $estimators, array $batchSizeAdjusters)
36  {
37  $this->batchRowsCount = $batchRowsCount;
38  $this->estimators = $estimators;
39  $this->batchSizeAdjusters = $batchSizeAdjusters;
40  }
41 
51  public function estimateBatchSize(\Magento\Framework\DB\Adapter\AdapterInterface $connection, $indexerTypeId)
52  {
53  $batchRowsCount = isset($this->batchRowsCount[$indexerTypeId])
54  ? $this->batchRowsCount[$indexerTypeId]
55  : $this->batchRowsCount['default'];
56 
58  $calculator = isset($this->estimators[$indexerTypeId])
59  ? $this->estimators[$indexerTypeId]
60  : $this->estimators['default'];
61 
62  $batchRowsCount = isset($this->batchSizeAdjusters[$indexerTypeId])
63  ? $this->batchSizeAdjusters[$indexerTypeId]->adjust($batchRowsCount)
64  : $batchRowsCount;
65 
66  $calculator->ensureBatchSize($connection, $batchRowsCount);
67 
68  return $batchRowsCount;
69  }
70 }
__construct(array $batchRowsCount, array $estimators, array $batchSizeAdjusters)
$connection
Definition: bulk.php:13