throw new RuntimeException("Index Block end offset is not more than start offset:");
}
}
}
if (!map.containsKey(columnValue)) {
map.put(columnValue, new LongPairWritable(outputValue));
} else {
LongPairWritable prevPair = map.get(columnValue);
if (prevPair.getSecond() > outputValue.getFirst() &&
outputValue.getFirst() < prevPair.getFirst()) {
throw new RuntimeException("error: overalapping index blocks at offset: " + key);
}
/*
*if we can combine the two blocks, then combine, otherwise send the
* previously stored index entry to reducer and store the new index entry.
* Two conditions to be met to combine:
* a) "adjacent" to each other;
* b) combined size cannot be more than the threshold
*/
if (prevPair.getSecond() + gapsize < outputValue.getFirst() ||
outputValue.getSecond() - prevPair.getFirst() > maxBlockSize) {
context.write(new TextLongPairWritable(new Text(columnValue), prevPair.getFirst()), prevPair);
if (LOG.isDebugEnabled()) {
LOG.debug("write to reducer: " + prevPair);
}
map.put(columnValue, new LongPairWritable(outputValue));
} else {
prevPair.setSecond(outputValue.getSecond());
map.put(columnValue, prevPair);
}
}
previousRowLineOffset = lineOffset;