jpountz commented on a change in pull request #320:
URL: https://github.com/apache/lucene/pull/320#discussion_r716936132
##########
File path: lucene/core/src/java/org/apache/lucene/index/DocValues.java
##########
@@ -157,97 +157,12 @@ public int getValueCount() {
/** An empty SortedNumericDocValues which returns zero values for every
document */
public static final SortedNumericDocValues emptySortedNumeric() {
- return new SortedNumericDocValues() {
-
- private int doc = -1;
-
- @Override
- public int advance(int target) {
- return doc = NO_MORE_DOCS;
- }
-
- @Override
- public boolean advanceExact(int target) throws IOException {
- doc = target;
- return false;
- }
-
- @Override
- public int docID() {
- return doc;
- }
-
- @Override
- public int nextDoc() {
- return doc = NO_MORE_DOCS;
- }
-
- @Override
- public long cost() {
- return 0;
- }
-
- @Override
- public int docValueCount() {
- throw new IllegalStateException();
- }
-
- @Override
- public long nextValue() {
- throw new IllegalStateException();
- }
- };
+ return singleton(emptyNumeric());
Review comment:
In general we're fine with creating some garbage on a per-segment basis
(rather than, say, per doc) so I'm not concerned by the additional garbage. I
guess it might have a positive impact when the caller optimizes for the
single-valued case already and a negative impact when the caller doesn't, but
in any case it is probably trivial? If this was a problem, then it would also
be a problem that we use this wrapper when returning
Sorted(Set|Numeric)DocValues over a single-valued field?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]