indexByLeadershipTermIdMap.put(leadershipTermId, nextEntryIndex);
public Map<Long, Long> create(final Object... entries) { final Long2LongHashMap map = new Long2LongHashMap( entries.length * 2, Hashing.DEFAULT_LOAD_FACTOR, -1L, false); for (final Object o : entries) { @SuppressWarnings("unchecked") final Map.Entry<Long, Long> e = (Map.Entry<Long, Long>)o; map.put(e.getKey(), e.getValue()); } return map; }
private void captureEntriesFromBuffer( final ByteBuffer byteBuffer, final UnsafeBuffer buffer, final ArrayList<Entry> entries) { for (int i = 0, length = byteBuffer.limit(); i < length; i += ENTRY_LENGTH) { final int entryType = buffer.getInt(i + ENTRY_TYPE_OFFSET); if (NULL_VALUE != entryType) { final Entry entry = new Entry( buffer.getLong(i + RECORDING_ID_OFFSET, LITTLE_ENDIAN), buffer.getLong(i + LEADERSHIP_TERM_ID_OFFSET, LITTLE_ENDIAN), buffer.getLong(i + TERM_BASE_LOG_POSITION_OFFSET, LITTLE_ENDIAN), buffer.getLong(i + LOG_POSITION_OFFSET, LITTLE_ENDIAN), buffer.getLong(i + TIMESTAMP_OFFSET, LITTLE_ENDIAN), buffer.getInt(i + SERVICE_ID_OFFSET, LITTLE_ENDIAN), entryType, nextEntryIndex); entries.add(entry); if (ENTRY_TYPE_TERM == entryType) { indexByLeadershipTermIdMap.put(entry.leadershipTermId, nextEntryIndex); } } ++nextEntryIndex; } }
/** * {@inheritDoc} */ public Long put(final Long key, final Long value) { return put((long)key, (long)value); }
public void newPosition(final int libraryId, final long endPosition) { libraryIdToPosition.put(libraryId, endPosition); }
public Long setValue(final Long value) { return Long2LongHashMap.this.put(k, value.longValue()); }
/** * {@inheritDoc} */ public void putAll(final Map<? extends Long, ? extends Long> map) { for (final Map.Entry<? extends Long, ? extends Long> entry : map.entrySet()) { put(entry.getKey(), entry.getValue()); } }
/** * {@inheritDoc} */ public void putAll(final Map<? extends Long, ? extends Long> map) { for (final Map.Entry<? extends Long, ? extends Long> entry : map.entrySet()) { put(entry.getKey(), entry.getValue()); } }
/** * {@inheritDoc} */ public Long put(final Long key, final Long value) { return valOrNull(put((long)key, (long)value)); }
/** * Primitive specialised version of {@link #replace(Object, Object, Object)} * * @param key key with which the specified value is associated * @param oldValue value expected to be associated with the specified key * @param newValue value to be associated with the specified key * @return {@code true} if the value was replaced */ public boolean replace(final long key, final long oldValue, final long newValue) { final long curValue = get(key); if (curValue != oldValue || curValue == missingValue) { return false; } put(key, newValue); return true; }
/** * Primitive specialised version of {@link #replace(Object, Object)} * * @param key key with which the specified value is associated * @param value value to be associated with the specified key * @return the previous value associated with the specified key, or * {@link #missingValue()} if there was no mapping for the key. */ public long replace(final long key, final long value) { long curValue = get(key); if (curValue != missingValue) { curValue = put(key, value); } return curValue; }
/** * Primitive specialised version of {@link #replace(Object, Object)} * * @param key key with which the specified value is associated * @param value value to be associated with the specified key * @return the previous value associated with the specified key, or * {@link #missingValue()} if there was no mapping for the key. */ public long replace(final long key, final long value) { long curValue = get(key); if (curValue != missingValue) { curValue = put(key, value); } return curValue; }
/** * Primitive specialised version of {@link #replace(Object, Object, Object)} * * @param key key with which the specified value is associated * @param oldValue value expected to be associated with the specified key * @param newValue value to be associated with the specified key * @return {@code true} if the value was replaced */ public boolean replace(final long key, long oldValue, long newValue) { final long curValue = get(key); if (curValue != oldValue || curValue == missingValue) { return false; } put(key, newValue); return true; }
/** * Primitive specialised version of {@link #computeIfAbsent(Object, Function)} * * @param key to search on. * @param mappingFunction to provide a value if the get returns null. * @return the value if found otherwise the missing value. */ public long computeIfAbsent(final long key, final LongUnaryOperator mappingFunction) { long value = get(key); if (value == missingValue) { value = mappingFunction.applyAsLong(key); if (value != missingValue) { put(key, value); } } return value; }
private void createNewRecord( final int sequenceNumber, final long sessionId, final int position) { recordOffsets.put(sessionId, position); lastKnownEncoder .wrap(inMemoryBuffer, position) .sessionId(sessionId); updateSequenceNumber(position, sequenceNumber); }
private void sendSlowStatus( final int libraryId, final long connectionId, final Long2LongHashMap toNotResend, final Long2LongHashMap toResend, final SlowStatus status) { toNotResend.remove(connectionId); final long position = inboundPublication.saveSlowStatusNotification(libraryId, connectionId, status); if (Pressure.isBackPressured(position)) { toResend.put(connectionId, libraryId); } } }
private void rehash(@DoNotSub final int newCapacity) { final long[] oldEntries = entries; final long missingValue = this.missingValue; @DoNotSub final int length = entries.length; capacity(newCapacity); for (@DoNotSub int i = 0; i < length; i += 2) { final long key = oldEntries[i]; if (key != missingValue) { put(key, oldEntries[i + 1]); } } }
private void quiesce() { final Long2LongHashMap inboundPositions = new Long2LongHashMap(CompletionPosition.MISSING_VALUE); inboundPositions.put(inboundPublication.id(), inboundPublication.position()); inboundCompletionPosition.complete(inboundPositions); final Long2LongHashMap outboundPositions = new Long2LongHashMap(CompletionPosition.MISSING_VALUE); idToLibrary.values().forEach(liveLibraryInfo -> { final int aeronSessionId = liveLibraryInfo.aeronSessionId(); final Image image = librarySubscription.imageBySessionId(aeronSessionId); if (image != null) { final long position = image.position(); outboundPositions.put(aeronSessionId, position); } }); outboundLibraryCompletionPosition.complete(outboundPositions); recordingCoordinator.completionPositions(inboundPositions, outboundPositions); }