You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/06/08 04:22:25 UTC
[GitHub] [arrow-rs] Jimexist opened a new pull request #424: WIP add lexicographically partition points
Jimexist opened a new pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424
# Which issue does this PR close?
<!---
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #.
# Rationale for this change
<!---
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!---
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!---
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking change` label.
-->
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] jorgecarleitao commented on a change in pull request #424: add lexicographically partition points and ranges
Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on a change in pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424#discussion_r647147870
##########
File path: arrow/src/compute/kernels/partition.rs
##########
@@ -25,7 +25,7 @@ use std::cmp::Ordering;
/// Given a list of sort columns, find partition points that would partition lexicographically
/// equal values across columns; Here LexicographicalComparator is used in conjunction with binary
/// search so the columns *MUST* be pre-sorted already.
-pub fn lex_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
+pub fn lexicographical_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
Review comment:
sure, let's keep it private, then. 👍
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] Jimexist commented on a change in pull request #424: add lexicographically partition points and ranges
Posted by GitBox <gi...@apache.org>.
Jimexist commented on a change in pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424#discussion_r647891165
##########
File path: arrow/src/compute/kernels/partition.rs
##########
@@ -0,0 +1,314 @@
+// 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.
+
+//! Defines partition kernel for `ArrayRef`
+
+use crate::compute::kernels::sort::LexicographicalComparator;
+use crate::compute::SortColumn;
+use crate::error::{ArrowError, Result};
+use std::cmp::Ordering;
+use std::ops::Range;
+
+/// Given a list of already sorted columns, find partition ranges that would partition
+/// lexicographically equal values across columns.
+///
+/// Here LexicographicalComparator is used in conjunction with binary
+/// search so the columns *MUST* be pre-sorted already.
+///
+/// The returned vec would be of size k where k is cardinality of the sorted values; Consecutive
+/// values will be connected: (a, b) and (b, c), where start = 0 and end = n for the first and last
+/// range.
+pub fn lexicographical_partition_ranges(
+ columns: &[SortColumn],
+) -> Result<Vec<Range<usize>>> {
+ let partition_points = lexicographical_partition_points(columns)?;
+ Ok(partition_points
+ .iter()
+ .zip(partition_points[1..].iter())
+ .map(|(&start, &end)| Range { start, end })
+ .collect())
+}
+
+/// Given a list of already sorted columns, find partition ranges that would partition
+/// lexicographically equal values across columns.
+///
+/// Here LexicographicalComparator is used in conjunction with binary
+/// search so the columns *MUST* be pre-sorted already.
+///
+/// The returned vec would be of size k+1 where k is cardinality of the sorted values; the first and
+/// last value would be 0 and n.
+fn lexicographical_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
Review comment:
tracked in https://github.com/apache/arrow-rs/issues/437
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb merged pull request #424: add lexicographically partition points and ranges
Posted by GitBox <gi...@apache.org>.
alamb merged pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] jorgecarleitao commented on a change in pull request #424: add lexicographically partition points and ranges
Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on a change in pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424#discussion_r647625641
##########
File path: arrow/src/compute/kernels/partition.rs
##########
@@ -0,0 +1,314 @@
+// 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.
+
+//! Defines partition kernel for `ArrayRef`
+
+use crate::compute::kernels::sort::LexicographicalComparator;
+use crate::compute::SortColumn;
+use crate::error::{ArrowError, Result};
+use std::cmp::Ordering;
+use std::ops::Range;
+
+/// Given a list of already sorted columns, find partition ranges that would partition
+/// lexicographically equal values across columns.
+///
+/// Here LexicographicalComparator is used in conjunction with binary
+/// search so the columns *MUST* be pre-sorted already.
+///
+/// The returned vec would be of size k where k is cardinality of the sorted values; Consecutive
+/// values will be connected: (a, b) and (b, c), where start = 0 and end = n for the first and last
+/// range.
+pub fn lexicographical_partition_ranges(
+ columns: &[SortColumn],
+) -> Result<Vec<Range<usize>>> {
+ let partition_points = lexicographical_partition_points(columns)?;
+ Ok(partition_points
+ .iter()
+ .zip(partition_points[1..].iter())
+ .map(|(&start, &end)| Range { start, end })
+ .collect())
+}
+
+/// Given a list of already sorted columns, find partition ranges that would partition
+/// lexicographically equal values across columns.
+///
+/// Here LexicographicalComparator is used in conjunction with binary
+/// search so the columns *MUST* be pre-sorted already.
+///
+/// The returned vec would be of size k+1 where k is cardinality of the sorted values; the first and
+/// last value would be 0 and n.
+fn lexicographical_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
Review comment:
It should be possible to write the below as an iterator, thereby avoiding the allocation of the vector.
The general idea: create a struct with a method `try_new`. That method initializes the struct's content and errors if something is wrong (e.g. empty columns). It also initializes `lexicographical_comparator`.
Next, implement `Iterator<Item=usize>` for that struct where `Iterator::next` yields `previous_partition_point` and increments it as written in this function.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] Jimexist commented on a change in pull request #424: add lexicographically partition points and ranges
Posted by GitBox <gi...@apache.org>.
Jimexist commented on a change in pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424#discussion_r647146529
##########
File path: arrow/src/compute/kernels/partition.rs
##########
@@ -25,7 +25,7 @@ use std::cmp::Ordering;
/// Given a list of sort columns, find partition points that would partition lexicographically
/// equal values across columns; Here LexicographicalComparator is used in conjunction with binary
/// search so the columns *MUST* be pre-sorted already.
-pub fn lex_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
+pub fn lexicographical_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
Review comment:
@jorgecarleitao actually this is intended to be used in lexicographical_partition_ranges. i can make this one private?
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] jorgecarleitao commented on a change in pull request #424: WIP add lexicographically partition points
Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on a change in pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424#discussion_r647104155
##########
File path: arrow/src/compute/kernels/partition.rs
##########
@@ -25,7 +25,7 @@ use std::cmp::Ordering;
/// Given a list of sort columns, find partition points that would partition lexicographically
/// equal values across columns; Here LexicographicalComparator is used in conjunction with binary
/// search so the columns *MUST* be pre-sorted already.
-pub fn lex_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
+pub fn lexicographical_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
Review comment:
Maybe return `UIntArray64` instead of `Vec<usize>` to keep it consistent with the rest of the kernels?
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb commented on pull request #424: add lexicographically partition points and ranges
Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424#issuecomment-857150318
BTW I hope to get this into Arrow 4.3 -- I plan to build a release candidate for that on Thursday or Friday this week and release early next week. Once it gets released it will then be available in DataFusion
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] Jimexist commented on a change in pull request #424: add lexicographically partition points and ranges
Posted by GitBox <gi...@apache.org>.
Jimexist commented on a change in pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424#discussion_r647146529
##########
File path: arrow/src/compute/kernels/partition.rs
##########
@@ -25,7 +25,7 @@ use std::cmp::Ordering;
/// Given a list of sort columns, find partition points that would partition lexicographically
/// equal values across columns; Here LexicographicalComparator is used in conjunction with binary
/// search so the columns *MUST* be pre-sorted already.
-pub fn lex_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
+pub fn lexicographical_partition_points(columns: &[SortColumn]) -> Result<Vec<usize>> {
Review comment:
@jorgecarleitao actually this is intended to be used in `lexicographical_partition_ranges`. i can make this one private?
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb commented on pull request #424: add lexicographically partition points and ranges
Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #424:
URL: https://github.com/apache/arrow-rs/pull/424#issuecomment-857145786
I filed https://github.com/apache/arrow-rs/issues/428 to track this. Thanks @Jimexist
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org