You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2010/05/03 20:06:50 UTC

svn commit: r940545 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/NumericUtils.java

Author: uschindler
Date: Mon May  3 18:06:49 2010
New Revision: 940545

URL: http://svn.apache.org/viewvc?rev=940545&view=rev
Log:
LUCENE-2438: Fix encoding in NumericUtils to also set offset to 0 (and javadocs)

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/NumericUtils.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/NumericUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/NumericUtils.java?rev=940545&r1=940544&r2=940545&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/NumericUtils.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/NumericUtils.java Mon May  3 18:06:49 2010
@@ -99,6 +99,7 @@ public final class NumericUtils {
   /**
    * Returns prefix coded bits after reducing the precision by <code>shift</code> bits.
    * This is method is used by {@link NumericTokenStream}.
+   * After encoding, {@code bytes.offset} will always be 0. 
    * @param val the numeric value
    * @param shift how many bits to strip from the right
    * @param bytes will contain the encoded value
@@ -108,6 +109,7 @@ public final class NumericUtils {
     if (shift>63 || shift<0)
       throw new IllegalArgumentException("Illegal shift value, must be 0..63");
     int hash, nChars = (63-shift)/7 + 1;
+    bytes.offset = 0;
     bytes.length = nChars+1;
     if (bytes.bytes.length < bytes.length) {
       bytes.grow(NumericUtils.BUF_SIZE_LONG);
@@ -157,6 +159,7 @@ public final class NumericUtils {
   /**
    * Returns prefix coded bits after reducing the precision by <code>shift</code> bits.
    * This is method is used by {@link NumericTokenStream}.
+   * After encoding, {@code bytes.offset} will always be 0. 
    * @param val the numeric value
    * @param shift how many bits to strip from the right
    * @param bytes will contain the encoded value
@@ -166,6 +169,7 @@ public final class NumericUtils {
     if (shift>31 || shift<0)
       throw new IllegalArgumentException("Illegal shift value, must be 0..31");
     int hash, nChars = (31-shift)/7 + 1;
+    bytes.offset = 0;
     bytes.length = nChars+1;
     if (bytes.bytes.length < bytes.length) {
       bytes.grow(NumericUtils.BUF_SIZE_INT);