Skip to main content

risingwave_stream/from_proto/
row_id_gen.rs

1// Copyright 2022 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use risingwave_pb::stream_plan::RowIdGenNode;
16use risingwave_storage::StateStore;
17
18use super::ExecutorBuilder;
19use crate::error::StreamResult;
20use crate::executor::Executor;
21use crate::executor::row_id_gen::RowIdGenExecutor;
22use crate::task::ExecutorParams;
23
24pub struct RowIdGenExecutorBuilder;
25
26impl_stream_node_body!(RowIdGen(RowIdGenNode) => RowIdGenExecutorBuilder);
27
28impl ExecutorBuilder for RowIdGenExecutorBuilder {
29    type Node = RowIdGenNode;
30
31    async fn new_boxed_executor(
32        params: ExecutorParams,
33        node: &Self::Node,
34        _store: impl StateStore,
35    ) -> StreamResult<Executor> {
36        let [upstream]: [_; 1] = params.input.try_into().unwrap();
37        tracing::debug!("row id gen executor: {:?}", params.vnode_bitmap);
38        let vnodes = params
39            .vnode_bitmap
40            .expect("vnodes not set for row id gen executor");
41        let exec = RowIdGenExecutor::new(
42            params.actor_context,
43            upstream,
44            node.row_id_index as _,
45            vnodes,
46        );
47        Ok((params.info, exec).into())
48    }
49}