Skip to content

Commit 14703aa

Browse files
committed
doc
1 parent 1842761 commit 14703aa

File tree

1 file changed

+65
-2
lines changed
  • modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/docset

1 file changed

+65
-2
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/docset/NotDocSet.java

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,74 @@ public NotDocSet(DocSet set, int max) {
3434
}
3535

3636
@Override public boolean isCacheable() {
37-
// if it is cached, create a new doc set for it so it will be fast for advance in iterator
38-
return false;
37+
return set.isCacheable();
3938
}
4039

4140
@Override public boolean get(int doc) throws IOException {
4241
return !set.get(doc);
4342
}
43+
44+
// This seems like overhead compared to testing with get and iterating over docs
45+
// @Override public DocIdSetIterator iterator() throws IOException {
46+
// return new NotDocIdSetIterator();
47+
// }
48+
//
49+
// class NotDocIdSetIterator extends DocIdSetIterator {
50+
// int lastReturn = -1;
51+
// private DocIdSetIterator it1 = null;
52+
// private int innerDocid = -1;
53+
//
54+
// NotDocIdSetIterator() throws IOException {
55+
// initialize();
56+
// }
57+
//
58+
// private void initialize() throws IOException {
59+
// it1 = set.iterator();
60+
//
61+
// if ((innerDocid = it1.nextDoc()) == DocIdSetIterator.NO_MORE_DOCS) it1 = null;
62+
// }
63+
//
64+
// @Override
65+
// public int docID() {
66+
// return lastReturn;
67+
// }
68+
//
69+
// @Override
70+
// public int nextDoc() throws IOException {
71+
// return advance(0);
72+
// }
73+
//
74+
// @Override
75+
// public int advance(int target) throws IOException {
76+
//
77+
// if (lastReturn == DocIdSetIterator.NO_MORE_DOCS) {
78+
// return DocIdSetIterator.NO_MORE_DOCS;
79+
// }
80+
//
81+
// if (target <= lastReturn) target = lastReturn + 1;
82+
//
83+
// if (it1 != null && innerDocid < target) {
84+
// if ((innerDocid = it1.advance(target)) == DocIdSetIterator.NO_MORE_DOCS) {
85+
// it1 = null;
86+
// }
87+
// }
88+
//
89+
// while (it1 != null && innerDocid == target) {
90+
// target++;
91+
// if (target >= max) {
92+
// return (lastReturn = DocIdSetIterator.NO_MORE_DOCS);
93+
// }
94+
// if ((innerDocid = it1.advance(target)) == DocIdSetIterator.NO_MORE_DOCS) {
95+
// it1 = null;
96+
// }
97+
// }
98+
//
99+
// // ADDED THIS, bug in code
100+
// if (target >= max) {
101+
// return (lastReturn = DocIdSetIterator.NO_MORE_DOCS);
102+
// }
103+
//
104+
// return (lastReturn = target);
105+
// }
106+
// }
44107
}

0 commit comments

Comments
 (0)