LUCENE-1318: InstantiatedIndexReader.norms(String, b[], int) didn't treat the array offset right.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@672568 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Karl-Johan Wettin 2008-06-28 18:52:12 +00:00
parent b8fc54e72a
commit 4f7ead8112
3 changed files with 18 additions and 1 deletions

View File

@ -16,6 +16,9 @@ Bug fixes
and tests that assert that deleted documents behaves as they should (they did).
(Jason Rutherglen, Karl Wettin)
2. LUCENE-1318: InstantiatedIndexReader.norms(String, b[], int) didn't treat
the array offset right. (Jason Rutherglen via Karl Wettin)
New features
(None)

View File

@ -294,7 +294,7 @@ public class InstantiatedIndexReader extends IndexReader {
public void norms(String field, byte[] bytes, int offset) throws IOException {
byte[] norms = getIndex().getNormsByFieldNameAndDocumentNumber().get(field);
System.arraycopy(norms, offset, bytes, 0, norms.length);
System.arraycopy(norms, 0, bytes, offset, norms.length);
}
protected void doSetNorm(int doc, String field, byte value) throws IOException {

View File

@ -252,6 +252,20 @@ public class TestIndicesEquals extends TestCase {
}
// test norms as used by multireader
aprioriNorms = new byte[aprioriReader.maxDoc() + 10];
aprioriReader.norms((String) field, aprioriNorms, 10);
testNorms = new byte[testReader.maxDoc() + 10];
testReader.norms((String) field, testNorms, 10);
assertEquals(aprioriNorms.length, testNorms.length);
for (int i = 0; i < aprioriNorms.length; i++) {
assertEquals("norms does not equals for field " + field + " in document " + i, aprioriNorms[i], testNorms[i]);
}
}
for (int docIndex = 0; docIndex < aprioriReader.numDocs(); docIndex++) {