Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(engine): update parameter names and enhance CityGML processing #587

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

miseyu
Copy link
Contributor

@miseyu miseyu commented Oct 22, 2024

Overview

What I've done

What I haven't done

How I tested

Screenshot

Which point I want you to review particularly

Memo

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new flatten parameter for FeatureReader and FileReader processors, allowing for flexible data structure handling during processing.
    • Enhanced CityGmlReaderParam to include an optional flatten field for improved parsing control.
  • Bug Fixes

    • Adjusted logic in the read_citygml function to utilize the flatten parameter, refining data processing.
  • Documentation

    • Updated schemas to reflect the addition of the flatten parameter in both FeatureReader and FileReader.

@miseyu miseyu self-assigned this Oct 22, 2024
@miseyu miseyu requested a review from a team as a code owner October 22, 2024 02:47
Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

The changes in this pull request primarily focus on restructuring the FeatureReader and its associated components within the engine/runtime/action-processor/src/feature/reader.rs file. Notably, the common_property field in several enums has been replaced by common_param, which is now of type CommonReaderParam. This adjustment is reflected across multiple variants of the FeatureReaderParam enum. Additionally, new parameters and structures have been introduced in the citygml.rs and csv.rs files to enhance the reading processes, including the addition of a flatten parameter to control data processing behavior.

Changes

File Path Change Summary
engine/runtime/action-processor/src/feature/reader.rs Restructured FeatureReaderParam and CompiledFeatureReaderParam enums to replace common_property with common_param. Updated the build and process methods accordingly. Renamed CommonPropertySchema to CommonReaderParam.
engine/runtime/action-processor/src/feature/reader/citygml.rs Added CityGmlReaderParam struct with a flatten field. Updated read_citygml function to accept this new parameter and modified parsing logic based on flatten.
engine/runtime/action-processor/src/feature/reader/csv.rs Renamed CsvPropertySchema to CsvReaderParam. Updated parameter types in read_csv function to reflect the new naming conventions.
engine/runtime/action-source/src/file/reader/citygml.rs Added CityGmlReaderParam struct. Updated read_citygml and parse_tree_reader function signatures to include flatten parameter.
engine/runtime/action-source/src/file/reader/runner.rs Added Citygml variant to FileReader enum with a new property field of type CityGmlReaderParam. Updated handling in the start method.
engine/runtime/examples/plateau/example_feature_transformer.rs Changed workflow file argument in helper::execute function from "data-convert/01-bldg/workflow.yml" to "data-convert/04-luse-lsld/workflow.yml".
engine/schema/actions.json Added optional flatten parameter to FeatureReader and FileReader processors, allowing for enhanced data structure handling.

Possibly related PRs

🐇 In the fields where features play,
New parameters come out to play.
Flattening trees, oh what a sight,
Data dances in the light!
With readers enhanced, we hop with glee,
Processing features, wild and free! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for reearth-flow canceled.

Name Link
🔨 Latest commit d13c5bb
🔍 Latest deploy log https://app.netlify.com/sites/reearth-flow/deploys/67171fcf7fe90100086ec017

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Outside diff range and nitpick comments (8)
engine/schema/actions.json (1)

1007-1012: LGTM. Consider updating documentation.

The addition of the flatten parameter to the FeatureReader action for the citygml format is a good enhancement. It provides more flexibility in CityGML data processing while maintaining backward compatibility.

Consider updating the user documentation to explain the purpose and usage of this new flatten parameter for CityGML processing.

engine/runtime/action-processor/src/feature/reader.rs (1)

187-187: Add pub visibility to CompiledCommonReaderParam if needed

The CompiledCommonReaderParam struct is currently private to the module. If this struct needs to be accessed from other modules, consider adding the pub visibility modifier.

Apply this diff if external access is required:

