Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.FloatWritable$Comparator


                Map<LongWritable, FloatWritable> edges = Maps.newHashMap();
                JSONArray jsonEdgeArray = jsonVertex.getJSONArray(2);
                for (int i = 0; i < jsonEdgeArray.length(); ++i) {
                    JSONArray jsonEdge = jsonEdgeArray.getJSONArray(i);
                    edges.put(new LongWritable(jsonEdge.getLong(0)),
                            new FloatWritable((float) jsonEdge.getDouble(1)));
                }
                vertex.initialize(vertexId, vertexValue, edges, null);
            } catch (JSONException e) {
                throw new IllegalArgumentException(
                    "next: Couldn't get vertex from line " + line, e);
View Full Code Here


                LOG.debug("compute: vertex " + getVertexId() +
                          " has value " + getVertexValue() +
                          " on superstep " + getSuperstep());
            }
            for (LongWritable targetVertexId : this) {
                FloatWritable edgeValue = getEdgeValue(targetVertexId);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("compute: vertex " + getVertexId() +
                              " sending edgeValue " + edgeValue +
                              " vertexValue " + vertexValue +
                              " total " +
                              (edgeValue.get() + (float) vertexValue) +
                              " to vertex " + targetVertexId +
                              " on superstep " + getSuperstep());
                }
                edgeValue.set(edgeValue.get() + (float) vertexValue);
                addEdge(targetVertexId, edgeValue);
                sendMsg(targetVertexId,
                    new VerifiableMessage(
                        getSuperstep(), getVertexId().get(), edgeValue.get()));
            }
        }
View Full Code Here

            long destVertexId =
                (vertexId.get() + 1) %
                    (inputSplit.getNumSplits() * totalRecords);
            float edgeValue = vertexId.get() * 100f;
            edgeMap.put(new LongWritable(destVertexId),
                        new FloatWritable(edgeValue));
            vertex.initialize(vertexId, vertexValue, edgeMap, null);
            ++recordsRead;
            if (LOG.isInfoEnabled()) {
                LOG.info("next: Return vertexId=" + vertex.getVertexId().get() +
                         ", vertexValue=" + vertex.getVertexValue() +
View Full Code Here

        setVertexValue(new IntWritable(vertexValue + (int) msgValue));
        System.out.println("compute: vertex " + getVertexId() +
                           " has value " + getVertexValue() +
                           " on superstep " + getSuperstep());
        for (LongWritable targetVertexId : this) {
            FloatWritable edgeValue = getEdgeValue(targetVertexId);
            System.out.println("compute: vertex " + getVertexId() +
                               " sending edgeValue " + edgeValue +
                               " vertexValue " + vertexValue +
                               " total " + (edgeValue.get() +
                               (float) vertexValue) +
                               " to vertex " + targetVertexId +
                               " on superstep " + getSuperstep());
            edgeValue.set(edgeValue.get() + (float) vertexValue);
            addEdge(targetVertexId, edgeValue);
            sendMsg(targetVertexId, new FloatWritable(edgeValue.get()));
        }
    }
View Full Code Here

    double total = 0.0;
    for (FloatWritable value : values) {
      total += value.get();
      count++;
    }
    context.write(key, new FloatWritable((float) (total / count)));
  }
View Full Code Here

      float itemAValue = first.getPrefValue();
      for (int j = i + 1; j < size; j++) {
        EntityPrefWritable second = prefs.get(j);
        long itemBID = second.getID();
        float itemBValue = second.getPrefValue();
        context.write(new EntityEntityWritable(itemAID, itemBID), new FloatWritable(itemBValue - itemAValue));
      }
    }
  }
View Full Code Here

    }

    @Override
    Object next(Object previous) throws IOException {
      super.next(previous);
      FloatWritable result = null;
      if (valuePresent) {
        if (previous == null) {
          result = new FloatWritable();
        } else {
          result = (FloatWritable) previous;
        }
        result.set(SerializationUtils.readFloat(stream));
      }
      return result;
    }
View Full Code Here

    private long topN;
    private long count = 0L;
   
    public void reduce(WritableComparable key, Iterator values, OutputCollector output, Reporter reporter) throws IOException {
      while (values.hasNext() && count < topN) {
        FloatWritable fw = (FloatWritable)key;
        fw.set(-fw.get());
        output.collect(fw, (Writable)values.next());
        count++;
      }
    }
View Full Code Here

  }

  @Test
  public void testFloats() throws Exception {
    float j = 55.5f;
    FloatWritable w = new FloatWritable(j);
    testInputOutputFn(Writables.floats(), j, w);
  }
View Full Code Here

    return ((FloatWritable)o).get();
  }

  @Override
  public Object copyObject(Object o) {
    return o == null ? null : new FloatWritable(((FloatWritable)o).get());
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.FloatWritable$Comparator

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.