Index: src/java/org/apache/lucene/search/ExtendedFieldCacheImpl.java
===================================================================
--- src/java/org/apache/lucene/search/ExtendedFieldCacheImpl.java	(revision 598393)
+++ src/java/org/apache/lucene/search/ExtendedFieldCacheImpl.java	(working copy)
@@ -25,18 +25,7 @@
       }
   };
 
-  private static final ByteParser BYTE_PARSER = new ByteParser() {
-    public byte parseByte(String string) {
-      return Byte.parseByte(string);
-    }
-  };
 
-  private static final ShortParser SHORT_PARSER = new ShortParser() {
-    public short parseShort(String string) {
-      return Short.parseShort(string);
-    }
-  };
-
   public long[] getLongs(IndexReader reader, String field) throws IOException {
     return getLongs(reader, field, LONG_PARSER);
   }
@@ -114,4 +103,63 @@
       return retArray;
     }
   };
+
+
+  // inherit javadocs
+  public Object getAuto(IndexReader reader, String field) throws IOException {
+    return autoCache.get(reader, field);
+  }
+
+  Cache autoCache = new Cache() {
+
+    protected Object createValue(IndexReader reader, Object fieldKey)
+        throws IOException {
+      String field = ((String)fieldKey).intern();
+      TermEnum enumerator = reader.terms (new Term (field, ""));
+      try {
+        Term term = enumerator.term();
+        if (term == null) {
+          throw new RuntimeException ("no terms in field " + field + " - cannot determine sort type");
+        }
+        Object ret = null;
+        if (term.field() == field) {
+          String termtext = term.text().trim();
+
+          /**
+           * Java 1.4 level code:
+
+           if (pIntegers.matcher(termtext).matches())
+           return IntegerSortedHitQueue.comparator (reader, enumerator, field);
+
+           else if (pFloats.matcher(termtext).matches())
+           return FloatSortedHitQueue.comparator (reader, enumerator, field);
+           */
+
+          // Java 1.3 level code:
+          try {
+            Integer.parseInt (termtext);
+            ret = getInts (reader, field);
+          } catch (NumberFormatException nfe1) {
+            try {
+              Long.parseLong(termtext);
+              ret = getLongs (reader, field);
+            } catch (NumberFormatException nfe2) {
+              try {
+                Float.parseFloat (termtext);
+                ret = getFloats (reader, field);
+              } catch (NumberFormatException nfe3) {
+                ret = getStringIndex (reader, field);
+              }
+            }
+          }
+        } else {
+          throw new RuntimeException ("field \"" + field + "\" does not appear to be indexed");
+        }
+        return ret;
+      } finally {
+        enumerator.close();
+      }
+    }
+  };
+
 }
Index: src/java/org/apache/lucene/search/FieldSortedHitQueue.java
===================================================================
--- src/java/org/apache/lucene/search/FieldSortedHitQueue.java	(revision 598393)
+++ src/java/org/apache/lucene/search/FieldSortedHitQueue.java	(working copy)
@@ -404,7 +404,7 @@
   static ScoreDocComparator comparatorAuto (final IndexReader reader, final String fieldname)
   throws IOException {
     final String field = fieldname.intern();
-    Object lookupArray = FieldCache.DEFAULT.getAuto (reader, field);
+    Object lookupArray = ExtendedFieldCache.EXT_DEFAULT.getAuto (reader, field);
     if (lookupArray instanceof FieldCache.StringIndex) {
       return comparatorString (reader, field);
     } else if (lookupArray instanceof int[]) {
Index: src/java/org/apache/lucene/search/FieldCacheImpl.java
===================================================================
--- src/java/org/apache/lucene/search/FieldCacheImpl.java	(revision 598393)
+++ src/java/org/apache/lucene/search/FieldCacheImpl.java	(working copy)
@@ -21,13 +21,12 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.index.TermEnum;
-import org.apache.lucene.search.ExtendedFieldCache.LongParser;
 
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.WeakHashMap;
-import java.util.HashMap;
 
 /**
  * Expert: The default cache implementation, storing all values in memory.
@@ -150,11 +149,6 @@
       }
   };
 
-  private static final LongParser LONG_PARSER = new LongParser() {
-    public long parseLong(String value) {
-      return Long.parseLong(value);
-    }
-  };
 
   private static final FloatParser FLOAT_PARSER = new FloatParser() {
       public float parseFloat(String value) {
@@ -279,46 +273,8 @@
     }
   };
 
-  // inherit javadocs
-  public long[] getLongs (IndexReader reader, String field) throws IOException {
-    return getLongs(reader, field, LONG_PARSER);
-  }
 
   // inherit javadocs
-  public long[] getLongs(IndexReader reader, String field, LongParser parser)
-      throws IOException {
-    return (long[]) longsCache.get(reader, new Entry(field, parser));
-  }
-
-  Cache longsCache = new Cache() {
-
-    protected Object createValue(IndexReader reader, Object entryKey)
-        throws IOException {
-      Entry entry = (Entry) entryKey;
-      String field = entry.field;
-      LongParser parser = (LongParser) entry.custom;
-      final long[] retArray = new long[reader.maxDoc()];
-      TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field, ""));
-      try {
-        do {
-          Term term = termEnum.term();
-          if (term==null || term.field() != field) break;
-          long termval = parser.parseLong(term.text());
-          termDocs.seek (termEnum);
-          while (termDocs.next()) {
-            retArray[termDocs.doc()] = termval;
-          }
-        } while (termEnum.next());
-      } finally {
-        termDocs.close();
-        termEnum.close();
-      }
-      return retArray;
-    }
-  };
-
-  // inherit javadocs
   public float[] getFloats (IndexReader reader, String field)
     throws IOException {
     return getFloats(reader, field, FLOAT_PARSER);
@@ -501,16 +457,11 @@
             ret = getInts (reader, field);
           } catch (NumberFormatException nfe1) {
             try {
-              Long.parseLong(termtext);
-              ret = getLongs (reader, field);
-            } catch (NumberFormatException nfe2) {
-              try {
                 Float.parseFloat (termtext);
                 ret = getFloats (reader, field);
               } catch (NumberFormatException nfe3) {
                 ret = getStringIndex (reader, field);
               }
-            }
           }          
         } else {
           throw new RuntimeException ("field \"" + field + "\" does not appear to be indexed");
