Skip to content

7499/indexer #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"description": "Base library for IntegerNet_Solr open source version",
"type": "magento-module",
"require": {
"php": "^5.6|^7.0|^7.1|^7.2"
},
"require-dev": {
"mikey179/vfsStream": "~1.3",
"phpunit/phpunit": "~4.5"
"phpunit/phpunit": "^5.0"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 10 additions & 2 deletions src/Solr/Indexer/Data/ProductIdChunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @copyright Copyright (c) 2016 integer_net GmbH (http://www.integer-net.de/)
* @author Andreas von Studnitz <avs@integer-net.de>
*/
final class ProductIdChunk
final class ProductIdChunk implements \Countable
{
/** @var int[] */
private $parentIds = array();
Expand All @@ -30,13 +30,21 @@ public function __construct()
}

/**
* @return int
* @return int Approximate size based on added products
*/
public function getSize()
{
return $this->size;
}

/**
* @return int Real size without duplicates
*/
public function count()
{
return count($this->getAllIds());
}

/**
* @return int[]
*/
Expand Down
14 changes: 14 additions & 0 deletions src/Solr/Indexer/Data/ProductIdChunks.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,18 @@ public static function withAssociationsTogether($allProductIds, $associations, $
}
return $productIdChunks;
}

/**
* @return int Total number of products in all chunks (with associations)
*/
public function totalCount()
{
return array_reduce(
$this->getArrayCopy(),
function ($count, ProductIdChunk $chunk) {
return $count + count($chunk);
},
0
);
}
}
88 changes: 88 additions & 0 deletions src/Solr/Indexer/Indexer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
* integer_net Magento Module
*
* @category IntegerNet
* @package IntegerNet_Solr
* @copyright Copyright (c) 2017 integer_net GmbH (http://www.integer-net.de/)
* @author Fabian Schmengler <fs@integer-net.de>
*/

namespace IntegerNet\Solr\Indexer;

use IntegerNet\Solr\Indexer\Progress\ProgressHandler;

interface Indexer
{
/**
* Adds a callback for progress updates
*
* @param ProgressHandler $handler
*/
public function addProgressHandler(ProgressHandler $handler);

/**
* Add/update entities in index
*
* The sliceId/totalNumberSlices parameters are deprecated, they cannot be used together with entityIds/emptyIndex.
* Use reindexSlice() instead to reindex slices.
*
* @param string[]|null $entityIds IDs to reindex, depends on content type of the concrete indexer. Null for "all"
* @param bool $emptyIndex If index should be cleared before writing
* @param int[]|null $restrictToStoreIds Store IDs to reindex. Null for "all"
* @param int|null $sliceId Number of slice for partial reindexing. Null for no partial reindexing.
* @param int|null $totalNumberSlices Number of slices. The entities are divided into this many slices.
*/
public function reindex(
$entityIds = null,
$emptyIndex = false,
$restrictToStoreIds = null,
$sliceId = null,
$totalNumberSlices = null
);

/**
* @param Slice $slice
* @return mixed
*/
public function reindexSlice(Slice $slice, $restrictToStoreIds = null);

/**
* Delete given entities from index
*
* @param string[] $entityIds IDs to delete, depends on content type of the concrete indexer.
*/
public function deleteIndex($entityIds);

/**
* Clear index for content type of concrete indexer and given store ID
*
* @param int $storeId
*/
public function clearIndex($storeId);

/**
* Check if swap configuration is valid to reindex given stores
* (e.g. all stores with same swap configuration must be reindexed at once)
*
* @param $restrictToStoreIds
*/
public function checkSwapCoresConfiguration($restrictToStoreIds);

/**
* Swap current core with shadow core (for all given stores)
*
* @param null|int[] $restrictToStoreIds
*/
public function swapCores($restrictToStoreIds);

/**
* Use the shadow core for subsequent indexing
*/
public function activateSwapCore();

/**
* Do not use the shadow core for subsequent indexing
*/
public function deactivateSwapCore();
}
Loading