1 /** @file mergepostlist.cc
2 * @brief PostList class implementing Query::OP_AND_NOT
4 /* Copyright 2017 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "mergepostlist.h"
25 #include "backends/multi.h"
26 #include "valuestreamdocument.h"
30 MergePostList::~MergePostList()
33 for (Xapian::doccount i
= 0; i
!= n_shards
; ++i
)
38 MergePostList::get_termfreq_min() const
40 Xapian::doccount result
= 0;
41 for (Xapian::doccount i
= 0; i
!= n_shards
; ++i
)
42 result
+= shard_pls
[i
]->get_termfreq_min();
47 MergePostList::get_termfreq_max() const
49 Xapian::doccount result
= 0;
50 for (Xapian::doccount i
= 0; i
!= n_shards
; ++i
)
51 result
+= shard_pls
[i
]->get_termfreq_max();
56 MergePostList::get_termfreq_est() const
58 Xapian::doccount result
= 0;
59 for (Xapian::doccount i
= 0; i
!= n_shards
; ++i
)
60 result
+= shard_pls
[i
]->get_termfreq_est();
65 MergePostList::get_docid() const
67 return unshard(WrapperPostList::get_docid(), shard
, n_shards
);
71 MergePostList::get_sort_key() const
73 return pl
->get_sort_key();
77 MergePostList::get_collapse_key() const
79 return pl
->get_collapse_key();
83 MergePostList::at_end() const
85 return shard
== n_shards
;
89 MergePostList::recalc_maxweight()
92 for (Xapian::doccount i
= 0; i
!= n_shards
; ++i
) {
93 result
= max(result
, shard_pls
[i
]->recalc_maxweight());
99 MergePostList::get_termfreq_est_using_stats(const Xapian::Weight::Internal
&) const
101 // We're only called by PostListTree which never calls this method.
107 MergePostList::next(double w_min
)
110 PostList
* result
= pl
->next(w_min
);
114 shard_pls
[shard
] = pl
;
116 if (!pl
->at_end() || ++shard
== n_shards
) {
119 // Move on to the next shard.
120 vsdoc
.new_shard(shard
);
121 pl
= shard_pls
[shard
];
127 MergePostList::skip_to(Xapian::docid
, double)
129 // We're only called by PostListTree which never calls this method.
135 MergePostList::get_description() const
137 string desc
= "MergePostList(";
138 for (Xapian::doccount i
= 0; i
!= n_shards
; ++i
) {
139 desc
+= shard_pls
[i
]->get_description();