Skip to content

Commit

Permalink
prefer to use try_collect
Browse files Browse the repository at this point in the history
Signed-off-by: TennyZhuang <[email protected]>
  • Loading branch information
TennyZhuang committed Jun 9, 2022
1 parent 5e14a67 commit d9ad267
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/batch/src/executor/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use risingwave_common::catalog::{Field, Schema};
use risingwave_common::error::{Result, RwError};
use risingwave_common::util::chunk_coalesce::DEFAULT_CHUNK_BUFFER_SIZE;
use risingwave_expr::expr::{build_from_prost, BoxedExpression};
use risingwave_expr::ExprResult;
use risingwave_pb::batch_plan::plan_node::NodeBody;

use crate::executor::{
Expand Down Expand Up @@ -118,11 +117,7 @@ impl BoxedExecutorBuilder for ValuesExecutor {

let mut rows: Vec<Vec<BoxedExpression>> = Vec::with_capacity(value_node.get_tuples().len());
for row in value_node.get_tuples() {
let expr_row = row
.get_cells()
.iter()
.map(build_from_prost)
.collect::<ExprResult<Vec<BoxedExpression>>>()?;
let expr_row: Vec<_> = row.get_cells().iter().map(build_from_prost).try_collect()?;
rows.push(expr_row);
}

Expand Down
1 change: 0 additions & 1 deletion src/expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ pub mod vector_op;

pub use error::ExprError;
pub type Result<T> = std::result::Result<T, ExprError>;
pub type ExprResult<T> = Result<T>;
5 changes: 2 additions & 3 deletions src/stream/src/from_proto/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

use risingwave_expr::expr::build_from_prost;
use risingwave_expr::ExprResult;

use super::*;
use crate::executor::ProjectExecutor;
Expand All @@ -28,11 +27,11 @@ impl ExecutorBuilder for ProjectExecutorBuilder {
_stream: &mut LocalStreamManagerCore,
) -> Result<BoxedExecutor> {
let node = try_match_expand!(node.get_node_body().unwrap(), NodeBody::Project)?;
let project_exprs = node
let project_exprs: Vec<_> = node
.get_select_list()
.iter()
.map(build_from_prost)
.collect::<ExprResult<Vec<_>>>()?;
.try_collect()?;

Ok(ProjectExecutor::new(
params.input.remove(0),
Expand Down

0 comments on commit d9ad267

Please sign in to comment.