read metadata in SimpleQueryableIndex if available to compute segment ordering (#17181)

This commit is contained in:
Clint Wylie 2024-09-27 19:39:03 -07:00 committed by GitHub
parent 7417ead3af
commit f8a72b987a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 7 deletions

View File

@ -49,6 +49,7 @@ public abstract class SimpleQueryableIndex implements QueryableIndex
private final Map<String, Supplier<ColumnHolder>> columns;
private final SmooshedFileMapper fileMapper;
private final Supplier<Map<String, DimensionHandler>> dimensionHandlers;
private final List<OrderBy> 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<OrderBy> 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