lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r507009 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/FieldsReader.java src/test/org/apache/lucene/index/TestFieldsReader.java
Date Tue, 13 Feb 2007 14:06:53 GMT
Author: gsingers
Date: Tue Feb 13 06:06:52 2007
New Revision: 507009

URL: http://svn.apache.org/viewvc?view=rev&rev=507009
Log:
LUCENE-799:  Added support for Lazy compressed string fields.  Thanks to Mike Klaas.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=507009&r1=507008&r2=507009
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Feb 13 06:06:52 2007
@@ -113,6 +113,8 @@
     which allow one to retrieve the size of a field without retrieving the actual field.
     (Chuck Williams via Grant Ingersoll)
 
+15. LUCENE-799: Properly handle lazy, compressed fields.  (Mike Klaas via Grant Ingersoll)
+
 API Changes
 
  1. LUCENE-438: Remove "final" from Token, implement Cloneable, allow

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java?view=diff&rev=507009&r1=507008&r2=507009
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java Tue Feb 13 06:06:52
2007
@@ -362,10 +362,16 @@
         IndexInput localFieldsStream = getFieldStream();
         try {
           localFieldsStream.seek(pointer);
-          //read in chars b/c we already know the length we need to read
-          char[] chars = new char[toRead];
-          localFieldsStream.readChars(chars, 0, toRead);
-          fieldsData = new String(chars);
+          if (isCompressed) {
+            final byte[] b = new byte[toRead];
+            localFieldsStream.readBytes(b, 0, b.length);
+            fieldsData = new String(uncompress(b), "UTF-8");
+          } else {
+            //read in chars b/c we already know the length we need to read
+            char[] chars = new char[toRead];
+            localFieldsStream.readChars(chars, 0, toRead);
+            fieldsData = new String(chars);
+          }
         } catch (IOException e) {
           throw new FieldReaderException(e);
         }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java?view=diff&rev=507009&r1=507008&r2=507009
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java Tue Feb 13 06:06:52
2007
@@ -93,6 +93,7 @@
     lazyFieldNames.add(DocHelper.LAZY_FIELD_KEY);
     lazyFieldNames.add(DocHelper.LAZY_FIELD_BINARY_KEY);
     lazyFieldNames.add(DocHelper.TEXT_FIELD_UTF2_KEY);
+    lazyFieldNames.add(DocHelper.COMPRESSED_TEXT_FIELD_2_KEY);
     SetBasedFieldSelector fieldSelector = new SetBasedFieldSelector(loadFieldNames, lazyFieldNames);
     Document doc = reader.doc(0, fieldSelector);
     assertTrue("doc is null and it shouldn't be", doc != null);
@@ -102,6 +103,12 @@
     String value = field.stringValue();
     assertTrue("value is null and it shouldn't be", value != null);
     assertTrue(value + " is not equal to " + DocHelper.LAZY_FIELD_TEXT, value.equals(DocHelper.LAZY_FIELD_TEXT)
== true);
+    field = doc.getFieldable(DocHelper.COMPRESSED_TEXT_FIELD_2_KEY);
+    assertTrue("field is null and it shouldn't be", field != null);
+    assertTrue("field is not lazy and it should be", field.isLazy());
+    value = field.stringValue();
+    assertTrue("value is null and it shouldn't be", value != null);
+    assertTrue(value + " is not equal to " + DocHelper.FIELD_2_COMPRESSED_TEXT, value.equals(DocHelper.FIELD_2_COMPRESSED_TEXT)
== true);
     field = doc.getFieldable(DocHelper.TEXT_FIELD_1_KEY);
     assertTrue("field is null and it shouldn't be", field != null);
     assertTrue("Field is lazy and it should not be", field.isLazy() == false);



Mime
View raw message