本文整理汇总了Java中org.apache.giraph.utils.WritableUtils.writeVertexToDataOutput方法的典型用法代码示例。如果您正苦于以下问题:Java WritableUtils.writeVertexToDataOutput方法的具体用法?Java WritableUtils.writeVertexToDataOutput怎么用?Java WritableUtils.writeVertexToDataOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.giraph.utils.WritableUtils
的用法示例。
在下文中一共展示了WritableUtils.writeVertexToDataOutput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public void write(DataOutput output) throws IOException {
output.writeInt(addedVertexList.size());
for (Vertex<I, V, E> vertex : addedVertexList) {
WritableUtils.writeVertexToDataOutput(output, vertex, getConf());
}
output.writeInt(removedVertexCount);
output.writeInt(addedEdgeList.size());
for (Edge<I, E> edge : addedEdgeList) {
edge.getTargetVertexId().write(output);
edge.getValue().write(output);
}
output.writeInt(removedEdgeList.size());
for (I removedEdge : removedEdgeList) {
removedEdge.write(output);
}
}
示例2: write
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public void write(DataOutput output) throws IOException {
output.writeInt(addedVertexList.size());
for (Vertex<I, V, E, M> vertex : addedVertexList) {
WritableUtils.writeVertexToDataOutput(output, vertex, getConf());
}
output.writeInt(removedVertexCount);
output.writeInt(addedEdgeList.size());
for (Edge<I, E> edge : addedEdgeList) {
edge.getTargetVertexId().write(output);
edge.getValue().write(output);
}
output.writeInt(removedEdgeList.size());
for (I removedEdge : removedEdgeList) {
removedEdge.write(output);
}
}
示例3: write
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public void write(DataOutput output) throws IOException {
super.write(output);
output.writeInt(vertexMap.size());
for (Vertex<I, V, E> vertex : vertexMap.values()) {
progress();
WritableUtils.writeVertexToDataOutput(output, vertex, getConf());
}
}
示例4: write
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public void write(DataOutput output) throws IOException {
super.write(output);
output.writeInt(vertexMap.size());
for (Vertex<I, V, E, M> vertex : vertexMap.values()) {
progress();
WritableUtils.writeVertexToDataOutput(output, vertex, getConf());
}
}
示例5: testDynamicChannelBufferSerializeOutEdgesClass
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
private void testDynamicChannelBufferSerializeOutEdgesClass(
Class<? extends OutEdges> edgesClass)
throws IOException {
Vertex<LongWritable, FloatWritable, DoubleWritable> 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>
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());
assertTrue(EdgeIterables.sameEdges(vertex.getEdges(), readVertex.getEdges()));
}
示例6: testDynamicChannelBufferSerializeOutEdgesClass
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
private void testDynamicChannelBufferSerializeOutEdgesClass(
Class<? extends OutEdges> edgesClass)
throws IOException {
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());
assertTrue(EdgeIterables.sameEdges(vertex.getEdges(), readVertex.getEdges()));
}