Example #1
0
    @Override
    public Vertex<VLongWritable, DoubleWritable, FloatWritable, DoubleWritable> getCurrentVertex()
        throws IOException {
      Vertex<VLongWritable, DoubleWritable, FloatWritable, DoubleWritable> vertex =
          BspUtils.createVertex(configuration);

      VLongWritable vertexId =
          new VLongWritable(inputSplit.getSplitIndex() * totalRecords + recordsRead);
      DoubleWritable vertexValue = new DoubleWritable(vertexId.get() * 10d);
      long destVertexId = (vertexId.get() + 1) % (inputSplit.getNumSplits() * totalRecords);
      float edgeValue = vertexId.get() * 100f;
      edges.put(new VLongWritable(destVertexId), new FloatWritable(edgeValue));
      vertex.initialize(vertexId, vertexValue, edges, null);
      ++recordsRead;
      if (LOG.getLevel() == Level.FINE) {
        LOG.fine(
            "next: Return vertexId="
                + vertex.getVertexId().get()
                + ", vertexValue="
                + vertex.getVertexValue()
                + ", destinationId="
                + destVertexId
                + ", edgeValue="
                + edgeValue);
      }
      return vertex;
    }
  @SuppressWarnings("unchecked")
  @Override
  public Vertex<VLongWritable, VLongWritable, FloatWritable, VLongWritable> getCurrentVertex()
      throws IOException, InterruptedException {
    used = 0;
    if (vertex == null) vertex = (Vertex) BspUtils.createVertex(getContext().getConfiguration());
    vertex.getMsgList().clear();
    vertex.getEdges().clear();

    vertex.reset();
    Text line = getRecordReader().getCurrentValue();
    String[] fields = line.toString().split(separator);

    if (fields.length > 0) {
      /** set the src vertex id */
      long src = Long.parseLong(fields[0]);
      vertexId.set(src);
      vertex.setVertexId(vertexId);
      long dest = -1L;

      /** set up edges */
      for (int i = 1; i < fields.length; i++) {
        dest = Long.parseLong(fields[i]);
        VLongWritable destId = allocate();
        destId.set(dest);
        vertex.addEdge(destId, null);
      }
    }
    // vertex.sortEdges();
    return vertex;
  }
  public AggregationEvaluator(
      IHyracksTaskContext ctx,
      IConfigurationFactory confFactory,
      boolean isFinalStage,
      boolean partialAggAsInput)
      throws HyracksDataException {
    this.conf = confFactory.createConfiguration(ctx);
    this.isFinalStage = isFinalStage;
    this.partialAggAsInput = partialAggAsInput;
    msgList.setConf(this.conf);

    combiner = BspUtils.createMessageCombiner(conf);
    key = BspUtils.createVertexIndex(conf);
    value =
        !partialAggAsInput
            ? BspUtils.createMessageValue(conf)
            : BspUtils.createPartialCombineValue(conf);
    skipKey = BspUtils.getSkipCombinerKey(conf);
  }
  @SuppressWarnings("unchecked")
  @Override
  public Vertex<VLongWritable, Text, FloatWritable, DoubleWritable> getCurrentVertex()
      throws IOException, InterruptedException {
    if (vertex == null) {
      vertex = BspUtils.createVertex(getContext().getConfiguration());
    }
    vertex.getMsgList().clear();
    vertex.getEdges().clear();

    vertex.reset();

    /** set the src vertex id */
    vertexId.set(currentId++);
    vertex.setVertexId(vertexId);

    /** set the vertex value */
    vertex.setVertexValue(new Text("aaa"));
    return vertex;
  }