-
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 remote-tracking branch 'origin/feature/query-stats-followup' in…
…to staging/query-statistics
- Loading branch information
Showing
3 changed files
with
186 additions
and
6 deletions.
There are no files selected for viewing
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
89 changes: 89 additions & 0 deletions
89
...nd/src/test/java/com/bakdata/conquery/models/query/statistics/BalancingHistogramTest.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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.bakdata.conquery.models.query.statistics; | ||
|
||
import java.util.List; | ||
import java.util.Random; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@Slf4j | ||
class BalancingHistogramTest { | ||
|
||
public static final int SEED = 0xD00F; | ||
private final int max = 250; | ||
|
||
@Test | ||
void balanced() { | ||
BalancingHistogram histogram = BalancingHistogram.create(0, max, 15, 0.8d, false); | ||
|
||
final Random random = new Random(SEED); | ||
|
||
for (int val = 0; val < 1000; val++) { | ||
histogram.add(random.nextDouble(0, max)); | ||
} | ||
|
||
for (int val = 0; val < 100; val++) { | ||
histogram.add(random.nextDouble(0, max / 5d)); | ||
} | ||
|
||
for (int val = 0; val < 100; val++) { | ||
histogram.add(random.nextDouble(max / 2d, max / 2d + max / 5d)); | ||
} | ||
|
||
histogram.add(max); | ||
|
||
|
||
List<BalancingHistogram.Node> balanced = histogram.balanced(); | ||
log.info("{}", balanced); | ||
} | ||
|
||
@Test | ||
void snapped() { | ||
BalancingHistogram histogram = BalancingHistogram.create(0, max, 15, 0.8d, false); | ||
|
||
final Random random = new Random(SEED); | ||
|
||
for (int val = 0; val < 1000; val++) { | ||
histogram.add(random.nextDouble(0, max)); | ||
} | ||
|
||
for (int val = 0; val < 100; val++) { | ||
histogram.add(random.nextDouble(0, max / 5d)); | ||
} | ||
|
||
for (int val = 0; val < 100; val++) { | ||
histogram.add(random.nextDouble(max / 2d, max / 2d + max / 5d)); | ||
} | ||
|
||
histogram.add(max); | ||
|
||
|
||
List<BalancingHistogram.Node> balanced = histogram.snapped(); | ||
log.info("{}", balanced); | ||
} | ||
|
||
@Test | ||
void plain() { | ||
BalancingHistogram histogram = BalancingHistogram.create(0, max, 15, 0.8d, false); | ||
|
||
final Random random = new Random(SEED); | ||
|
||
for (int val = 0; val < 1000; val++) { | ||
histogram.add(random.nextDouble(0, max)); | ||
} | ||
|
||
for (int val = 0; val < 100; val++) { | ||
histogram.add(random.nextDouble(0, max / 5d)); | ||
} | ||
|
||
for (int val = 0; val < 100; val++) { | ||
histogram.add(random.nextDouble(max / 2d, max / 2d + max / 5d)); | ||
} | ||
|
||
histogram.add(max); | ||
|
||
|
||
List<BalancingHistogram.Node> balanced = histogram.nodes(); | ||
log.info("{}", balanced); | ||
} | ||
} |