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
pub mod aggr_executor;
pub mod hash_aggr_helper;
#[cfg(test)]
pub mod mock_executor;
pub mod scan_executor;
use tipb::FieldType;
use tidb_query_common::Result;
use tidb_query_datatype::codec::batch::LazyBatchColumnVec;
use tidb_query_datatype::expr::EvalContext;
use tidb_query_expr::RpnExpression;
use tidb_query_expr::RpnStackNode;
pub fn ensure_columns_decoded(
ctx: &mut EvalContext,
exprs: &[RpnExpression],
schema: &[FieldType],
input_physical_columns: &mut LazyBatchColumnVec,
input_logical_rows: &[usize],
) -> Result<()> {
for expr in exprs {
expr.ensure_columns_decoded(ctx, schema, input_physical_columns, input_logical_rows)?;
}
Ok(())
}
pub unsafe fn eval_exprs_decoded_no_lifetime<'a>(
ctx: &mut EvalContext,
exprs: &[RpnExpression],
schema: &[FieldType],
input_physical_columns: &LazyBatchColumnVec,
input_logical_rows: &[usize],
output: &mut Vec<RpnStackNode<'a>>,
) -> Result<()> {
unsafe fn erase_lifetime<'a, T: ?Sized>(v: &T) -> &'a T {
&*(v as *const T)
}
for expr in exprs {
output.push(erase_lifetime(expr).eval_decoded(
ctx,
erase_lifetime(schema),
erase_lifetime(input_physical_columns),
erase_lifetime(input_logical_rows),
input_logical_rows.len(),
)?)
}
Ok(())
}