-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathindex_scan.rs
More file actions
62 lines (56 loc) · 1.74 KB
/
index_scan.rs
File metadata and controls
62 lines (56 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
use crate::execution::{Executor, ReadExecutor};
use crate::expression::range_detacher::Range;
use crate::planner::operator::table_scan::TableScanOperator;
use crate::storage::{Iter, StatisticsMetaCache, TableCache, Transaction, ViewCache};
use crate::throw;
use crate::types::index::IndexMetaRef;
pub(crate) struct IndexScan {
op: TableScanOperator,
index_by: IndexMetaRef,
ranges: Vec<Range>,
}
impl From<(TableScanOperator, IndexMetaRef, Range)> for IndexScan {
fn from((op, index_by, range): (TableScanOperator, IndexMetaRef, Range)) -> Self {
let ranges = match range {
Range::SortedRanges(ranges) => ranges,
range => vec![range],
};
IndexScan {
op,
index_by,
ranges,
}
}
}
impl<'a, T: Transaction + 'a> ReadExecutor<'a, T> for IndexScan {
fn execute(
self,
(table_cache, _, _): (&'a TableCache, &'a ViewCache, &'a StatisticsMetaCache),
transaction: *mut T,
) -> Executor<'a> {
Box::new(
#[coroutine]
move || {
let TableScanOperator {
table_name,
columns,
limit,
with_pk,
..
} = self.op;
let mut iter = throw!(unsafe { &(*transaction) }.read_by_index(
table_cache,
table_name,
limit,
columns,
self.index_by,
self.ranges,
with_pk,
));
while let Some(tuple) = throw!(iter.next_tuple()) {
yield Ok(tuple);
}
},
)
}
}