Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-11238 - indexing-job: de-duplicate entries when writing to disk the intermediate sorted files with FFS contents. #1835

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Locale;
import java.util.concurrent.BlockingQueue;
Expand Down Expand Up @@ -195,9 +196,16 @@ private void sortAndSaveBatch(NodeStateEntryBatch nseb) throws Exception {
Path newtmpfile = Files.createTempFile(sortWorkDir, "sortInBatch", "flatfile");
long textSize = 0;
batchesProcessed++;
String[] prevPathElements = null;
int duplicateEntriesSkippped = 0;
try (OutputStream os = IndexStoreUtils.createOutputStream(newtmpfile, algorithm)) {
for (SortKey entry : sortBuffer) {
entriesProcessed++;
if (Arrays.equals(prevPathElements, entry.getPathElements())) {
duplicateEntriesSkippped++;
continue;
}
prevPathElements = entry.getPathElements();
// Retrieve the entry from the buffer
int posInBuffer = entry.getBufferPos();
buffer.position(posInBuffer);
Expand All @@ -213,11 +221,13 @@ private void sortAndSaveBatch(NodeStateEntryBatch nseb) throws Exception {
}
timeWritingMillis += saveClock.elapsed().toMillis();
long compressedSize = Files.size(newtmpfile);
LOG.info("Wrote batch of size {} (uncompressed {}) with {} entries in {} at {}",
int entriesWritten = sortBuffer.size() - duplicateEntriesSkippped;
LOG.info("Wrote batch of size {} (uncompressed {}) with {} entries in {} at {}. Duplicate entries skipped: {}",
humanReadableByteCountBin(compressedSize),
humanReadableByteCountBin(textSize),
sortBuffer.size(), saveClock,
PipelinedUtils.formatAsTransferSpeedMBs(compressedSize, saveClock.elapsed().toMillis())
entriesWritten, saveClock,
PipelinedUtils.formatAsTransferSpeedMBs(compressedSize, saveClock.elapsed().toMillis()),
duplicateEntriesSkippped
);
// Free the memory taken by the entries in the buffer
sortBuffer.clear();
Expand Down
Loading