@Override public int hashCode() { int result = 7; result = result * 17 + cardS.hashCode(); result = result * 17 + cardP.hashCode(); result = result * 17 + cardO.hashCode(); result = result * 17 + cardSP.hashCode(); result = result * 17 + cardPO.hashCode(); result = result * 17 + cardSO.hashCode(); return result; }
/** * Compute partition given id, partitionCount, workerCount & target * @param id vertex id * @param partitionCount number of partitions * @param workerCount number of workers * @param target target worker * @return partition number */ protected int computePartition(LongWritable id, int partitionCount, int workerCount, byte target) { int numRows = partitionCount / workerCount; numRows = (numRows * workerCount == partitionCount) ? numRows : numRows + 1; if (target == -1) { // default to hash based partitioning return Math.abs(id.hashCode() % partitionCount); } else { int targetWorker = target & 0xFF; // assume zero based indexing of partition & worker [also consecutive] return numRows * targetWorker + Math.abs(id.hashCode() % numRows); } } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((state == null) ? 0 : state.hashCode()); result = prime * result + ((vertexID == null) ? 0 : vertexID.hashCode()); return result; }
public int hashCode() { return first.hashCode() * 163 + second.hashCode(); }
@Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { int sid = 0; for (String sentence : value.toString().split("\n")) { // do nothing, if maximum number of documents has been seen if (--maxdocs < 0) { return; } long did = key.hashCode() * 10000L + (long) sid++;; OpenObjectIntHashMap<String> wordCounts = new OpenObjectIntHashMap<String>(); for (String term : sentence.split("\\s+")) { wordCounts.adjustOrPutValue(term, +1, +1); } for (String term : wordCounts.keys()) { outKey.set(term); outValue.setDId(did); outValue.setOffsets(new int[]{wordCounts.get(term)}); context.write(outKey, outValue); } } } }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void map(LongWritable key, Text value, Mapper.Context context) throws IOException, InterruptedException { int sid = 0; for (String sentence : value.toString().split("\n")) { // do nothing, if maximum number of documents has been seen if (--maxdocs < 0) { return; } IntArrayList tids = new IntArrayList(); for (String term : sentence.split("\\s+")) { tids.add(termTIdMap.get(term)); } long did = key.hashCode() * 10000L + (long) sid++; outKey.set(did); outValue.setContents(tids.toArray(new int[0])); context.write(outKey, outValue); } } }