@Override public Edge<I, E> next() { try { WritableUtils.readEdge(extendedDataInput, representativeEdge); } catch (IOException e) { throw new IllegalStateException( "next: Failed on pos " + extendedDataInput.getPos() + " edge " + representativeEdge); } return representativeEdge; }
@Override public void add(Edge<I, E> edge) { ExtendedDataOutput extendedDataOutput = getConf().createExtendedDataOutput(serializedEdges, serializedEdgesBytesUsed); try { WritableUtils.writeEdge(extendedDataOutput, edge); } catch (IOException e) { throw new IllegalStateException("add: Failed to write to the new " + "byte array"); } serializedEdges = extendedDataOutput.getByteArray(); serializedEdgesBytesUsed = extendedDataOutput.getPos(); ++edgeCount; }
@Override public void initialize(Iterable<Edge<I, E>> edges) { ExtendedDataOutput extendedOutputStream = getConf().createExtendedDataOutput(); for (Edge<I, E> edge : edges) { try { WritableUtils.writeEdge(extendedOutputStream, edge); } catch (IOException e) { throw new IllegalStateException("initialize: Failed to serialize " + edge); } ++edgeCount; } serializedEdges = extendedOutputStream.getByteArray(); serializedEdgesBytesUsed = extendedOutputStream.getPos(); }
@Override public void readFields(DataInput input) throws IOException { computationClass = WritableUtils.readClass(input); incomingMessageClasses = WritableUtils.readWritableObject(input, conf); outgoingMessageClasses = WritableUtils.readWritableObject(input, conf); }
@Override public void write(DataOutput output) throws IOException { WritableUtils.writeClass(computationClass, output); WritableUtils.writeWritableObject(incomingMessageClasses, output); WritableUtils.writeWritableObject(outgoingMessageClasses, output); }