@Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields.length; i++) { final Key<?> k = candidate.getField(this.keyFields[i], this.transientKeyHolders[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields[i]); } else if (!k.equals(this.keyHolders[i])) { return false; } } return true; }
@Override public void setReference(Record reference) { for (int i = 0; i < this.keyFields1.length; i++) { if (!reference.getFieldInto(this.keyFields1[i], this.keyHolders1[i])) { throw new NullKeyFieldException(this.keyFields1[i]); } } }
@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); } }
/** * Returns the record to write at the given position */ protected Record getRecord(int index) { return new Record(new IntValue(index), new StringValue(String.valueOf(index))); }
public StringIntPair(String first, int second) { super(new StringValue(first), new IntValue(second)); } }
@Override public IntValue[] getBucketBoundary(int bucketNum, int totalNumBuckets) { long diff = ((long) max) - ((long) min) + 1; double bucketSize = diff / ((double) totalNumBuckets); return new IntValue[] {new IntValue(min + (int) ((bucketNum+1) * bucketSize)) }; }
/** * 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, DoubleValue value) { return value.getValue() == 0; } }
/** * Initializes the StringValue to a sub-string of the given StringValue. * * @param value The string containing the substring. * @param offset The offset of the substring. * @param len The length of the substring. */ public StringValue(StringValue value, int offset, int len) { this.value = EMPTY_STRING; setValue(value, offset, len); }
@Override public void copy(DataInputView source, DataOutputView target) throws IOException { StringValue.copyString(source, target); } }
@Override public IntValue deserialize(IntValue reuse, DataInputView source) throws IOException { reuse.read(source); return reuse; }
@Override public BooleanValue deserialize(BooleanValue reuse, DataInputView source) throws IOException { reuse.read(source); return reuse; }
@Override public LongValue deserialize(LongValue reuse, DataInputView source) throws IOException { reuse.read(source); return reuse; }
/** * Finds any occurrence of the <code>str</code> character sequence in this StringValue. * * @return The position of the first occurrence of the search string in the string value, or <code>-1</code>, if * the character sequence was not found. */ public int find(CharSequence str) { return find(str, 0); }
@Override public FloatValue deserialize(FloatValue reuse, DataInputView source) throws IOException { reuse.read(source); return reuse; }
@SuppressWarnings("rawtypes") @Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields2.length; i++) { final Key k = candidate.getField(this.keyFields2[i], this.keyHolders2[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields2[i]); } else if (!k.equals(this.keyHolders1[i])) { return false; } } return true; }
@Override public void setReference(Record toCompare) { for (int i = 0; i < this.keyFields.length; i++) { if (!toCompare.getFieldInto(this.keyFields[i], this.keyHolders[i])) { throw new NullKeyFieldException(this.keyFields[i]); } } }