Fixed BLUR-187
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/7fb3c14d Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/7fb3c14d Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/7fb3c14d Branch: refs/heads/master Commit: 7fb3c14dd516a556a1609796a61b2a8296904baf Parents: 45e5541 Author: Aaron McCurry <[email protected]> Authored: Fri Aug 2 20:56:16 2013 -0400 Committer: Aaron McCurry <[email protected]> Committed: Fri Aug 2 20:56:16 2013 -0400 ---------------------------------------------------------------------- .../blur/manager/writer/IndexImporter.java | 28 +++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7fb3c14d/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java b/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java index 82af733..8c31d6b 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java +++ b/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java @@ -179,19 +179,21 @@ public class IndexImporter extends TimerTask implements Closeable { AtomicReader atomicReader = context.reader(); Fields fields = atomicReader.fields(); Terms terms = fields.terms(BlurConstants.ROW_ID); - TermsEnum termsEnum = terms.iterator(null); - BytesRef ref = null; - while ((ref = termsEnum.next()) != null) { - byte[] rowIdInBytes = ref.bytes; - key.set(rowIdInBytes, 0, rowIdInBytes.length); - int partition = blurPartitioner.getPartition(key, null, numberOfShards); - int shardId = BlurUtil.getShardIndex(shard); - if (shardId != partition) { - return false; - } - if (emitDeletes) { - Term term = new Term(BlurConstants.ROW_ID, BytesRef.deepCopyOf(ref)); - indexWriter.deleteDocuments(term); + if (terms != null) { + TermsEnum termsEnum = terms.iterator(null); + BytesRef ref = null; + while ((ref = termsEnum.next()) != null) { + byte[] rowIdInBytes = ref.bytes; + key.set(rowIdInBytes, 0, rowIdInBytes.length); + int partition = blurPartitioner.getPartition(key, null, numberOfShards); + int shardId = BlurUtil.getShardIndex(shard); + if (shardId != partition) { + return false; + } + if (emitDeletes) { + Term term = new Term(BlurConstants.ROW_ID, BytesRef.deepCopyOf(ref)); + indexWriter.deleteDocuments(term); + } } } }
