mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Add ChronicleHashBuilder.allowSegmentTiering() config for regressions and EntryCountMapTest
This commit is contained in:
@@ -293,6 +293,25 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
|
||||
*/
|
||||
B maxBloatFactor(double maxBloatFactor);
|
||||
|
||||
/**
|
||||
* In addition to {@link #maxBloatFactor(double) maxBloatFactor(1.0)}, that <i>does not</i>
|
||||
* guarantee that segments won't tier (due to bad hash distribution or natural variance),
|
||||
* configuring {@code allowSegmentTiering(false)} makes Chronicle Hashes, created by this
|
||||
* builder, to throw {@code IllegalStateException} immediately when some segment overflows.
|
||||
*
|
||||
* <p>Useful exactly for testing hash distribution and variance of segment filling.
|
||||
*
|
||||
* <p>Default is {@code true}, segments are allowed to tier.
|
||||
*
|
||||
* <p>When configured to {@code false}, {@link #maxBloatFactor(double)} configuration becomes
|
||||
* irrelevant, because effectively no bloat is allowed.
|
||||
*
|
||||
* @param allowSegmentTiering if {@code true}, when a segment overflows a next tier
|
||||
* is allocated to accommodate new entries
|
||||
* @return this builder back
|
||||
*/
|
||||
B allowSegmentTiering(boolean allowSegmentTiering);
|
||||
|
||||
/**
|
||||
* Configures the actual maximum number entries, that could be inserted into any single segment
|
||||
* of the hash containers, created by this builder. Configuring both the actual number of
|
||||
|
||||
@@ -158,6 +158,7 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
private TimeUnit lockTimeOutUnit = TimeUnit.MILLISECONDS;
|
||||
private int metaDataBytes = 0;
|
||||
private double maxBloatFactor = 1.0;
|
||||
private boolean allowSegmentTiering = true;
|
||||
|
||||
private boolean putReturnsNull = false;
|
||||
private boolean removeReturnsNull = false;
|
||||
@@ -1033,7 +1034,15 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChronicleMapBuilder<K, V> allowSegmentTiering(boolean allowSegmentTiering) {
|
||||
this.allowSegmentTiering = allowSegmentTiering;
|
||||
return this;
|
||||
}
|
||||
|
||||
long maxExtraTiers(boolean replicated) {
|
||||
if (!allowSegmentTiering)
|
||||
return 0;
|
||||
int actualSegments = actualSegments(replicated);
|
||||
// maxBloatFactor is scale, so we do (- 1.0) to compute _extra_ tiers
|
||||
return ((long) (maxBloatFactor - 1.0) * actualSegments)
|
||||
|
||||
@@ -171,6 +171,12 @@ public final class ChronicleSetBuilder<K>
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChronicleSetBuilder<K> allowSegmentTiering(boolean allowSegmentTiering) {
|
||||
chronicleMapBuilder.allowSegmentTiering(allowSegmentTiering);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return " ChronicleSetBuilder{" +
|
||||
|
||||
Reference in New Issue
Block a user