private ArrayListWritable<PairOfInts> fetchPostings(String term) throws IOException { Text key = new Text(); PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>> value = new PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>>(); key.set(term); index.get(key, value); return value.getRightElement(); }
private ArrayListWritable<PairOfInts> fetchPostings(String term) throws IOException { Text key = new Text(); PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>> value = new PairOfWritables<>(); key.set(term); index.get(key, value); return value.getRightElement(); }
@Override public void reduce(Text key, Iterable<PairOfInts> values, Context context) throws IOException, InterruptedException { Iterator<PairOfInts> iter = values.iterator(); ArrayListWritable<PairOfInts> postings = new ArrayListWritable<>(); int df = 0; while (iter.hasNext()) { postings.add(iter.next().clone()); df++; } // Sort the postings by docno ascending. Collections.sort(postings); DF.set(df); context.write(key, new PairOfWritables<>(DF, postings)); } }
@Override public void reduce(Text key, Iterable<PairOfInts> values, Context context) throws IOException, InterruptedException { Iterator<PairOfInts> iter = values.iterator(); ArrayListWritable<PairOfInts> postings = new ArrayListWritable<PairOfInts>(); int df = 0; while (iter.hasNext()) { postings.add(iter.next().clone()); df++; } // Sort the postings by docno ascending. Collections.sort(postings); DF.set(df); context.write(key, new PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>>(DF, postings)); } }
list.add(new PairOfWritables<K, V>(key, value)); if (k >= max) { break;
new PairOfWritables<IntWritable, ArrayListWritable<PairOfInts>>();
list.add(new PairOfWritables<K, V>(key, value)); if (k >= max) { break;