xushiyan commented on code in PR #395:
URL: https://github.com/apache/hudi-rs/pull/395#discussion_r2384475925


##########
crates/core/src/timeline/selector.rs:
##########
@@ -523,24 +533,33 @@ mod tests {
     }
 
     async fn create_test_timeline() -> Timeline {
-        let instants = vec![
+        let storage = Storage::new(
+            Arc::new(HashMap::new()),
+            Arc::new(HudiConfigs::new([
+                (HudiTableConfig::BasePath, "file:///tmp/base".to_string()),
+                (HudiTableConfig::TableVersion, "6".to_string()),
+            ])),
+        )
+        .unwrap();
+        let mut timeline = TimelineBuilder::new(
+            Arc::new(HudiConfigs::new([
+                (HudiTableConfig::BasePath, "file:///tmp/base".to_string()),
+                (HudiTableConfig::TableVersion, "6".to_string()),

Review Comment:
   ```suggestion
                   (HudiTableConfig::BasePath, "file:///tmp/base"),
                   (HudiTableConfig::TableVersion, "6"),
   ```
   
   same as above. the api supports `Into<String>()`



##########
crates/core/src/timeline/loader.rs:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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::internal::HudiInternalConfig::{
+    TimelineArchivedReadEnabled, TimelineArchivedUnavailableBehavior,
+};
+use crate::config::table::HudiTableConfig::ArchiveLogFolder;
+use crate::config::HudiConfigs;
+use crate::error::CoreError;
+use crate::metadata::HUDI_METADATA_DIR;
+use crate::storage::Storage;
+use crate::timeline::instant::Instant;
+use crate::timeline::lsm_tree::LSM_TIMELINE_DIR;
+use crate::timeline::selector::TimelineSelector;
+use crate::Result;
+use log::debug;
+use std::sync::Arc;
+
+#[derive(Debug, Clone)]
+pub enum TimelineLoader {
+    LayoutOneActive(Arc<Storage>),
+    LayoutOneArchived(Arc<Storage>),
+    LayoutTwoActive(Arc<Storage>),
+    LayoutTwoArchived(Arc<Storage>),
+}
+
+impl TimelineLoader {
+    pub async fn load_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        match self {
+            TimelineLoader::LayoutOneActive(storage) => {
+                let files = storage.list_files(Some(HUDI_METADATA_DIR)).await?;
+                let mut instants = Vec::with_capacity(files.len() / 3);
+
+                for file_info in files {
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            TimelineLoader::LayoutTwoActive(storage) => {
+                let files = storage.list_files(Some(LSM_TIMELINE_DIR)).await?;
+                let mut instants = Vec::new();
+
+                for file_info in files {
+                    if file_info.name.starts_with("history/") || 
file_info.name.ends_with(".crc") {
+                        continue;
+                    }
+                    match selector.try_create_instant(file_info.name.as_str()) 
{

Review Comment:
   i think this API needs to handle v8 instants as the completed ones have 
completion ts



##########
crates/core/src/config/table.rs:
##########
@@ -166,6 +174,9 @@ impl ConfigParser for HudiTableConfig {
             Self::TimelineTimezone => Some(HudiConfigValue::String(
                 TimelineTimezoneValue::UTC.as_ref().to_string(),
             )),
+            // Fallbacks are handled in callers; no defaults here
+            Self::ArchiveLogFolder => None,
+            Self::TimelineHistoryPath => None,

Review Comment:
   these 2 do have default values right? why not provide them through this API? 



##########
crates/core/src/timeline/loader.rs:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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::internal::HudiInternalConfig::{
+    TimelineArchivedReadEnabled, TimelineArchivedUnavailableBehavior,
+};
+use crate::config::table::HudiTableConfig::ArchiveLogFolder;
+use crate::config::HudiConfigs;
+use crate::error::CoreError;
+use crate::metadata::HUDI_METADATA_DIR;
+use crate::storage::Storage;
+use crate::timeline::instant::Instant;
+use crate::timeline::lsm_tree::LSM_TIMELINE_DIR;
+use crate::timeline::selector::TimelineSelector;
+use crate::Result;
+use log::debug;
+use std::sync::Arc;
+
+#[derive(Debug, Clone)]
+pub enum TimelineLoader {
+    LayoutOneActive(Arc<Storage>),
+    LayoutOneArchived(Arc<Storage>),
+    LayoutTwoActive(Arc<Storage>),
+    LayoutTwoArchived(Arc<Storage>),
+}
+
+impl TimelineLoader {
+    pub async fn load_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        match self {
+            TimelineLoader::LayoutOneActive(storage) => {
+                let files = storage.list_files(Some(HUDI_METADATA_DIR)).await?;
+                let mut instants = Vec::with_capacity(files.len() / 3);
+
+                for file_info in files {
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            TimelineLoader::LayoutTwoActive(storage) => {
+                let files = storage.list_files(Some(LSM_TIMELINE_DIR)).await?;
+                let mut instants = Vec::new();
+
+                for file_info in files {
+                    if file_info.name.starts_with("history/") || 
file_info.name.ends_with(".crc") {

Review Comment:
   ```suggestion
                       // TODO: make `storage.list_files` api support such 
filtering, like ignore crc and return files only
                       if file_info.name.starts_with("history/") || 
file_info.name.ends_with(".crc") {
   ```



##########
crates/core/src/timeline/loader.rs:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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::internal::HudiInternalConfig::{
+    TimelineArchivedReadEnabled, TimelineArchivedUnavailableBehavior,
+};
+use crate::config::table::HudiTableConfig::ArchiveLogFolder;
+use crate::config::HudiConfigs;
+use crate::error::CoreError;
+use crate::metadata::HUDI_METADATA_DIR;
+use crate::storage::Storage;
+use crate::timeline::instant::Instant;
+use crate::timeline::lsm_tree::LSM_TIMELINE_DIR;
+use crate::timeline::selector::TimelineSelector;
+use crate::Result;
+use log::debug;
+use std::sync::Arc;
+
+#[derive(Debug, Clone)]
+pub enum TimelineLoader {
+    LayoutOneActive(Arc<Storage>),
+    LayoutOneArchived(Arc<Storage>),
+    LayoutTwoActive(Arc<Storage>),
+    LayoutTwoArchived(Arc<Storage>),
+}
+
+impl TimelineLoader {
+    pub async fn load_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        match self {
+            TimelineLoader::LayoutOneActive(storage) => {
+                let files = storage.list_files(Some(HUDI_METADATA_DIR)).await?;
+                let mut instants = Vec::with_capacity(files.len() / 3);
+
+                for file_info in files {
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            TimelineLoader::LayoutTwoActive(storage) => {
+                let files = storage.list_files(Some(LSM_TIMELINE_DIR)).await?;
+                let mut instants = Vec::new();
+
+                for file_info in files {
+                    if file_info.name.starts_with("history/") || 
file_info.name.ends_with(".crc") {
+                        continue;
+                    }
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            _ => Err(CoreError::Unsupported(
+                "Loading from this timeline layout is not implemented 
yet.".to_string(),
+            )),
+        }
+    }
+
+    pub(crate) async fn load_archived_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        // Config wiring: if archived read not enabled, return behavior based 
on policy
+        let storage = match self {
+            TimelineLoader::LayoutOneArchived(storage)
+            | TimelineLoader::LayoutTwoArchived(storage) => storage.clone(),
+            _ => return Ok(Vec::new()), // Active loaders don't have archived 
parts
+        };
+
+        let configs: Arc<HudiConfigs> = storage.hudi_configs.clone();
+        let enabled = configs
+            .get_or_default(TimelineArchivedReadEnabled)
+            .to::<bool>();
+        if !enabled {
+            let behavior = configs
+                .get_or_default(TimelineArchivedUnavailableBehavior)
+                .to::<String>()
+                .to_ascii_lowercase();
+            return match behavior.as_str() {
+                "error" => Err(CoreError::Unsupported(
+                    "Archived timeline read is disabled; shorten time range or 
enable archived read"
+                        .to_string(),
+                )),
+                _ => Ok(Vec::new()), // continue silently with empty archived
+            };
+        }
+
+        match self {
+            TimelineLoader::LayoutOneArchived(storage) => {
+                // Resolve archive folder from configs or fallback
+                let archive_dir = configs
+                    .try_get(ArchiveLogFolder)
+                    .map(|v| v.to::<String>())
+                    .unwrap_or_else(|| ".hoodie/archived".to_string());
+
+                // List files and try creating instants through selector
+                let files = storage.list_files(Some(&archive_dir)).await?;
+                let mut instants = Vec::new();
+                for file_info in files {
+                    if file_info.name.ends_with(".crc") {
+                        continue;
+                    }

Review Comment:
   i think we can skip checking `.crc` in this pr for simplicity. there is an 
open PR addresses this from storage level 



##########
crates/core/src/timeline/loader.rs:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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::internal::HudiInternalConfig::{
+    TimelineArchivedReadEnabled, TimelineArchivedUnavailableBehavior,
+};
+use crate::config::table::HudiTableConfig::ArchiveLogFolder;
+use crate::config::HudiConfigs;
+use crate::error::CoreError;
+use crate::metadata::HUDI_METADATA_DIR;
+use crate::storage::Storage;
+use crate::timeline::instant::Instant;
+use crate::timeline::lsm_tree::LSM_TIMELINE_DIR;
+use crate::timeline::selector::TimelineSelector;
+use crate::Result;
+use log::debug;
+use std::sync::Arc;
+
+#[derive(Debug, Clone)]
+pub enum TimelineLoader {
+    LayoutOneActive(Arc<Storage>),
+    LayoutOneArchived(Arc<Storage>),
+    LayoutTwoActive(Arc<Storage>),
+    LayoutTwoArchived(Arc<Storage>),
+}
+
+impl TimelineLoader {
+    pub async fn load_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        match self {
+            TimelineLoader::LayoutOneActive(storage) => {
+                let files = storage.list_files(Some(HUDI_METADATA_DIR)).await?;
+                let mut instants = Vec::with_capacity(files.len() / 3);
+
+                for file_info in files {
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            TimelineLoader::LayoutTwoActive(storage) => {
+                let files = storage.list_files(Some(LSM_TIMELINE_DIR)).await?;
+                let mut instants = Vec::new();
+
+                for file_info in files {
+                    if file_info.name.starts_with("history/") || 
file_info.name.ends_with(".crc") {
+                        continue;
+                    }
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            _ => Err(CoreError::Unsupported(
+                "Loading from this timeline layout is not implemented 
yet.".to_string(),
+            )),
+        }
+    }
+
+    pub(crate) async fn load_archived_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        // Config wiring: if archived read not enabled, return behavior based 
on policy
+        let storage = match self {
+            TimelineLoader::LayoutOneArchived(storage)
+            | TimelineLoader::LayoutTwoArchived(storage) => storage.clone(),
+            _ => return Ok(Vec::new()), // Active loaders don't have archived 
parts
+        };

Review Comment:
   this storage clone does not need happen here?



##########
crates/core/src/timeline/loader.rs:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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::internal::HudiInternalConfig::{
+    TimelineArchivedReadEnabled, TimelineArchivedUnavailableBehavior,
+};
+use crate::config::table::HudiTableConfig::ArchiveLogFolder;
+use crate::config::HudiConfigs;
+use crate::error::CoreError;
+use crate::metadata::HUDI_METADATA_DIR;
+use crate::storage::Storage;
+use crate::timeline::instant::Instant;
+use crate::timeline::lsm_tree::LSM_TIMELINE_DIR;
+use crate::timeline::selector::TimelineSelector;
+use crate::Result;
+use log::debug;
+use std::sync::Arc;
+
+#[derive(Debug, Clone)]
+pub enum TimelineLoader {
+    LayoutOneActive(Arc<Storage>),
+    LayoutOneArchived(Arc<Storage>),
+    LayoutTwoActive(Arc<Storage>),
+    LayoutTwoArchived(Arc<Storage>),
+}
+
+impl TimelineLoader {
+    pub async fn load_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        match self {
+            TimelineLoader::LayoutOneActive(storage) => {
+                let files = storage.list_files(Some(HUDI_METADATA_DIR)).await?;
+                let mut instants = Vec::with_capacity(files.len() / 3);
+
+                for file_info in files {
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            TimelineLoader::LayoutTwoActive(storage) => {
+                let files = storage.list_files(Some(LSM_TIMELINE_DIR)).await?;
+                let mut instants = Vec::new();
+
+                for file_info in files {
+                    if file_info.name.starts_with("history/") || 
file_info.name.ends_with(".crc") {
+                        continue;
+                    }
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            _ => Err(CoreError::Unsupported(
+                "Loading from this timeline layout is not implemented 
yet.".to_string(),
+            )),
+        }
+    }
+
+    pub(crate) async fn load_archived_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        // Config wiring: if archived read not enabled, return behavior based 
on policy
+        let storage = match self {
+            TimelineLoader::LayoutOneArchived(storage)
+            | TimelineLoader::LayoutTwoArchived(storage) => storage.clone(),
+            _ => return Ok(Vec::new()), // Active loaders don't have archived 
parts
+        };
+
+        let configs: Arc<HudiConfigs> = storage.hudi_configs.clone();
+        let enabled = configs
+            .get_or_default(TimelineArchivedReadEnabled)
+            .to::<bool>();
+        if !enabled {
+            let behavior = configs
+                .get_or_default(TimelineArchivedUnavailableBehavior)
+                .to::<String>()
+                .to_ascii_lowercase();
+            return match behavior.as_str() {
+                "error" => Err(CoreError::Unsupported(
+                    "Archived timeline read is disabled; shorten time range or 
enable archived read"
+                        .to_string(),
+                )),
+                _ => Ok(Vec::new()), // continue silently with empty archived
+            };
+        }
+
+        match self {
+            TimelineLoader::LayoutOneArchived(storage) => {
+                // Resolve archive folder from configs or fallback
+                let archive_dir = configs
+                    .try_get(ArchiveLogFolder)
+                    .map(|v| v.to::<String>())
+                    .unwrap_or_else(|| ".hoodie/archived".to_string());

Review Comment:
   here this default value can be provided through `default_value()` ? the 
`try_get()` API handles it



##########
crates/core/src/timeline/loader.rs:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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::internal::HudiInternalConfig::{
+    TimelineArchivedReadEnabled, TimelineArchivedUnavailableBehavior,
+};
+use crate::config::table::HudiTableConfig::ArchiveLogFolder;
+use crate::config::HudiConfigs;
+use crate::error::CoreError;
+use crate::metadata::HUDI_METADATA_DIR;
+use crate::storage::Storage;
+use crate::timeline::instant::Instant;
+use crate::timeline::lsm_tree::LSM_TIMELINE_DIR;
+use crate::timeline::selector::TimelineSelector;
+use crate::Result;
+use log::debug;
+use std::sync::Arc;
+
+#[derive(Debug, Clone)]
+pub enum TimelineLoader {
+    LayoutOneActive(Arc<Storage>),
+    LayoutOneArchived(Arc<Storage>),
+    LayoutTwoActive(Arc<Storage>),
+    LayoutTwoArchived(Arc<Storage>),
+}
+
+impl TimelineLoader {
+    pub async fn load_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        match self {
+            TimelineLoader::LayoutOneActive(storage) => {
+                let files = storage.list_files(Some(HUDI_METADATA_DIR)).await?;
+                let mut instants = Vec::with_capacity(files.len() / 3);
+
+                for file_info in files {
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            TimelineLoader::LayoutTwoActive(storage) => {
+                let files = storage.list_files(Some(LSM_TIMELINE_DIR)).await?;
+                let mut instants = Vec::new();
+
+                for file_info in files {
+                    if file_info.name.starts_with("history/") || 
file_info.name.ends_with(".crc") {
+                        continue;
+                    }
+                    match selector.try_create_instant(file_info.name.as_str()) 
{
+                        Ok(instant) => instants.push(instant),
+                        Err(e) => {
+                            debug!(
+                                "Instant not created from file {:?} due to: 
{:?}",
+                                file_info, e
+                            );
+                        }
+                    }
+                }
+
+                instants.sort_unstable();
+                instants.shrink_to_fit();
+
+                if desc {
+                    Ok(instants.into_iter().rev().collect())
+                } else {
+                    Ok(instants)
+                }
+            }
+            _ => Err(CoreError::Unsupported(
+                "Loading from this timeline layout is not implemented 
yet.".to_string(),
+            )),
+        }
+    }
+
+    pub(crate) async fn load_archived_instants(
+        &self,
+        selector: &TimelineSelector,
+        desc: bool,
+    ) -> Result<Vec<Instant>> {
+        // Config wiring: if archived read not enabled, return behavior based 
on policy
+        let storage = match self {
+            TimelineLoader::LayoutOneArchived(storage)
+            | TimelineLoader::LayoutTwoArchived(storage) => storage.clone(),
+            _ => return Ok(Vec::new()), // Active loaders don't have archived 
parts
+        };
+
+        let configs: Arc<HudiConfigs> = storage.hudi_configs.clone();
+        let enabled = configs
+            .get_or_default(TimelineArchivedReadEnabled)
+            .to::<bool>();
+        if !enabled {
+            let behavior = configs
+                .get_or_default(TimelineArchivedUnavailableBehavior)

Review Comment:
   looks like we just need 1 config? `TimelineArchivedUnavailableBehavior` 
default to continue will just either load archived or do nothing. even for 
internal config, we need to keep it simple for easy maintenance



-- 
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]

Reply via email to