Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/query-stats-followup' in…
Browse files Browse the repository at this point in the history
…to staging/query-statistics
  • Loading branch information
awildturtok committed Jan 9, 2024
2 parents b9a2586 + 2c2dd77 commit 79319c2
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ public void consume(String value) {

@Override
public ResultColumnStatistics describe() {
final List<Map.Entry<Comparable<?>, Long>> entriesSorted =
final List<Map.Entry<Comparable<?>, Long>>
entriesSorted =
StreamSupport.stream(((Iterable<Map.Entry<Comparable<?>, Long>>) frequencies::entrySetIterator).spliterator(), false)
.sorted(Map.Entry.<Comparable<?>, Long>comparingByValue().reversed()).toList();
.sorted(Map.Entry.<Comparable<?>, Long>comparingByValue().reversed())
.toList();

final long end = Math.min(limit, entriesSorted.size());

final List<HistogramColumnDescription.Entry> head = new ArrayList<>();
long shownTotal = 0;


for (int i = 0; i < limit; i++) {
Map.Entry<Comparable<?>, Long> counts = entriesSorted.get(i);
for (int i = 0; i < end; i++) {
final Map.Entry<Comparable<?>, Long> counts = entriesSorted.get(i);

final HistogramColumnDescription.Entry entry = new HistogramColumnDescription.Entry(((String) counts.getKey()), counts.getValue());
head.add(entry);
Expand All @@ -59,9 +62,11 @@ public ResultColumnStatistics describe() {

}

final Map<String, String> extras = entriesSorted.size() > limit
? Collections.emptyMap()
: Map.of(C10N.get(StatisticsLabels.class).remainingNodes( entriesSorted.size() - limit), Long.toString(frequencies.getSumFreq() - shownTotal));
final Map<String, String>
extras =
entriesSorted.size() > limit
? Collections.emptyMap()
: Map.of(C10N.get(StatisticsLabels.class).remainingNodes(entriesSorted.size() - limit), Long.toString(frequencies.getSumFreq() - shownTotal));

return new HistogramColumnDescription(getName(), getLabel(), getDescription(), head, extras, getType().typeInfo());
}
Expand Down

0 comments on commit 79319c2

Please sign in to comment.