Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable> vertex =
buildVertex(edgesClass);
long serializeNanosStart;
long serializeNanos = 0;
DynamicChannelBufferOutputStream outputStream = null;
for (int i = 0; i <
REPS; ++i) {
serializeNanosStart = SystemTime.get().getNanoseconds();
outputStream =
new DynamicChannelBufferOutputStream(32);
WritableUtils.writeVertexToDataOutput(outputStream, vertex, vertex.getConf());
serializeNanos += Times.getNanosecondsSince(SystemTime.get(),
serializeNanosStart);
}
serializeNanos /= REPS;
System.out.println("testDynamicChannelBufferSerializeOutEdgesClass: " +
"Serializing took " + serializeNanos + " ns for " +
outputStream.getDynamicChannelBuffer().writerIndex() + " bytes " +
(outputStream.getDynamicChannelBuffer().writerIndex() * 1f *
Time.NS_PER_SECOND / serializeNanos) +
" bytes / sec for " + edgesClass.getName());
Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable>
readVertex = buildVertex(edgesClass);
long deserializeNanosStart;
long deserializeNanos = 0;
for (int i = 0; i < REPS; ++i) {
deserializeNanosStart = SystemTime.get().getNanoseconds();
DynamicChannelBufferInputStream inputStream = new
DynamicChannelBufferInputStream(
outputStream.getDynamicChannelBuffer());
WritableUtils.reinitializeVertexFromDataInput(
inputStream, readVertex, readVertex.getConf());
deserializeNanos += Times.getNanosecondsSince(SystemTime.get(),
deserializeNanosStart);
outputStream.getDynamicChannelBuffer().readerIndex(0);
}
deserializeNanos /= REPS;
System.out.println("testDynamicChannelBufferSerializeOutEdgesClass: " +
"Deserializing took " + deserializeNanos + " ns for " +
outputStream.getDynamicChannelBuffer().writerIndex() + " bytes " +
(outputStream.getDynamicChannelBuffer().writerIndex() * 1f *
Time.NS_PER_SECOND / deserializeNanos) +
" bytes / sec for " + edgesClass.getName());
assertEquals(vertex.getId(), readVertex.getId());
assertEquals(vertex.getValue(), readVertex.getValue());