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 2012/11/09 19:47:12 UTC

svn commit: r1407588 - in /lucene/dev/branches/lucene4547/lucene: codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java core/src/java/org/apache/lucene/index/DocValues.java

Author: mikemccand
Date: Fri Nov  9 18:47:12 2012
New Revision: 1407588

URL: http://svn.apache.org/viewvc?rev=1407588&view=rev
Log:
start at ST producer

Modified:
    lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java
    lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/DocValues.java

Modified: lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java?rev=1407588&r1=1407587&r2=1407588&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java (original)
+++ lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java Fri Nov  9 18:47:12 2012
@@ -241,7 +241,7 @@ public class SimpleTextSimpleDocValuesFo
       String pattern;
       int maxLength;
       int minValue;
-    }
+    };
 
     final IndexInput data;
     final BytesRef scratch = new BytesRef();
@@ -307,10 +307,63 @@ public class SimpleTextSimpleDocValuesFo
       }
     }
 
+    class SimpleTextDocValues extends DocValues {
+      private final OneField field;
+
+      public SimpleTextDocValues(OneField field) {
+        this.field = field;
+      }
+
+      @Override
+      public Source loadSource() throws IOException {
+        // nocommit todo
+        return null;
+      }
+
+      @Override
+      public DocValues.Type getType() {
+        return field.fieldInfo.getDocValuesType();
+      }
+
+      @Override
+      public Source loadDirectSource() throws IOException {
+        DocValues.Type dvType = field.fieldInfo.getDocValuesType();
+        if (DocValues.isNumber(dvType)) {
+          final IndexInput in = data.clone();
+          final BytesRef scratch = new BytesRef();
+          final DecimalFormat decoder = new DecimalFormat(field.pattern, new DecimalFormatSymbols(Locale.ROOT));
+          final ParsePosition pos = new ParsePosition(0);
+          return new Source(dvType) {
+            @Override
+            public long getInt(int docID) {
+              try {
+                in.seek(field.dataStartFilePointer + (1+field.pattern.length())*docID);
+                SimpleTextUtil.readLine(in, scratch);
+                return decoder.parse(scratch.utf8ToString(), pos).longValue();
+              } catch (IOException ioe) {
+                throw new RuntimeException(ioe);
+              }
+            }
+          };
+        } else if (DocValues.isBytes(dvType)) {
+          // nocommit
+          return null;
+        } else if (DocValues.isSortedBytes(dvType)) {
+          // nocommit
+          return null;
+        }
+        // nocommit
+        return null;
+      }
+    }
+
     @Override
     public DocValues docValues(String fieldName) {
-      // nocommit TODO
-      return null;
+      OneField field = fields.get(fieldName);
+      if (field == null) {
+        return null;
+      }
+      return new SimpleTextDocValues(field);
     }
 
     @Override

Modified: lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/DocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/DocValues.java?rev=1407588&r1=1407587&r2=1407588&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/DocValues.java (original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/DocValues.java Fri Nov  9 18:47:12 2012
@@ -511,6 +511,44 @@ public abstract class DocValues implemen
       }
     };
   }
+
+  // nocommit nuke
+  public static boolean isSortedBytes(Type type) {
+    switch(type) {
+    case BYTES_VAR_SORTED:
+    case BYTES_FIXED_SORTED:
+    case BYTES_VAR_DEREF:
+    case BYTES_FIXED_DEREF:
+      return true;
+    default:
+      return false;
+    }
+  }
+
+  // nocommit nuke
+  public static boolean isBytes(Type type) {
+    switch(type) {
+    case BYTES_VAR_STRAIGHT:
+    case BYTES_FIXED_STRAIGHT:
+      return true;
+    default:
+      return false;
+    }
+  }
+
+  // nocommit nuke
+  public static boolean isNumber(Type type) {
+    switch(type) {
+    case VAR_INTS:
+    case FIXED_INTS_8:
+    case FIXED_INTS_16:
+    case FIXED_INTS_32:
+    case FIXED_INTS_64:
+      return true;
+    default:
+      return false;
+    }
+  }
   
   /**
    * <code>Type</code> specifies the {@link DocValues} type for a