public VLongWritable readVLong(VLongWritable lw) throws IOException { if (lw == null) { lw = new VLongWritable(); } lw.set(in.readLong()); return lw; }
/** * This reducer is only useful to Kneser-Ney language models as a combiner. It is included for * later implementation of techniques such as stupid backoff. */ @Override public void reduce(CountOfCountsInfo key, Iterable<VLongWritable> values, Context context) { try { long sum = 0; for (VLongWritable count : values) { sum += count.get(); } writable.set(sum); context.write(key, writable); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
@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; }
@Override protected void map(LongWritable key, cidynamonode node, Context context) throws IOException, InterruptedException { if (flushed != null) { Long count = flushed.get(node.getClient()); if (count == null || node.getCount() >= count) { context.getCounter(Counts.IGNORED).increment(1); return; } } row.set(key.get()); context.write(row, DEF); if (node.getPrev() >= 0) { ref.set((long) node.getPrev()); vrow.set(key.get()); context.write(ref, vrow); } }