当前位置: 首页>>代码示例>>Java>>正文


Java WritableUtils类代码示例

本文整理汇总了Java中org.apache.giraph.utils.WritableUtils的典型用法代码示例。如果您正苦于以下问题:Java WritableUtils类的具体用法?Java WritableUtils怎么用?Java WritableUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WritableUtils类属于org.apache.giraph.utils包,在下文中一共展示了WritableUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@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();
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:17,代码来源:ByteArrayEdges.java

示例2: readFields

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Override
public void readFields(DataInput input) throws IOException {
  super.readFields(input);
  if (USE_OUT_OF_CORE_MESSAGES.get(getConf())) {
    vertexMap = new ConcurrentSkipListMap<I, Vertex<I, V, E>>();
  } else {
    vertexMap = Maps.newConcurrentMap();
  }
  int vertices = input.readInt();
  for (int i = 0; i < vertices; ++i) {
    progress();
    Vertex<I, V, E> vertex =
        WritableUtils.readVertexFromDataInput(input, getConf());
    if (vertexMap.put(vertex.getId(), vertex) != null) {
      throw new IllegalStateException(
          "readFields: " + this +
          " already has same id " + vertex);
    }
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:SimplePartition.java

示例3: readFields

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Override
public void readFields(DataInput input) throws IOException {
  addedVertexList.clear();
  addedEdgeList.clear();
  removedEdgeList.clear();

  int addedVertexListSize = input.readInt();
  for (int i = 0; i < addedVertexListSize; ++i) {
    Vertex<I, V, E> vertex =
        WritableUtils.readVertexFromDataInput(input, getConf());
    addedVertexList.add(vertex);
  }
  removedVertexCount = input.readInt();
  int addedEdgeListSize = input.readInt();
  for (int i = 0; i < addedEdgeListSize; ++i) {
    Edge<I, E> edge = conf.createEdge();
    WritableUtils.readEdge(input, edge);
    addedEdgeList.add(edge);
  }
  int removedEdgeListSize = input.readInt();
  for (int i = 0; i < removedEdgeListSize; ++i) {
    I removedEdge = conf.createVertexId();
    removedEdge.readFields(input);
    removedEdgeList.add(removedEdge);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:27,代码来源:VertexMutations.java

示例4: 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);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:18,代码来源:VertexMutations.java

示例5: testVectorSerialize

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Test
public void testVectorSerialize() throws Exception {
  int size = 100;

  // Serialize from
  IntVector from = new IntVector(size);
  from.set(0, 10);
  from.set(10, 5);
  from.set(12, 1);
  byte[] data = WritableUtils.writeToByteArray(from);

  // De-serialize to
  IntVector to = new IntVector();
  WritableUtils.readFieldsFromByteArray(data, to);

  // The vectors should be equal
  for (int i = 0; i < size; ++i) {
    assertEquals(from.get(i), to.get(i));
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:TestIntMatrix.java

示例6: testVectorSerialize

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Test
public void testVectorSerialize() throws Exception {
  int size = 100;

  // Serialize from
  FloatVector from = new FloatVector(size);
  from.set(0, 10.0f);
  from.set(10, 5.0f);
  from.set(12, 1.0f);
  byte[] data = WritableUtils.writeToByteArray(from);

  // De-serialize to
  FloatVector to = new FloatVector();
  WritableUtils.readFieldsFromByteArray(data, to);

  // The vectors should be equal
  for (int i = 0; i < size; ++i) {
    assertEquals(from.get(i), to.get(i), E);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:TestFloatMatrix.java

示例7: testVectorSerialize

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Test
public void testVectorSerialize() throws Exception {
  int size = 100;

  // Serialize from
  DoubleVector from = new DoubleVector(size);
  from.set(0, 10.0);
  from.set(10, 5.0);
  from.set(12, 1.0);
  byte[] data = WritableUtils.writeToByteArray(from);

  // De-serialize to
  DoubleVector to = new DoubleVector();
  WritableUtils.readFieldsFromByteArray(data, to);

  // The vectors should be equal
  for (int i = 0; i < size; ++i) {
    assertEquals(from.get(i), to.get(i), E);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:TestDoubleMatrix.java

示例8: testVectorSerialize

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Test
public void testVectorSerialize() throws Exception {
  int size = 100;

  // Serialize from
  LongVector from = new LongVector(size);
  from.set(0, 10);
  from.set(10, 5);
  from.set(12, 1);
  byte[] data = WritableUtils.writeToByteArray(from);

  // De-serialize to
  LongVector to = new LongVector();
  WritableUtils.readFieldsFromByteArray(data, to);

  // The vectors should be equal
  for (int i = 0; i < size; ++i) {
    assertEquals(from.get(i), to.get(i));
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:TestLongMatrix.java

示例9: readFields

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Override
public void readFields(DataInput input) throws IOException {
  super.readFields(input);
  if (USE_OUT_OF_CORE_MESSAGES.get(getConf())) {
    vertexMap = new ConcurrentSkipListMap<I, Vertex<I, V, E, M>>();
  } else {
    vertexMap = Maps.newConcurrentMap();
  }
  int vertices = input.readInt();
  for (int i = 0; i < vertices; ++i) {
    progress();
    Vertex<I, V, E, M> vertex =
        WritableUtils.readVertexFromDataInput(input, getConf());
    if (vertexMap.put(vertex.getId(), vertex) != null) {
      throw new IllegalStateException(
          "readFields: " + this +
          " already has same id " + vertex);
    }
  }
}
 
开发者ID:zfighter,项目名称:giraph-research,代码行数:21,代码来源:SimplePartition.java

示例10: readFields

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Override
public void readFields(DataInput input) throws IOException {
  addedVertexList.clear();
  addedEdgeList.clear();
  removedEdgeList.clear();

  int addedVertexListSize = input.readInt();
  for (int i = 0; i < addedVertexListSize; ++i) {
    Vertex<I, V, E, M> vertex =
        WritableUtils.readVertexFromDataInput(input, getConf());
    addedVertexList.add(vertex);
  }
  removedVertexCount = input.readInt();
  int addedEdgeListSize = input.readInt();
  for (int i = 0; i < addedEdgeListSize; ++i) {
    Edge<I, E> edge = conf.createEdge();
    WritableUtils.readEdge(input, edge);
    addedEdgeList.add(edge);
  }
  int removedEdgeListSize = input.readInt();
  for (int i = 0; i < removedEdgeListSize; ++i) {
    I removedEdge = conf.createVertexId();
    removedEdge.readFields(input);
    removedEdgeList.add(removedEdge);
  }
}
 
开发者ID:zfighter,项目名称:giraph-research,代码行数:27,代码来源:VertexMutations.java

示例11: 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);
  }
}
 
开发者ID:zfighter,项目名称:giraph-research,代码行数:18,代码来源:VertexMutations.java

示例12: add

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@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;
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:16,代码来源:ByteArrayEdges.java

示例13: next

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@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;
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:11,代码来源:ByteArrayEdges.java

示例14: readFields

import org.apache.giraph.utils.WritableUtils; //导入依赖的package包/类
@Override
public void readFields(DataInput in) throws IOException {
  int numEdges = in.readInt();
  initialize(numEdges);
  for (int i = 0; i < numEdges; ++i) {
    Edge<I, E> edge = getConf().createEdge();
    WritableUtils.readEdge(in, edge);
    edgeList.add(edge);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:11,代码来源:ArrayListEdges.java

示例15: 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());
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:10,代码来源:SimplePartition.java


注:本文中的org.apache.giraph.utils.WritableUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。