mapleFU commented on code in PR #43763:
URL: https://github.com/apache/arrow/pull/43763#discussion_r1739595621
##########
cpp/src/arrow/compute/row/row_encoder_internal.h:
##########
@@ -142,41 +159,33 @@ struct ARROW_EXPORT VarLengthKeyEncoder : KeyEncoder {
Status Encode(const ExecValue& data, int64_t batch_length,
uint8_t** encoded_bytes) override {
+ auto handle_next_valid_value = [&encoded_bytes](std::string_view bytes) {
+ auto& encoded_ptr = *encoded_bytes++;
+ *encoded_ptr++ = kValidByte;
+ util::SafeStore(encoded_ptr, static_cast<Offset>(bytes.size()));
+ encoded_ptr += sizeof(Offset);
+ memcpy(encoded_ptr, bytes.data(), bytes.size());
+ encoded_ptr += bytes.size();
+ };
+ auto handle_next_null_value = [&encoded_bytes]() {
+ auto& encoded_ptr = *encoded_bytes++;
+ *encoded_ptr++ = kNullByte;
+ util::SafeStore(encoded_ptr, static_cast<Offset>(0));
+ encoded_ptr += sizeof(Offset);
+ };
if (data.is_array()) {
- VisitArraySpanInline<T>(
- data.array,
- [&](std::string_view bytes) {
- auto& encoded_ptr = *encoded_bytes++;
- *encoded_ptr++ = kValidByte;
- util::SafeStore(encoded_ptr, static_cast<Offset>(bytes.size()));
- encoded_ptr += sizeof(Offset);
- memcpy(encoded_ptr, bytes.data(), bytes.size());
- encoded_ptr += bytes.size();
- },
- [&] {
- auto& encoded_ptr = *encoded_bytes++;
- *encoded_ptr++ = kNullByte;
- util::SafeStore(encoded_ptr, static_cast<Offset>(0));
- encoded_ptr += sizeof(Offset);
- });
+ VisitArraySpanInline<T>(data.array, handle_next_valid_value,
Review Comment:
no I just found that method is low efficient in compute length...
--
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]