Author: shalin
Date: Sun Dec 28 23:39:26 2008
New Revision: 729834
URL: http://svn.apache.org/viewvc?rev=729834&view=rev
Log:
SOLR-902 -- FastInputStream#read(byte b[], int off, int len) gives incorrect
results when amount left to read is less than buffer size
Added:
lucene/solr/trunk/src/test/org/apache/solr/common/util/TestFastInputStream.java
(with props)
Modified:
lucene/solr/trunk/CHANGES.txt
lucene/solr/trunk/src/common/org/apache/solr/common/util/FastInputStream.java
Modified: lucene/solr/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=729834&r1=729833&r2=729834&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Sun Dec 28 23:39:26 2008
@@ -118,7 +118,7 @@
optimized distributed faceting refinement by lowering parsing overhead and
by making requests and responses smaller.
-25. SOLR-876: WordDelimiterFilter now supports a splitOnNumerics
+25. SOLR-876: WordDelimiterFilter now supports a splitOnNumerics
option, as well as a list of protected terms.
(Dan Rosher via hossman)
@@ -147,7 +147,7 @@
2. SOLR-771: CoreAdminHandler STATUS should display 'normalized' paths (koji,
hossman, shalin)
- 3. SOLR-532: WordDelimiterFilter now respects payloads and other attributes
of the original Token by
+ 3. SOLR-532: WordDelimiterFilter now respects payloads and other attributes
of the original Token by
using Token.clone() (Tricia Williams, gsingers)
4. SOLR-805: DisMax queries are not being cached in QueryResultCache (Todd
Feak via koji)
@@ -193,7 +193,7 @@
19. SOLR-802: Fix a potential null pointer error in the distributed
FacetComponent
(David Bowen via ryan)
-
+
20. SOLR-346: Use perl regex to improve accuracy of finding latest snapshot in
snapinstaller (billa)
21. SOLR-830: Use perl regex to improve accuracy of finding latest snapshot in
snappuller (billa)
@@ -202,6 +202,9 @@
23. SOLR-925: Fixed highlighting on fields with multiValued="true" and
termOffsets="true" (koji)
+24. SOLR-902: FastInputStream#read(byte b[], int off, int len) gives incorrect
results when amount left to read is less
+ than buffer size (Noble Paul via shalin)
+
Other Changes
----------------------
Modified:
lucene/solr/trunk/src/common/org/apache/solr/common/util/FastInputStream.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/src/common/org/apache/solr/common/util/FastInputStream.java?rev=729834&r1=729833&r2=729834&view=diff
==============================================================================
---
lucene/solr/trunk/src/common/org/apache/solr/common/util/FastInputStream.java
(original)
+++
lucene/solr/trunk/src/common/org/apache/solr/common/util/FastInputStream.java
Sun Dec 28 23:39:26 2008
@@ -105,7 +105,7 @@
return r;
}
- return -1;
+ return r > 0 ? r : -1;
}
@Override
Added:
lucene/solr/trunk/src/test/org/apache/solr/common/util/TestFastInputStream.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/common/util/TestFastInputStream.java?rev=729834&view=auto
==============================================================================
---
lucene/solr/trunk/src/test/org/apache/solr/common/util/TestFastInputStream.java
(added)
+++
lucene/solr/trunk/src/test/org/apache/solr/common/util/TestFastInputStream.java
Sun Dec 28 23:39:26 2008
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.common.util;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+import java.io.*;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * Test for FastInputStream.
+ *
+ * @version $Id$
+ * @see org.apache.solr.common.util.FastInputStream
+ */
+public class TestFastInputStream {
+ @Test
+ public void testgzip() throws Exception {
+ ByteArrayOutputStream b = new ByteArrayOutputStream();
+ FastOutputStream fos = new FastOutputStream(b);
+ GZIPOutputStream gzos = new GZIPOutputStream(fos);
+ String ss = "Helloooooooooooooooooooo";
+ writeChars(gzos, ss, 0, ss.length());
+ gzos.close();
+ NamedListCodec.writeVInt(10, fos);
+ fos.flushBuffer();
+ GZIPInputStream gzis = new GZIPInputStream(new
ByteArrayInputStream(b.toByteArray(), 0, b.size()));
+ char[] cbuf = new char[ss.length()];
+ readChars(gzis, cbuf, 0, ss.length());
+ assertEquals(new String(cbuf), ss);
+ System.out.println("passes w/o FastInputStream");
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(b.toByteArray(), 0,
b.size());
+ gzis = new GZIPInputStream(new FastInputStream(bis));
+ cbuf = new char[ss.length()];
+ readChars(gzis, cbuf, 0, ss.length());
+ assertEquals(new String(cbuf), ss);
+ System.out.println("passes w FastInputStream");
+
+
+ }
+
+ //code copied from NamedListCodec#readChars
+ public static void readChars(InputStream in, char[] buffer, int start, int
length)
+ throws IOException {
+ final int end = start + length;
+ for (int i = start; i < end; i++) {
+ int b = in.read();
+ if ((b & 0x80) == 0)
+ buffer[i] = (char) b;
+ else if ((b & 0xE0) != 0xE0) {
+ buffer[i] = (char) (((b & 0x1F) << 6)
+ | (in.read() & 0x3F));
+ } else
+ buffer[i] = (char) (((b & 0x0F) << 12)
+ | ((in.read() & 0x3F) << 6)
+ | (in.read() & 0x3F));
+ }
+ }
+
+ // code copied rfrom NamedlistCode#writechars
+ public static void writeChars(OutputStream os, String s, int start, int
length) throws IOException {
+ final int end = start + length;
+ for (int i = start; i < end; i++) {
+ final int code = (int) s.charAt(i);
+ if (code >= 0x01 && code <= 0x7F)
+ os.write(code);
+ else if (((code >= 0x80) && (code <= 0x7FF)) || code == 0) {
+ os.write(0xC0 | (code >> 6));
+ os.write(0x80 | (code & 0x3F));
+ } else {
+ os.write(0xE0 | (code >>> 12));
+ os.write(0x80 | ((code >> 6) & 0x3F));
+ os.write(0x80 | (code & 0x3F));
+ }
+ }
+ }
+}
Propchange:
lucene/solr/trunk/src/test/org/apache/solr/common/util/TestFastInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
lucene/solr/trunk/src/test/org/apache/solr/common/util/TestFastInputStream.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL