private <K,V> Entry<K,V> entry(K k, V v) { return Maps.immutableEntry(k, v); } }
void reportArchivedFilesForQuota(List<? extends StoreFile> archivedFiles, List<Long> fileSizes) { // Sanity check from the caller if (archivedFiles.size() != fileSizes.size()) { throw new RuntimeException("Coding error: should never see lists of varying size"); } RegionServerServices rss = this.region.getRegionServerServices(); if (rss == null) { return; } List<Entry<String,Long>> filesWithSizes = new ArrayList<>(archivedFiles.size()); Iterator<Long> fileSizeIter = fileSizes.iterator(); for (StoreFile storeFile : archivedFiles) { final long fileSize = fileSizeIter.next(); if (storeFile.isHFile() && fileSize != 0) { filesWithSizes.add(Maps.immutableEntry(storeFile.getPath().getName(), fileSize)); } } if (LOG.isTraceEnabled()) { LOG.trace("Files archived: " + archivedFiles + ", reporting the following to the Master: " + filesWithSizes); } boolean success = rss.reportFileArchivalForQuotas(getTableName(), filesWithSizes); if (!success) { LOG.warn("Failed to report archival of files: " + filesWithSizes); } }
/** * Count the number of rows and the number of entries from a scanner * * @param scanner * The Scanner * @return An entry where the first item is rows observed and the second is entries observed. */ private Entry<Long,Long> sumTable(ResultScanner scanner) { long rowsObserved = 0L; long entriesObserved = 0L; // Read all the records in the table for (Result result : scanner) { rowsObserved++; while (result.advance()) { entriesObserved++; } } return Maps.immutableEntry(rowsObserved,entriesObserved); } }
public void processFileArchivals(FileArchiveNotificationRequest request, Connection conn, Configuration conf, FileSystem fs) throws IOException { final HashMultimap<TableName,Entry<String,Long>> archivedFilesByTable = HashMultimap.create(); // Group the archived files by table for (FileWithSize fileWithSize : request.getArchivedFilesList()) { TableName tn = ProtobufUtil.toTableName(fileWithSize.getTableName()); archivedFilesByTable.put( tn, Maps.immutableEntry(fileWithSize.getName(), fileWithSize.getSize())); } if (LOG.isTraceEnabled()) { LOG.trace("Grouped archived files by table: " + archivedFilesByTable); } // Report each set of files to the appropriate object for (TableName tn : archivedFilesByTable.keySet()) { final Set<Entry<String,Long>> filesWithSize = archivedFilesByTable.get(tn); final FileArchiverNotifier notifier = FileArchiverNotifierFactoryImpl.getInstance().get( conn, conf, fs, tn); notifier.addArchivedFiles(filesWithSize); } } }
@Override Entry<K, V> output(K key, V value) { return Maps.immutableEntry(key, value); } };
@Override public boolean containsEntry(Object key, Object value) { return map.entrySet().contains(Maps.immutableEntry(key, value)); }
@Override public boolean remove(Object key, Object value) { return map.entrySet().remove(Maps.immutableEntry(key, value)); }
@Override Entry<K, V> transform(final K key) { return immutableEntry(key, function.apply(key)); } };
@Override public boolean apply(Entry<V, K> input) { return forwardPredicate.apply(Maps.immutableEntry(input.getValue(), input.getKey())); } };
boolean apply(@Nullable Object key, @Nullable V value) { // This method is called only when the key is in the map, implying that // key is a K. @SuppressWarnings("unchecked") K k = (K) key; return predicate.apply(Maps.immutableEntry(k, value)); }
@Override ImmutableSet<Entry<K, V>> createEntrySet() { return ImmutableSet.of(Maps.immutableEntry(singleKey, singleValue)); }
@Override protected Entry<Cut<C>, Range<C>> computeNext() { if (!backingItr.hasNext()) { return endOfData(); } Range<C> range = backingItr.next(); if (upperBoundWindow.upperBound.isLessThan(range.upperBound)) { return endOfData(); } else { return Maps.immutableEntry(range.upperBound, range); } } };
@Override public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { unfiltered() .replaceAll( (key, value) -> predicate.apply(Maps.immutableEntry(key, value)) ? function.apply(key, value) : value); }
@Override Spliterator<Entry<K, V>> entrySpliterator() { return CollectSpliterators.flatMap( map.entrySet().spliterator(), keyToValueCollectionEntry -> { K key = keyToValueCollectionEntry.getKey(); Collection<V> valueCollection = keyToValueCollectionEntry.getValue(); return CollectSpliterators.map( valueCollection.spliterator(), (V value) -> Maps.immutableEntry(key, value)); }, Spliterator.SIZED, size()); }
@Override protected Entry<Cut<C>, Range<C>> computeNext() { if (!completeRangeItr.hasNext()) { return endOfData(); } Range<C> nextRange = completeRangeItr.next(); if (upperBoundOnLowerBounds.isLessThan(nextRange.lowerBound)) { return endOfData(); } else { nextRange = nextRange.intersection(restriction); return Maps.immutableEntry(nextRange.lowerBound, nextRange); } } };
@Override protected Entry<K, V> computeNext() { for (index++; index < maxIndex; index++) { V value = getValue(index); if (value != null) { return Maps.immutableEntry(getKey(index), value); } } return endOfData(); } };
@Override Spliterator<Entry<K, V>> entrySpliterator() { return CollectSpliterators.map(set.spliterator(), e -> immutableEntry(e, function.apply(e))); }
/** * Associates the specified range with the specified value. * * @throws IllegalArgumentException if {@code range} is empty */ @CanIgnoreReturnValue public Builder<K, V> put(Range<K> range, V value) { checkNotNull(range); checkNotNull(value); checkArgument(!range.isEmpty(), "Range must not be empty, but was %s", range); entries.add(Maps.immutableEntry(range, value)); return this; }
@Override Spliterator<Entry<K, V>> entrySpliterator() { return CollectSpliterators.flatMap( asMap().entrySet().spliterator(), keyToValueCollectionEntry -> { K key = keyToValueCollectionEntry.getKey(); Collection<V> valueCollection = keyToValueCollectionEntry.getValue(); return CollectSpliterators.map( valueCollection.spliterator(), (V value) -> Maps.immutableEntry(key, value)); }, Spliterator.SIZED | (this instanceof SetMultimap ? Spliterator.DISTINCT : 0), size()); }
@Override protected Entry<Cut<C>, Range<C>> computeNext() { if (!backingItr.hasNext()) { return endOfData(); } Range<C> range = backingItr.next(); return upperBoundWindow.lowerBound.isLessThan(range.upperBound) ? Maps.immutableEntry(range.upperBound, range) : endOfData(); } };