/** * Returns true, if the aggregator value is zero, false otherwise. * * @param iteration The number of the iteration superstep. Ignored in this case. * @param value The aggregator value, which is compared to zero. * @return True, if the aggregator value is zero, false otherwise. */ @Override public boolean isConverged(int iteration, LongValue value) { return value.getValue() == 0; } }
@Override public void aggregate(LongValue count) { this.count += count.getValue(); }
/** * Returns true, if the aggregator value is zero, false otherwise. * * @param iteration The number of the iteration superstep. Ignored in this case. * @param value The aggregator value, which is compared to zero. * @return True, if the aggregator value is zero, false otherwise. */ @Override public boolean isConverged(int iteration, LongValue value) { return value.getValue() == 0; } }
@Override public void aggregate(LongValue element) { sum += element.getValue(); }
@Override public void aggregate(LongValue element) { sum += element.getValue(); }
@Override public void aggregate(LongValue count) { this.count += count.getValue(); }
@Override public boolean isConverged(int iteration, LongValue value) { long updatedElements = value.getValue(); if (log.isInfoEnabled()) { log.info("[" + updatedElements + "] elements updated in the solutionset in iteration [" + iteration + "]"); } return updatedElements == 0; } }
@Override public boolean isConverged(int iteration, LongValue value) { long updatedElements = value.getValue(); if (log.isInfoEnabled()) { log.info("[" + updatedElements + "] elements updated in the solutionset in iteration [" + iteration + "]"); } return updatedElements == 0; } }
@Override public boolean isConverged(int iteration, LongValue countAggregate) { long count = countAggregate.getValue(); if (log.isInfoEnabled()) { log.info("Termination criterion stats in iteration [" + iteration + "]: " + count); } if(count == 0) { return true; } else { return false; } } }
@Override public boolean isConverged(int iteration, LongValue countAggregate) { long count = countAggregate.getValue(); if (log.isInfoEnabled()) { log.info("Termination criterion stats in iteration [" + iteration + "]: " + count); } if(count == 0) { return true; } else { return false; } } }
@Override public LongValue copy(LongValue from, LongValue reuse) { reuse.setValue(from.getValue()); return reuse; }
@Override public LongValue copy(LongValue from, LongValue reuse) { reuse.setValue(from.getValue()); return reuse; }
@Override public void join(Record newVertexWithComponent, Record currentVertexWithComponent, Collector<Record> out){ long candidateComponentID = newVertexWithComponent.getField(1, LongValue.class).getValue(); long currentComponentID = currentVertexWithComponent.getField(1, LongValue.class).getValue(); if (candidateComponentID < currentComponentID) { out.collect(newVertexWithComponent); } } }
@Override public void join(Record currentVertexWithComponent, Record newVertexWithComponent, Collector<Record> out){ long candidateComponentID = newVertexWithComponent.getField(1, LongValue.class).getValue(); long currentComponentID = currentVertexWithComponent.getField(1, LongValue.class).getValue(); if (candidateComponentID < currentComponentID) { out.collect(newVertexWithComponent); } } }
@Override public void join(Record newVertexWithComponent, Record currentVertexWithComponent, Collector<Record> out){ long candidateComponentID = newVertexWithComponent.getField(1, LongValue.class).getValue(); long currentComponentID = currentVertexWithComponent.getField(1, LongValue.class).getValue(); if (candidateComponentID < currentComponentID) { out.collect(newVertexWithComponent); } } }
@Override public void join(Record currentVertexWithComponent, Record newVertexWithComponent, Collector<Record> out){ long candidateComponentID = newVertexWithComponent.getField(1, LongValue.class).getValue(); long currentComponentID = currentVertexWithComponent.getField(1, LongValue.class).getValue(); if (candidateComponentID < currentComponentID) { out.collect(newVertexWithComponent); } } }
@Override public void coGroup(Iterator<Record> candidates, Iterator<Record> current, Collector<Record> out) throws Exception { if (!current.hasNext()) { throw new Exception("Error: Id not encountered before."); } Record old = current.next(); long oldId = old.getField(1, LongValue.class).getValue(); long minimumComponentID = Long.MAX_VALUE; while (candidates.hasNext()) { long candidateComponentID = candidates.next().getField(1, LongValue.class).getValue(); if (candidateComponentID < minimumComponentID) { minimumComponentID = candidateComponentID; } } if (minimumComponentID < oldId) { newComponentId.setValue(minimumComponentID); old.setField(1, newComponentId); out.collect(old); } }
@Override public void reduce(Iterator<Record> records, Collector<Record> out) { final Record first = records.next(); final long vertexID = first.getField(0, LongValue.class).getValue(); long minimumComponentID = first.getField(1, LongValue.class).getValue(); while (records.hasNext()) { long candidateComponentID = records.next().getField(1, LongValue.class).getValue(); if (candidateComponentID < minimumComponentID) { minimumComponentID = candidateComponentID; } } this.vertexId.setValue(vertexID); this.minComponentId.setValue(minimumComponentID); this.result.setField(0, this.vertexId); this.result.setField(1, this.minComponentId); out.collect(this.result); } }
@Override public void map(Record record, Collector<Record> out) throws Exception { for (Record model : this.models) { // compute dot product between model and pair long product = 0; for (int i = 1; i <= NUM_FEATURES; i++) { product += model.getField(i, this.lft).getValue() * record.getField(i, this.rgt).getValue(); } this.prd.setValue(product); // construct result this.result.copyFrom(model, new int[] { 0 }, new int[] { 0 }); this.result.copyFrom(record, new int[] { 0 }, new int[] { 1 }); this.result.setField(2, this.prd); // emit result out.collect(this.result); } } }
@Override public void join(Record vertexWithRank, Record edgeWithWeight, Collector<Record> out) throws Exception { result.setField(0, edgeWithWeight.getField(1, LongValue.class)); final long outLinks = edgeWithWeight.getField(2, LongValue.class).getValue(); final double rank = vertexWithRank.getField(1, DoubleValue.class).getValue(); partRank.setValue(rank / (double) outLinks); result.setField(1, partRank); out.collect(result); } }