Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Added MutableMapArray #1311

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jondo2010
Copy link
Contributor

@jondo2010 jondo2010 commented Dec 1, 2022

There's still a few things to do on this (2 todo!()'s still in the MutableArray impl), but wanted to get early feedback.

Closes #1310

@codecov
Copy link

codecov bot commented Dec 1, 2022

Codecov Report

Base: 83.12% // Head: 83.09% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (f4c9823) compared to base (0ba4f8e).
Patch coverage: 44.44% of modified lines in pull request are covered.

❗ Current head f4c9823 differs from pull request most recent head 9106355. Consider uploading reports for the commit 9106355 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1311      +/-   ##
==========================================
- Coverage   83.12%   83.09%   -0.04%     
==========================================
  Files         369      370       +1     
  Lines       40180    40386     +206     
==========================================
+ Hits        33399    33558     +159     
- Misses       6781     6828      +47     
Impacted Files Coverage Δ
src/array/map/mod.rs 64.37% <ø> (+5.00%) ⬆️
src/array/mod.rs 64.93% <ø> (ø)
src/array/map/mutable.rs 38.98% <38.98%> (ø)
src/array/struct_/mutable.rs 45.78% <62.85%> (+8.02%) ⬆️
src/io/ipc/read/file.rs 96.42% <0.00%> (-0.45%) ⬇️
src/ffi/schema.rs 90.08% <0.00%> (-0.30%) ⬇️
src/array/specification.rs 92.23% <0.00%> (-0.16%) ⬇️
src/io/parquet/write/sink.rs 72.41% <0.00%> (ø)
src/io/parquet/write/mod.rs 86.72% <0.00%> (+0.37%) ⬆️
src/io/parquet/read/deserialize/utils.rs 82.23% <0.00%> (+0.89%) ⬆️
... and 9 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jorgecarleitao jorgecarleitao added the feature A new feature label Dec 2, 2022
Copy link
Owner

@jorgecarleitao jorgecarleitao left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the contribution! This looks great!

I left minor comments, but otherwise I think we just need a bit more tests covering the different APIs.

One imo useful test here is:

let mut mutable = MutableMapArray::...
let a = mutable.take_into();
let b: MapArray = mutable.into()

assert_eq!(b.len(), 0)


use super::MapArray;

/// The mutable version lf [`MapArray`].
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
/// The mutable version lf [`MapArray`].
/// The mutable version of [`MapArray`].

fn take_into(&mut self) -> MapArray {
MapArray::from_data(
self.data_type.clone(),
std::mem::take(&mut self.offsets).into(),
Copy link
Owner

Choose a reason for hiding this comment

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

if we take here, the offsets end up being empty, which I believe violates an invariant of self

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah, the API on MutableArray is unclear here. Shouldn't as_box and as_arc take self instead of &mut self?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, but that would require MutableArray to not be object safe, and we need that for using it as a trait object.

/// * `data_type` is not [`DataType::Struct`]
/// * The inner types of `data_type` are not equal to those of `values`
/// * `validity` is not `None` and its length is different from the `values`'s length
pub fn from_data(
pub fn try_from_data(
Copy link
Owner

Choose a reason for hiding this comment

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

could we rename it to try_new instead? It is more aligned with the rest of the containers

@jorgecarleitao
Copy link
Owner

Hey! Could you rebase so we can merge it in? :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Add MutableMapArray
2 participants