himanshug commented on a change in pull request #6988: [Improvement] historical
fast restart by lazy load columns metadata(20X faster)
URL: https://github.com/apache/incubator-druid/pull/6988#discussion_r281799846
##########
File path: processing/src/main/java/org/apache/druid/segment/IndexIO.java
##########
@@ -449,59 +455,71 @@ public QueryableIndex load(File inDir, ObjectMapper
mapper) throws IOException
if (index.getSpatialIndexes().get(dimension) != null) {
builder.setSpatialIndex(new
SpatialIndexColumnPartSupplier(index.getSpatialIndexes().get(dimension)));
}
- columns.put(
- dimension,
- builder.build()
- );
+ if (lazy) {
+ columns.put(dimension, Suppliers.memoize(() -> builder.build()));
+ } else {
+ ColumnHolder columnHolder = builder.build();
+ columns.put(dimension, () -> columnHolder);
+ }
Review comment:
this pattern of code is repeated in many places, is it possible to add a
private method `Supplier<ColumnHolder> getColumnHolderSupplier(ColumnBuilder
builder, boolean lazy)` and use that here and all other places like
```suggestion
columns.put(dimension, getColumnHolderSupplier(builder, lazy);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]