lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r829530 - in /lucene/java/trunk/src/java/org/apache/lucene: index/SegmentReader.java store/LockStressTest.java store/MMapDirectory.java
Date Sun, 25 Oct 2009 10:51:53 GMT
Author: uschindler
Date: Sun Oct 25 10:51:53 2009
New Revision: 829530

URL: http://svn.apache.org/viewvc?rev=829530&view=rev
Log:
Some more cleanups and removal of deprecated SegmentReader GCJ settings

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/java/org/apache/lucene/store/LockStressTest.java
    lucene/java/trunk/src/java/org/apache/lucene/store/MMapDirectory.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=829530&r1=829529&r2=829530&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Sun Oct 25 10:51:53
2009
@@ -543,45 +543,6 @@
 
   Map<String,Norm> norms = new HashMap<String,Norm>();
   
-  /** The class which implements SegmentReader. */
-  // @deprecated (LUCENE-1677)
-  private static Class IMPL;
-  static {
-    try {
-      String name =
-        System.getProperty("org.apache.lucene.SegmentReader.class",
-                           SegmentReader.class.getName());
-      IMPL = Class.forName(name);
-    } catch (ClassNotFoundException e) {
-      throw new RuntimeException("cannot load SegmentReader class: " + e, e);
-    } catch (SecurityException se) {
-      try {
-        IMPL = Class.forName(SegmentReader.class.getName());
-      } catch (ClassNotFoundException e) {
-        throw new RuntimeException("cannot load default SegmentReader class: " + e, e);
-      }
-    }
-  }
-
-  // @deprecated (LUCENE-1677)
-  private static Class READONLY_IMPL;
-  static {
-    try {
-      String name =
-        System.getProperty("org.apache.lucene.ReadOnlySegmentReader.class",
-                           ReadOnlySegmentReader.class.getName());
-      READONLY_IMPL = Class.forName(name);
-    } catch (ClassNotFoundException e) {
-      throw new RuntimeException("cannot load ReadOnlySegmentReader class: " + e, e);
-    } catch (SecurityException se) {
-      try {
-        READONLY_IMPL = Class.forName(ReadOnlySegmentReader.class.getName());
-      } catch (ClassNotFoundException e) {
-        throw new RuntimeException("cannot load default ReadOnlySegmentReader class: " +
e, e);
-      }
-    }
-  }
-
   /**
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
@@ -601,15 +562,7 @@
                                   boolean doOpenStores,
                                   int termInfosIndexDivisor)
     throws CorruptIndexException, IOException {
-    SegmentReader instance;
-    try {
-      if (readOnly)
-        instance = (SegmentReader)READONLY_IMPL.newInstance();
-      else
-        instance = (SegmentReader)IMPL.newInstance();
-    } catch (Exception e) {
-      throw new RuntimeException("cannot load SegmentReader class: " + e, e);
-    }
+    SegmentReader instance = readOnly ? new ReadOnlySegmentReader() : new SegmentReader();
     instance.readOnly = readOnly;
     instance.si = si;
     instance.readBufferSize = readBufferSize;
@@ -717,15 +670,7 @@
     assert !doClone || (normsUpToDate && deletionsUpToDate);
 
     // clone reader
-    SegmentReader clone;
-    try {
-      if (openReadOnly)
-        clone = (SegmentReader) READONLY_IMPL.newInstance();
-      else
-        clone = (SegmentReader) IMPL.newInstance();
-    } catch (Exception e) {
-      throw new RuntimeException("cannot load SegmentReader class: " + e, e);
-    }
+    SegmentReader clone = openReadOnly ? new ReadOnlySegmentReader() : new SegmentReader();
 
     boolean success = false;
     try {

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/LockStressTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/LockStressTest.java?rev=829530&r1=829529&r2=829530&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/LockStressTest.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/LockStressTest.java Sun Oct 25 10:51:53
2009
@@ -65,30 +65,23 @@
     final String lockDirName = args[4];
     final int sleepTimeMS = Integer.parseInt(args[5]);
 
-    Class c;
-    try {
-      c = Class.forName(lockFactoryClassName);
-    } catch (ClassNotFoundException e) {
-      throw new IOException("unable to find LockClass " + lockFactoryClassName);
-    }
-
     LockFactory lockFactory;
     try {
-      lockFactory = (LockFactory) c.newInstance();          
+      lockFactory = Class.forName(lockFactoryClassName).asSubclass(LockFactory.class).newInstance();
         
     } catch (IllegalAccessException e) {
       throw new IOException("IllegalAccessException when instantiating LockClass " + lockFactoryClassName);
     } catch (InstantiationException e) {
       throw new IOException("InstantiationException when instantiating LockClass " + lockFactoryClassName);
     } catch (ClassCastException e) {
       throw new IOException("unable to cast LockClass " + lockFactoryClassName + " instance
to a LockFactory");
+    } catch (ClassNotFoundException e) {
+      throw new IOException("unable to find LockClass " + lockFactoryClassName);
     }
 
     File lockDir = new File(lockDirName);
 
-    if (lockFactory instanceof NativeFSLockFactory) {
-      ((NativeFSLockFactory) lockFactory).setLockDir(lockDir);
-    } else if (lockFactory instanceof SimpleFSLockFactory) {
-      ((SimpleFSLockFactory) lockFactory).setLockDir(lockDir);
+    if (lockFactory instanceof FSLockFactory) {
+      ((FSLockFactory) lockFactory).setLockDir(lockDir);
     }
 
     lockFactory.setLockPrefix("test");

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/MMapDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/MMapDirectory.java?rev=829530&r1=829529&r2=829530&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/MMapDirectory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/MMapDirectory.java Sun Oct 25 10:51:53
2009
@@ -91,9 +91,6 @@
     super(path, null);
   }
 
-  static final Class[] NO_PARAM_TYPES = new Class[0];
-  static final Object[] NO_PARAMS = new Object[0];
-  
   private boolean useUnmapHack = false;
   private int maxBBuf = Constants.JRE_IS_64BIT ? Integer.MAX_VALUE : (256*1024*1024);
   
@@ -106,7 +103,7 @@
     try {
       Class.forName("sun.misc.Cleaner");
       Class.forName("java.nio.DirectByteBuffer")
-        .getMethod("cleaner", NO_PARAM_TYPES);
+        .getMethod("cleaner");
       v = true;
     } catch (Exception e) {
       v = false;
@@ -151,12 +148,12 @@
         AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
           public Object run() throws Exception {
             final Method getCleanerMethod = buffer.getClass()
-              .getMethod("cleaner", NO_PARAM_TYPES);
+              .getMethod("cleaner");
             getCleanerMethod.setAccessible(true);
-            final Object cleaner = getCleanerMethod.invoke(buffer, NO_PARAMS);
+            final Object cleaner = getCleanerMethod.invoke(buffer);
             if (cleaner != null) {
-              cleaner.getClass().getMethod("clean", NO_PARAM_TYPES)
-                .invoke(cleaner, NO_PARAMS);
+              cleaner.getClass().getMethod("clean")
+                .invoke(cleaner);
             }
             return null;
           }



Mime
View raw message