public IndexSummary sharedCopy() { return new IndexSummary(this); }
public byte[] getKey(int index) { long start = getPositionInSummary(index); int keySize = (int) (calculateEnd(index) - start - 8L); byte[] key = new byte[keySize]; entries.getBytes(start, key, 0, keySize); return key; }
void releaseSummary() { summary.close(); assert summary.isCleanedUp(); summary = null; } }
int currentSamplingLevel = existing.getSamplingLevel(); assert currentSamplingLevel > newSamplingLevel; assert minIndexInterval == existing.getMinIndexInterval(); int newKeyCount = existing.size(); long newEntriesLength = existing.getEntriesLength(); for (int start : startPoints) for (int j = start; j < existing.size(); j += currentSamplingLevel) long length = existing.getEndInSummary(j) - existing.getPositionInSummary(j); newEntriesLength -= length; Memory oldEntries = existing.getEntries(); Memory newOffsets = Memory.allocate(newKeyCount * 4); Memory newEntries = Memory.allocate(newEntriesLength); int newEntriesOffset = 0; outer: for (int oldSummaryIndex = 0; oldSummaryIndex < existing.size(); oldSummaryIndex++) long start = existing.getPositionInSummary(oldSummaryIndex); long length = existing.getEndInSummary(oldSummaryIndex) - start; newEntries.put(newEntriesOffset, oldEntries, start, length); newEntriesOffset += length; return new IndexSummary(partitioner, newOffsets, newKeyCount, newEntries, newEntriesLength, existing.getMaxNumberOfEntries(), minIndexInterval, newSamplingLevel);
PartitionPosition rightPosition = range.right.maxKeyBound(); int left = summary.binarySearch(leftPosition); if (left < 0) left = (left + 1) * -1; if (left == summary.size()) ? summary.size() - 1 : summary.binarySearch(rightPosition); if (right < 0)
int binarySearchResult = indexSummary.binarySearch(key); long sampledPosition = getIndexScanPositionFromBinarySearchResult(binarySearchResult, indexSummary); int sampledIndex = getIndexSummaryIndexFromBinarySearchResult(binarySearchResult); int effectiveInterval = indexSummary.getEffectiveIndexIntervalAfterIndex(sampledIndex);
public void run() { if (logger.isTraceEnabled()) logger.trace("Async instance tidier for {}, before barrier", descriptor); if (barrier != null) barrier.await(); if (logger.isTraceEnabled()) logger.trace("Async instance tidier for {}, after barrier", descriptor); if (bf != null) bf.close(); if (summary != null) summary.close(); if (runOnClose != null) runOnClose.run(); if (dfile != null) dfile.close(); if (ifile != null) ifile.close(); globalRef.release(); if (logger.isTraceEnabled()) logger.trace("Async instance tidier for {}, completed", descriptor); } });
public long getEndInSummary(int index) { return calculateEnd(index); }
/** * Returns the key for the index summary entry at `index`. */ public byte[] getIndexSummaryKey(int index) { return indexSummary.getKey(index); }
/** * @return An estimate of the number of keys in this SSTable based on the index summary. */ public long estimatedKeys() { return indexSummary.getEstimatedKeyCount(); }
/** * Gets the position in the index file to start scanning to find the given key (at most indexInterval keys away, * modulo downsampling of the index summary). Always returns a {@code value >= 0} */ public long getIndexScanPosition(PartitionPosition key) { if (openReason == OpenReason.MOVED_START && key.compareTo(first) < 0) key = first; return getIndexScanPositionFromBinarySearchResult(indexSummary.binarySearch(key), indexSummary); }
int currentSamplingLevel = existing.getSamplingLevel(); assert currentSamplingLevel > newSamplingLevel; assert minIndexInterval == existing.getMinIndexInterval(); int newKeyCount = existing.size(); long newEntriesLength = existing.getEntriesLength(); for (int start : startPoints) for (int j = start; j < existing.size(); j += currentSamplingLevel) long length = existing.getEndInSummary(j) - existing.getPositionInSummary(j); newEntriesLength -= length; Memory oldEntries = existing.getEntries(); Memory newOffsets = Memory.allocate(newKeyCount * 4); Memory newEntries = Memory.allocate(newEntriesLength); int newEntriesOffset = 0; outer: for (int oldSummaryIndex = 0; oldSummaryIndex < existing.size(); oldSummaryIndex++) long start = existing.getPositionInSummary(oldSummaryIndex); long length = existing.getEndInSummary(oldSummaryIndex) - start; newEntries.put(newEntriesOffset, oldEntries, start, length); newEntriesOffset += length; return new IndexSummary(partitioner, newOffsets, newKeyCount, newEntries, newEntriesLength, existing.getMaxNumberOfEntries(), minIndexInterval, newSamplingLevel);
PartitionPosition rightPosition = range.right.maxKeyBound(); int left = summary.binarySearch(leftPosition); if (left < 0) left = (left + 1) * -1; if (left == summary.size()) ? summary.size() - 1 : summary.binarySearch(rightPosition); if (right < 0)
int binarySearchResult = indexSummary.binarySearch(key); long sampledPosition = getIndexScanPositionFromBinarySearchResult(binarySearchResult, indexSummary); int sampledIndex = getIndexSummaryIndexFromBinarySearchResult(binarySearchResult); int effectiveInterval = indexSummary.getEffectiveIndexIntervalAfterIndex(sampledIndex);
public void run() { if (logger.isTraceEnabled()) logger.trace("Async instance tidier for {}, before barrier", descriptor); if (barrier != null) barrier.await(); if (logger.isTraceEnabled()) logger.trace("Async instance tidier for {}, after barrier", descriptor); if (bf != null) bf.close(); if (summary != null) summary.close(); if (runOnClose != null) runOnClose.run(); if (dfile != null) dfile.close(); if (ifile != null) ifile.close(); globalRef.release(); if (logger.isTraceEnabled()) logger.trace("Async instance tidier for {}, completed", descriptor); } });
public long getEndInSummary(int index) { return calculateEnd(index); }
/** * Returns the key for the index summary entry at `index`. */ public byte[] getIndexSummaryKey(int index) { return indexSummary.getKey(index); }
/** * @return An estimate of the number of keys in this SSTable based on the index summary. */ public long estimatedKeys() { return indexSummary.getEstimatedKeyCount(); }