You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by is...@apache.org on 2025/08/07 15:02:21 UTC
(solr) 04/14: SOLR-17631: Fixing field cache ords counting, fixes TestFieldCache and TestFieldCacheVsDocValues
This is an automated email from the ASF dual-hosted git repository.
ishan pushed a commit to branch ishan/upgrade-to-lucene-10
in repository https://gitbox.apache.org/repos/asf/solr.git
commit d3d7d05122fc85d7a7f014b3b461c268f387ecdc
Author: Ishan Chattopadhyaya <ic...@gmail.com>
AuthorDate: Wed Aug 6 16:21:50 2025 +0530
SOLR-17631: Fixing field cache ords counting, fixes TestFieldCache and TestFieldCacheVsDocValues
---
.../src/java/org/apache/solr/uninverting/DocTermOrds.java | 6 ++++--
.../src/test/org/apache/solr/uninverting/TestFieldCache.java | 12 ++++++------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java b/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java
index 74d886c0235..55071e4d856 100644
--- a/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java
+++ b/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java
@@ -816,9 +816,10 @@ public class DocTermOrds implements Accountable {
// This value was inlined, and then read into a single buffer
return bufferLength;
} else {
- // scan logic taken from read()
+ // scan logic taken from read() - count the number of term ordinals
int start = index[doc] & 0x7fffffff;
int cursor = start;
+ int count = 0;
for (; ; ) {
int delta = 0;
for (; ; ) {
@@ -827,9 +828,10 @@ public class DocTermOrds implements Accountable {
if ((b & 0x80) == 0) break;
}
if (delta == 0) break;
+ count++;
}
- return cursor - start - 1;
+ return count;
}
}
diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCache.java b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCache.java
index c0d7985955f..9c6bb0a9969 100644
--- a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCache.java
+++ b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCache.java
@@ -269,22 +269,22 @@ public class TestFieldCache extends SolrTestCase {
termOrds = cache.getDocTermOrds(reader, "theRandomUnicodeMultiValuedField", null);
assertEquals(numEntries, cache.getCacheEntries().length);
- for (int i = 0; i < NUM_DOCS; i++) {
+ int doc;
+ while ((doc = termOrds.nextDoc()) != NO_MORE_DOCS) {
// This will remove identical terms. A DocTermOrds doesn't return duplicate ords for a docId
- List<BytesRef> values = new ArrayList<>(new LinkedHashSet<>(Arrays.asList(multiValued[i])));
+ List<BytesRef> values = new ArrayList<>(new LinkedHashSet<>(Arrays.asList(multiValued[doc])));
+ int processedValues = 0;
for (BytesRef v : values) {
if (v == null) {
// why does this test use null values... instead of an empty list: confusing
break;
}
- if (i > termOrds.docID()) {
- assertEquals(i, termOrds.nextDoc());
- }
long ord = termOrds.nextOrd();
BytesRef scratch = termOrds.lookupOrd(ord);
assertEquals(v, scratch);
+ processedValues++;
}
- assertEquals(i, termOrds.docValueCount());
+ assertEquals(processedValues, termOrds.docValueCount());
}
// test bad field