use crate::core::index::index_reader::Identity;
use crate::core::index::index_reader_context::IndexReaderContext;
use crate::core::search::index_searcher::IndexSearcher;
use crate::core::search::query::{Query, QueryBase, QueryWeight};
use crate::core::search::query_visitor::QueryVisitor;
use crate::core::search::score_mode::ScoreMode;
use crate::core::search::similarities_impl::similarities::Similarity;
use crate::core::util::core_helper::HasIdentity;
use crate::core::util::error::lucene_error::Result;
#[derive(Debug, Clone)]
pub struct DummyQuery {
id: Identity,
}
impl DummyQuery {
pub fn new() -> Self {
Self {
id: Identity::new(),
}
}
}
impl Default for DummyQuery {
fn default() -> Self {
Self::new()
}
}
impl PartialEq for DummyQuery {
fn eq(&self, _other: &Self) -> bool {
true
}
}
impl Eq for DummyQuery {}
impl std::hash::Hash for DummyQuery {
fn hash<H>(&self, state: &mut H)
where
H: std::hash::Hasher,
{
0usize.hash(state);
}
}
impl HasIdentity for DummyQuery {
fn identity(&self) -> &Identity {
&self.id
}
}
impl QueryBase for DummyQuery {
type Weight<IRC, SIM>
= QueryWeight<IRC, SIM>
where
SIM: Similarity,
IRC: IndexReaderContext + 'static;
fn to_string(&self, _field: &str) -> Result<String> {
dummy_unreachable!()
}
fn create_weight<IRC, SIM>(
self,
_searcher: &IndexSearcher<IRC, SIM>,
_score_mode: &ScoreMode,
_boost: f32,
) -> crate::core::util::error::lucene_error::Result<Self::Weight<IRC, SIM>>
where
SIM: Similarity,
IRC: IndexReaderContext + 'static,
Self: Sized,
IndexSearcher<IRC, SIM>: Sync,
{
dummy_unreachable!()
}
fn rewrite<IRC, SIM>(
&self,
_searcher: &IndexSearcher<IRC, SIM>,
) -> crate::core::util::error::lucene_error::Result<Option<Query>>
where
SIM: Similarity,
IRC: IndexReaderContext + 'static,
IndexSearcher<IRC, SIM>: Sync,
{
dummy_unreachable!()
}
fn visit<QV>(&self, _visitor: &mut QV) -> Result<()>
where
QV: QueryVisitor,
{
dummy_unreachable!()
}
}
impl crate::core::util::accountable::Accountable for DummyQuery {
fn ram_bytes_used(&self) -> crate::core::util::error::lucene_error::Result<i64> {
Ok(crate::core::util::ram_usage_estimator::QUERY_DEFAULT_RAM_BYTES_USED)
}
}