@Override public int getPartition(PairOfStrings key, FloatWritable value, int numReduceTasks) { return (key.getLeftElement().hashCode() & Integer.MAX_VALUE) % numReduceTasks; } }
@Override public int getPartition(PairOfStrings key, IntWritable value, int numReduceTasks) { return (key.getLeftElement().hashCode() & Integer.MAX_VALUE) % numReduceTasks; } }
@Override public int getPartition(PairOfStrings key, FloatWritable value, int numReduceTasks) { return (key.getLeftElement().hashCode() & Integer.MAX_VALUE) % numReduceTasks; } }
@Override public int getPartition(PairOfStrings key, IntWritable value, int numReduceTasks) { return (key.getLeftElement().hashCode() & Integer.MAX_VALUE) % numReduceTasks; } }
/** * Checks two pairs for equality. * * @param obj object for comparison * @return <code>true</code> if <code>obj</code> is equal to this object, <code>false</code> * otherwise */ public boolean equals(Object obj) { PairOfStrings pair = (PairOfStrings) obj; return leftElement.equals(pair.getLeftElement()) && rightElement.equals(pair.getRightElement()); }
/** * Defines a natural sort order for pairs. Pairs are sorted first by the left element, and then by * the right element. * * @return a value less than zero, a value greater than zero, or zero if this pair should be * sorted before, sorted after, or is equal to <code>obj</code>. */ public int compareTo(PairOfStrings pair) { String pl = pair.getLeftElement(); String pr = pair.getRightElement(); if (leftElement.equals(pl)) { return rightElement.compareTo(pr); } return leftElement.compareTo(pl); }
PairOfStrings now = iter.next(); double w = Double.parseDouble(now.getRightElement()); double x = Double.parseDouble(now.getLeftElement()); sum += w; mu += x * w;
public void reduce(PairOfStringInt key, Iterator<PairOfStrings> values, OutputCollector<IntWritable, PairOfIntString> output, Reporter reporter) throws IOException { if (key.getRightElement() == 0) { targetTitle = key.getLeftElement(); targetDocid = Integer.parseInt(values.next().getLeftElement()); } else { if (!key.getLeftElement().equals(targetTitle)) { return; } while (values.hasNext()) { PairOfStrings pair = values.next(); SRCID.set(Integer.parseInt(pair.getLeftElement())); TARGET_ANCHOR_PAIR.set(targetDocid, pair.getRightElement()); output.collect(SRCID, TARGET_ANCHOR_PAIR); } } } }
PairOfStrings bigram = p.getLeftElement(); if (bigram.getLeftElement().equals("light")) { list1.add(p); if (bigram.getLeftElement().equals("contain")) { list2.add(p);