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

Add contains(List, Array) #263

Open
jyizheng opened this issue Aug 9, 2021 · 7 comments
Open

Add contains(List, Array) #263

jyizheng opened this issue Aug 9, 2021 · 7 comments
Labels
feature A new feature good first issue Good for newcomers

Comments

@jyizheng
Copy link

jyizheng commented Aug 9, 2021

For the contains operations, the list needs to be duplicated for each element in the array, according to the test pointed by the link below. What is the reason behind this implementation?

let data = vec![

@jorgecarleitao
Copy link
Owner

jorgecarleitao commented Aug 9, 2021

contains is currently implemented as contains(Array, Array) -> BooleanArray and vectorized over each item of each (a la zip). The tests is written just to test the different behaviors.

Are you wondering why there isn't something like list_array.contains(item) -> bool?

@jorgecarleitao jorgecarleitao added the question Further information is requested label Aug 9, 2021
@jyizheng
Copy link
Author

jyizheng commented Aug 9, 2021

Thanks for your timely reply. My question is why the interface is not list_array.contains(array) -> BooleanArray.
In the current implementation, the first array duplicates the list many times, which consumes more memory than necessary.
I guess the reason for such an implementation is vectorization.

@jorgecarleitao
Copy link
Owner

just to check I understood: given let r = list_array.contains(array), r.len() == array.len(), I.e. is the idea to check whether list_array contains item 0, 1, 2, ..., N of array, right?

@jyizheng
Copy link
Author

jyizheng commented Aug 9, 2021

Yes, that is what I mean.

@jorgecarleitao
Copy link
Owner

cool. If you think it is useful, let's convert this question into an issue not framed as a question and implement it as a function, e.g. something like

fn can_in_list(&DataType) -> bool;
fn in_list<O: Offset>(list: ListArray<O>, values: &dyn Array) -> Result<BooleanArray>;

@jyizheng
Copy link
Author

jyizheng commented Aug 9, 2021

Sure. I am happy to do that.

@jorgecarleitao jorgecarleitao added feature A new feature and removed question Further information is requested labels Oct 8, 2021
@jorgecarleitao jorgecarleitao changed the title contains operation Add contains(List, value) Oct 8, 2021
@jorgecarleitao jorgecarleitao changed the title Add contains(List, value) Add contains(List, Array) Oct 8, 2021
@jorgecarleitao jorgecarleitao added the good first issue Good for newcomers label Oct 8, 2021
@ozgrakkurt
Copy link
Contributor

Hey, I'm working on this

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

Successfully merging a pull request may close this issue.

3 participants