Skip to content

Commit 86da56e

Browse files
author
Stanislav Idolov
committed
MAGETWO-64479: [Indexer optimizations] Indexation process in non-locking way for stock indexer
1 parent a36dde0 commit 86da56e

File tree

5 files changed

+60
-22
lines changed

5 files changed

+60
-22
lines changed

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,6 @@ private function getQueryProcessorComposite()
404404

405405
/**
406406
* @inheritdoc
407-
* Returns main table name based on the suffix stored in the 'indexer_state' table
408-
*
409-
* @return string
410407
*/
411408
public function getMainTable()
412409
{

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/IndexTableRowSizeEstimator.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/code/Magento/CatalogInventory/etc/di.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@
8888
</type>
8989
<virtualType name="Magento\CatalogInventory\Model\Indexer\Stock\BatchSizeManagement" type="Magento\Framework\Indexer\BatchSizeManagement">
9090
<arguments>
91-
<argument name="rowSizeEstimator" xsi:type="object" shared="false">Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\IndexTableRowSizeEstimator</argument>
91+
<argument name="rowSizeEstimator" xsi:type="object">Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\IndexTableRowSizeEstimator</argument>
92+
</arguments>
93+
</virtualType>
94+
<virtualType name="Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\IndexTableRowSizeEstimator" type="Magento\Framework\Indexer\IndexTableRowSizeEstimator">
95+
<arguments>
96+
<argument name="rowMemorySize" xsi:type="number">100</argument>
9297
</arguments>
9398
</virtualType>
9499
<type name="Magento\CatalogInventory\Model\Indexer\Stock\Action\Full">
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Indexer;
8+
9+
/**
10+
* Generic implementation for row size estimation.
11+
*/
12+
class IndexTableRowSizeEstimator implements IndexTableRowSizeEstimatorInterface
13+
{
14+
/**
15+
* @var int
16+
*/
17+
private $rowMemorySize;
18+
19+
/**
20+
* @param int $rowMemorySize
21+
*/
22+
public function __construct($rowMemorySize)
23+
{
24+
$this->rowMemorySize = $rowMemorySize;
25+
}
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
public function estimateRowSize()
31+
{
32+
return $this->rowMemorySize;
33+
}
34+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Indexer\Test\Unit;
8+
9+
class IndexTableRowSizeEstimatorTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* Test for estimateRowSize method
13+
*/
14+
public function testEstimateRowSize()
15+
{
16+
$rowMemorySize = 100;
17+
$model = new \Magento\Framework\Indexer\IndexTableRowSizeEstimator($rowMemorySize);
18+
$this->assertEquals($model->estimateRowSize(), $rowMemorySize);
19+
}
20+
}

0 commit comments

Comments
 (0)