-struct CompiledCommonReaderParam {
+pub struct CompiledCommonReaderParam {
     expr: rhai::AST,
 }
engine/runtime/action-source/src/file/reader/citygml.rs (1)

Line range hint 122-138: Encapsulate coordinate transformation into a separate function

The coordinate swapping logic at lines 135-137 could be moved into a dedicated function or method. This would enhance code readability and make future maintenance or changes to the transformation logic easier.

engine/runtime/action-processor/src/feature/reader/citygml.rs (5)

24-28: Add documentation comments to CityGmlReaderParam.

Consider adding Rust documentation comments (///) to the CityGmlReaderParam struct and its fields to enhance code readability and maintainability.

Apply this diff to add documentation:

 #[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
 #[serde(rename_all = "camelCase")]
+/// Parameters for reading CityGML data.
 pub struct CityGmlReaderParam {
+    /// If true, entities will be flattened.
     pub(super) flatten: Option<bool>,
 }

31-32: Ensure consistent error messages in read_citygml.

The error handling within read_citygml uses custom messages. To improve debugging and user feedback, ensure these messages are consistent and provide clear context for the errors.


64-71: Simplify the flatten parameter handling.

Unwrapping citygml_params.flatten before the function call improves readability and avoids repetitive code.

Apply this diff:

 let code_resolver = nusamai_plateau::codelist::Resolver::new();
 let expr_engine = Arc::clone(&ctx.expr_engine);
 let feature = &ctx.feature;
 let scope = feature.new_scope(expr_engine.clone());
 let city_gml_path = scope.eval_ast::<String>(&params.expr).map_err(|e| {
     super::errors::FeatureProcessorError::FileCityGmlReader(format!(
         "Failed to evaluate expr: {}",
         e
     ))
 })?;
 let flatten = citygml_params.flatten.unwrap_or(false);

 parse_tree_reader(
     &mut st,
-    citygml_params.flatten.unwrap_or(false),
+    flatten,
     base_url,
     ctx,
     fw,
 )
 .map_err(|e| super::errors::FeatureProcessorError::FileCityGmlReader(format!("{:?}", e)))?;

Line range hint 77-188: Refactor to reduce code duplication in the flatten conditional blocks.

The if flatten and else blocks share similar logic with minor differences. Refactoring can improve code maintainability and reduce duplication.

You might consider extracting the common code into a separate function:

if flatten {
    let entities = FlattenTreeTransform::transform(entity);
    process_entities(entities, &mut transformer, &attributes, ctx, fw)?;
} else {
    transformer.transform(&mut entity);
    process_entities(vec![entity], &mut transformer, &attributes, ctx, fw)?;
}

fn process_entities(
    entities: Vec<Entity>,
    transformer: &mut GeometricMergedownTransform,
    attributes: &HashMap<Attribute, AttributeValue>,
    ctx: ExecutorContext,
    fw: &mut dyn ProcessorChannelForwarder,
) -> Result<(), super::errors::FeatureProcessorError> {
    for mut entity in entities {
        transformer.transform(&mut entity);
        let geometry: Geometry = entity.try_into().map_err(|e| {
            super::errors::FeatureProcessorError::FileCityGmlReader(format!("{:?}", e))
        })?;
        let mut feature: Feature = geometry.into();
        feature.extend(attributes.clone());
        fw.send(ctx.new_with_feature_and_port(feature, DEFAULT_PORT.clone()));
    }
    Ok(())
}

160-168: Ensure consistent attribute naming conventions.

The keys in the attributes HashMap (e.g., "cityGmlAttributes", "gmlName", "gmlId", "gmlRootId") should follow a consistent naming convention for clarity and to prevent potential issues during attribute access.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between adffad5 and d70301e.

⛔ Files ignored due to path filters (1)
  • engine/docs/mdbook/src/action.md is excluded by !**/*.md
📒 Files selected for processing (7)
  • engine/runtime/action-processor/src/feature/reader.rs (4 hunks)
  • engine/runtime/action-processor/src/feature/reader/citygml.rs (3 hunks)
  • engine/runtime/action-processor/src/feature/reader/csv.rs (1 hunks)
  • engine/runtime/action-source/src/file/reader/citygml.rs (6 hunks)
  • engine/runtime/action-source/src/file/reader/runner.rs (2 hunks)
  • engine/runtime/examples/plateau/example_feature_transformer.rs (1 hunks)
  • engine/schema/actions.json (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • engine/runtime/examples/plateau/example_feature_transformer.rs
🧰 Additional context used
🔇 Additional comments (9)
engine/runtime/action-processor/src/feature/reader/csv.rs (3)

11-11: LGTM: New import aligns with restructuring.

The addition of use super::CompiledCommonReaderParam; is consistent with the refactoring mentioned in the summary, where CommonReaderParam replaces CommonPropertySchema.


15-15: LGTM: Struct renamed for clarity.

The renaming of CsvPropertySchema to CsvReaderParam improves code clarity by better reflecting its purpose as a parameter for the CSV reader.


21-22: LGTM: Function signature updated to match new parameter types.

The read_csv function signature has been correctly updated to use CompiledCommonReaderParam and CsvReaderParam, aligning with the struct renaming and new parameter types.

To ensure consistency across the codebase, please run the following script to check for any remaining references to the old types:

✅ Verification successful

Verified: No remaining references to CompiledCommonPropertySchema or CsvPropertySchema were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to old types

# Test 1: Search for CompiledCommonPropertySchema
echo "Searching for CompiledCommonPropertySchema:"
rg "CompiledCommonPropertySchema"

# Test 2: Search for CsvPropertySchema
echo "Searching for CsvPropertySchema:"
rg "CsvPropertySchema"

# Test 3: Search for calls to read_csv function
echo "Searching for read_csv function calls:"
ast-grep --pattern 'read_csv($$$)'

Length of output: 352

engine/schema/actions.json (1)

1348-1353: LGTM. Ensure consistency across the codebase.

The addition of the flatten parameter to the FileReader action for the citygml format is consistent with the changes in FeatureReader. This provides a unified approach to CityGML processing across different reader types.

To ensure consistency, please run the following script to check if the flatten parameter is used consistently across the codebase:

✅ Verification successful

Please run the following script to verify the consistent usage of the flatten parameter across all action schema files:


'Flatten' parameter consistency verified across action schemas.

All relevant reader actions include the flatten parameter for CityGML processing.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of the 'flatten' parameter across the codebase.

# Test: Search for 'flatten' usage in relation to CityGML processing
rg -i 'flatten.*citygml|citygml.*flatten' --type rust

Length of output: 166


Script:

# 
#!/bin/bash
# Description: Verify 'flatten' parameter consistency across all action schema JSON files.

# Test: Search for 'flatten' parameter in all JSON action schema files
rg -i '"flatten"\s*:' --type json

Length of output: 143

engine/runtime/action-source/src/file/reader/runner.rs (2)

44-45: Maintain consistency in parameter handling across all file formats

The Citygml variant now includes a property field with #[serde(flatten)], aligning it with the Csv and Tsv variants. This promotes consistency in how additional parameters are handled for different file formats, which is good practice.


112-117: Handle potential errors from get_input_path uniformly

In the match arms for other file formats, if get_input_path returns an error, it propagates up appropriately. Ensure that the error handling for Citygml is consistent with the rest of the codebase, and that any errors from get_input_path are properly managed.

Run the following script to check for consistent error handling:

✅ Verification successful

Consistent Error Handling Verified

All instances of get_input_path uniformly propagate errors using the ? operator. No discrepancies found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all uses of `get_input_path` handle errors consistently.

# Search for all instances where `get_input_path` is called.
rg 'let input_path = get_input_path\(&ctx, common_property\)\?;'

# Check that the error handling after each call matches.

# There should be no discrepancies in how errors are propagated after calling `get_input_path`.

Length of output: 578

engine/runtime/action-processor/src/feature/reader.rs (1)

Line range hint 140-152: Ensure consistent usage of CommonReaderParam

The struct CommonPropertySchema has been renamed to CommonReaderParam. Verify that all references to CommonPropertySchema are updated throughout the codebase to prevent any inconsistencies or compilation errors.

Run the following script to check for any remaining references:

engine/runtime/action-source/src/file/reader/citygml.rs (2)

133-138: Verify the coordinate swapping logic for accuracy

The code swaps the x and y coordinates of each vertex at lines 135-137. Ensure that this transformation accurately reflects the intended coordinate system conversion (e.g., from (lat, lng) to (lng, lat)). Misordering coordinates can lead to incorrect geometries and map rendering issues.


167-167: Optimize attribute cloning to improve performance

At line 167, attributes.clone() is called for each feature within the loop. If the attributes HashMap remains unchanged throughout the loop, clone it once before the loop and reuse the cloned version to avoid unnecessary overhead.

[performance]

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (4)
engine/schema/actions.json (2)

1007-1012: LGTM. Consider updating documentation.

The addition of the optional flatten parameter to the FeatureReader processor for the citygml format is a good enhancement. It provides more flexibility in processing CityGML data while maintaining backward compatibility.

Consider updating the processor's description or adding inline comments to explain the purpose and effect of the flatten parameter.


1007-1012: Summary: Consistent and backward-compatible enhancement

The addition of the flatten parameter to both FeatureReader and FileReader processors for CityGML format is a well-implemented enhancement. It provides more flexibility in data processing while maintaining backward compatibility. The consistent implementation across both readers ensures a uniform approach to handling CityGML data.

Consider adding a brief explanation of the flatten parameter's functionality in the schema descriptions for both processors to improve clarity for users of this schema.

Also applies to: 1348-1353

engine/runtime/action-source/src/file/reader/citygml.rs (2)

23-27: Add documentation for CityGmlReaderParam and its fields

Providing documentation comments for the CityGmlReaderParam struct and its flatten field will enhance code readability and maintainability.


150-158: Avoid shadowing the attributes variable

The variable attributes is redefined as a HashMap, which may cause confusion with the existing attributes derived from entity.root.to_attribute_json(). Consider renaming one of the variables to improve clarity.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between adffad5 and d70301e.

⛔ Files ignored due to path filters (1)
  • engine/docs/mdbook/src/action.md is excluded by !**/*.md
📒 Files selected for processing (7)
  • engine/runtime/action-processor/src/feature/reader.rs (4 hunks)
  • engine/runtime/action-processor/src/feature/reader/citygml.rs (3 hunks)
  • engine/runtime/action-processor/src/feature/reader/csv.rs (1 hunks)
  • engine/runtime/action-source/src/file/reader/citygml.rs (6 hunks)
  • engine/runtime/action-source/src/file/reader/runner.rs (2 hunks)
  • engine/runtime/examples/plateau/example_feature_transformer.rs (1 hunks)
  • engine/schema/actions.json (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • engine/runtime/examples/plateau/example_feature_transformer.rs
🧰 Additional context used
🔇 Additional comments (13)
engine/runtime/action-processor/src/feature/reader/csv.rs (4)

11-11: LGTM: Import statement updated correctly.

The import statement has been updated to reflect the renaming of CompiledCommonPropertySchema to CompiledCommonReaderParam. This change is consistent with the refactoring mentioned in the PR objectives.


Line range hint 1-78: Summary: Successful refactoring of CSV reader component.

The changes in this file successfully implement the refactoring mentioned in the PR objectives. The renaming of structs and updating of parameter types improve code clarity and consistency. The core CSV reading functionality remains intact, which is crucial for maintaining existing behavior.

Key points:

  1. CsvPropertySchema renamed to CsvReaderParam
  2. CompiledCommonPropertySchema replaced with CompiledCommonReaderParam
  3. Function parameters in read_csv updated accordingly

These changes align well with the overall goal of refactoring the engine component and updating parameter names.


21-22: LGTM: Function parameters updated correctly.

The parameter types in the read_csv function have been properly updated to reflect the renamed structs:

  1. params: &CompiledCommonReaderParam
  2. csv_params: &CsvReaderParam

These changes maintain consistency with the struct renaming.

To ensure all calls to this function have been updated accordingly, please run the following verification:

#!/bin/bash
# Description: Check for any remaining occurrences of old parameter types in function calls
# Test: Search for read_csv function calls. Expect: All calls use new parameter types

rg 'read_csv\s*\(' -A 3

15-15: LGTM: Struct renamed for clarity.

The struct has been appropriately renamed from CsvPropertySchema to CsvReaderParam, which better reflects its purpose as a parameter for the CSV reader.

To ensure consistency across the codebase, please verify all occurrences of this struct have been updated:

✅ Verification successful

Verified: Struct renaming successful.

All instances of CsvPropertySchema have been correctly updated to CsvReaderParam, ensuring consistency across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining occurrences of CsvPropertySchema
# Test: Search for CsvPropertySchema. Expect: No results

rg 'CsvPropertySchema'

Length of output: 2154

engine/schema/actions.json (1)

1348-1353: LGTM. Ensure consistent implementation.

The addition of the optional flatten parameter to the FileReader processor for the citygml format is consistent with the changes made to the FeatureReader. This ensures a uniform approach to processing CityGML data across different reader types.

To ensure consistency, please verify that the implementation of the flatten parameter in both FeatureReader and FileReader behaves identically for CityGML processing. Run the following script to check for any discrepancies:

✅ Verification successful

Verified: Consistent implementation of flatten parameter in both FeatureReader and FileReader.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent implementation of `flatten` parameter in FeatureReader and FileReader

# Test: Search for the implementation of flatten parameter in both readers
echo "Searching for flatten parameter implementation in FeatureReader:"
rg -p 'impl.*FeatureReader.*flatten' engine/runtime/action-processor/src/feature/reader/

echo "\nSearching for flatten parameter implementation in FileReader:"
rg -p 'impl.*FileReader.*flatten' engine/runtime/action-source/src/file/reader/

Length of output: 448


Script:

#!/bin/bash
# Description: Verify consistent implementation of `flatten` parameter in FeatureReader and FileReader with adjusted patterns

# Test: Search for the usage and implementation of flatten parameter in both readers
echo "Searching for 'flatten' parameter usage in FeatureReader:"
rg 'flatten' engine/runtime/action-processor/src/feature/reader/

echo "\nSearching for 'flatten' parameter usage in FileReader:"
rg 'flatten' engine/runtime/action-source/src/file/reader/

Length of output: 1709

engine/runtime/action-processor/src/feature/reader.rs (2)

203-232: Confirm that updated parameters are correctly utilized in processing

In the process method, ensure that the updated common_param and param are correctly passed to the reading functions for each format. This is crucial to guarantee that the new parameter structures are utilized properly during processing.

You can verify the correctness by reviewing the function signatures in citygml.rs and csv.rs to ensure they accept the updated parameters.


Line range hint 140-187: Ensure all references to renamed structs are updated

The struct CommonPropertySchema has been renamed to CommonReaderParam, and CompiledCommonPropertySchema to CompiledCommonReaderParam. Verify that all references to the old struct names have been updated throughout the codebase to prevent compilation errors.

Run the following script to check for any remaining references to the old struct names:

✅ Verification successful

All references to the old struct names have been successfully updated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for occurrences of the old struct names in the codebase

# Expect: No matches found for `CommonPropertySchema` or `CompiledCommonPropertySchema`
rg 'CommonPropertySchema|CompiledCommonPropertySchema'

Length of output: 56


Script:

#!/bin/bash
# Description: Search for exact occurrences of the old struct names in the codebase

# Expect: No matches found for `CommonPropertySchema` or `CompiledCommonPropertySchema`
rg '\bCommonPropertySchema\b|\bCompiledCommonPropertySchema\b' --case-sensitive -A 2

Length of output: 86

engine/runtime/action-source/src/file/reader/citygml.rs (1)

132-138: Verify the necessity of swapping vertex coordinates

Swapping the x and y coordinates of the vertices may lead to incorrect geometries if not intended. Please verify that this transformation is necessary for the data being processed and aligns with the coordinate system conventions.

engine/runtime/action-processor/src/feature/reader/citygml.rs (4)

24-28: Addition of CityGmlReaderParam struct is appropriate

The CityGmlReaderParam struct is well-defined with serialization and deserialization traits, enhancing the configurability of the CityGML reader.


31-32: Update of read_citygml function signature aligns with new parameters

Including citygml_params in the read_citygml function signature accommodates the new parameters and maintains consistency in parameter passing.


64-71: Passing flatten parameter to parse_tree_reader is correctly implemented

Using citygml_params.flatten.unwrap_or(false) safely handles the optional flatten parameter, defaulting to false when not provided.


77-77: Update of parse_tree_reader function signature is appropriate

Adding the flatten parameter to the parse_tree_reader function signature properly integrates the new functionality.

engine/runtime/action-source/src/file/reader/runner.rs (1)

44-45: LGTM!

Adding the property field to the Citygml variant maintains consistency with other variants like Csv and Tsv. The use of #[serde(flatten)] is appropriate for serializing and deserializing nested parameters.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (4)
engine/runtime/action-source/src/file/reader/runner.rs (1)

44-45: LGTM! Consider adding documentation for the new Citygml variant.

The addition of the Citygml variant to the FileReader enum is well-structured and consistent with the existing code. It aligns with the PR objectives to enhance CityGML processing.

Consider adding a brief documentation comment for the Citygml variant to explain its purpose and usage, similar to other variants if they exist.

engine/runtime/action-processor/src/feature/reader/citygml.rs (3)

30-32: LGTM: Updated function signature improves flexibility.

The changes to the read_citygml function signature, including the new citygml_params parameter and the updated params type, enhance the configurability of the CityGML reading process. This aligns well with the PR objectives.

Consider updating the error handling to include the new citygml_params in error messages for better debugging:

super::errors::FeatureProcessorError::FileCityGmlReader(format!(
    "Failed to evaluate expr: {}. CityGML params: {:?}",
    e, citygml_params
))

64-71: LGTM: Flattening option adds flexibility to CityGML processing.

The addition of the flatten parameter to parse_tree_reader and its usage in read_citygml provide a way to control the CityGML structure processing. This enhancement aligns with the PR objectives.

Consider adding more context to the error message:

super::errors::FeatureProcessorError::FileCityGmlReader(format!(
    "Error parsing tree reader with flatten={}: {:?}",
    flatten, e
))

Also applies to: 76-77


162-185: LGTM: Improved attribute handling and flexible entity processing.

The use of HashMap for attributes and the addition of new metadata attributes (gmlName, gmlId, gmlRootId) enhance the feature representation. The conditional processing based on the flatten parameter provides flexibility in output structure, aligning with the PR objectives.

Consider using HashMap::with_capacity to potentially improve performance:

let mut attributes = HashMap::with_capacity(4 + ctx.feature.attributes.len());
attributes.insert(Attribute::new("cityGmlAttributes"), attributes.into());
// ... insert other attributes
attributes.extend(ctx.feature.attributes.clone());
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d70301e and d13c5bb.

📒 Files selected for processing (3)
  • engine/runtime/action-processor/src/feature/reader/citygml.rs (4 hunks)
  • engine/runtime/action-source/src/file/reader/citygml.rs (6 hunks)
  • engine/runtime/action-source/src/file/reader/runner.rs (2 hunks)
🧰 Additional context used
🔇 Additional comments (5)
engine/runtime/action-source/src/file/reader/runner.rs (1)

Line range hint 112-122: LGTM! The Citygml case is well-implemented.

The implementation of the Citygml case in the start method is consistent with other file format handlers and correctly uses the new property field. Great job implementing the suggestion from past reviews by passing storage_resolver instead of ctx to read_citygml.

engine/runtime/action-processor/src/feature/reader/citygml.rs (2)

2-2: LGTM: New imports and struct enhance functionality.

The addition of HashMap, FlattenTreeTransform, and JsonSchema imports, along with the new CityGmlReaderParam struct, provide the necessary components for the flattening feature and improved attribute handling. These changes align well with the PR objectives of enhancing CityGML processing.

Also applies to: 8-10, 18-19, 24-28


171-171: 🛠️ Refactor suggestion

Consider optimizing attribute cloning.

The unnecessary cloning of ctx.feature.attributes noted in a previous review is still present. This can have performance implications, especially for large attribute sets.

Consider using a reference or moving the attributes instead of cloning:

let mut attributes = ctx.feature.attributes.clone();
attributes.insert(Attribute::new("cityGmlAttributes"), cityGml_attributes.into());
attributes.insert(Attribute::new("gmlName"), name);
attributes.insert(Attribute::new("gmlId"), gml_id);
attributes.insert(Attribute::new("gmlRootId"), AttributeValue::String(format!("root_{}", to_hash(base_url.as_str()))));

This approach clones the attributes once and then modifies the cloned version, which may be more efficient.

engine/runtime/action-source/src/file/reader/citygml.rs (2)

2-25: LGTM

The introduction of the CityGmlReaderParam struct and the updates to include the flatten parameter enhance the flexibility of the code. Serialization and deserialization are correctly implemented, and the optional flatten parameter is appropriately handled.


157-177: LGTM

The implementation of the flatten parameter logic correctly handles the entity transformation based on its value. The use of FlattenTreeTransform::transform(entity) when flatten is true and the subsequent processing are appropriately managed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant