You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/11/15 06:44:38 UTC

svn commit: r1409653 - in /lucene/dev/branches/lucene4547/lucene: codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java core/src/test/org/apache/lucene/TestDemoDocValue.java

Author: rmuir
Date: Thu Nov 15 05:44:37 2012
New Revision: 1409653

URL: http://svn.apache.org/viewvc?rev=1409653&view=rev
Log:
fix simpletext to encode with biginteger

Modified:
    lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java
    lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/TestDemoDocValue.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=1409653&r1=1409652&r2=1409653&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 Thu Nov 15 05:44:37 2012
@@ -17,6 +17,8 @@ package org.apache.lucene.codecs.simplet
  * limitations under the License.
  */
 import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.ParseException;
@@ -149,7 +151,7 @@ public class SimpleTextSimpleDocValuesFo
       SimpleTextUtil.writeNewline(data);
 
       // build up our fixed-width "simple text packed ints" format
-      int maxBytesPerValue = Long.toString(maxValue - minValue).length();
+      int maxBytesPerValue = BigInteger.valueOf(maxValue).subtract(BigInteger.valueOf(minValue)).toString().length();
       StringBuilder sb = new StringBuilder();
       for (int i = 0; i < maxBytesPerValue; i++) {
         sb.append('0');
@@ -166,7 +168,7 @@ public class SimpleTextSimpleDocValuesFo
 
         @Override
         public void add(long value) throws IOException {
-          long delta = value - minValue;
+          Number delta = BigInteger.valueOf(value).subtract(BigInteger.valueOf(minValue));
           SimpleTextUtil.write(data, encoder.format(delta), scratch);
           SimpleTextUtil.writeNewline(data);
           numDocsWritten++;
@@ -510,6 +512,7 @@ public class SimpleTextSimpleDocValuesFo
         final DecimalFormat decoder = new DecimalFormat(field.pattern, new DecimalFormatSymbols(Locale.ROOT));
 
         if (DocValues.isNumber(dvType)) {
+          decoder.setParseBigDecimal(true);
           return new Source(dvType) {
             @Override
             public long getInt(int docID) {
@@ -520,7 +523,8 @@ public class SimpleTextSimpleDocValuesFo
                 in.seek(field.dataStartFilePointer + (1+field.pattern.length())*docID);
                 SimpleTextUtil.readLine(in, scratch);
                 System.out.println("parsing delta: " + scratch.utf8ToString());
-                return field.minValue + decoder.parse(scratch.utf8ToString(), new ParsePosition(0)).longValue();
+                BigDecimal bd = (BigDecimal) decoder.parse(scratch.utf8ToString(), new ParsePosition(0));
+                return BigInteger.valueOf(field.minValue).add(bd.toBigIntegerExact()).longValue();
               } catch (IOException ioe) {
                 throw new RuntimeException(ioe);
               }

Modified: lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/TestDemoDocValue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/TestDemoDocValue.java?rev=1409653&r1=1409652&r2=1409653&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/TestDemoDocValue.java (original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/TestDemoDocValue.java Thu Nov 15 05:44:37 2012
@@ -122,7 +122,6 @@ public class TestDemoDocValue extends Lu
     directory.close();
   }
 
-  @Ignore("get ST to use bigdecimal, also negatives are maybe not working yet!")
   public void testBigRange() throws IOException {
     Analyzer analyzer = new MockAnalyzer(random());