You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by lu...@apache.org on 2022/06/14 05:03:25 UTC
[lucene] branch main updated: LUCENE-10598: Use count to record docValueCount similar to SortedNumericDocValues did (#942)
This is an automated email from the ASF dual-hosted git repository.
luxugang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 7504b0a258d LUCENE-10598: Use count to record docValueCount similar to SortedNumericDocValues did (#942)
7504b0a258d is described below
commit 7504b0a258d3c3209110e6476072b6ca6a2e82ff
Author: Lu Xugang <q1...@Gmail.com>
AuthorDate: Tue Jun 14 13:03:19 2022 +0800
LUCENE-10598: Use count to record docValueCount similar to SortedNumericDocValues did (#942)
---
.../lucene80/Lucene80DocValuesProducer.java | 12 ++++++++----
.../core/src/java/org/apache/lucene/index/CheckIndex.java | 15 +++++++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene80/Lucene80DocValuesProducer.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene80/Lucene80DocValuesProducer.java
index 32a898db09d..60c6b36fbc6 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene80/Lucene80DocValuesProducer.java
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene80/Lucene80DocValuesProducer.java
@@ -1560,8 +1560,8 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
return new BaseSortedSetDocValues(entry, data) {
int doc = -1;
- long start;
- long end;
+ long start, end;
+ long count;
@Override
public int nextDoc() throws IOException {
@@ -1585,6 +1585,7 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
}
start = addresses.get(target);
end = addresses.get(target + 1L);
+ count = (end - start);
return doc = target;
}
@@ -1592,6 +1593,7 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
public boolean advanceExact(int target) throws IOException {
start = addresses.get(target);
end = addresses.get(target + 1L);
+ count = (end - start);
doc = target;
return true;
}
@@ -1606,7 +1608,7 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
@Override
public long docValueCount() {
- return end - start;
+ return count;
}
};
} else {
@@ -1624,6 +1626,7 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
boolean set;
long start;
long end = 0;
+ long count;
@Override
public int nextDoc() throws IOException {
@@ -1658,6 +1661,7 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
final int index = disi.index();
start = addresses.get(index);
end = addresses.get(index + 1L);
+ count = end - start;
set = true;
return true;
}
@@ -1678,7 +1682,7 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
@Override
public long docValueCount() {
set();
- return end - start;
+ return count;
}
};
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
index 2b47c6fdcbb..81e9eb2cd48 100644
--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
@@ -3357,6 +3357,14 @@ public final class CheckIndex implements Closeable {
long ord;
int ordCount = 0;
while ((ord = dv.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
+ if (count != dv.docValueCount()) {
+ throw new CheckIndexException(
+ "value count changed from "
+ + count
+ + " to "
+ + dv.docValueCount()
+ + " during iterating over all values");
+ }
long ord2 = dv2.nextOrd();
if (ord != ord2) {
throw new CheckIndexException(
@@ -3374,6 +3382,13 @@ public final class CheckIndex implements Closeable {
seenOrds.set(ord);
ordCount++;
}
+ if (dv.docValueCount() != dv2.docValueCount()) {
+ throw new CheckIndexException(
+ "dv and dv2 report different values count after iterating over all values: "
+ + dv.docValueCount()
+ + " != "
+ + dv2.docValueCount());
+ }
if (ordCount == 0) {
throw new CheckIndexException(
"dv for field: " + fieldName + " returned docID=" + docID + " yet has no ordinals");