Struct versatile_data::search::Search
source · pub struct Search<'a> { /* private fields */ }Implementations§
source§impl<'a> Search<'a>
impl<'a> Search<'a>
sourcepub fn new(data: &'a Data) -> Self
pub fn new(data: &'a Data) -> Self
Examples found in repository?
src/lib.rs (line 578)
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
pub fn begin_search(&self) -> Search {
Search::new(self)
}
pub fn search_field(&self, field_name: impl Into<String>, condition: search::Field) -> Search {
Search::new(self).search_field(field_name, condition)
}
pub fn search_activity(&self, condition: Activity) -> Search {
Search::new(self).search_activity(condition)
}
pub fn search_term(&self, condition: search::Term) -> Search {
Search::new(self).search_term(condition)
}
pub fn search_row(&self, condition: search::Number) -> Search {
Search::new(self).search_row(condition)
}
pub fn search_default(&self) -> Search {
Search::new(self).search_default()
}More examples
src/search.rs (line 59)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
match condition {
Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
Condition::Field(field_name, condition) => {
Self::search_exec_field(data, field_name, condition, tx)
}
Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
Condition::LastUpdated(condition) => {
Self::search_exec_last_updated(data, condition, tx)
}
Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
Condition::Narrow(conditions) => {
let mut new_search = Search::new(data);
for c in conditions {
new_search = new_search.search(c.clone());
}
tx.send(new_search.result()).unwrap();
}
Condition::Wide(conditions) => {
let (tx_inner, rx) = std::sync::mpsc::channel();
for c in conditions {
let tx_inner = tx_inner.clone();
Self::search_exec_cond(data, c, tx_inner);
}
drop(tx_inner);
std::thread::spawn(move || {
let mut tmp = RowSet::default();
for ref mut rs in rx {
tmp.append(rs);
}
tx.send(tmp).unwrap();
});
}
};
}sourcepub fn search_default(self) -> Self
pub fn search_default(self) -> Self
sourcepub fn search_field(self, field_name: impl Into<String>, condition: Field) -> Self
pub fn search_field(self, field_name: impl Into<String>, condition: Field) -> Self
sourcepub fn search_term(self, condition: Term) -> Self
pub fn search_term(self, condition: Term) -> Self
sourcepub fn search_activity(self, condition: Activity) -> Self
pub fn search_activity(self, condition: Activity) -> Self
sourcepub fn search_row(self, condition: Number) -> Self
pub fn search_row(self, condition: Number) -> Self
sourcepub fn search(self, condition: Condition) -> Self
pub fn search(self, condition: Condition) -> Self
Examples found in repository?
src/search.rs (line 29)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
pub fn search_field(self, field_name: impl Into<String>, condition: Field) -> Self {
self.search(Condition::Field(field_name.into(), condition))
}
pub fn search_term(self, condition: Term) -> Self {
self.search(Condition::Term(condition))
}
pub fn search_activity(self, condition: Activity) -> Self {
self.search(Condition::Activity(condition))
}
pub fn search_row(self, condition: Number) -> Self {
self.search(Condition::Row(condition))
}
pub fn search(mut self, condition: Condition) -> Self {
self.conditions.push(condition);
self
}
pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
match condition {
Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
Condition::Field(field_name, condition) => {
Self::search_exec_field(data, field_name, condition, tx)
}
Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
Condition::LastUpdated(condition) => {
Self::search_exec_last_updated(data, condition, tx)
}
Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
Condition::Narrow(conditions) => {
let mut new_search = Search::new(data);
for c in conditions {
new_search = new_search.search(c.clone());
}
tx.send(new_search.result()).unwrap();
}
Condition::Wide(conditions) => {
let (tx_inner, rx) = std::sync::mpsc::channel();
for c in conditions {
let tx_inner = tx_inner.clone();
Self::search_exec_cond(data, c, tx_inner);
}
drop(tx_inner);
std::thread::spawn(move || {
let mut tmp = RowSet::default();
for ref mut rs in rx {
tmp.append(rs);
}
tx.send(tmp).unwrap();
});
}
};
}sourcepub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>)
pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>)
Examples found in repository?
src/search.rs (line 69)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
match condition {
Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
Condition::Field(field_name, condition) => {
Self::search_exec_field(data, field_name, condition, tx)
}
Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
Condition::LastUpdated(condition) => {
Self::search_exec_last_updated(data, condition, tx)
}
Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
Condition::Narrow(conditions) => {
let mut new_search = Search::new(data);
for c in conditions {
new_search = new_search.search(c.clone());
}
tx.send(new_search.result()).unwrap();
}
Condition::Wide(conditions) => {
let (tx_inner, rx) = std::sync::mpsc::channel();
for c in conditions {
let tx_inner = tx_inner.clone();
Self::search_exec_cond(data, c, tx_inner);
}
drop(tx_inner);
std::thread::spawn(move || {
let mut tmp = RowSet::default();
for ref mut rs in rx {
tmp.append(rs);
}
tx.send(tmp).unwrap();
});
}
};
}
fn search_exec(&mut self) -> RowSet {
let mut rows = RowSet::default();
if self.conditions.len() > 0 {
let (tx, rx) = std::sync::mpsc::channel();
for c in &self.conditions {
let tx = tx.clone();
Self::search_exec_cond(self.data, c, tx);
}
drop(tx);
let mut fst = true;
for rs in rx {
if fst {
rows = rs;
fst = false;
} else {
rows = rows.intersection(&rs).map(|&x| x).collect()
}
}
} else {
for row in self.data.serial.read().unwrap().index().triee().iter() {
rows.insert(row.row());
}
}
rows
}sourcepub fn result(self) -> RowSet
pub fn result(self) -> RowSet
Examples found in repository?
src/search.rs (line 63)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
match condition {
Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
Condition::Field(field_name, condition) => {
Self::search_exec_field(data, field_name, condition, tx)
}
Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
Condition::LastUpdated(condition) => {
Self::search_exec_last_updated(data, condition, tx)
}
Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
Condition::Narrow(conditions) => {
let mut new_search = Search::new(data);
for c in conditions {
new_search = new_search.search(c.clone());
}
tx.send(new_search.result()).unwrap();
}
Condition::Wide(conditions) => {
let (tx_inner, rx) = std::sync::mpsc::channel();
for c in conditions {
let tx_inner = tx_inner.clone();
Self::search_exec_cond(data, c, tx_inner);
}
drop(tx_inner);
std::thread::spawn(move || {
let mut tmp = RowSet::default();
for ref mut rs in rx {
tmp.append(rs);
}
tx.send(tmp).unwrap();
});
}
};
}pub fn result_with_sort(&mut self, orders: Vec<Order>) -> Vec<u32>
sourcepub fn search_exec_uuid(data: &Data, uuid: &u128, tx: Sender<RowSet>)
pub fn search_exec_uuid(data: &Data, uuid: &u128, tx: Sender<RowSet>)
Examples found in repository?
src/search.rs (line 57)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
match condition {
Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
Condition::Field(field_name, condition) => {
Self::search_exec_field(data, field_name, condition, tx)
}
Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
Condition::LastUpdated(condition) => {
Self::search_exec_last_updated(data, condition, tx)
}
Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
Condition::Narrow(conditions) => {
let mut new_search = Search::new(data);
for c in conditions {
new_search = new_search.search(c.clone());
}
tx.send(new_search.result()).unwrap();
}
Condition::Wide(conditions) => {
let (tx_inner, rx) = std::sync::mpsc::channel();
for c in conditions {
let tx_inner = tx_inner.clone();
Self::search_exec_cond(data, c, tx_inner);
}
drop(tx_inner);
std::thread::spawn(move || {
let mut tmp = RowSet::default();
for ref mut rs in rx {
tmp.append(rs);
}
tx.send(tmp).unwrap();
});
}
};
}