DirectoryReader reader = DirectoryReader.open(directory);
try {
LOG.info("Applying deletes in reader [{0}]", reader);
CompositeReaderContext compositeReaderContext = reader.getContext();
List<AtomicReaderContext> leaves = compositeReaderContext.leaves();
BlurPartitioner blurPartitioner = new BlurPartitioner();
Text key = new Text();
int numberOfShards = _shardContext.getTableContext().getDescriptor().getShardCount();
int shardId = BlurUtil.getShardIndex(shard);
for (AtomicReaderContext context : leaves) {
AtomicReader atomicReader = context.reader();
Fields fields = atomicReader.fields();
Terms terms = fields.terms(BlurConstants.ROW_ID);
if (terms != null) {
TermsEnum termsEnum = terms.iterator(null);
BytesRef ref = null;
while ((ref = termsEnum.next()) != null) {
key.set(ref.bytes, ref.offset, ref.length);
int partition = blurPartitioner.getPartition(key, null, numberOfShards);
if (shardId != partition) {
throw new IOException("Index is corrupted, RowIds are found in wrong shard, partition [" + partition
+ "] does not shard [" + shardId + "], this can happen when rows are not hashed correctly.");
}
if (emitDeletes) {