Skip to content

Commit

Permalink
read metadata in SimpleQueryableIndex if available to compute segment…
Browse files Browse the repository at this point in the history
… ordering (#17181)
  • Loading branch information
clintropolis authored Sep 28, 2024
1 parent 7417ead commit f8a72b9
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -83,6 +84,14 @@ public SimpleQueryableIndex(
} 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
Expand Down Expand Up @@ -112,13 +121,7 @@ public Indexed<String> getAvailableDimensions()
@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
Expand Down

0 comments on commit f8a72b9

Please sign in to comment.