@SuppressWarnings("rawtypes") @Override public int compare(WritableComparable w1, WritableComparable w2) { ArticleIDTimestampWritable firstComposite = (ArticleIDTimestampWritable) w1; ArticleIDTimestampWritable secondComposite = (ArticleIDTimestampWritable) w2; int result = firstComposite.getArticleId().compareTo(secondComposite.getArticleId()); if (result == 0) { Date cmpDate = ISO8601Utils.parse(secondComposite.getTimeStamp()); Date originDate = ISO8601Utils.parse(firstComposite.getTimeStamp()); result = -originDate.compareTo(cmpDate); } return result; }
@Override public int getPartition(ArticleIDTimestampWritable key, IntWritable value, int numPartitions) { int hash = key.getArticleId().hashCode(); return hash % numPartitions; }