@Test public void testSingleEntry() throws IOException { File inputFile = tempFolder.newFile(); try (LargeFileWriter<ObjectEntry> writer = fileWriterFactory.apply(inputFile)) { writer.writeEntry(new ObjectEntry().setObjectId("obj1").setSize(1L)); } File sortedFile = instance.sortLargeFile(inputFile); try (LargeFileReader<ObjectEntry> reader = fileReaderFactory.apply(sortedFile)) { List<ObjectEntry> objectEntries = IteratorUtils.toList(reader); assertThat(objectEntries).hasSize(1); assertThat(objectEntries.get(0).getObjectId()).isEqualTo("obj1"); assertThat(objectEntries.get(0).getSize()).isEqualTo(1L); } assertThat(tmpFileCounter).isEqualTo(1); ensureAllTempFileCleaned(inputFile, sortedFile); }
public File sortLargeFile(File inputFile) throws IOException { try (LargeFileReader<T> reader = this.fileReaderFactory.apply(inputFile)) { List<File> filesToMerge = splitIntoInitialSortedChunkFiles(reader); return mergeSortFiles(filesToMerge); } }
LargeFileSorter { public File sortLargeFile(File inputFile) throws IOException { try (LargeFileReader<T> reader = this.fileReaderFactory.apply(inputFile)) { List<File> filesToMerge = splitIntoInitialSortedChunkFiles(reader); return mergeSortFiles(filesToMerge); } } }
LargeFileSorter { public File sortLargeFile(File inputFile) throws IOException { try (LargeFileReader<T> reader = this.fileReaderFactory.apply(inputFile)) { List<File> filesToMerge = splitIntoInitialSortedChunkFiles(reader); return mergeSortFiles(filesToMerge); } } LargeFileSorter(
        Function<File, LargeFileReader<T>> fileReaderFactory,
        Function<File, LargeFileWriter<T>> fileWriterFactory,
        Comparator<T> entryComparator,
        Supplier<File> tempFileCreator); @VisibleForTesting  LargeFileSorter(
        int initialFileChunkSizeToSortInMemory, int nbFilesToMergeSort,
        Function<File, LargeFileReader<T>> fileReaderFactory,
        Function<File, LargeFileWriter<T>> fileWriterFactory,
        Comparator<T> entryComparator,
        Supplier<File> tempFileCreator); }
LargeFileSorter { public File sortLargeFile(File inputFile) throws IOException { try (LargeFileReader<T> reader = this.fileReaderFactory.apply(inputFile)) { List<File> filesToMerge = splitIntoInitialSortedChunkFiles(reader); return mergeSortFiles(filesToMerge); } } LargeFileSorter(
        Function<File, LargeFileReader<T>> fileReaderFactory,
        Function<File, LargeFileWriter<T>> fileWriterFactory,
        Comparator<T> entryComparator,
        Supplier<File> tempFileCreator); @VisibleForTesting  LargeFileSorter(
        int initialFileChunkSizeToSortInMemory, int nbFilesToMergeSort,
        Function<File, LargeFileReader<T>> fileReaderFactory,
        Function<File, LargeFileWriter<T>> fileWriterFactory,
        Comparator<T> entryComparator,
        Supplier<File> tempFileCreator); File sortLargeFile(File inputFile); }
LargeFileSorter { public File sortLargeFile(File inputFile) throws IOException { try (LargeFileReader<T> reader = this.fileReaderFactory.apply(inputFile)) { List<File> filesToMerge = splitIntoInitialSortedChunkFiles(reader); return mergeSortFiles(filesToMerge); } } LargeFileSorter(
        Function<File, LargeFileReader<T>> fileReaderFactory,
        Function<File, LargeFileWriter<T>> fileWriterFactory,
        Comparator<T> entryComparator,
        Supplier<File> tempFileCreator); @VisibleForTesting  LargeFileSorter(
        int initialFileChunkSizeToSortInMemory, int nbFilesToMergeSort,
        Function<File, LargeFileReader<T>> fileReaderFactory,
        Function<File, LargeFileWriter<T>> fileWriterFactory,
        Comparator<T> entryComparator,
        Supplier<File> tempFileCreator); File sortLargeFile(File inputFile); static final int INITIAL_FILE_CHUNK_SIZE_TO_SORT_IN_MEMORY; static final int NB_FILES_TO_MERGE_SORT; }