You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/01/28 22:24:19 UTC

lucene-solr git commit: add CrankyPointFormat

Repository: lucene-solr
Updated Branches:
  refs/heads/master 70b1eb03c -> da5cc3cad


add CrankyPointFormat


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/da5cc3ca
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/da5cc3ca
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/da5cc3ca

Branch: refs/heads/master
Commit: da5cc3cad56c97d203d9f1ffe267e24ce615766b
Parents: 70b1eb0
Author: Mike McCandless <mi...@apache.org>
Authored: Thu Jan 28 16:24:27 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Thu Jan 28 16:24:27 2016 -0500

----------------------------------------------------------------------
 .../apache/lucene/index/SegmentCoreReaders.java |   4 +-
 .../lucene/codecs/cranky/CrankyCodec.java       |   6 +
 .../lucene/codecs/cranky/CrankyPointFormat.java | 176 +++++++++++++++++++
 3 files changed, 184 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/da5cc3ca/lucene/core/src/java/org/apache/lucene/index/SegmentCoreReaders.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentCoreReaders.java b/lucene/core/src/java/org/apache/lucene/index/SegmentCoreReaders.java
index 414c707..b5d1221 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentCoreReaders.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentCoreReaders.java
@@ -166,7 +166,7 @@ final class SegmentCoreReaders {
     }
   }
   
-  private void notifyCoreClosedListeners(Throwable th) {
+  private void notifyCoreClosedListeners(Throwable th) throws IOException {
     synchronized(coreClosedListeners) {
       for (CoreClosedListener listener : coreClosedListeners) {
         // SegmentReader uses our instance as its
@@ -181,7 +181,7 @@ final class SegmentCoreReaders {
           }
         }
       }
-      IOUtils.reThrowUnchecked(th);
+      IOUtils.reThrow(th);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/da5cc3ca/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java
index 7925356..3367d42 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java
@@ -26,6 +26,7 @@ import org.apache.lucene.codecs.FieldInfosFormat;
 import org.apache.lucene.codecs.FilterCodec;
 import org.apache.lucene.codecs.LiveDocsFormat;
 import org.apache.lucene.codecs.NormsFormat;
+import org.apache.lucene.codecs.PointFormat;
 import org.apache.lucene.codecs.PostingsFormat;
 import org.apache.lucene.codecs.SegmentInfoFormat;
 import org.apache.lucene.codecs.StoredFieldsFormat;
@@ -92,6 +93,11 @@ public class CrankyCodec extends FilterCodec {
   }
 
   @Override
+  public PointFormat pointFormat() {
+    return new CrankyPointFormat(delegate.pointFormat(), random);
+  }
+
+  @Override
   public String toString() {
     return "Cranky(" + delegate + ")";
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/da5cc3ca/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyPointFormat.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyPointFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyPointFormat.java
new file mode 100644
index 0000000..ed2b7a3
--- /dev/null
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyPointFormat.java
@@ -0,0 +1,176 @@
+package org.apache.lucene.codecs.cranky;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.util.Random;
+
+import org.apache.lucene.codecs.PointFormat;
+import org.apache.lucene.codecs.PointReader;
+import org.apache.lucene.codecs.PointWriter;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.MergeState;
+import org.apache.lucene.index.SegmentInfo;
+import org.apache.lucene.index.SegmentReadState;
+import org.apache.lucene.index.SegmentWriteState;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IOContext;
+
+class CrankyPointFormat extends PointFormat {
+  PointFormat delegate;
+  Random random;
+  
+  CrankyPointFormat(PointFormat delegate, Random random) {
+    this.delegate = delegate;
+    this.random = random;
+  }
+
+  @Override
+  public PointWriter fieldsWriter(SegmentWriteState state) throws IOException {
+    return new CrankyPointWriter(delegate.fieldsWriter(state), random);
+  }
+
+  @Override
+  public PointReader fieldsReader(SegmentReadState state) throws IOException {
+    return new CrankyPointReader(delegate.fieldsReader(state), random);
+  }
+
+  static class CrankyPointWriter extends PointWriter {
+    final PointWriter delegate;
+    final Random random;
+
+    public CrankyPointWriter(PointWriter delegate, Random random) {
+      this.delegate = delegate;
+      this.random = random;
+    }
+
+    @Override
+    public void writeField(FieldInfo fieldInfo, PointReader values) throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+      delegate.writeField(fieldInfo, values);
+    }
+
+    @Override
+    public void finish() throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+      delegate.finish();
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+    }
+
+    @Override
+    public void merge(MergeState mergeState) throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+      delegate.merge(mergeState);
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+    }
+
+    @Override
+    public void close() throws IOException {
+      delegate.close();
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+    }
+  }
+
+  static class CrankyPointReader extends PointReader {
+    final PointReader delegate;
+    final Random random;
+    public CrankyPointReader(PointReader delegate, Random random) {
+      this.delegate = delegate;
+      this.random = random;
+    }
+
+    @Override
+    public void checkIntegrity() throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }
+      delegate.checkIntegrity();
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+    }
+
+    @Override
+    public void intersect(String fieldName, IntersectVisitor visitor) throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }
+      delegate.intersect(fieldName, visitor);
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+    }
+
+    @Override
+    public byte[] getMinPackedValue(String fieldName) throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }
+      return delegate.getMinPackedValue(fieldName);
+    }
+
+    @Override
+    public byte[] getMaxPackedValue(String fieldName) throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }
+      return delegate.getMaxPackedValue(fieldName);
+    }
+
+    @Override
+    public int getNumDimensions(String fieldName) throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }
+      return delegate.getNumDimensions(fieldName);
+    }
+
+    @Override
+    public int getBytesPerDimension(String fieldName) throws IOException {
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }
+      return delegate.getBytesPerDimension(fieldName);
+    }
+
+    @Override
+    public void close() throws IOException {
+      delegate.close();
+      if (random.nextInt(100) == 0) {
+        throw new IOException("Fake IOException");
+      }  
+    }
+
+    @Override
+    public long ramBytesUsed() {
+      return delegate.ramBytesUsed();
+    }
+  }
+}