@Override public Iterable<FileStatus> getDeletableFiles(Iterable<FileStatus> files) { return Iterables.filter(files, this::isFileDeletable); }
@Override public Iterable<Entry<RegionInfo, Long>> filterBySubject(String namespace) { rlock.lock(); try { return Iterables.filter(regionUsage.entrySet(), new Predicate<Entry<RegionInfo,Long>>() { @Override public boolean apply(Entry<RegionInfo,Long> input) { return namespace.equals(input.getKey().getTable().getNamespaceAsString()); } }); } finally { rlock.unlock(); } }
@Override public Iterable<Entry<RegionInfo,Long>> filterBySubject(TableName table) { rlock.lock(); try { return Iterables.filter(regionUsage.entrySet(), new Predicate<Entry<RegionInfo,Long>>() { @Override public boolean apply(Entry<RegionInfo,Long> input) { return table.equals(input.getKey().getTable()); } }); } finally { rlock.unlock(); } }
@Override public Iterable<FileStatus> getDeletableFiles(Iterable<FileStatus> files) { // all members of this class are null if replication is disabled, // so we cannot filter the files if (this.getConf() == null) { return files; } if (wals == null) { return Collections.emptyList(); } return Iterables.filter(files, new Predicate<FileStatus>() { @Override public boolean apply(FileStatus file) { String wal = file.getPath().getName(); boolean logInReplicationQueue = wals.contains(wal); if (logInReplicationQueue) { LOG.debug("Found up in ZooKeeper, NOT deleting={}", wal); } return !logInReplicationQueue && (file.getModificationTime() < readZKTimestamp); } }); }
return Collections.emptyList(); return Iterables.filter(files, new Predicate<FileStatus>() { @Override public boolean apply(FileStatus file) {
@Override public void addCompactionResults(Collection<HStoreFile> newCompactedfiles, Collection<HStoreFile> results) { this.storefiles = ImmutableList.sortedCopyOf(storeFileComparator, Iterables .concat(Iterables.filter(storefiles, sf -> !newCompactedfiles.contains(sf)), results)); // Mark the files as compactedAway once the storefiles and compactedfiles list is finalized // Let a background thread close the actual reader on these compacted files and also // ensure to evict the blocks from block cache so that they are no longer in // cache newCompactedfiles.forEach(HStoreFile::markCompactedAway); this.compactedfiles = ImmutableList.sortedCopyOf(storeFileComparator, Iterables.concat(this.compactedfiles, newCompactedfiles)); }
return Collections.emptyList(); Iterable<FileStatus> deletables = Iterables.filter(files, file -> {
/** * Returns the elements from this fluent iterable that satisfy a predicate. The resulting fluent * iterable's iterator does not support {@code remove()}. * * <p><b>{@code Stream} equivalent:</b> {@link Stream#filter} (same). */ public final FluentIterable<E> filter(Predicate<? super E> predicate) { return from(Iterables.filter(getDelegate(), predicate)); }
private static Iterable<Type> filterUpperBounds(Iterable<Type> bounds) { return Iterables.filter(bounds, Predicates.not(Predicates.<Type>equalTo(Object.class))); }
private ArrayList<HRegionInfo> filterTableRegions(final TableName tableName, List<HRegionInfo> onlineRegions) { return Lists.newArrayList(Iterables.filter(onlineRegions, new Predicate<HRegionInfo>() { @Override public boolean apply(HRegionInfo input) { return input.getTable().equals(tableName); } })); }
/** * Returns the elements from this fluent iterable that are instances of class {@code type}. * * <p><b>{@code Stream} equivalent:</b> {@code stream.filter(type::isInstance).map(type::cast)}. * This does perform a little more work than necessary, so another option is to insert an * unchecked cast at some later point: * * <pre> * {@code @SuppressWarnings("unchecked") // safe because of ::isInstance check * ImmutableList<NewType> result = * (ImmutableList) stream.filter(NewType.class::isInstance).collect(toImmutableList());} * </pre> */ @GwtIncompatible // Class.isInstance public final <T> FluentIterable<T> filter(Class<T> type) { return from(Iterables.filter(getDelegate(), type)); }