use of com.baidu.hugegraph.computer.core.io.BytesInput in project hugegraph-computer by hugegraph.
the class BytesId method asObject.
@Override
public Object asObject() {
switch(this.idType) {
case LONG:
BytesInput input = IOFactory.createBytesInput(this.bytes, 0, this.length);
try {
return input.readLong();
} catch (IOException e) {
throw new ComputerException("Failed to read BytesId to " + "Long object");
}
case UTF8:
return CoderUtil.decode(this.bytes, 0, this.length);
case UUID:
input = IOFactory.createBytesInput(this.bytes, 0, this.length);
try {
long high = input.readLong();
long low = input.readLong();
return new UUID(high, low);
} catch (IOException e) {
throw new ComputerException("Failed to read BytesId to " + "UUID object");
}
default:
throw new ComputerException("Unexpected IdType %s", this.idType);
}
}
use of com.baidu.hugegraph.computer.core.io.BytesInput in project hugegraph-computer by hugegraph.
the class EntriesUtil method kvEntryWithFirstSubKv.
public static KvEntryWithFirstSubKv kvEntryWithFirstSubKv(KvEntry entry) {
try {
BytesInput input = IOFactory.createBytesInput(entry.value().bytes());
// Read sub-entry size
long subKvNum = input.readFixedInt();
KvEntry firstSubKv = EntriesUtil.subKvEntryFromInput(input, true);
return new KvEntryWithFirstSubKv(entry.key(), entry.value(), firstSubKv, subKvNum);
} catch (IOException e) {
throw new ComputerException(e.getMessage(), e);
}
}
Aggregations