mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-387 add a way to limit hash lookup slots to 4 bytes
This commit is contained in:
@@ -555,6 +555,17 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
|
||||
*/
|
||||
B immutableKeys();
|
||||
|
||||
/**
|
||||
* Specifies whether on the current combination of platform, OS and Jvm aligned 8-byte reads
|
||||
* and writes are atomic or not. By default, Chronicle tries to determine this itself, but
|
||||
* if it fails it pessimistically assumes that 64-bit memory operations are <i>not</i> atomic.
|
||||
*
|
||||
* @param aligned64BitMemoryOperationsAtomic {@code true} if aligned 8-byte memory operations
|
||||
* are atomic
|
||||
* @return this builder back
|
||||
*/
|
||||
B aligned64BitMemoryOperationsAtomic(boolean aligned64BitMemoryOperationsAtomic);
|
||||
|
||||
/**
|
||||
* Configures replication of the hash containers, created by this builder. See <a
|
||||
* href="https://github.com/OpenHFT/Chronicle-Map#tcp--udp-replication"> the section about
|
||||
|
||||
@@ -37,4 +37,6 @@ public interface ChronicleHashBuilderPrivateAPI<K> {
|
||||
int actualSegments(boolean replicated);
|
||||
|
||||
long maxExtraTiers(boolean replicated);
|
||||
|
||||
boolean aligned64BitMemoryOperationsAtomic();
|
||||
}
|
||||
|
||||
@@ -187,6 +187,10 @@ public abstract class VanillaChronicleHash<K, KI, MKI extends MetaBytesInterop<K
|
||||
segmentHashLookupKeyBits = keyBits(entriesPerSegment, segmentHashLookupValueBits);
|
||||
segmentHashLookupEntrySize =
|
||||
entrySize(segmentHashLookupKeyBits, segmentHashLookupValueBits);
|
||||
if (!privateAPI.aligned64BitMemoryOperationsAtomic() && segmentHashLookupEntrySize > 4) {
|
||||
throw new IllegalStateException("aligned64BitMemoryOperationsAtomic() == false, " +
|
||||
"but hash lookup slot is " + segmentHashLookupEntrySize);
|
||||
}
|
||||
segmentHashLookupCapacity = CompactOffHeapLinearHashTable.capacityFor(entriesPerSegment);
|
||||
segmentHashLookupInnerSize = segmentHashLookupCapacity * segmentHashLookupEntrySize;
|
||||
segmentHashLookupOuterSize = CACHE_LINES.align(segmentHashLookupInnerSize, BYTES);
|
||||
|
||||
Reference in New Issue
Block a user