File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
modules/elasticsearch/src/main/java/org
elasticsearch/common/lucene/search Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ public boolean equals(Object obj) {
64
64
@ Override
65
65
public int hashCode () {
66
66
int hash = 9 ;
67
- for (Iterator <Term > iter = terms .iterator (); iter .hasNext ();) {
67
+ for (Iterator <Term > iter = terms .iterator (); iter .hasNext (); ) {
68
68
Term term = iter .next ();
69
69
hash = 31 * hash + term .hashCode ();
70
70
}
@@ -73,13 +73,19 @@ public int hashCode() {
73
73
74
74
@ Override
75
75
public DocIdSet getDocIdSet (IndexReader reader ) throws IOException {
76
- OpenBitSet result = new OpenBitSet ( reader . maxDoc ()) ;
76
+ OpenBitSet result = null ;
77
77
TermDocs td = reader .termDocs ();
78
78
try {
79
79
for (Term term : terms ) {
80
80
td .seek (term );
81
- while (td .next ()) {
81
+ if (td .next ()) {
82
+ if (result == null ) {
83
+ result = new OpenBitSet (reader .maxDoc ());
84
+ }
82
85
result .fastSet (td .doc ());
86
+ while (td .next ()) {
87
+ result .fastSet (td .doc ());
88
+ }
83
89
}
84
90
}
85
91
} finally {
Original file line number Diff line number Diff line change @@ -46,15 +46,18 @@ public Term getTerm() {
46
46
}
47
47
48
48
@ Override public DocIdSet getDocIdSet (IndexReader reader ) throws IOException {
49
- OpenBitSet result = new OpenBitSet ( reader . maxDoc ()) ;
49
+ OpenBitSet result = null ;
50
50
TermDocs td = reader .termDocs ();
51
51
try {
52
52
td .seek (term );
53
- while (td .next ()) {
53
+ if (td .next ()) {
54
+ result = new OpenBitSet (reader .maxDoc ());
54
55
result .fastSet (td .doc ());
56
+ while (td .next ()) {
57
+ result .fastSet (td .doc ());
58
+ }
55
59
}
56
- }
57
- finally {
60
+ } finally {
58
61
td .close ();
59
62
}
60
63
return result ;
You can’t perform that action at this time.
0 commit comments