use of com.baidu.hugegraph.computer.core.common.exception.ComputerException in project hugegraph-computer by hugegraph.
the class EdgesInput method edges.
public Edges edges(ReusablePointer vidPointer) {
try {
while (this.input.available() > 0) {
long startPosition = this.input.position();
this.idPointer.read(this.input);
int status = vidPointer.compareTo(this.idPointer);
if (status < 0) {
// No edges
/*
* The current batch belong to vertex that vertex id is
* bigger than specified id.
*/
this.input.seek(startPosition);
return EmptyEdges.instance();
} else if (status == 0) {
// Has edges
this.valuePointer.read(this.input);
Edges edges = this.readEdges(this.valuePointer.input());
if (edges.size() < this.flushThreshold) {
return edges;
} else {
return new SuperEdges(vidPointer, edges, startPosition);
}
} else {
/*
* The current batch belong to vertex that vertex id is
* smaller than specified id.
*/
int valueLength = this.input.readFixedInt();
this.input.skip(valueLength);
}
}
return EmptyEdges.instance();
} catch (IOException e) {
throw new ComputerException("Can't read from edges input '%s'", e, this.edgeFile.getAbsoluteFile());
}
}
use of com.baidu.hugegraph.computer.core.common.exception.ComputerException in project hugegraph-computer by hugegraph.
the class VertexInput method next.
public Vertex next() {
this.readCount++;
try {
this.idPointer.read(this.input);
this.valuePointer.read(this.input);
RandomAccessInput valueInput = this.valuePointer.input();
this.vertex.label(StreamGraphInput.readLabel(valueInput));
this.properties.read(valueInput);
this.vertex.id(StreamGraphInput.readId(this.idPointer.input()));
this.vertex.properties(this.properties);
} catch (IOException e) {
throw new ComputerException("Can't read vertex from input '%s'", e, this.vertexFile.getAbsolutePath());
}
return this.vertex;
}
use of com.baidu.hugegraph.computer.core.common.exception.ComputerException 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.common.exception.ComputerException in project hugegraph-computer by hugegraph.
the class BytesId method of.
public static BytesId of(UUID value) {
E.checkArgument(value != null, "The value can't be null");
long high = value.getMostSignificantBits();
long low = value.getLeastSignificantBits();
BytesOutput output = IOFactory.createBytesOutput(16);
try {
output.writeLong(high);
output.writeLong(low);
} catch (IOException e) {
throw new ComputerException("Failed to write UUID object to " + "BytesId");
}
return new BytesId(IdType.UUID, output.buffer(), output.position());
}
use of com.baidu.hugegraph.computer.core.common.exception.ComputerException in project hugegraph-computer by hugegraph.
the class AbstractPointerCombiner method combine.
public Pointer combine(Pointer v1, Pointer v2) {
try {
RandomAccessInput input1 = v1.input();
RandomAccessInput input2 = v2.input();
input1.seek(v1.offset());
input2.seek(v2.offset());
this.v1.read(input1);
this.v2.read(input2);
this.combiner.combine(this.v1, this.v2, this.result);
this.output.seek(0L);
this.result.write(this.output);
return new InlinePointer(this.output.buffer(), this.output.position());
} catch (Exception e) {
throw new ComputerException("Failed to combine pointer1(offset=%s, length=%s) and " + "pointer2(offset=%s, length=%s)'", e, v1.offset(), v1.length(), v2.offset(), v2.length());
}
}
Aggregations