flow/expr/
id.rs

1// Copyright 2023 Greptime Team
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
15//! `Id` is used to identify a dataflow component in plan like `Plan::Get{id: Id}`, this could be a source of data for an arrangement.
16
17use serde::{Deserialize, Serialize};
18
19/// Global id's scope is in Current Flow node, and is cross-dataflow
20#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
21pub enum GlobalId {
22    /// System namespace.
23    System(u64),
24    /// User namespace.
25    User(u64),
26    /// Transient namespace.
27    Transient(u64),
28    /// Dummy id for query being explained
29    Explain,
30}
31
32/// Local id is used in local scope created by `Plan::Let{id: LocalId, value, body}`
33#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
34pub struct LocalId(pub(crate) u64);
35
36/// Id is used to identify a dataflow component in plan like `Plan::Get{id: Id}`
37#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
38pub enum Id {
39    /// An identifier that refers to a local component of a dataflow.
40    Local(LocalId),
41    /// An identifier that refers to a global dataflow.
42    Global(GlobalId),
43}