rtpsw commented on code in PR #14352:
URL: https://github.com/apache/arrow/pull/14352#discussion_r1027279305
##########
cpp/src/arrow/compute/row/grouper.h:
##########
@@ -30,6 +30,44 @@
namespace arrow {
namespace compute {
+/// \brief A segment of contiguous rows for grouping
+struct ARROW_EXPORT GroupingSegment {
+ int64_t offset;
+ int64_t length;
+ bool is_open;
+};
+
+inline bool operator==(const GroupingSegment& segment1, const GroupingSegment&
segment2) {
+ return segment1.offset == segment2.offset && segment1.length ==
segment2.length &&
+ segment1.is_open == segment2.is_open;
+}
+inline bool operator!=(const GroupingSegment& segment1, const GroupingSegment&
segment2) {
+ return !(segment1 == segment2);
+}
+
+/// \brief Computes grouping segments for a batch. Each segment covers rows
with identical
+/// values in the batch. The values in the batch are often selected as keys
from a larger
+/// batch.
+class ARROW_EXPORT GroupingSegmenter {
+ public:
+ virtual ~GroupingSegmenter() = default;
+
+ /// \brief Construct a GroupingSegmenter which receives the specified key
types
+ static Result<std::unique_ptr<GroupingSegmenter>> Make(
+ std::vector<TypeHolder> key_types, ExecContext* ctx =
default_exec_context());
+
+ /// \brief Reset this grouping segmenter
+ virtual Status Reset() = 0;
+
+ /// \brief Get the next segment for the given batch starting from the given
offset
+ virtual Result<GroupingSegment> GetNextSegment(const ExecSpan& batch,
+ int64_t offset) = 0;
+
+ /// \brief Get the next segment for the given batch starting from the given
offset
+ virtual Result<GroupingSegment> GetNextSegment(const ExecBatch& batch,
+ int64_t offset) = 0;
Review Comment:
I don't see a clean way. Since this is a virtual method, a template approach
is inapplicable. And while it's possible to use a variant with `ExecSpan` and
`ExecBatch` as its types, this approach doesn't look cleaner than the current
one.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]