xushiyan commented on code in PR #395: URL: https://github.com/apache/hudi-rs/pull/395#discussion_r2203937373
########## crates/core/src/timeline/layout.rs: ########## @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use crate::config::HudiConfigs; +use crate::storage::Storage; +use crate::timeline::instant::Instant; +use crate::timeline::selector::TimelineSelector; +use crate::Result; +use std::sync::Arc; + +/// Timeline layout implementations for different table versions. +#[derive(Debug, Clone)] +pub enum TimelineLayoutType { + Active(super::active::ActiveTimeline), + Lsm(super::lsm::LsmTimeline), Review Comment: We think of `Timeline` as a top level interface where callers can interact with, the layout is an internal config that resolved based on table version and timeline layout version (as you resolved in `create_layout()`. It'd be a bit odd to see a "Type" struct having a Timeline instance basically for choosing a Timeline to use. How about we design it like: - `Timeline` remains as the top-level interface - When a Timeline is created, it resolves `HudiConfigs`, and create an internal model call `TimelineLoader` based on the configs - `TimelineLoader` can be an enum, it has these items: ``` LayoutOneActive LayoutOneArchived LayoutTwoActive LayoutTwoCompacted ``` Each loader will implement the logic to load its intended commit files. - When some APIs are invoked and need to load archived or compacted commits, the Timeline instance will use the needed `Loader`s to do IO - `Timeline` is responsible for collecting and stitching the `Loader`s' return data and returning final data to callers - We also avoid calling a LSM timeline since LSM tree is just one impl of Timeline which should be hidden away from Timeline's level ########## crates/core/src/timeline/lsm.rs: ########## @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use crate::config::HudiConfigs; +use crate::metadata::HUDI_METADATA_DIR; +use crate::storage::Storage; +use crate::timeline::instant::Instant; +use crate::timeline::selector::TimelineSelector; +use crate::Result; +use log::debug; +use std::sync::Arc; + +/// LSM timeline for table version 8. +/// For now, falls back to reading from .hoodie/ directory like active timeline. +/// TODO: Add LSM timeline history reading from .hoodie/timeline/ directory +#[derive(Debug, Clone)] +pub struct LsmTimeline { + storage: Arc<Storage>, +} + +impl LsmTimeline { Review Comment: We can keep LSM tree related logic in here. As commented above, LSM tree is internal to `TimelineLoader::LayoutTwoActive, LayoutTwoCompacted`, so just those 2 loaders can make use of the logic here. Btw, the correct name is LSM tree, so let's keep it in full like `lsm_tree.rs` and `LSMTree` for other applicable names ? ########## cpp/Cargo.toml: ########## @@ -28,7 +28,7 @@ homepage.workspace = true repository = "https://github.com/apache/hudi-rs/tree/main/cpp/" [lib] -name = "hudi" +name = "hudi_cpp" Review Comment: this actually impact the library name which is used in CMakeLists.txt . let's keep unrelated change out from the PR anyway. We try to keep artifact name minimum: we don't need to call it hudi_cpp as a c++ lib, just like we don't need to call the python artifact pyhudi - we just `pip install hudi` ########## crates/core/src/timeline/active.rs: ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use crate::config::HudiConfigs; +use crate::metadata::HUDI_METADATA_DIR; +use crate::storage::Storage; +use crate::timeline::instant::Instant; +use crate::timeline::selector::TimelineSelector; +use crate::Result; +use log::debug; +use std::sync::Arc; + +/// Active timeline for table versions 5-8. +/// Reads individual instant files from `.hoodie/` directory. +#[derive(Debug, Clone)] +pub struct ActiveTimeline { + storage: Arc<Storage>, +} + +impl ActiveTimeline { Review Comment: let's take the opportunity to re-think some of the model design: from the callers perspective, they should not care if the commits should come from active timeline `history/` or `archived/` because these are all timeline internal logic flow. If the caller requests require looking into compacted or archived commits, the timeline instance will need to make a call and fetch the data as needed. So at the interface level, we don't need an explicit `ActiveTimeline`. We can just keep it `Timeline` as the front-facing model. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
