List of usage examples for org.apache.hadoop.io NullWritable get
public static NullWritable get()
From source file:org.apache.giraph.block_app.library.pagerank.PageRankTest.java
License:Apache License
/** * Creates a map of unweighted edges from neighbors * * @param neighbors neighbors/* w w w .j a va 2 s . c o m*/ * @return returns the edges */ private static Map.Entry<LongWritable, NullWritable>[] createEdgesWeightless(int[] neighbors) { Map.Entry<LongWritable, NullWritable>[] edges = new Map.Entry[neighbors.length]; for (int i = 0; i < neighbors.length; i++) { edges[i] = new AbstractMap.SimpleEntry<>(new LongWritable(neighbors[i]), NullWritable.get()); } return edges; }
From source file:org.apache.giraph.block_app.test_setup.TestGraphUtils.java
License:Apache License
public static Supplier<NullWritable> nullSupplier() { return new Supplier<NullWritable>() { @Override// ww w . ja va2 s . c o m public NullWritable get() { return NullWritable.get(); } }; }
From source file:org.apache.giraph.combiner.NullMessageCombiner.java
License:Apache License
@Override public NullWritable createInitialMessage() { return NullWritable.get(); }
From source file:org.apache.giraph.debugger.mock.TestGraphGenerator.java
License:Apache License
/** * Constructs a {@link Writable} object with the appropriate type that * contains the specified content. For example, type can be LongWritable, * and content can be 100L, and this method would return a new * {@link LongWritable} that has value 100. * @param contents contetns of the writable. * @param type type of the writable./*from w w w . j av a 2 s . c om*/ * @return a {@link Writable} object of appropriate type, whose value contains * the given contents. */ private Writable convertToSuitableType(String contents, WritableType type) { switch (type) { case NULL: return NullWritable.get(); case LONG: return new LongWritable(Long.valueOf(contents)); case DOUBLE: return new DoubleWritable(Double.valueOf(contents)); default: throw new IllegalStateException("Unknown type!"); } }
From source file:org.apache.giraph.edge.EdgeNoValue.java
License:Apache License
@Override public NullWritable getValue() { return NullWritable.get(); }
From source file:org.apache.giraph.edge.IntNullArrayEdges.java
License:Apache License
@Override public Iterator<Edge<IntWritable, NullWritable>> iterator() { // Returns an iterator that reuses objects. return new UnmodifiableIterator<Edge<IntWritable, NullWritable>>() { /** Wrapped neighbors iterator. */ private final IntIterator neighborsIt = neighbors.iterator(); /** Representative edge object. */ private final Edge<IntWritable, NullWritable> representativeEdge = EdgeFactory.create(new IntWritable(), NullWritable.get()); @Override/* w w w . j a va2s .co m*/ public boolean hasNext() { return neighborsIt.hasNext(); } @Override public Edge<IntWritable, NullWritable> next() { representativeEdge.getTargetVertexId().set(neighborsIt.nextInt()); return representativeEdge; } }; }
From source file:org.apache.giraph.edge.LongNullHashSetEdges.java
License:Apache License
@Override public NullWritable getEdgeValue(LongWritable targetVertexId) { if (neighbors.contains(targetVertexId.get())) { return NullWritable.get(); } else {//from w w w .j a va 2 s .com return null; } }
From source file:org.apache.giraph.examples.scc.SccComputationTestInMemory.java
License:Apache License
@SuppressWarnings("unchecked") public static Entry<LongWritable, NullWritable>[] makeEdges(long... args) { Entry<LongWritable, NullWritable> result[] = new Entry[args.length]; for (int i = 0; i < args.length; i++) { result[i] = new SimpleEntry<LongWritable, NullWritable>(new LongWritable(args[i]), NullWritable.get()); }/* w w w . j av a2 s. c o m*/ return result; }
From source file:org.apache.giraph.graph.DefaultVertexValueFactory.java
License:Apache License
@Override public V createVertexValue() { if (vertexValueClass == NullWritable.class) { return (V) NullWritable.get(); } else {/*from www .j av a 2 s . c o m*/ try { return vertexValueClass.newInstance(); } catch (InstantiationException e) { throw new IllegalArgumentException("createVertexValue: Failed to instantiate", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("createVertexValue: Illegally accessed", e); } } }
From source file:org.apache.giraph.graph.IntIntNullIntVertex.java
License:Apache License
@Override public NullWritable getEdgeValue(IntWritable targetVertexId) { return NullWritable.get(); }