From 0ffdbaa6eb71abd0c3247687e8a0362ac4af3961 Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Fri, 4 Oct 2024 08:45:27 -0700 Subject: [PATCH] read metadata in SimpleQueryableIndex if available to compute segment ordering (#17181) (#17191) --- .../druid/segment/SimpleQueryableIndex.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/processing/src/main/java/org/apache/druid/segment/SimpleQueryableIndex.java b/processing/src/main/java/org/apache/druid/segment/SimpleQueryableIndex.java index 3f6c0f5e825..9518876cb75 100644 --- a/processing/src/main/java/org/apache/druid/segment/SimpleQueryableIndex.java +++ b/processing/src/main/java/org/apache/druid/segment/SimpleQueryableIndex.java @@ -49,6 +49,7 @@ public abstract class SimpleQueryableIndex implements QueryableIndex private final Map> columns; private final SmooshedFileMapper fileMapper; private final Supplier> dimensionHandlers; + private final List ordering; public SimpleQueryableIndex( Interval dataInterval, @@ -83,6 +84,14 @@ public abstract class SimpleQueryableIndex implements QueryableIndex } else { this.dimensionHandlers = () -> initDimensionHandlers(availableDimensions); } + + final Metadata metadata = getMetadata(); + if (metadata != null && metadata.getOrdering() != null) { + this.ordering = metadata.getOrdering(); + } else { + // When sort order isn't set in metadata.drd, assume the segment is sorted by __time. + this.ordering = Cursors.ascendingTimeOrder(); + } } @Override @@ -112,13 +121,7 @@ public abstract class SimpleQueryableIndex implements QueryableIndex @Override public List getOrdering() { - final Metadata metadata = getMetadata(); - if (metadata != null && metadata.getOrdering() != null) { - return metadata.getOrdering(); - } else { - // When sort order isn't set in metadata.drd, assume the segment is sorted by __time. - return Cursors.ascendingTimeOrder(); - } + return ordering; } @Override