lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1441543 - in /lucene/dev/branches/lucene4547/lucene: core/src/java/org/apache/lucene/index/ core/src/java/org/apache/lucene/util/ core/src/test/org/apache/lucene/util/ suggest/src/java/org/apache/lucene/search/suggest/
Date Fri, 01 Feb 2013 17:21:03 GMT
Author: rmuir
Date: Fri Feb  1 17:21:03 2013
New Revision: 1441543

URL: http://svn.apache.org/viewvc?rev=1441543&view=rev
Log:
fix bytesref problems in readBytes, just take byte[],int,int

Modified:
    lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.java
    lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java
    lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java
    lucene/dev/branches/lucene4547/lucene/suggest/src/java/org/apache/lucene/search/suggest/BytesRefArray.java

Modified: lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.java?rev=1441543&r1=1441542&r2=1441543&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.java
Fri Feb  1 17:21:03 2013
@@ -112,7 +112,9 @@ class BinaryDocValuesWriter extends DocV
       }
       if (upto < size) {
         int length = (int) lengthsIterator.next();
-        pool.readBytes(value, byteOffset, length);
+        value.grow(length);
+        value.length = length;
+        pool.readBytes(byteOffset, value.bytes, value.offset, value.length);
         byteOffset += length;
       } else {
         // This is to handle last N documents not having

Modified: lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java?rev=1441543&r1=1441542&r2=1441543&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java
Fri Feb  1 17:21:03 2013
@@ -327,32 +327,29 @@ public final class ByteBlockPool {
   
   /**
    * Reads bytes bytes out of the pool starting at the given offset with the given  
-   * length into the given {@link BytesRef} at offset <tt>0</tt>.
+   * length into the given byte array at offset <tt>off</tt>.
    * <p>Note: this method allows to copy across block boundaries.</p>
    */
-  public void readBytes(final BytesRef bytes, final long offset, final int length) {
-    bytes.offset = 0;
-    bytes.grow(length);
-    bytes.length = length;
+  public void readBytes(final long offset, final byte bytes[], final int off, final int length)
{
     if (length == 0) {
       return;
     }
+    int bytesOffset = off;
+    int bytesLength = length;
     int bufferIndex = (int) (offset >> BYTE_BLOCK_SHIFT);
     byte[] buffer = buffers[bufferIndex];
     int pos = (int) (offset & BYTE_BLOCK_MASK);
     int overflow = (pos + length) - BYTE_BLOCK_SIZE;
     do {
       if (overflow <= 0) {
-        System.arraycopy(buffer, pos, bytes.bytes, bytes.offset, bytes.length);
-        bytes.length = length;
-        bytes.offset = 0;
+        System.arraycopy(buffer, pos, bytes, bytesOffset, bytesLength);
         break;
       } else {
         final int bytesToCopy = length - overflow;
-        System.arraycopy(buffer, pos, bytes.bytes, bytes.offset, bytesToCopy);
+        System.arraycopy(buffer, pos, bytes, bytesOffset, bytesToCopy);
         pos = 0;
-        bytes.length -= bytesToCopy;
-        bytes.offset += bytesToCopy;
+        bytesLength -= bytesToCopy;
+        bytesOffset += bytesToCopy;
         buffer = buffers[++bufferIndex];
         overflow = overflow - BYTE_BLOCK_SIZE;
       }

Modified: lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java?rev=1441543&r1=1441542&r2=1441543&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java
Fri Feb  1 17:21:03 2013
@@ -43,7 +43,9 @@ public class TestByteBlockPool extends L
       // verify
       long position = 0;
       for (BytesRef expected : list) {
-        pool.readBytes(ref, position, expected.length);
+        ref.grow(expected.length);
+        ref.length = expected.length;
+        pool.readBytes(position, ref.bytes, ref.offset, ref.length);
         assertEquals(expected, ref);
         position += ref.length;
       }

Modified: lucene/dev/branches/lucene4547/lucene/suggest/src/java/org/apache/lucene/search/suggest/BytesRefArray.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/suggest/src/java/org/apache/lucene/search/suggest/BytesRefArray.java?rev=1441543&r1=1441542&r2=1441543&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/suggest/src/java/org/apache/lucene/search/suggest/BytesRefArray.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/suggest/src/java/org/apache/lucene/search/suggest/BytesRefArray.java
Fri Feb  1 17:21:03 2013
@@ -104,7 +104,10 @@ public final class BytesRefArray {
       int offset = offsets[ord];
       int length = ord == lastElement - 1 ? currentOffset - offset
           : offsets[ord + 1] - offset;
-      pool.readBytes(spare, offset, length);
+      assert spare.offset == 0;
+      spare.grow(length);
+      spare.length = length;
+      pool.readBytes(offset, spare.bytes, spare.offset, spare.length);
       return spare;
     }
     throw new IndexOutOfBoundsException("index " + ord



Mime
View raw message