Example usage for org.apache.hadoop.io LongWritable get

List of usage examples for org.apache.hadoop.io LongWritable get

Introduction

In this page you can find the example usage for org.apache.hadoop.io LongWritable get.

Prototype

public long get() 

Source Link

Document

Return the value of this LongWritable.

Usage

From source file:org.apache.giraph.debugger.examples.mwm.MWMDebugConfig.java

License:Apache License

@Override
public boolean isVertexValueCorrect(LongWritable vertexId, VertexValue value) {
    return value.getMatchedID() != vertexId.get();
}

From source file:org.apache.giraph.debugger.examples.mwm.MWMDebugConfig.java

License:Apache License

@Override
public boolean isMessageCorrect(LongWritable srcId, LongWritable dstId, LongWritable message,
        long superstepNo) {
    return message.get() == srcId.get();
}

From source file:org.apache.giraph.debugger.examples.simpledebug.BuggySimpleShortestPathsComputation.java

License:Apache License

@Override
public void compute(Vertex<LongWritable, DoubleWritable, FloatWritable> vertex,
        Iterable<DoubleWritable> messages) throws IOException {
    // We do a dummy read of the aggregator below because for now we only
    // intercept an aggregator
    // if at least one vertex reads it.
    LongWritable aggregatedValue = getAggregatedValue(
            SimpleShortestPathsMaster.NV_DISTANCE_LESS_THAN_THREE_AGGREGATOR);
    if (aggregatedValue != null) {
        System.out.print("NV_DISTANCE_LESS_THAN_THREE_AGGREGATOR: " + aggregatedValue.get() + "\n");
    }//from w  ww . jav  a  2s .c o  m
    if (getSuperstep() == 0) {
        vertex.setValue(new DoubleWritable(isSource(vertex) ? 0d : Double.MAX_VALUE));
    }
    double previousValue = vertex.getValue().get();
    double minDist = previousValue;
    for (DoubleWritable message : messages) {
        minDist = Math.min(minDist, message.get());
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Vertex " + vertex.getId() + " got minDist = " + minDist + " vertex value = "
                + vertex.getValue());
    }
    if (minDist < vertex.getValue().get() || getSuperstep() == 0 && minDist == 0) {
        vertex.setValue(new DoubleWritable(minDist));
        for (Edge<LongWritable, FloatWritable> edge : vertex.getEdges()) {
            double distance = minDist + edge.getValue().get();
            if (LOG.isDebugEnabled()) {
                LOG.debug(
                        "Vertex " + vertex.getId() + " sent to " + edge.getTargetVertexId() + " = " + distance);
            }
            // INTENTIONAL BUG:Instead of sending the distance (i.e. by adding edge
            // values),
            // we send minDist, which is the vertex value.
            sendMessage(edge.getTargetVertexId(), new DoubleWritable(minDist));
        }
    }
    if (previousValue > 3 && minDist <= 3) {
        aggregate(SimpleShortestPathsMaster.NV_DISTANCE_LESS_THAN_THREE_AGGREGATOR, new LongWritable(1));
    }
    vertex.voteToHalt();
}

From source file:org.apache.giraph.debugger.examples.simpledebug.SimpleShortestPathsMaster.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override/*from   ww w . j  av a2 s.  co m*/
public void compute() {
    System.out.print("Running SimpleShortestPathsMaster.compute. superstep " + getSuperstep() + "\n");
    LongWritable aggregatorValue = getAggregatedValue(NV_DISTANCE_LESS_THAN_THREE_AGGREGATOR);
    if (aggregatorValue != null) {
        System.out.print("At Master.compute() with aggregator: " + aggregatorValue.get() + "\n");
    }
    // if (getSuperstep() == 2) {
    // throw new IllegalArgumentException("DUMMY EXCEPTION FOR TESTING");
    // }

    // Dummy code for testing Instrumenter analysis
    if (getSuperstep() == 100000) {
        // which is extremely less likely to happen,
        setComputation(BuggySimpleTriangleClosingComputation.class);
    } else if (getSuperstep() == 200000) {
        try {
            setComputation((Class<? extends Computation>) Class.forName(
                    "org.apache.giraph.debugger.examples.integrity." + "ConnectedComponentsActualComputation"));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.apache.giraph.edge.LongDiffNullArrayEdges.java

License:Apache License

@Override
public void remove(LongWritable targetVertexId) {
    edges.remove(targetVertexId.get());
}

From source file:org.apache.giraph.edge.LongDoubleArrayEdges.java

License:Apache License

@Override
public void remove(LongWritable targetVertexId) {
    // Thanks to the constant-time implementation of removeAt(int),
    // we can remove all matching edges in linear time.
    for (int i = neighbors.size() - 1; i >= 0; --i) {
        if (neighbors.getLong(i) == targetVertexId.get()) {
            removeAt(i);//from  w  w w  .  j a  v a  2s  .  c  om
        }
    }
}

From source file:org.apache.giraph.edge.LongDoubleHashMapEdges.java

License:Apache License

@Override
public void remove(LongWritable targetVertexId) {
    edgeMap.remove(targetVertexId.get());
}

From source file:org.apache.giraph.edge.LongDoubleHashMapEdges.java

License:Apache License

@Override
public DoubleWritable getEdgeValue(LongWritable targetVertexId) {
    if (!edgeMap.containsKey(targetVertexId.get())) {
        return null;
    }//from w  ww. j  a  va  2  s  .com
    if (representativeEdgeValue == null) {
        representativeEdgeValue = new DoubleWritable();
    }
    representativeEdgeValue.set(edgeMap.get(targetVertexId.get()));
    return representativeEdgeValue;
}

From source file:org.apache.giraph.edge.LongDoubleHashMapEdges.java

License:Apache License

@Override
public void setEdgeValue(LongWritable targetVertexId, DoubleWritable edgeValue) {
    if (edgeMap.containsKey(targetVertexId.get())) {
        edgeMap.put(targetVertexId.get(), edgeValue.get());
    }/*  w  w  w . ja  v  a 2 s  . com*/
}

From source file:org.apache.giraph.edge.LongNullHashSetEdges.java

License:Apache License

@Override
public void remove(LongWritable targetVertexId) {
    neighbors.remove(targetVertexId.get());
}