incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/2] git commit: Fixing a potential problem where the filter file could be truncated during creation because of failure. Filters with incorrect size because of the segment size will be deleted and recreated.
Date Thu, 24 Oct 2013 19:40:01 GMT
Updated Branches:
  refs/heads/master 6f6b9b733 -> fe0f9a809


Fixing a potential problem where the filter file could be truncated during creation because
of failure.  Filters with incorrect size because of the segment size will be deleted and recreated.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/9de208fb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/9de208fb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/9de208fb

Branch: refs/heads/master
Commit: 9de208fbb880d52dbc9c26cc24e903b3802dc049
Parents: 6f6b9b7
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Thu Oct 24 15:26:38 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu Oct 24 15:26:38 2013 -0400

----------------------------------------------------------------------
 .../org/apache/blur/filter/IndexFileBitSet.java | 21 ++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9de208fb/blur-query/src/main/java/org/apache/blur/filter/IndexFileBitSet.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/filter/IndexFileBitSet.java b/blur-query/src/main/java/org/apache/blur/filter/IndexFileBitSet.java
index 4ef6031..199b8be 100644
--- a/blur-query/src/main/java/org/apache/blur/filter/IndexFileBitSet.java
+++ b/blur-query/src/main/java/org/apache/blur/filter/IndexFileBitSet.java
@@ -19,6 +19,8 @@ package org.apache.blur.filter;
 import java.io.Closeable;
 import java.io.IOException;
 
+import org.apache.blur.log.Log;
+import org.apache.blur.log.LogFactory;
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.store.Directory;
@@ -28,6 +30,8 @@ import org.apache.lucene.store.IndexOutput;
 
 public class IndexFileBitSet extends DocIdSet implements Closeable {
 
+  private static final Log LOG = LogFactory.getLog(IndexFileBitSet.class);
+
   public static final String EXTENSION = ".filter";
 
   private final String _id;
@@ -49,7 +53,16 @@ public class IndexFileBitSet extends DocIdSet implements Closeable {
   }
 
   public boolean exists() throws IOException {
-    return _directory.fileExists(getFileName());
+    boolean fileExists = _directory.fileExists(getFileName());
+    if (fileExists) {
+      int words = (_numBits / 64) + 1;
+      int correctLength = words * 8;
+      long length = _indexInput.length();
+      if (correctLength == length) {
+        return true;
+      }
+    }
+    return false;
   }
 
   private String getFileName() {
@@ -70,6 +83,10 @@ public class IndexFileBitSet extends DocIdSet implements Closeable {
 
   public void create(DocIdSetIterator it) throws IOException {
     String fileName = getFileName();
+    if (_directory.fileExists(getFileName())) {
+      LOG.warn("Filter [{0}] in directory [{1}] being recreated due to incorrect size.",
fileName, _directory);
+      _directory.deleteFile(fileName);
+    }
     IndexOutput output = _directory.createOutput(fileName, IOContext.READ);
     int index;
     int currentWordNum = 0;
@@ -89,7 +106,7 @@ public class IndexFileBitSet extends DocIdSet implements Closeable {
       wordValue |= bitmask;
     }
     if (_numBits > 0) {
-      int totalWords =  (_numBits / 64) + 1;
+      int totalWords = (_numBits / 64) + 1;
       while (currentWordNum < totalWords) {
         output.writeLong(wordValue);
         currentWordNum++;


Mime
View raw message