public SingleChronicleQueueBuilder indexCount(int indexCount) { this.indexCount = Maths.nextPower2(indexCount, 8); return this; }
public SingleChronicleQueueBuilder indexSpacing(int indexSpacing) { this.indexSpacing = Maths.nextPower2(indexSpacing, 1); return this; }
RollCycles(String format, int length, int indexCount, int indexSpacing) { this.format = format; this.length = length; this.indexCount = Maths.nextPower2(indexCount, 8); this.indexSpacing = Maths.nextPower2(indexSpacing, 1); cycleShift = Math.max(32, Maths.intLog2(indexCount) * 2 + Maths.intLog2(indexSpacing)); sequenceMask = (1L << cycleShift) - 1; }
/** * @param rollCycle the current rollCycle * @param wireType the wire type that is being used * @param mappedBytes used to mapped the data store file * @param indexCount the number of entries in each index. * @param indexSpacing the spacing between indexed entries. */ public SingleChronicleQueueStore(@NotNull RollCycle rollCycle, @NotNull final WireType wireType, @NotNull MappedBytes mappedBytes, int indexCount, int indexSpacing) { this.mappedBytes = mappedBytes; this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); indexCount = Maths.nextPower2(indexCount, 8); indexSpacing = Maths.nextPower2(indexSpacing, 1); this.indexing = new SCQIndexing(wireType, indexCount, indexSpacing); this.indexing.writePosition = this.writePosition = wireType.newTwoLongReference().get(); this.indexing.sequence = this.sequence = new RollCycleEncodeSequence(writePosition, rollCycle.defaultIndexCount(), rollCycle.defaultIndexSpacing()); }
.blockSize(Maths.nextPower2(EXTREMELY_LARGE.length() * 4, 256 << 10))
/** * Volatile or ordered puts, unlike volatile gets, CASes and atomic adds, cannot extract the * field from wider byte/short/int/long word, => must be alone in the word. */ int sizeInBitsConsideringVolatileOrOrderedPuts(int rawSizeInBits) { int minBits = setOrdered != null ? 32 : 8; return setVolatile != null || setOrdered != null ? Maths.nextPower2(rawSizeInBits, minBits) : rawSizeInBits; }
/** * Volatile or ordered puts, unlike volatile gets, CASes and atomic adds, cannot extract the * field from wider byte/short/int/long word, => must be alone in the word. */ int sizeInBitsConsideringVolatileOrOrderedPuts(int rawSizeInBits) { int minBits = setOrdered != null ? 32 : 8; return setVolatile != null || setOrdered != null ? Maths.nextPower2(rawSizeInBits, minBits) : rawSizeInBits; }
public static long capacityFor(long entriesPerSegment) { if (entriesPerSegment < 0L) throw new AssertionError("entriesPerSegment should be positive: " + entriesPerSegment); long capacity = Maths.nextPower2(entriesPerSegment, 64L); if (entriesPerSegment > MAX_UPPER_BOUND_LOAD_FACTOR * capacity) capacity *= 2; return capacity; }
public ParsingCache(int capacity, Function<String, E> eFunction) throws IllegalArgumentException { this.eFunction = eFunction; int n = Maths.nextPower2(capacity, 128); shift = Maths.intLog2(n); interner = new ParsedData[n]; mask = n - 1; }
public AbstractInterner(int capacity) throws IllegalArgumentException { int n = Maths.nextPower2(capacity, 128); shift = Maths.intLog2(n); entries = new InternerEntry[n]; mask = n - 1; }
public EnumInterner(Class<E> eClass, int capacity) { int n = Maths.nextPower2(capacity, 16); interner = (E[]) new Enum[n]; mask = n - 1; enumCache = EnumCache.of(eClass); }
public StringInterner(int capacity) throws IllegalArgumentException { int n = Maths.nextPower2(capacity, 128); shift = Maths.intLog2(n); interner = new String[n]; mask = n - 1; }
@Override int dontCrossAlignmentInBytes() { if (dontCrossAlignment == Align.DEFAULT) return Maths.nextPower2(sizeInBits(), 8) / 8; return dontCrossAlignment; } }
public ParsingCache(int capacity, Function<String, E> eFunction) throws IllegalArgumentException { this.eFunction = eFunction; int n = Maths.nextPower2(capacity, 128); shift = Maths.intLog2(n); interner = new ParsedData[n]; mask = n - 1; }
@Override int offsetAlignmentInBytes() { if (offsetAlignment == Align.DEFAULT) return Maths.nextPower2(sizeInBits(), 8) / 8; return offsetAlignment; }
@Override int offsetAlignmentInBytes() { if (offsetAlignment == Align.DEFAULT) return Maths.nextPower2(sizeInBits(), 8) / 8; return offsetAlignment; }
@Override int dontCrossAlignmentInBytes() { if (dontCrossAlignment == Align.DEFAULT) return Maths.nextPower2(sizeInBits(), 8) / 8; return dontCrossAlignment; } }
RollCycles(String format, int length, int indexCount, int indexSpacing) { this.format = format; this.length = length; this.indexCount = Maths.nextPower2(indexCount, 8); this.indexSpacing = Maths.nextPower2(indexSpacing, 1); cycleShift = Math.max(32, Maths.intLog2(indexCount) * 2 + Maths.intLog2(indexSpacing)); sequenceMask = (1L << cycleShift) - 1; }
private long trySegments(long entriesPerSegment, int maxSegments) { long segments = segmentsGivenEntriesPerSegmentFixed(entriesPerSegment); segments = nextPower2(Math.max(segments, minSegments()), 1L); return segments <= maxSegments ? segments : -segments; }
private long computeNumberOfTiersInBulk() { // TODO review heuristics int tiersInBulk = actualSegments / 8; tiersInBulk = Maths.nextPower2(tiersInBulk, 1); while (computeTierBulkBytesSize(tiersInBulk) < OS.pageSize()) { tiersInBulk *= 2; } return tiersInBulk; }