-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3329 from ingef/feature/dont-use-atomics
Cleanup BooleanStatsCollector and all other collectors for performance issues
- Loading branch information
Showing
5 changed files
with
58 additions
and
32 deletions.
There are no files selected for viewing
32 changes: 27 additions & 5 deletions
32
...c/main/java/com/bakdata/conquery/models/query/statistics/BooleanColumnStatsCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,50 @@ | ||
package com.bakdata.conquery.models.query.statistics; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import c10n.C10N; | ||
import com.bakdata.conquery.models.query.PrintSettings; | ||
import com.bakdata.conquery.models.types.ResultType; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class BooleanColumnStatsCollector extends ColumnStatsCollector { | ||
|
||
private final StringColumnStatsCollector delegate; | ||
private int trues, falses, missing; | ||
|
||
public BooleanColumnStatsCollector(String name, String label, String description, PrintSettings printSettings) { | ||
super(name, label, description, printSettings); | ||
delegate = new StringColumnStatsCollector(name, label, description, ResultType.StringT.INSTANCE, printSettings, Integer.MAX_VALUE); | ||
} | ||
|
||
@Override | ||
public void consume(Object value) { | ||
final String printed = value == null ? null : ResultType.BooleanT.INSTANCE.printNullable(getPrintSettings(), value); | ||
delegate.consume(printed); | ||
if (value == null) { | ||
missing++; | ||
return; | ||
} | ||
|
||
if (((Boolean) value)) { | ||
trues++; | ||
} | ||
else { | ||
falses++; | ||
} | ||
} | ||
|
||
@Override | ||
public ResultColumnStatistics describe() { | ||
return delegate.describe(); | ||
return new HistogramColumnDescription( | ||
getName(), getLabel(), getDescription(), | ||
List.of( | ||
new HistogramColumnDescription.Entry(ResultType.BooleanT.INSTANCE.print(getPrintSettings(), true), trues), | ||
new HistogramColumnDescription.Entry(ResultType.BooleanT.INSTANCE.print(getPrintSettings(), false), falses) | ||
), | ||
Map.of( | ||
C10N.get(StatisticsLabels.class, getPrintSettings().getLocale()).missing(), | ||
getPrintSettings().getIntegerFormat().format(getMissing()) | ||
) | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters