@Override public void loadFiles(List<HStoreFile> storeFiles) { this.storefiles = ImmutableList.sortedCopyOf(storeFileComparator, storeFiles); }
@Override public void insertNewFiles(Collection<HStoreFile> sfs) throws IOException { this.storefiles = ImmutableList.sortedCopyOf(storeFileComparator, Iterables.concat(this.storefiles, sfs)); }
@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)); }
/** * Returns an <b>immutable</b> list containing {@code elements} sorted by this ordering. The input * is not modified. * * <p>Unlike {@link Sets#newTreeSet(Iterable)}, this method does not discard elements that are * duplicates according to the comparator. The sort performed is <i>stable</i>, meaning that such * elements will appear in the returned list in the same order they appeared in {@code elements}. * * <p><b>Performance note:</b> According to our * benchmarking * on Open JDK 7, this method is the most efficient way to make a sorted copy of a collection. * * @throws NullPointerException if any element of {@code elements} is {@code null} * @since 3.0 */ // TODO(kevinb): rerun benchmarks including new options @CanIgnoreReturnValue // TODO(kak): Consider removing this before internal migration public <E extends T> ImmutableList<E> immutableSortedCopy(Iterable<E> elements) { return ImmutableList.sortedCopyOf(this, elements); }
private static final <R, C, V> RegularImmutableTable<R, C, V> forCellsInternal( Iterable<Cell<R, C, V>> cells, @Nullable Comparator<? super R> rowComparator, @Nullable Comparator<? super C> columnComparator) { Set<R> rowSpaceBuilder = new LinkedHashSet<R>(); Set<C> columnSpaceBuilder = new LinkedHashSet<C>(); ImmutableList<Cell<R, C, V>> cellList = ImmutableList.copyOf(cells); for (Cell<R, C, V> cell : cells) { rowSpaceBuilder.add(cell.getRowKey()); columnSpaceBuilder.add(cell.getColumnKey()); } ImmutableSet<R> rowSpace = (rowComparator == null) ? ImmutableSet.copyOf(rowSpaceBuilder) : ImmutableSet.copyOf(ImmutableList.sortedCopyOf(rowComparator, rowSpaceBuilder)); ImmutableSet<C> columnSpace = (columnComparator == null) ? ImmutableSet.copyOf(columnSpaceBuilder) : ImmutableSet.copyOf(ImmutableList.sortedCopyOf(columnComparator, columnSpaceBuilder)); return forOrderedComponents(cellList, rowSpace, columnSpace); }