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

[Rust] Support row map #1206

Merged
merged 1 commit into from
Dec 4, 2023
Merged

[Rust] Support row map #1206

merged 1 commit into from
Dec 4, 2023

Conversation

theweipeng
Copy link
Member

What do these changes do?

  1. Ensure that the library only exports the necessary modules.
  2. Rust row format support Map.
    Add a new binary accessor named MapGetter, which wraps two ArrayGetter instances to access keys and values. Additionally, include a function to convert keys and values into a BTreeMap.

usage:

#[test]
fn rowmap() {
    #[derive(FuryRow)]
    struct Foo {
        f5: BTreeMap<String, String>,
    }

    let mut f5: BTreeMap<String, String> = BTreeMap::new();
    f5.insert(String::from("k1"), String::from("v1"));
    f5.insert(String::from("k2"), String::from("v2"));

    let row = to_row(&Foo {
        f5,
    },);

    let obj = from_row::<Foo>(&row);
    let binding = obj.f5();

    assert_eq!(binding.keys().size(), 2);
    assert_eq!(binding.keys().get(0), "k1");

    assert_eq!(binding.values().size(), 2);
    assert_eq!(binding.values().get(0), "v1");

    let f5 = binding.to_btree_map().expect("should be map");
    assert_eq!(f5.get("k1").expect("should exists"), &"v1");
    assert_eq!(f5.get("k2").expect("should exists"), &"v2");
}

Related issue number

Closes #1205

Check code requirements

  • tests added / passed (if needed)
  • Ensure all linting tests pass, see here for how to run them

Copy link
Collaborator

@chaokunyang chaokunyang left a comment

Choose a reason for hiding this comment

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

LGTM, great work!

@chaokunyang chaokunyang merged commit e814db7 into apache:main Dec 4, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Rust] Support for BTreeMap in Rust row format should be added
2 participants