@Override public FloatValue next() { value.setValue(data[pos++]); return value; }
private void setAdamicAdarScore(float adamicAdarScore) { this.adamicAdarScore.setValue(adamicAdarScore); }
@Override public FloatValue copy(FloatValue from, FloatValue reuse) { reuse.setValue(from.getValue()); return reuse; }
@Override public Tuple3<T, LongValue, FloatValue> map(Vertex<T, LongValue> value) throws Exception { output.f0 = value.f0; output.f1 = value.f1; long degree = value.f1.getValue(); // when the degree is one the logarithm is zero so avoid dividing by this value float inverseLogDegree = (degree == 1) ? 0.0f : 1.0f / (float) Math.log(value.f1.getValue()); output.f2.setValue(inverseLogDegree); return output; } }
@Override public FloatValue translate(LongValue value, FloatValue reuse) throws Exception { if (reuse == null) { reuse = new FloatValue(); } long l = value.getValue(); if (l < 0 || l >= MAX_VERTEX_COUNT) { throw new IllegalArgumentException("Cannot cast long value " + value + " to float."); } reuse.setValue(Float.intBitsToFloat((int) (l & (MAX_VERTEX_COUNT - 1)))); return reuse; } }
@Override public int parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, FloatValue reusable) { final int endPos = nextStringEndPos(bytes, startPos, limit, delimiter); if (endPos < 0) { return -1; } if (endPos > startPos && (Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[endPos - 1]))) { setErrorState(ParseErrorState.NUMERIC_VALUE_ILLEGAL_CHARACTER); return -1; } String str = new String(bytes, startPos, endPos - startPos, ConfigConstants.DEFAULT_CHARSET); try { float value = Float.parseFloat(str); reusable.setValue(value); this.result = reusable; return (endPos == limit) ? limit : endPos + delimiter.length; } catch (NumberFormatException e) { setErrorState(ParseErrorState.NUMERIC_VALUE_FORMAT_ERROR); return -1; } }
@Override public Tuple2<FloatValue, LongValue> map(Tuple3<T, LongValue, FloatValue> value) throws Exception { long degree = value.f1.getValue(); long neighborPairs = degree * (degree - 1) / 2; sumOfScores.setValue(value.f2.getValue() * neighborPairs); numberOfNeighborPairs.setValue(neighborPairs); return output; } }
@Override public FloatValue next() { value.setValue(data[pos++]); return value; }
@Override public FloatValue next() { value.setValue(data[pos++]); return value; }
private void setAdamicAdarScore(float adamicAdarScore) { this.adamicAdarScore.setValue(adamicAdarScore); }
private void setAdamicAdarScore(float adamicAdarScore) { this.adamicAdarScore.setValue(adamicAdarScore); }
@Override public FloatValue copy(FloatValue from, FloatValue reuse) { reuse.setValue(from.getValue()); return reuse; }
@Override public FloatValue copy(FloatValue from, FloatValue reuse) { reuse.setValue(from.getValue()); return reuse; }
@Override public void setFloat(int i, float value) { FloatValue wrap; if ((wrap = (FloatValue) fields[i]) == null) { wrap = new FloatValue(); fields[i] = wrap; } wrap.setValue(value); }
@Override public Tuple3<T, LongValue, FloatValue> map(Vertex<T, LongValue> value) throws Exception { output.f0 = value.f0; output.f1 = value.f1; long degree = value.f1.getValue(); // when the degree is one the logarithm is zero so avoid dividing by this value float inverseLogDegree = (degree == 1) ? 0.0f : 1.0f / (float) Math.log(value.f1.getValue()); output.f2.setValue(inverseLogDegree); return output; } }
@Override public Tuple3<T, LongValue, FloatValue> map(Vertex<T, LongValue> value) throws Exception { output.f0 = value.f0; output.f1 = value.f1; long degree = value.f1.getValue(); // when the degree is one the logarithm is zero so avoid dividing by this value float inverseLogDegree = (degree == 1) ? 0.0f : 1.0f / (float)Math.log(value.f1.getValue()); output.f2.setValue(inverseLogDegree); return output; } }
@Override public Tuple3<T, LongValue, FloatValue> map(Vertex<T, LongValue> value) throws Exception { output.f0 = value.f0; output.f1 = value.f1; long degree = value.f1.getValue(); // when the degree is one the logarithm is zero so avoid dividing by this value float inverseLogDegree = (degree == 1) ? 0.0f : 1.0f / (float) Math.log(value.f1.getValue()); output.f2.setValue(inverseLogDegree); return output; } }
@Override public Tuple2<FloatValue, LongValue> map(Tuple3<T, LongValue, FloatValue> value) throws Exception { long degree = value.f1.getValue(); long neighborPairs = degree * (degree - 1) / 2; sumOfScores.setValue(value.f2.getValue() * neighborPairs); numberOfNeighborPairs.setValue(neighborPairs); return output; } }
@Override public Tuple2<FloatValue, LongValue> map(Tuple3<T, LongValue, FloatValue> value) throws Exception { long degree = value.f1.getValue(); long neighborPairs = degree * (degree - 1) / 2; sumOfScores.setValue(value.f2.getValue() * neighborPairs); numberOfNeighborPairs.setValue(neighborPairs); return output; } }
@Override public Tuple2<FloatValue, LongValue> map(Tuple3<T, LongValue, FloatValue> value) throws Exception { long degree = value.f1.getValue(); long neighborPairs = degree * (degree - 1) / 2; sumOfScores.setValue(value.f2.getValue() * neighborPairs); numberOfNeighborPairs.setValue(neighborPairs); return output; } }