Skip to content

Commit 02e96a9

Browse files
author
Stanislav Idolov
committed
MAGETWO-64187: Batch size algorithm
1 parent 01da000 commit 02e96a9

File tree

6 files changed

+22
-24
lines changed

6 files changed

+22
-24
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
class Price extends \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice
1616
{
1717
/**
18-
* {@inheritdoc}
19-
* @param null|array $entityIds
18+
* @inheritdoc
2019
*/
2120
protected function reindex($entityIds = null)
2221
{

app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function _syncData(array $processIds = [])
135135
{
136136
// delete invalid rows
137137
$select = $this->_connection->select()->from(
138-
['index_price' => $this->getIndexerDefaultTable()],
138+
['index_price' => $this->getIndexTargetTable()],
139139
null
140140
)->joinLeft(
141141
['ip_tmp' => $this->_defaultIndexerResource->getIdxTable()],
@@ -152,7 +152,7 @@ protected function _syncData(array $processIds = [])
152152

153153
$this->_insertFromTable(
154154
$this->_defaultIndexerResource->getIdxTable(),
155-
$this->getIndexerDefaultTable()
155+
$this->getIndexTargetTable()
156156
);
157157
return $this;
158158
}
@@ -471,7 +471,7 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null)
471471

472472
if ($children) {
473473
$select = $this->_connection->select()->from(
474-
$this->getIndexerDefaultTable()
474+
$this->getIndexTargetTable()
475475
)->where(
476476
'entity_id IN(?)',
477477
$children
@@ -484,14 +484,13 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null)
484484
}
485485

486486
/**
487-
* Returns default table name for writing
487+
* Retrieve index table that will be used for write operations.
488488
*
489-
* Method support writing to frontend table in case with partial reindex
490-
* and case with writing to replica table during full reindex
489+
* This method is used to during both partial and full reindex to identify the the table.
491490
*
492491
* @return string
493492
*/
494-
protected function getIndexerDefaultTable()
493+
protected function getIndexTargetTable()
495494
{
496495
return $this->indexerFrontendResource->getMainTable();
497496
}

app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ public function __construct(
5757
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator $batchSizeCalculator = null,
5858
\Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null
5959
) {
60-
$this->metadataPool = $metadataPool ?: ObjectManager::getInstance()->get(
61-
\Magento\Framework\EntityManager\MetadataPool::class
62-
);
63-
$this->batchSizeCalculator = $batchSizeCalculator ?: ObjectManager::getInstance()->get(
64-
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator::class
65-
);
66-
$this->batchProvider = $batchProvider ?: ObjectManager::getInstance()->get(
67-
\Magento\Framework\Indexer\BatchProviderInterface::class
68-
);
6960
parent::__construct(
7061
$config,
7162
$storeManager,
@@ -77,6 +68,15 @@ public function __construct(
7768
$defaultIndexerResource,
7869
$indexerFrontendResource
7970
);
71+
$this->metadataPool = $metadataPool ?: ObjectManager::getInstance()->get(
72+
\Magento\Framework\EntityManager\MetadataPool::class
73+
);
74+
$this->batchSizeCalculator = $batchSizeCalculator ?: ObjectManager::getInstance()->get(
75+
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator::class
76+
);
77+
$this->batchProvider = $batchProvider ?: ObjectManager::getInstance()->get(
78+
\Magento\Framework\Indexer\BatchProviderInterface::class
79+
);
8080
}
8181

8282
/**
@@ -140,9 +140,8 @@ public function execute($ids = null)
140140

141141
/**
142142
* @inheritdoc
143-
* @return string
144143
*/
145-
protected function getIndexerDefaultTable()
144+
protected function getIndexTargetTable()
146145
{
147146
return $this->_defaultIndexerResource->getMainTable();
148147
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public function __construct(array $batchRowsCount, array $estimators)
3333
}
3434

3535
/**
36-
* Composite object for batch size calculators
36+
* Retrieve batch size for the given indexer.
37+
*
38+
* Ensure that the database will be able to handle provided batch size correctly.
3739
*
3840
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
3941
* @param string $indexerTypeId

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(
3838
/**
3939
* Calculate memory size for largest composite product in database.
4040
*
41-
* @inheritdoc
41+
* {@inheritdoc}
4242
*/
4343
public function estimateRowSize()
4444
{

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,10 +709,9 @@ protected function hasEntity()
709709
}
710710

711711
/**
712-
* @inheritdoc
713712
* Returns main table name based on the suffix stored in the 'indexer_state' table
714713
*
715-
* @return string
714+
* {@inheritdoc}
716715
*/
717716
public function getMainTable()
718717
{

0 commit comments

Comments
 (0)