Skip to content

Commit ecbb338

Browse files
committedJul 2, 2021
TASK: Use legacy dimension value combinations from cr adpter package for compatibility
1 parent 56d7fa1 commit ecbb338

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed
 

Diff for: ‎Classes/Command/GraphIndexNewCommandController.php

+15-14
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ class GraphIndexNewCommandController extends CommandController
135135
*/
136136
protected $contentDimensionCombinator;
137137

138+
/**
139+
* @Flow\Inject
140+
* @var DimensionsService
141+
*/
142+
protected $dimensionService;
143+
138144
/**
139145
* @Flow\Inject
140146
* @var WorkspaceIndexer
@@ -249,15 +255,9 @@ public function buildCommand(int $limit = null, bool $update = false, string $wo
249255
$this->nodeIndexer->setContentGraph($graph);
250256
$this->outputLine('<success>Done</success> (took %s seconds)', [number_format(microtime(true) - $timeStart, 2)]);
251257

252-
$dimensionSpacePointSet = $this->contentDimensionZookeeper->getAllowedDimensionSubspace();
253-
$workspaceDimensionIdentifier = new ContentDimensionIdentifier('_workspace');
254-
foreach ($dimensionSpacePointSet as $dimensionSpacePoint) {
255-
if ($dimensionSpacePoint->getCoordinate($workspaceDimensionIdentifier) === 'live') {
256-
$coordinates = $dimensionSpacePoint->getCoordinates();
257-
unset($coordinates['_workspace']);
258-
$dimensionSpacepointWithoutWorkspace = new DimensionSpacePoint($coordinates);
259-
$this->buildIndexForDimensionSpacePoint($graph, $dimensionSpacepointWithoutWorkspace, $postfix, $limit);
260-
}
258+
$dimensionCombinations = new ArrayCollection($this->contentDimensionCombinator->getAllAllowedCombinations());
259+
foreach ($dimensionCombinations as $dimensionCombination) {
260+
$this->buildIndexForDimensionSpacePoint($graph, $dimensionCombination, $postfix, $limit);
261261
}
262262

263263
$runAndLog($refresh, 'Refresh indicies');
@@ -296,18 +296,19 @@ private function aliasesExist(): bool
296296
* Build up the node index
297297
*
298298
* @param ContentGraph $graph
299-
* @param DimensionSpacePoint $dimensionSpacePoint
299+
* @param array $dimensionValues
300300
* @param string|null $postfix
301301
* @param int|null $limit
302302
* @throws ConfigurationException
303303
* @throws Exception
304304
* @throws RuntimeException
305305
* @throws SubProcessException
306306
*/
307-
private function buildIndexForDimensionSpacePoint(ContentGraph $graph, DimensionSpacePoint $dimensionSpacePoint, string $postfix, $limit = null): void
307+
private function buildIndexForDimensionSpacePoint(ContentGraph $graph, array $dimensionValues, string $postfix, $limit = null): void
308308
{
309-
$dimensionsValues = $dimensionSpacePoint->getCoordinates();
310-
$dimensionsValues = $this->configureNodeIndexer($dimensionsValues, $postfix);
309+
$dimensionsValues = $this->configureNodeIndexer($dimensionValues, $postfix);
310+
$dimensionSpacePoint = DimensionSpacePoint::fromLegacyDimensionArray($dimensionsValues);
311+
$dimensionHash = $this->dimensionService->hash($dimensionsValues);
311312

312313
$this->output("Indexing dimension %s" . '... ' , [json_encode($dimensionsValues)]);
313314

@@ -331,7 +332,7 @@ private function buildIndexForDimensionSpacePoint(ContentGraph $graph, Dimension
331332
continue;
332333
}
333334

334-
$this->nodeIndexer->indexGraphNode($node, $dimensionSpacePoint);
335+
$this->nodeIndexer->indexGraphNode($node, $dimensionSpacePoint, $dimensionHash);
335336
$indexedHierarchyRelations += count($node->getIncomingHierarchyRelations());
336337
$nodesSinceLastFlush++;
337338
$nodesIndexed++;

Diff for: ‎Classes/Indexer/NodeIndexer.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function setContentGraph(ContentGraph $contentGraph): void
5252
$this->contentGraph = $contentGraph;
5353
}
5454

55-
public function indexGraphNode(Node $dataNode, DimensionSpacePoint $dimensionSpacePoint): void
55+
public function indexGraphNode(Node $dataNode, DimensionSpacePoint $dimensionSpacePoint, string $dimensionHash): void
5656
{
5757
$occupiedDimensionSpacePoints = new DimensionSpacePointSet([$dataNode->getOriginDimensionSpacePoint()]);
5858
$isFulltextRoot = IsFulltextRoot::isSatisfiedBy($dataNode);
@@ -123,9 +123,8 @@ public function indexGraphNode(Node $dataNode, DimensionSpacePoint $dimensionSpa
123123
];
124124
}
125125

126-
$hash = $this->dimensionService->hash($dimensionSpacePoint->getCoordinates());
127-
$this->currentBulkRequest[] = new BulkRequestPart($hash, $this->indexerDriver->document($this->getIndexName(), $nodeAdapter, $document, $documentData));
128-
$this->currentBulkRequest[] = new BulkRequestPart($hash, $this->indexerDriver->fulltext($nodeAdapter, $fulltextIndexOfNode));
126+
$this->currentBulkRequest[] = new BulkRequestPart($dimensionHash, $this->indexerDriver->document($this->getIndexName(), $nodeAdapter, $document, $documentData));
127+
$this->currentBulkRequest[] = new BulkRequestPart($dimensionHash, $this->indexerDriver->fulltext($nodeAdapter, $fulltextIndexOfNode));
129128

130129
$serializedVariant = json_encode([
131130
'nodeAggregateIdentifier' => $virtualVariant->getNodeAggregateIdentifier(),

0 commit comments

Comments
 (0)
Please sign in to comment.