@Override public void putAll(Map<? extends K, ? extends V> map) { for (K key : map.keySet()) { checkValid(key); } delegate.putAll(map); }
/** * Used to sort a Map by the values. */ @VisibleForTesting public <K extends Comparable<K>, V extends Comparable<V>> NavigableMap<K, V> sortByValues(final Map<K, V> map) { Comparator<K> valueComparator = (k1, k2) -> { int compare = map.get(k2).compareTo(map.get(k1)); if (compare == 0) { return k2.compareTo(k1); } else { return compare; } }; NavigableMap<K, V> sortedByValues = new TreeMap<>(valueComparator); sortedByValues.putAll(map); return sortedByValues; }
@Override public void appendEvents(List<? extends EventMessage<?>> events) { synchronized (this.events) { GlobalSequenceTrackingToken trackingToken = nextTrackingToken(); this.events.putAll(IntStream.range(0, events.size()).mapToObj( i -> asTrackedEventMessage((EventMessage<?>) events.get(i), trackingToken.offsetBy(i))).collect( Collectors.toMap(TrackedEventMessage::trackingToken, Function.identity()))); } }
/** * Simulates the operations done by the framework when there is a time change. If the time is * changed, the timestamps of all existing usage events will be shifted by the same offset as the * time change, in order to make sure they remain stable relative to the new time. * * This method won't affect the results of {@link #queryUsageStats} method. * * @param offsetToAddInMillis the offset to be applied to all events. For example, if {@code * offsetInMillis} is 60,000, then all {@link Event}s will be shifted forward by 1 minute * (into the future). Likewise, if {@code offsetInMillis} is -60,000, then all {@link Event}s * will be shifted backward by 1 minute (into the past). */ public void simulateTimeChange(long offsetToAddInMillis) { ImmutableMap.Builder<Long, Event> eventMapBuilder = ImmutableMap.builder(); for (Event event : eventsByTimeStamp.values()) { long newTimestamp = event.getTimeStamp() + offsetToAddInMillis; eventMapBuilder.put( newTimestamp, EventBuilder.fromEvent(event).setTimeStamp(newTimestamp).build()); } eventsByTimeStamp.putAll(eventMapBuilder.build()); }
private void initPendingCommit() { RedisCommands commands = null; try { commands = container.getInstance(); if (commands.exists(prepareNamespace)) { LOG.debug("Loading previously prepared commit from {}", prepareNamespace); NavigableMap<byte[], byte[]> pendingCommitMap = new TreeMap<>(UnsignedBytes.lexicographicalComparator()); pendingCommitMap.putAll(commands.hgetAll(prepareNamespace)); pendingCommit = Maps.unmodifiableNavigableMap(pendingCommitMap); } else { LOG.debug("No previously prepared commits."); pendingCommit = EMPTY_PENDING_COMMIT_MAP; } } finally { container.returnInstance(commands); } }
@GwtIncompatible // NavigableMap void ensureNotDirectlyModifiable(NavigableMap<Integer, String> unmod) { try { unmod.put(4, "four"); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } try { unmod.putAll(Collections.singletonMap(4, "four")); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } try { unmod.remove(4); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } try { unmod.pollFirstEntry(); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } try { unmod.pollLastEntry(); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } }
@Override public void merge(BackendEntry other) { TextBackendEntry text = (TextBackendEntry) other; this.columns.putAll(text.columns); }
private static void transferCells(Mutation source, Mutation target) { target.getFamilyCellMap().putAll(source.getFamilyCellMap()); } private static void transferAttributes(Mutation source, Mutation target) {
/** * Add a map of region plans. */ public void addPlans(Map<String, RegionPlan> plans) { synchronized (regionPlans) { regionPlans.putAll(plans); } }
/** * @param m * @see java.util.Map#putAll(java.util.Map) */ @Override public void putAll(Map<? extends Double, ? extends Color> m) { mapping.putAll(m); } /**
public OSBTreeRidBag(OBonsaiCollectionPointer pointer, Map<OIdentifiable, Change> changes) { this.collectionPointer = pointer; this.changes.putAll(changes); this.size = -1; }
private static NavigableMap<Long, Update> createVersionedValuesMap(SortedMap<Long, Update> copy) { NavigableMap<Long, Update> map = Maps.newTreeMap(VERSIONED_VALUE_MAP_COMPARATOR); map.putAll(copy); return map; }
@Override public void putAll(Map<? extends K, ? extends V> map) { for (K key : map.keySet()) { checkValid(key); } delegate.putAll(map); }
@Override public void appendEvents(List<? extends EventMessage<?>> events) { synchronized (this.events) { GlobalSequenceTrackingToken trackingToken = nextTrackingToken(); this.events.putAll(IntStream.range(0, events.size()).mapToObj( i -> asTrackedEventMessage((EventMessage<?>) events.get(i), trackingToken.offsetBy(i))).collect( Collectors.toMap(TrackedEventMessage::trackingToken, Function.identity()))); } }
private static void transferCells(Mutation source, Mutation target) { target.getFamilyCellMap().putAll(source.getFamilyCellMap()); } private static void transferAttributes(Mutation source, Mutation target) {
/** * Copy constructor * @param a */ public Append(Append a) { this.row = a.getRow(); this.ts = a.getTimeStamp(); this.familyMap.putAll(a.getFamilyCellMap()); for (Map.Entry<String, byte[]> entry : a.getAttributesMap().entrySet()) { this.setAttribute(entry.getKey(), entry.getValue()); } }
public static void setChildMetadata(Command subCommand, TempMetadataStore parentTempMetadata, GroupContext parentContext) { TempMetadataStore tempMetadata = subCommand.getTemporaryMetadata(); if(tempMetadata == null) { subCommand.setTemporaryMetadata(parentTempMetadata.clone()); } else { tempMetadata.getData().putAll(parentTempMetadata.getData()); } subCommand.setExternalGroupContexts(parentContext); }
public static void setChildMetadata(Command subCommand, TempMetadataStore parentTempMetadata, GroupContext parentContext) { TempMetadataStore tempMetadata = subCommand.getTemporaryMetadata(); if(tempMetadata == null) { subCommand.setTemporaryMetadata(parentTempMetadata.clone()); } else { tempMetadata.getData().putAll(parentTempMetadata.getData()); } subCommand.setExternalGroupContexts(parentContext); }
public static void setChildMetadata(Command subCommand, TempMetadataStore parentTempMetadata, GroupContext parentContext) { TempMetadataStore tempMetadata = subCommand.getTemporaryMetadata(); if(tempMetadata == null) { subCommand.setTemporaryMetadata(parentTempMetadata.clone()); } else { tempMetadata.getData().putAll(parentTempMetadata.getData()); } subCommand.setExternalGroupContexts(parentContext); }