zanmato1984 commented on code in PR #44217:
URL: https://github.com/apache/arrow/pull/44217#discussion_r1858029415
##########
cpp/src/arrow/compute/kernels/vector_sort_internal.h:
##########
@@ -142,53 +144,73 @@ int CompareTypeValues(const Value& left, const Value&
right, SortOrder order,
return ValueComparator<Type>::Compare(left, right, order, null_placement);
}
-struct NullPartitionResult {
- uint64_t* non_nulls_begin;
- uint64_t* non_nulls_end;
- uint64_t* nulls_begin;
- uint64_t* nulls_end;
+template <typename IndexType>
+struct GenericNullPartitionResult {
+ IndexType* non_nulls_begin;
+ IndexType* non_nulls_end;
+ IndexType* nulls_begin;
+ IndexType* nulls_end;
- uint64_t* overall_begin() const { return std::min(nulls_begin,
non_nulls_begin); }
+ IndexType* overall_begin() const { return std::min(nulls_begin,
non_nulls_begin); }
- uint64_t* overall_end() const { return std::max(nulls_end, non_nulls_end); }
+ IndexType* overall_end() const { return std::max(nulls_end, non_nulls_end); }
int64_t non_null_count() const { return non_nulls_end - non_nulls_begin; }
int64_t null_count() const { return nulls_end - nulls_begin; }
- static NullPartitionResult NoNulls(uint64_t* indices_begin, uint64_t*
indices_end,
- NullPlacement null_placement) {
+ static GenericNullPartitionResult NoNulls(IndexType* indices_begin,
+ IndexType* indices_end,
+ NullPlacement null_placement) {
if (null_placement == NullPlacement::AtStart) {
return {indices_begin, indices_end, indices_begin, indices_begin};
} else {
return {indices_begin, indices_end, indices_end, indices_end};
}
}
- static NullPartitionResult NullsOnly(uint64_t* indices_begin, uint64_t*
indices_end,
- NullPlacement null_placement) {
+ static GenericNullPartitionResult NullsOnly(IndexType* indices_begin,
+ IndexType* indices_end,
+ NullPlacement null_placement) {
if (null_placement == NullPlacement::AtStart) {
return {indices_end, indices_end, indices_begin, indices_end};
} else {
return {indices_begin, indices_begin, indices_begin, indices_end};
}
}
- static NullPartitionResult NullsAtEnd(uint64_t* indices_begin, uint64_t*
indices_end,
- uint64_t* midpoint) {
+ static GenericNullPartitionResult NullsAtEnd(IndexType* indices_begin,
+ IndexType* indices_end,
+ IndexType* midpoint) {
DCHECK_GE(midpoint, indices_begin);
DCHECK_LE(midpoint, indices_end);
return {indices_begin, midpoint, midpoint, indices_end};
}
- static NullPartitionResult NullsAtStart(uint64_t* indices_begin, uint64_t*
indices_end,
- uint64_t* midpoint) {
+ static GenericNullPartitionResult NullsAtStart(IndexType* indices_begin,
+ IndexType* indices_end,
+ IndexType* midpoint) {
DCHECK_GE(midpoint, indices_begin);
DCHECK_LE(midpoint, indices_end);
return {midpoint, indices_end, indices_begin, midpoint};
}
+
+ template <typename SourceIndexType>
+ static GenericNullPartitionResult TranslateFrom(
+ GenericNullPartitionResult<SourceIndexType> source,
+ SourceIndexType* source_indices_begin, IndexType* target_indices_begin) {
+ return {
+ (source.non_nulls_begin - source_indices_begin) + target_indices_begin,
+ (source.non_nulls_end - source_indices_begin) + target_indices_begin,
+ (source.nulls_begin - source_indices_begin) + target_indices_begin,
+ (source.nulls_end - source_indices_begin) + target_indices_begin,
+ };
+ }
Review Comment:
Can this be a non-static member function for simplicity?
```suggestion
template <typename TargetIndexType>
GenericNullPartitionResult<TargetIndexType> Translate(
IndexType* source_indices_begin, TargetIndexType*
target_indices_begin) {
return {
(non_nulls_begin - source_indices_begin) + target_indices_begin,
(non_nulls_end - source_indices_begin) + target_indices_begin,
(nulls_begin - source_indices_begin) + target_indices_begin,
(nulls_end - source_indices_begin) + target_indices_begin,
};
}
```
--
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]