Search in sources :

Example 1 with RandomAccessOutput

use of com.baidu.hugegraph.computer.core.io.RandomAccessOutput 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();
}
Also used : RandomAccessOutput(com.baidu.hugegraph.computer.core.io.RandomAccessOutput) BytesInput(com.baidu.hugegraph.computer.core.io.BytesInput) File(java.io.File)

Example 2 with RandomAccessOutput

use of com.baidu.hugegraph.computer.core.io.RandomAccessOutput 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();
}
Also used : RandomAccessOutput(com.baidu.hugegraph.computer.core.io.RandomAccessOutput) BytesInput(com.baidu.hugegraph.computer.core.io.BytesInput) File(java.io.File)

Example 3 with RandomAccessOutput

use of com.baidu.hugegraph.computer.core.io.RandomAccessOutput in project hugegraph-computer by hugegraph.

the class KvEntryWriterImpl method writeData.

private void writeData(Writable data) throws IOException {
    RandomAccessOutput output;
    if (this.needSort) {
        assert this.subKvBuffer != null;
        output = this.subKvBuffer;
    } else {
        output = this.output;
    }
    long position = output.position();
    // Write data length placeholder
    output.writeFixedInt(0);
    // Write data
    data.write(output);
    // Fill data length placeholder
    long dataLength = output.position() - position - Integer.BYTES;
    output.writeFixedInt(position, (int) dataLength);
    this.total += Integer.BYTES + dataLength;
}
Also used : RandomAccessOutput(com.baidu.hugegraph.computer.core.io.RandomAccessOutput)

Example 4 with RandomAccessOutput

use of com.baidu.hugegraph.computer.core.io.RandomAccessOutput in project hugegraph-computer by hugegraph.

the class KvEntryWriterImpl method writeData.

private void writeData(Writable data) throws IOException {
    RandomAccessOutput output;
    if (this.needSort) {
        assert this.subKvBuffer != null;
        output = this.subKvBuffer;
    } else {
        output = this.output;
    }
    long position = output.position();
    // Write data length placeholder
    output.writeFixedInt(0);
    // Write data
    data.write(output);
    // Fill data length placeholder
    long dataLength = output.position() - position - Integer.BYTES;
    output.writeFixedInt(position, (int) dataLength);
    this.total += Integer.BYTES + dataLength;
}
Also used : RandomAccessOutput(com.baidu.hugegraph.computer.core.io.RandomAccessOutput)

Aggregations

RandomAccessOutput (com.baidu.hugegraph.computer.core.io.RandomAccessOutput)4 BytesInput (com.baidu.hugegraph.computer.core.io.BytesInput)2 File (java.io.File)2