Search in sources :

Example 1 with EntryIterator

use of com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator in project hugegraph-computer by hugegraph.

the class SorterImpl method sortBuffers.

private void sortBuffers(List<EntryIterator> entries, OuterSortFlusher flusher, String output) throws IOException {
    InputsSorter sorter = new InputsSorterImpl();
    try (HgkvDirBuilder builder = new HgkvDirBuilderImpl(this.config, output)) {
        EntryIterator result = sorter.sort(entries);
        flusher.flush(result, builder);
    }
}
Also used : HgkvDirBuilder(com.baidu.hugegraph.computer.core.store.hgkvfile.file.builder.HgkvDirBuilder) InputsSorterImpl(com.baidu.hugegraph.computer.core.sort.sorter.InputsSorterImpl) InputsSorter(com.baidu.hugegraph.computer.core.sort.sorter.InputsSorter) EntryIterator(com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator) HgkvDirBuilderImpl(com.baidu.hugegraph.computer.core.store.hgkvfile.file.builder.HgkvDirBuilderImpl)

Example 2 with EntryIterator

use of com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator in project hugegraph-computer by hugegraph.

the class SorterImpl method sortBuffer.

@Override
public void sortBuffer(RandomAccessInput input, InnerSortFlusher flusher, boolean withSubKv) throws Exception {
    try (EntryIterator entries = new KvEntriesInput(input, withSubKv)) {
        InputSorter sorter = new JavaInputSorter();
        flusher.flush(sorter.sort(entries));
    }
}
Also used : JavaInputSorter(com.baidu.hugegraph.computer.core.sort.sorter.JavaInputSorter) InputSorter(com.baidu.hugegraph.computer.core.sort.sorter.InputSorter) JavaInputSorter(com.baidu.hugegraph.computer.core.sort.sorter.JavaInputSorter) KvEntriesInput(com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.KvEntriesInput) EntryIterator(com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator)

Example 3 with EntryIterator

use of com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator in project hugegraph-computer by hugegraph.

the class HgkvDirMergerImpl method mergeInputs.

private void mergeInputs(List<String> inputs, InputToEntries inputToEntries, OuterSortFlusher flusher, String output) throws Exception {
    /*
         * File value format is different, upper layer is required to
         * provide the file reading mode
         */
    List<EntryIterator> entries = inputs.stream().map(inputToEntries::inputToEntries).collect(Collectors.toList());
    InputsSorter sorter = new InputsSorterImpl();
    // Merge inputs and write to output
    try (EntryIterator sortedKv = sorter.sort(entries);
        HgkvDirBuilder builder = new HgkvDirBuilderImpl(this.config, output)) {
        flusher.flush(sortedKv, builder);
    }
}
Also used : HgkvDirBuilder(com.baidu.hugegraph.computer.core.store.hgkvfile.file.builder.HgkvDirBuilder) InputsSorterImpl(com.baidu.hugegraph.computer.core.sort.sorter.InputsSorterImpl) EntryIterator(com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator) InputsSorter(com.baidu.hugegraph.computer.core.sort.sorter.InputsSorter) HgkvDirBuilderImpl(com.baidu.hugegraph.computer.core.store.hgkvfile.file.builder.HgkvDirBuilderImpl)

Example 4 with EntryIterator

use of com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator in project hugegraph-computer by hugegraph.

the class SorterImpl method iterator.

@Override
public PeekableIterator<KvEntry> iterator(List<String> inputs, boolean withSubKv) throws IOException {
    InputsSorterImpl sorter = new InputsSorterImpl();
    List<EntryIterator> entries = new ArrayList<>();
    for (String input : inputs) {
        HgkvDirReader reader = new HgkvDirReaderImpl(input, false, withSubKv);
        entries.add(reader.iterator());
    }
    return PeekableIteratorAdaptor.of(sorter.sort(entries));
}
Also used : HgkvDirReaderImpl(com.baidu.hugegraph.computer.core.store.hgkvfile.file.reader.HgkvDirReaderImpl) InputsSorterImpl(com.baidu.hugegraph.computer.core.sort.sorter.InputsSorterImpl) ArrayList(java.util.ArrayList) EntryIterator(com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator) HgkvDirReader(com.baidu.hugegraph.computer.core.store.hgkvfile.file.reader.HgkvDirReader)

Aggregations

EntryIterator (com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.EntryIterator)4 InputsSorterImpl (com.baidu.hugegraph.computer.core.sort.sorter.InputsSorterImpl)3 InputsSorter (com.baidu.hugegraph.computer.core.sort.sorter.InputsSorter)2 HgkvDirBuilder (com.baidu.hugegraph.computer.core.store.hgkvfile.file.builder.HgkvDirBuilder)2 HgkvDirBuilderImpl (com.baidu.hugegraph.computer.core.store.hgkvfile.file.builder.HgkvDirBuilderImpl)2 InputSorter (com.baidu.hugegraph.computer.core.sort.sorter.InputSorter)1 JavaInputSorter (com.baidu.hugegraph.computer.core.sort.sorter.JavaInputSorter)1 KvEntriesInput (com.baidu.hugegraph.computer.core.store.hgkvfile.buffer.KvEntriesInput)1 HgkvDirReader (com.baidu.hugegraph.computer.core.store.hgkvfile.file.reader.HgkvDirReader)1 HgkvDirReaderImpl (com.baidu.hugegraph.computer.core.store.hgkvfile.file.reader.HgkvDirReaderImpl)1 ArrayList (java.util.ArrayList)1