@Override public Collection<HStoreFile> clearCompactedFiles() { List<HStoreFile> result = compactedfiles; compactedfiles = ImmutableList.of(); return result; }
State newState = new State(); newState.level0Files = (this.level0Files == null) ? oldState.level0Files : ImmutableList.copyOf(this.level0Files); newState.stripeEndRows = (this.stripeEndRows == null) ? oldState.stripeEndRows : this.stripeEndRows.toArray(new byte[this.stripeEndRows.size()][]); for (List<HStoreFile> newStripe : this.stripeFiles) { newState.stripeFiles.add(newStripe instanceof ImmutableList<?> ? (ImmutableList<HStoreFile>)newStripe : ImmutableList.copyOf(newStripe)); newAllFiles.addAll(results); newState.allFilesCached = ImmutableList.copyOf(newAllFiles); newState.allCompactedFilesCached = ImmutableList.copyOf(newAllCompactedFiles); return newState;
public static CombinedAsyncWriter create(AsyncWriter writer, AsyncWriter... writers) { return new CombinedAsyncWriter( ImmutableList.<AsyncWriter> builder().add(writer).add(writers).build()); } }
@Override public CompletableFuture<Long> sync() { CompletableFuture<Long> future = new CompletableFuture<>(); AtomicInteger remaining = new AtomicInteger(writers.size()); writers.forEach(w -> w.sync().whenComplete((length, error) -> { if (error != null) { future.completeExceptionally(error); return; } if (remaining.decrementAndGet() == 0) { future.complete(length); } })); return future; }
@Override public double getCompactionPressure() { State stateLocal = this.state; if (stateLocal.allFilesCached.size() > blockingFileCount) { int delta = stateLocal.level0Files.isEmpty() ? 0 : 1; double max = 0.0; for (ImmutableList<HStoreFile> stripeFile : stateLocal.stripeFiles) { int stripeFileCount = stripeFile.size(); double normCount = (double) (stripeFileCount + delta - config.getStripeCompactMinFiles())
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) { this.rowList = ImmutableList.copyOf(rowKeys); this.columnList = ImmutableList.copyOf(columnKeys); checkArgument(!rowList.isEmpty()); checkArgument(!columnList.isEmpty()); /* * TODO(jlevy): Support empty rowKeys or columnKeys? If we do, when * columnKeys is empty but rowKeys isn't, the table is empty but * containsRow() can return true and rowKeySet() isn't empty. */ rowKeyToIndex = Maps.indexMap(rowList); columnKeyToIndex = Maps.indexMap(columnList); @SuppressWarnings("unchecked") V[][] tmpArray = (V[][]) new Object[rowList.size()][columnList.size()]; array = tmpArray; // Necessary because in GWT the arrays are initialized with "undefined" instead of null. eraseAll(); }
static <E> List<List<E>> create(List<? extends List<? extends E>> lists) { ImmutableList.Builder<List<E>> axesBuilder = new ImmutableList.Builder<List<E>>(lists.size()); for (List<? extends E> list : lists) { List<E> copy = ImmutableList.copyOf(list); if (copy.isEmpty()) { return ImmutableList.of(); } axesBuilder.add(copy); } return new CartesianList<E>(axesBuilder.build()); }
private Collection<HStoreFile> findExpiredFiles(ImmutableList<HStoreFile> stripe, long maxTs, List<HStoreFile> filesCompacting, Collection<HStoreFile> expiredStoreFiles) { // Order by seqnum is reversed. for (int i = 1; i < stripe.size(); ++i) { HStoreFile sf = stripe.get(i); synchronized (sf) { long fileTs = sf.getReader().getMaxTimestamp(); if (fileTs < maxTs && !filesCompacting.contains(sf)) { LOG.info("Found an expired store file: " + sf.getPath() + " whose maxTimestamp is " + fileTs + ", which is below " + maxTs); if (expiredStoreFiles == null) { expiredStoreFiles = new ArrayList<>(); } expiredStoreFiles.add(sf); } } } return expiredStoreFiles; }
public static <T> ImmutableList<ListenableFuture<T>> inCompletionOrder( Iterable<? extends ListenableFuture<? extends T>> futures) { ImmutableList<ListenableFuture<? extends T>> copy = ImmutableList.copyOf(futures); ImmutableList.Builder<SettableFuture<T>> delegatesBuilder = ImmutableList.builder(); for (int i = 0; i < copy.size(); i++) { delegatesBuilder.add(SettableFuture.<T>create());
@Override public long getLength() { return writers.get(0).getLength(); }
@Override public ImmutableMap<Range<K>, V> asDescendingMapOfRanges() { if (ranges.isEmpty()) { return ImmutableMap.of(); } RegularImmutableSortedSet<Range<K>> rangeSet = new RegularImmutableSortedSet<Range<K>>( ranges.reverse(), Range.<K>rangeLexOrdering().reverse()); return new ImmutableSortedMap<Range<K>, V>(rangeSet, values.reverse()); }
/** * Returns an immutable sorted set containing the elements of a sorted set, * sorted by the same {@code Comparator}. That behavior differs from {@link * #copyOf(Iterable)}, which always uses the natural ordering of the * elements. * * <p>Despite the method name, this method attempts to avoid actually copying * the data when it is safe to do so. The exact circumstances under which a * copy will or will not be performed are undocumented and subject to change. * * <p>This method is safe to use even when {@code sortedSet} is a synchronized * or concurrent collection that is currently being modified by another * thread. * * @throws NullPointerException if {@code sortedSet} or any of its elements * is null */ public static <E> ImmutableSortedSet<E> copyOfSorted(SortedSet<E> sortedSet) { Comparator<? super E> comparator = SortedIterables.comparator(sortedSet); ImmutableList<E> list = ImmutableList.copyOf(sortedSet); if (list.isEmpty()) { return emptySet(comparator); } else { return new RegularImmutableSortedSet<E>(list, comparator); } }
si = createStripesWithSizes(0, 0, stripes); List<HStoreFile> compactFile = new ArrayList<>(); Iterator<HStoreFile> iter = si.getStripes().get(0).listIterator(1); while (iter.hasNext()) { compactFile.add(iter.next());
@Override public Collection<HStoreFile> getFilesForScan(byte[] startRow, boolean includeStartRow, byte[] stopRow, boolean includeStopRow) { if (state.stripeFiles.isEmpty()) { return state.level0Files; // There's just L0. } int firstStripe = findStripeForRow(startRow, true); int lastStripe = findStripeForRow(stopRow, false); assert firstStripe <= lastStripe; if (firstStripe == lastStripe && state.level0Files.isEmpty()) { return state.stripeFiles.get(firstStripe); // There's just one stripe we need. } if (firstStripe == 0 && lastStripe == (state.stripeFiles.size() - 1)) { return state.allFilesCached; // We need to read all files. } ConcatenatedLists<HStoreFile> result = new ConcatenatedLists<>(); result.addAllSublists(state.stripeFiles.subList(firstStripe, lastStripe + 1)); result.addSublist(state.level0Files); return result; }