use of com.baidu.hugegraph.computer.core.io.BytesInput in project hugegraph-computer by hugegraph.
the class KvEntryWriterImpl method sortAndWriteSubKvs.
private void sortAndWriteSubKvs() throws IOException {
BytesInput input = EntriesUtil.inputFromOutput(this.subKvBuffer);
InputSorter sorter = new JavaInputSorter();
Iterator<KvEntry> subKvs = sorter.sort(new KvEntriesInput(input));
while (subKvs.hasNext()) {
KvEntry subKv = subKvs.next();
subKv.key().write(this.output);
subKv.value().write(this.output);
}
}
use of com.baidu.hugegraph.computer.core.io.BytesInput in project hugegraph-computer by hugegraph.
the class StoreTestUtil method bufferFileFromKvMap.
public static void bufferFileFromKvMap(List<Integer> map, String path) throws IOException {
RandomAccessOutput output = IOFactory.createFileOutput(new File(path));
BytesInput buffer = SorterTestUtil.inputFromKvMap(map);
output.write(buffer.readBytes((int) buffer.available()));
output.close();
}
use of com.baidu.hugegraph.computer.core.io.BytesInput in project hugegraph-computer by hugegraph.
the class StoreTestUtil method kvEntriesFromMap.
public static List<KvEntry> kvEntriesFromMap(List<Integer> map) throws IOException {
BytesOutput data = IOFactory.createBytesOutput(Constants.SMALL_BUF_SIZE);
Iterator<Integer> iterator = map.iterator();
while (iterator.hasNext()) {
// Write key length
writeData(data, iterator.next());
// Write value length
writeData(data, iterator.next());
}
BytesInput input = IOFactory.createBytesInput(data.buffer(), (int) data.position());
KvEntriesInput iter = new KvEntriesInput(input);
List<KvEntry> entries = new ArrayList<>();
while (iter.hasNext()) {
entries.add(iter.next());
}
iter.close();
return entries;
}
use of com.baidu.hugegraph.computer.core.io.BytesInput in project hugegraph-computer by hugegraph.
the class StoreTestUtil method idFromPointer.
public static Id idFromPointer(Pointer pointer) throws IOException {
BytesInput input = IOFactory.createBytesInput(pointer.bytes());
Id id = new BytesId();
id.read(input);
return id;
}
use of com.baidu.hugegraph.computer.core.io.BytesInput in project hugegraph-computer by hugegraph.
the class StoreTestUtil method bufferFileFromSubKvMap.
public static void bufferFileFromSubKvMap(List<List<Integer>> map, String path) throws IOException {
RandomAccessOutput output = IOFactory.createFileOutput(new File(path));
BytesInput buffer = SorterTestUtil.inputFromSubKvMap(map);
output.write(buffer.readBytes((int) buffer.available()));
output.close();
}
Aggregations