@Override public int getStoreCompactionPriority() { int priority = blockingFileCount - storefiles.size(); return (priority == HStore.PRIORITY_USER) ? priority + 1 : priority; }
@Override public int getStorefileCount() { return state.allFilesCached.size(); }
@Override public final int getStorefileCount() { return storefiles.size(); }
@Override public int getCompactedFilesCount() { return state.allCompactedFilesCached.size(); }
@Override public final int getCompactedFilesCount() { return compactedfiles.size(); }
@Override public int getStoreCompactionPriority() { // If there's only L0, do what the default store does. // If we are in critical priority, do the same - we don't want to trump all stores all // the time due to how many files we have. int fc = getStorefileCount(); if (state.stripeFiles.isEmpty() || (this.blockingFileCount <= fc)) { return this.blockingFileCount - fc; } // If we are in good shape, we don't want to be trumped by all other stores due to how // many files we have, so do an approximate mapping to normal priority range; L0 counts // for all stripes. int l0 = state.level0Files.size(), sc = state.stripeFiles.size(); int priority = (int)Math.ceil(((double)(this.blockingFileCount - fc + l0) / sc) - l0); return (priority <= HStore.PRIORITY_USER) ? (HStore.PRIORITY_USER + 1) : priority; }
@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; }
private void debugDumpState(String string) { if (!LOG.isDebugEnabled()) return; StringBuilder sb = new StringBuilder(); sb.append("\n" + string + "; current stripe state is as such:"); sb.append("\n level 0 with ") .append(state.level0Files.size()) .append( " files: " + TraditionalBinaryPrefix.long2String( StripeCompactionPolicy.getTotalFileSize(state.level0Files), "", 1) + ";"); for (int i = 0; i < state.stripeFiles.size(); ++i) { String endRow = (i == state.stripeEndRows.length) ? "(end)" : "[" + Bytes.toString(state.stripeEndRows[i]) + "]"; sb.append("\n stripe ending in ") .append(endRow) .append(" with ") .append(state.stripeFiles.get(i).size()) .append( " files: " + TraditionalBinaryPrefix.long2String( StripeCompactionPolicy.getTotalFileSize(state.stripeFiles.get(i)), "", 1) + ";"); } sb.append("\n").append(state.stripeFiles.size()).append(" stripes total."); sb.append("\n").append(getStorefileCount()).append(" files total."); LOG.debug(sb.toString()); }
@Override public Collection<HStoreFile> getUnneededFiles(long maxTs, List<HStoreFile> filesCompacting) { ImmutableList<HStoreFile> files = storefiles; // 1) We can never get rid of the last file which has the maximum seqid. // 2) Files that are not the latest can't become one due to (1), so the rest are fair game. return files.stream().limit(Math.max(0, files.size() - 1)).filter(sf -> { long fileTs = sf.getReader().getMaxTimestamp(); if (fileTs < maxTs && !filesCompacting.contains(sf)) { LOG.info("Found an expired store file {} whose maxTimestamp is {}, which is below {}", sf.getPath(), fileTs, maxTs); return true; } else { return false; } }).collect(Collectors.toList()); }
@Override public double getCompactionPressure() { State stateLocal = this.state; if (stateLocal.allFilesCached.size() > blockingFileCount) { double max = 0.0; for (ImmutableList<HStoreFile> stripeFile : stateLocal.stripeFiles) { int stripeFileCount = stripeFile.size(); double normCount = (double) (stripeFileCount + delta - config.getStripeCompactMinFiles())
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; }
boolean hasAllFiles = filesToCompact.size() == stripes.get(bqIndex).size(); String splitString = ""; if (hasAllFiles && bqTotalSize >= config.getSplitSize()) {
/** * Indicates whether this domain is composed of two or more parts. */ public boolean hasParent() { return parts.size() > 1; }
@Override int copyIntoArray(Object[] dst, int offset) { // this loop is faster for RandomAccess instances, which ImmutableLists are int size = size(); for (int i = 0; i < size; i++) { dst[offset + i] = get(i); } return offset + size; }
@Override public int hashCode() { int hashCode = 1; int n = size(); for (int i = 0; i < n; i++) { hashCode = 31 * hashCode + get(i).hashCode(); hashCode = ~~hashCode; // needed to deal with GWT integer overflow } return hashCode; }
/** * Returns a view of this immutable list in reverse order. For example, {@code * ImmutableList.of(1, 2, 3).reverse()} is equivalent to {@code * ImmutableList.of(3, 2, 1)}. * * @return a view of this immutable list in reverse order * @since 7.0 */ public ImmutableList<E> reverse() { return (size() <= 1) ? this : new ReverseImmutableList<E>(this); }
/** * Returns the ancestor of the current domain at the given number of levels "higher" (rightward) * in the subdomain list. The number of levels must be non-negative, and less than {@code N-1}, * where {@code N} is the number of parts in the domain. * * <p>TODO: Reasonable candidate for addition to public API. */ private InternetDomainName ancestor(int levels) { return from(DOT_JOINER.join(parts.subList(levels, parts.size()))); }
@Override public Range<K> span() { if (ranges.isEmpty()) { throw new NoSuchElementException(); } Range<K> firstRange = ranges.get(0); Range<K> lastRange = ranges.get(ranges.size() - 1); return Range.create(firstRange.lowerBound, lastRange.upperBound); }
/** A factory that chooses the most space-efficient representation of the table. */ static <R, C, V> RegularImmutableTable<R, C, V> forOrderedComponents( ImmutableList<Cell<R, C, V>> cellList, ImmutableSet<R> rowSpace, ImmutableSet<C> columnSpace) { // use a dense table if more than half of the cells have values // TODO(gak): tune this condition based on empirical evidence return (cellList.size() > (((long) rowSpace.size() * columnSpace.size()) / 2)) ? new DenseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace) : new SparseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace); } }