@@ -172,11 +172,6 @@ class GraphIndexNewCommandController extends CommandController
172
172
*/
173
173
protected $ dimensionsService ;
174
174
175
- /**
176
- * @var boolean
177
- */
178
- protected $ displayProgress = true ;
179
-
180
175
/**
181
176
* @var int
182
177
*/
@@ -201,8 +196,8 @@ public function buildCommand(int $limit = null, bool $update = false, string $wo
201
196
{
202
197
$ this ->logger ->info (sprintf ('Starting elasticsearch indexing %s sub processes ' , $ this ->useSubProcesses ? 'with ' : 'without ' ), LogEnvironment::fromMethodName (__METHOD__ ));
203
198
204
- if ($ workspace !== null && $ this -> workspaceRepository -> findByIdentifier ( $ workspace ) === null ) {
205
- $ this ->logger ->error ('The given workspace ( ' . $ workspace . ' ) does not exist. ' , LogEnvironment:: fromMethodName ( __METHOD__ ) );
199
+ if ($ workspace !== null ) {
200
+ $ this ->logger ->error ('Workspace indexing is not yet supported by in memory graph. ' );
206
201
$ this ->quit (1 );
207
202
}
208
203
@@ -217,10 +212,6 @@ public function buildCommand(int $limit = null, bool $update = false, string $wo
217
212
]);
218
213
};
219
214
220
- // $buildIndex = function (array $dimensionsValues) use ($workspace, $limit, $postfix) {
221
- // $this->build($dimensionsValues, $workspace, $postfix, $limit);
222
- // };
223
-
224
215
$ refresh = function (array $ dimensionsValues ) use ($ postfix ) {
225
216
$ this ->executeInternalCommand ('refreshInternal ' , [
226
217
'dimensionsValues ' => json_encode ($ dimensionsValues ),
@@ -251,14 +242,11 @@ public function buildCommand(int $limit = null, bool $update = false, string $wo
251
242
$ runAndLog ($ updateAliases , 'Set up aliases ' );
252
243
}
253
244
254
- // $runAndLog($buildIndex, 'Indexing nodes');
255
- $ this ->outputLine ('Initializing content graph... ' );
256
- if ($ this ->displayProgress ) {
257
- $ graph = $ this ->graphService ->getContentGraph ($ this ->output );
258
- } else {
259
- $ graph = $ this ->graphService ->getContentGraph ();
260
- }
245
+ $ timeStart = microtime (true );
246
+ $ this ->output (str_pad ('Initializing graph ' . '... ' , 20 ));
247
+ $ graph = $ this ->graphService ->getContentGraph ();
261
248
$ this ->nodeIndexer ->setContentGraph ($ graph );
249
+ $ this ->outputLine ('<success>Done</success> (took %s seconds) ' , [number_format (microtime (true ) - $ timeStart , 2 )]);
262
250
263
251
$ dimensionSpacePointSet = $ this ->contentDimensionZookeeper ->getAllowedDimensionSubspace ();
264
252
$ workspaceDimensionIdentifier = new ContentDimensionIdentifier ('_workspace ' );
@@ -320,23 +308,15 @@ private function buildIndexForDimensionSpacePoint(ContentGraph $graph, Dimension
320
308
$ dimensionsValues = $ dimensionSpacePoint ->getCoordinates ();
321
309
$ dimensionsValues = $ this ->configureNodeIndexer ($ dimensionsValues , $ postfix );
322
310
323
- $ this ->outputLine ("Build index for dimensionValues %s " , [json_encode ($ dimensionsValues )]);
324
-
311
+ $ this ->output ("Indexing dimension %s " . '... ' , [json_encode ($ dimensionsValues )]);
325
312
326
313
$ timeStart = microtime (true );
327
- if ($ this ->displayProgress ) {
328
- $ this ->output ->progressStart (count ($ graph ->getNodes ()));
329
- }
330
314
331
315
$ nodesIndexed = 0 ;
316
+ $ indexedHierarchyRelations = 0 ;
332
317
$ nodesSinceLastFlush = 0 ;
333
318
foreach ($ graph ->getNodes () as $ node ) {
334
319
$ include = false ;
335
-
336
- if ($ this ->displayProgress ) {
337
- $ this ->output ->progressAdvance ();
338
- }
339
-
340
320
foreach ($ node ->getIncomingHierarchyRelations () as $ hierarchyRelation ){
341
321
$ relationDimensionsValues = $ hierarchyRelation ->getSubgraph ()->getDimensionSpacePoint ()->getCoordinates ();
342
322
unset($ relationDimensionsValues ['_workspace ' ]);
@@ -351,22 +331,24 @@ private function buildIndexForDimensionSpacePoint(ContentGraph $graph, Dimension
351
331
}
352
332
353
333
$ this ->nodeIndexer ->indexGraphNode ($ node , $ dimensionSpacePoint );
334
+ $ indexedHierarchyRelations += count ($ node ->getIncomingHierarchyRelations ());
354
335
$ nodesSinceLastFlush ++;
355
336
$ nodesIndexed ++;
356
337
357
338
if ($ nodesSinceLastFlush >= $ this ->batchSize ) {
358
339
$ this ->nodeIndexer ->flush ();
359
340
$ nodesSinceLastFlush = 0 ;
360
341
}
342
+
343
+ if ($ limit > 0 && $ nodesIndexed > $ limit ) {
344
+ break ;
345
+ }
361
346
}
347
+
362
348
$ this ->nodeIndexer ->flush ();
363
- if ($ this ->displayProgress ) {
364
- $ this ->output ->progressFinish ();
365
- }
366
349
367
350
$ timeSpent = number_format (microtime (true ) - $ timeStart , 2 );
368
- $ this ->outputLine ();
369
- $ this ->outputLine ('<success>Done</success> (took %s seconds, %s nodes indexed) ' , [$ timeSpent , $ nodesIndexed ]);
351
+ $ this ->outputLine ('<success>Done</success> (%s nodes and %s edges indexed, took %s seconds, ) ' , [$ nodesIndexed , $ indexedHierarchyRelations , $ timeSpent ]);
370
352
371
353
$ this ->logger ->info ('Done. Indexed ' . $ nodesIndexed . ' nodes in ' . $ timeSpent );
372
354
$ this ->nodeIndexer ->getIndex ()->refresh ();
0 commit comments