本文整理汇总了Java中org.apache.giraph.utils.WritableUtils.reinitializeVertexFromByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java WritableUtils.reinitializeVertexFromByteArray方法的具体用法?Java WritableUtils.reinitializeVertexFromByteArray怎么用?Java WritableUtils.reinitializeVertexFromByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.giraph.utils.WritableUtils
的用法示例。
在下文中一共展示了WritableUtils.reinitializeVertexFromByteArray方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVertex
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public Vertex<I, V, E> getVertex(I vertexIndex) {
byte[] vertexData = vertexMap.get(vertexIndex);
if (vertexData == null) {
return null;
}
WritableUtils.reinitializeVertexFromByteArray(
vertexData, representativeVertex, useUnsafeSerialization, getConf());
return representativeVertex;
}
示例2: putVertex
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public Vertex<I, V, E> putVertex(Vertex<I, V, E> vertex) {
byte[] vertexData =
WritableUtils.writeVertexToByteArray(
vertex, useUnsafeSerialization, getConf());
byte[] oldVertexBytes = vertexMap.put(vertex.getId(), vertexData);
if (oldVertexBytes == null) {
return null;
} else {
WritableUtils.reinitializeVertexFromByteArray(oldVertexBytes,
representativeVertex, useUnsafeSerialization, getConf());
return representativeVertex;
}
}
示例3: removeVertex
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public Vertex<I, V, E> removeVertex(I vertexIndex) {
byte[] vertexBytes = vertexMap.remove(vertexIndex);
if (vertexBytes == null) {
return null;
}
WritableUtils.reinitializeVertexFromByteArray(vertexBytes,
representativeVertex, useUnsafeSerialization, getConf());
return representativeVertex;
}
示例4: getEdgeCount
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public long getEdgeCount() {
long edges = 0;
for (byte[] vertexBytes : vertexMap.values()) {
WritableUtils.reinitializeVertexFromByteArray(vertexBytes,
representativeVertex, useUnsafeSerialization, getConf());
edges += representativeVertex.getNumEdges();
}
return edges;
}
示例5: removeVertex
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public Vertex<I, V, E, M> removeVertex(I vertexIndex) {
byte[] vertexBytes = vertexMap.remove(vertexIndex);
if (vertexBytes == null) {
return null;
}
WritableUtils.reinitializeVertexFromByteArray(vertexBytes,
representativeVertex, useUnsafeSerialization, getConf());
return representativeVertex;
}
示例6: next
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public Vertex<I, V, E, M> next() {
WritableUtils.reinitializeVertexFromByteArray(
vertexDataIterator.next(), representativeVertex,
useUnsafeSerialization, getConf());
return representativeVertex;
}
示例7: getVertex
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public Vertex<I, V, E, M> getVertex(I vertexIndex) {
byte[] vertexData = vertexMap.get(vertexIndex);
if (vertexData == null) {
return null;
}
WritableUtils.reinitializeVertexFromByteArray(
vertexData, representativeVertex, useUnsafeSerialization, getConf());
return representativeVertex;
}
示例8: putVertex
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Override
public Vertex<I, V, E, M> putVertex(Vertex<I, V, E, M> vertex) {
byte[] vertexData =
WritableUtils.writeVertexToByteArray(
vertex, useUnsafeSerialization, getConf());
byte[] oldVertexBytes = vertexMap.put(vertex.getId(), vertexData);
if (oldVertexBytes == null) {
return null;
} else {
WritableUtils.reinitializeVertexFromByteArray(oldVertexBytes,
representativeVertex, useUnsafeSerialization, getConf());
return representativeVertex;
}
}
示例9: testSerializeOutEdgesClass
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
private void testSerializeOutEdgesClass(
Class<? extends OutEdges> edgesClass) {
Vertex<LongWritable, FloatWritable, DoubleWritable, LongWritable> vertex =
buildVertex(edgesClass);
long serializeNanosStart;
long serializeNanos = 0;
byte[] byteArray = null;
for (int i = 0; i < REPS; ++i) {
serializeNanosStart = SystemTime.get().getNanoseconds();
byteArray = WritableUtils.writeVertexToByteArray(
vertex, false, vertex.getConf());
serializeNanos += Times.getNanosecondsSince(SystemTime.get(),
serializeNanosStart);
}
serializeNanos /= REPS;
System.out.println("testSerialize: Serializing took " +
serializeNanos + " ns for " + byteArray.length + " bytes " +
(byteArray.length * 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();
WritableUtils.reinitializeVertexFromByteArray(byteArray, readVertex, false,
readVertex.getConf());
deserializeNanos += Times.getNanosecondsSince(SystemTime.get(),
deserializeNanosStart);
}
deserializeNanos /= REPS;
System.out.println("testSerialize: Deserializing took " +
deserializeNanos + " ns for " + byteArray.length + " bytes " +
(byteArray.length * 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()));
}