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

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

Introduction

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

Prototype

public void set(long value) 

Source Link

Document

Set the value of this LongWritable.

Usage

From source file:org.apache.giraph.conf.TestObjectCreation.java

License:Apache License

@Test
public void testConstructorNewInstance() throws IllegalAccessException, InstantiationException,
        NoSuchMethodException, InvocationTargetException {
    Constructor<?> constructor = LongWritable.class.getDeclaredConstructor(new Class[] {});
    startNanos = TIME.getNanoseconds();/*from ww  w .  jav a 2  s .c  o  m*/
    for (int i = 0; i < COUNT; ++i) {
        LongWritable value = (LongWritable) constructor.newInstance();
        value.set(i);
        total += value.get();
    }
}

From source file:org.apache.giraph.conf.TestObjectCreation.java

License:Apache License

@Test
public void testImmutableClassesGiraphConfigurationNewInstance() {
    startNanos = TIME.getNanoseconds();/*from  w  w  w  . ja  v  a  2s  .c  o  m*/
    for (int i = 0; i < COUNT; ++i) {
        LongWritable value = getConfiguration().createVertexValue();
        value.set(i);
        total += value.get();
    }
}

From source file:org.apache.giraph.edge.primitives.LongEdgeStore.java

License:Apache License

@Override
protected LongWritable getVertexId(Long2ObjectMap.Entry<OutEdges<LongWritable, E>> entry,
        LongWritable representativeVertexId) {
    representativeVertexId.set(entry.getLongKey());
    return representativeVertexId;
}

From source file:org.apache.giraph.examples.SimpleInDegreeCountComputation.java

License:Apache License

@Override
public void compute(Vertex<LongWritable, LongWritable, DoubleWritable> vertex,
        Iterable<DoubleWritable> messages) throws IOException {
    if (getSuperstep() == 0) {
        Iterable<Edge<LongWritable, DoubleWritable>> edges = vertex.getEdges();
        for (Edge<LongWritable, DoubleWritable> edge : edges) {
            sendMessage(edge.getTargetVertexId(), new DoubleWritable(1.0));
        }// w  w  w .  j av  a  2  s  .  c o  m
    } else {
        long sum = 0;
        for (DoubleWritable message : messages) {
            sum++;
        }
        LongWritable vertexValue = vertex.getValue();
        vertexValue.set(sum);
        vertex.setValue(vertexValue);
        vertex.voteToHalt();
    }
}

From source file:org.apache.giraph.examples.SimpleInDegreeCountVertex.java

License:Apache License

@Override
public void compute(Iterable<DoubleWritable> messages) {
    if (getSuperstep() == 0) {
        Iterable<Edge<LongWritable, DoubleWritable>> edges = getEdges();
        for (Edge<LongWritable, DoubleWritable> edge : edges) {
            sendMessage(edge.getTargetVertexId(), new DoubleWritable(1.0));
        }/*from   ww w  . j a v a 2  s. c  o m*/
    } else {
        long sum = 0;
        for (DoubleWritable message : messages) {
            sum++;
        }
        LongWritable vertexValue = getValue();
        vertexValue.set(sum);
        setValue(vertexValue);
        voteToHalt();
    }
}

From source file:org.apache.giraph.examples.SimpleOutDegreeCountComputation.java

License:Apache License

@Override
public void compute(Vertex<LongWritable, LongWritable, DoubleWritable> vertex,
        Iterable<DoubleWritable> messages) throws IOException {
    LongWritable vertexValue = vertex.getValue();
    vertexValue.set(vertex.getNumEdges());
    vertex.setValue(vertexValue);//from   w  ww  . ja  v  a2  s  .com
    vertex.voteToHalt();
}

From source file:org.apache.giraph.examples.SimpleOutDegreeCountVertex.java

License:Apache License

@Override
public void compute(Iterable<DoubleWritable> messages) {
    LongWritable vertexValue = getValue();
    vertexValue.set(getNumEdges());
    setValue(vertexValue);/*from w  w w .jav a2s  .  c o  m*/
    voteToHalt();
}

From source file:org.apache.giraph.hive.common.HiveParsing.java

License:Apache License

/**
 * Parse a Long ID from a Hive record/*from  w ww. j a  v a  2 s. c o  m*/
 * @param record Hive record to parse
 * @param columnIndex offset of column in row
 * @param reusableId Reusable vertex id object
 * @return LongWritable ID
 */
public static LongWritable parseLongID(HiveReadableRecord record, int columnIndex, LongWritable reusableId) {
    reusableId.set(record.getLong(columnIndex));
    return reusableId;
}

From source file:org.apache.giraph.hive.input.mapping.examples.LongByteHiveToMapping.java

License:Apache License

@Override
public LongWritable getVertexId(HiveReadableRecord record) {
    LongWritable reusableId = getReusableVertexId();
    reusableId.set(record.getLong(0));
    return reusableId;
}

From source file:org.apache.giraph.hive.input.mapping.examples.LongInt2ByteHiveToMapping.java

License:Apache License

@Override
public LongWritable getVertexId(HiveReadableRecord record) {
    long id = record.getLong(0);
    LongWritable reusableId = getReusableVertexId();
    reusableId.set(id);
    return reusableId;
}