Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copr: add projection #10689

Merged
merged 6 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/tidb_query_common/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ make_auto_flush_static_metric! {
batch_stream_aggr,
batch_limit,
batch_top_n,
batch_projection,
table_scan,
index_scan,
selection,
Expand Down
41 changes: 41 additions & 0 deletions components/tidb_query_datatype/src/codec/data_type/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,47 @@ impl VectorValue {
}
}

/// Creates a `VectorValue` of length `len` with the given value `scalar`.
#[inline]
pub fn from_scalar(scalar: &ScalarValue, len: usize) -> Self {
macro_rules! expand_convertion {
($val:tt, $( $tp:tt : $chktp:ty ),* ) => {
match &$val {
$(
&ScalarValue::$tp(val) => {
let mut v: $chktp = ChunkedVec::with_capacity(len);
match val {
None => {
for _ in 0..len {
v.push_null();
}
},
Some(val) => {
for _ in 0..len {
v.push_data(val.clone());
}
}
}
VectorValue::$tp(v)
}
)*
}
}
}
expand_convertion!(
scalar,
Int: ChunkedVecSized<Int>,
Real: ChunkedVecSized<Real>,
Decimal: ChunkedVecSized<Decimal>,
DateTime: ChunkedVecSized<DateTime>,
Duration: ChunkedVecSized<Duration>,
Set: ChunkedVecSet,
Json: ChunkedVecJson,
Enum: ChunkedVecEnum,
Bytes: ChunkedVecBytes
)
}

/// Creates a new empty `VectorValue` with the same eval type.
#[inline]
#[must_use]
Expand Down
2 changes: 2 additions & 0 deletions components/tidb_query_executors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mod fast_hash_aggr_executor;
mod index_scan_executor;
pub mod interface;
mod limit_executor;
mod projection_executor;
pub mod runner;
mod selection_executor;
mod simple_aggr_executor;
Expand All @@ -42,6 +43,7 @@ mod util;
pub use self::fast_hash_aggr_executor::BatchFastHashAggregationExecutor;
pub use self::index_scan_executor::BatchIndexScanExecutor;
pub use self::limit_executor::BatchLimitExecutor;
pub use self::projection_executor::BatchProjectionExecutor;
pub use self::selection_executor::BatchSelectionExecutor;
pub use self::simple_aggr_executor::BatchSimpleAggregationExecutor;
pub use self::slow_hash_aggr_executor::BatchSlowHashAggregationExecutor;
Expand Down
Loading