Package org.apache.giraph.utils.io

Examples of org.apache.giraph.utils.io.DataInputOutput


      // Dump the vertices and their messages in a sorted order
      for (Map.Entry<I, DataInputOutput> entry : messageMap.entrySet()) {
        I destinationVertexId = entry.getKey();
        destinationVertexId.write(out);
        DataInputOutput dataInputOutput = entry.getValue();
        Iterable<M> messages = new MessagesIterable<M>(
            dataInputOutput, messageValueFactory);
        int messageCount = Iterables.size(messages);
        out.writeInt(messageCount);
        if (LOG.isDebugEnabled()) {
View Full Code Here


   * @return DataInputOutput for this vertex id (created if necessary)
   */
  private DataInputOutput getDataInputOutput(
      Basic2ObjectMap<I, DataInputOutput> partitionMap,
      I vertexId) {
    DataInputOutput dataInputOutput = partitionMap.get(vertexId);
    if (dataInputOutput == null) {
      dataInputOutput = config.createMessagesInputOutput();
      partitionMap.put(vertexId, dataInputOutput);
    }
    return dataInputOutput;
View Full Code Here

      // expensive. If this type of iterator is not available, fall back to
      // deserializing/serializing the messages
      if (vertexIdMessageBytesIterator != null) {
        while (vertexIdMessageBytesIterator.hasNext()) {
          vertexIdMessageBytesIterator.next();
          DataInputOutput dataInputOutput = getDataInputOutput(
              partitionMap, vertexIdMessageBytesIterator.getCurrentVertexId());
          vertexIdMessageBytesIterator.writeCurrentMessageBytes(
              dataInputOutput.getDataOutput());
        }
      } else {
        VertexIdMessageIterator<I, M> iterator =
            messages.getVertexIdMessageIterator();
        while (iterator.hasNext()) {
          iterator.next();
          DataInputOutput dataInputOutput =
              getDataInputOutput(partitionMap, iterator.getCurrentVertexId());

          VerboseByteStructMessageWrite.verboseWriteCurrentMessage(iterator,
              dataInputOutput.getDataOutput());
        }
      }
    }
  }
View Full Code Here

    return getPartitionMap(vertexId).containsKey(vertexId);
  }

  @Override
  public Iterable<M> getVertexMessages(I vertexId) throws IOException {
    DataInputOutput dataInputOutput = getPartitionMap(vertexId).get(vertexId);
    if (dataInputOutput == null) {
      return EmptyIterable.get();
    } else {
      return new MessagesIterable<M>(dataInputOutput, messageValueFactory);
    }
View Full Code Here

   * @param vertexId Id of the vertex
   * @return DataInputOutput for this vertex id (created if necessary)
   */
  private DataInputOutput getDataInputOutput(
    Long2ObjectOpenHashMap<DataInputOutput> partitionMap, long vertexId) {
    DataInputOutput dataInputOutput = partitionMap.get(vertexId);
    if (dataInputOutput == null) {
      dataInputOutput = config.createMessagesInputOutput();
      partitionMap.put(vertexId, dataInputOutput);
    }
    return dataInputOutput;
View Full Code Here

      // expensive.  If this type of iterator is not available, fall back to
      // deserializing/serializing the messages
      if (vertexIdMessageBytesIterator != null) {
        while (vertexIdMessageBytesIterator.hasNext()) {
          vertexIdMessageBytesIterator.next();
          DataInputOutput dataInputOutput = getDataInputOutput(partitionMap,
              vertexIdMessageBytesIterator.getCurrentVertexId().get());
          vertexIdMessageBytesIterator.writeCurrentMessageBytes(
              dataInputOutput.getDataOutput());
        }
      } else {
        VertexIdMessageIterator<LongWritable, M>
            iterator = messages.getVertexIdMessageIterator();
        while (iterator.hasNext()) {
          iterator.next();
          DataInputOutput dataInputOutput =  getDataInputOutput(partitionMap,
              iterator.getCurrentVertexId().get());
          VerboseByteStructMessageWrite.verboseWriteCurrentMessage(iterator,
              dataInputOutput.getDataOutput());
        }
      }
    }
  }
View Full Code Here

  }

  @Override
  public Iterable<M> getVertexMessages(
    LongWritable vertexId) throws IOException {
    DataInputOutput dataInputOutput =
        getPartitionMap(vertexId).get(vertexId.get());
    if (dataInputOutput == null) {
      return EmptyIterable.get();
    } else {
      return new MessagesIterable<M>(dataInputOutput, messageValueFactory);
View Full Code Here

    int size = in.readInt();
    Long2ObjectOpenHashMap<DataInputOutput> partitionMap =
        new Long2ObjectOpenHashMap<DataInputOutput>(size);
    while (size-- > 0) {
      long vertexId = in.readLong();
      DataInputOutput dataInputOutput = config.createMessagesInputOutput();
      dataInputOutput.readFields(in);
      partitionMap.put(vertexId, dataInputOutput);
    }
    synchronized (map) {
      map.put(partitionId, partitionMap);
    }
View Full Code Here

TOP

Related Classes of org.apache.giraph.utils.io.DataInputOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.