github-actions[bot] commented on code in PR #41683: URL: https://github.com/apache/doris/pull/41683#discussion_r1796572696
########## be/src/util/byte_stream_split.cpp: ########## @@ -0,0 +1,115 @@ +// 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, WITHdst WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "byte_stream_split.h" + +#include <vector> + +#include "gutil/port.h" + +namespace doris { + +inline void do_merge_streams(const uint8_t** src_streams, int width, int64_t nvalues, + uint8_t* dest) { + // Value empirically chosen to provide the best performance on the author's machine + constexpr int kBlockSize = 128; + + while (nvalues >= kBlockSize) { + for (int stream = 0; stream < width; ++stream) { + // Take kBlockSize bytes from the given stream and spread them + // to their logical places in destination. + const uint8_t* src = src_streams[stream]; + for (int i = 0; i < kBlockSize; i += 8) { + uint64_t v; + std::memcpy(&v, src + i, sizeof(v)); +#ifdef IS_LITTLE_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v >> 56); +#elif defined IS_BIG_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v >> 56); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v); +#endif + } + src_streams[stream] += kBlockSize; + } + dest += width * kBlockSize; + nvalues -= kBlockSize; + } + + // Epilog + for (int stream = 0; stream < width; ++stream) { + const uint8_t* src = src_streams[stream]; + for (int64_t i = 0; i < nvalues; ++i) { + dest[stream + i * width] = src[i]; + } + } +} + +template <int kNumStreams> +void byte_stream_split_decode_scalar(const uint8_t* src, int width, int64_t offset, + int64_t num_values, int64_t stride, uint8_t* dest) { + assert(width == kNumStreams); + std::array<const uint8_t*, kNumStreams> src_streams; Review Comment: warning: no member named 'array' in namespace 'std' [clang-diagnostic-error] ```cpp std::array<const uint8_t*, kNumStreams> src_streams; ^ ``` ########## be/src/util/byte_stream_split.cpp: ########## @@ -0,0 +1,115 @@ +// 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, WITHdst WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "byte_stream_split.h" + +#include <vector> + +#include "gutil/port.h" + +namespace doris { + +inline void do_merge_streams(const uint8_t** src_streams, int width, int64_t nvalues, + uint8_t* dest) { + // Value empirically chosen to provide the best performance on the author's machine + constexpr int kBlockSize = 128; + + while (nvalues >= kBlockSize) { + for (int stream = 0; stream < width; ++stream) { + // Take kBlockSize bytes from the given stream and spread them + // to their logical places in destination. + const uint8_t* src = src_streams[stream]; + for (int i = 0; i < kBlockSize; i += 8) { + uint64_t v; + std::memcpy(&v, src + i, sizeof(v)); Review Comment: warning: no member named 'memcpy' in namespace 'std'; did you mean simply 'memcpy'? [clang-diagnostic-error] ```suggestion memcpy(&v, src + i, sizeof(v)); ``` <details> <summary>Additional context</summary> **/usr/include/string.h:42:** 'memcpy' declared here ```cpp extern void *memcpy (void *__restrict __dest, const void *__restrict __src, ^ ``` </details> ########## be/src/util/byte_stream_split.cpp: ########## @@ -0,0 +1,115 @@ +// 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, WITHdst WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "byte_stream_split.h" + +#include <vector> + +#include "gutil/port.h" + +namespace doris { + +inline void do_merge_streams(const uint8_t** src_streams, int width, int64_t nvalues, + uint8_t* dest) { + // Value empirically chosen to provide the best performance on the author's machine + constexpr int kBlockSize = 128; + + while (nvalues >= kBlockSize) { + for (int stream = 0; stream < width; ++stream) { + // Take kBlockSize bytes from the given stream and spread them + // to their logical places in destination. + const uint8_t* src = src_streams[stream]; + for (int i = 0; i < kBlockSize; i += 8) { + uint64_t v; + std::memcpy(&v, src + i, sizeof(v)); +#ifdef IS_LITTLE_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v >> 56); +#elif defined IS_BIG_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v >> 56); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v); +#endif + } + src_streams[stream] += kBlockSize; + } + dest += width * kBlockSize; + nvalues -= kBlockSize; + } + + // Epilog + for (int stream = 0; stream < width; ++stream) { + const uint8_t* src = src_streams[stream]; + for (int64_t i = 0; i < nvalues; ++i) { + dest[stream + i * width] = src[i]; + } + } +} + +template <int kNumStreams> +void byte_stream_split_decode_scalar(const uint8_t* src, int width, int64_t offset, + int64_t num_values, int64_t stride, uint8_t* dest) { + assert(width == kNumStreams); + std::array<const uint8_t*, kNumStreams> src_streams; + for (int stream = 0; stream < kNumStreams; ++stream) { + src_streams[stream] = &src[stream * stride + offset]; Review Comment: warning: use of undeclared identifier 'src_streams' [clang-diagnostic-error] ```cpp src_streams[stream] = &src[stream * stride + offset]; ^ ``` ########## be/src/util/byte_stream_split.cpp: ########## @@ -0,0 +1,115 @@ +// 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, WITHdst WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "byte_stream_split.h" + +#include <vector> + +#include "gutil/port.h" + +namespace doris { + +inline void do_merge_streams(const uint8_t** src_streams, int width, int64_t nvalues, + uint8_t* dest) { + // Value empirically chosen to provide the best performance on the author's machine + constexpr int kBlockSize = 128; + + while (nvalues >= kBlockSize) { + for (int stream = 0; stream < width; ++stream) { + // Take kBlockSize bytes from the given stream and spread them + // to their logical places in destination. + const uint8_t* src = src_streams[stream]; + for (int i = 0; i < kBlockSize; i += 8) { + uint64_t v; + std::memcpy(&v, src + i, sizeof(v)); +#ifdef IS_LITTLE_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v >> 56); +#elif defined IS_BIG_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v >> 56); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v); +#endif + } + src_streams[stream] += kBlockSize; + } + dest += width * kBlockSize; + nvalues -= kBlockSize; + } + + // Epilog + for (int stream = 0; stream < width; ++stream) { + const uint8_t* src = src_streams[stream]; + for (int64_t i = 0; i < nvalues; ++i) { + dest[stream + i * width] = src[i]; + } + } +} + +template <int kNumStreams> +void byte_stream_split_decode_scalar(const uint8_t* src, int width, int64_t offset, + int64_t num_values, int64_t stride, uint8_t* dest) { + assert(width == kNumStreams); + std::array<const uint8_t*, kNumStreams> src_streams; Review Comment: warning: expected expression [clang-diagnostic-error] ```cpp std::array<const uint8_t*, kNumStreams> src_streams; ^ ``` ########## be/src/util/byte_stream_split.cpp: ########## @@ -0,0 +1,115 @@ +// 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, WITHdst WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "byte_stream_split.h" + +#include <vector> + +#include "gutil/port.h" + +namespace doris { + +inline void do_merge_streams(const uint8_t** src_streams, int width, int64_t nvalues, + uint8_t* dest) { + // Value empirically chosen to provide the best performance on the author's machine + constexpr int kBlockSize = 128; + + while (nvalues >= kBlockSize) { + for (int stream = 0; stream < width; ++stream) { + // Take kBlockSize bytes from the given stream and spread them + // to their logical places in destination. + const uint8_t* src = src_streams[stream]; + for (int i = 0; i < kBlockSize; i += 8) { + uint64_t v; + std::memcpy(&v, src + i, sizeof(v)); +#ifdef IS_LITTLE_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v >> 56); +#elif defined IS_BIG_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v >> 56); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v); +#endif + } + src_streams[stream] += kBlockSize; + } + dest += width * kBlockSize; + nvalues -= kBlockSize; + } + + // Epilog + for (int stream = 0; stream < width; ++stream) { + const uint8_t* src = src_streams[stream]; + for (int64_t i = 0; i < nvalues; ++i) { + dest[stream + i * width] = src[i]; + } + } +} + +template <int kNumStreams> +void byte_stream_split_decode_scalar(const uint8_t* src, int width, int64_t offset, + int64_t num_values, int64_t stride, uint8_t* dest) { + assert(width == kNumStreams); Review Comment: warning: use of undeclared identifier 'assert' [clang-diagnostic-error] ```cpp assert(width == kNumStreams); ^ ``` ########## be/src/util/byte_stream_split.cpp: ########## @@ -0,0 +1,115 @@ +// 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, WITHdst WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "byte_stream_split.h" + +#include <vector> + +#include "gutil/port.h" + +namespace doris { + +inline void do_merge_streams(const uint8_t** src_streams, int width, int64_t nvalues, + uint8_t* dest) { + // Value empirically chosen to provide the best performance on the author's machine + constexpr int kBlockSize = 128; + + while (nvalues >= kBlockSize) { + for (int stream = 0; stream < width; ++stream) { + // Take kBlockSize bytes from the given stream and spread them + // to their logical places in destination. + const uint8_t* src = src_streams[stream]; + for (int i = 0; i < kBlockSize; i += 8) { + uint64_t v; + std::memcpy(&v, src + i, sizeof(v)); +#ifdef IS_LITTLE_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v >> 56); +#elif defined IS_BIG_ENDIAN + dest[stream + i * width] = static_cast<uint8_t>(v >> 56); + dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 48); + dest[stream + (i + 2) * width] = static_cast<uint8_t>(v >> 40); + dest[stream + (i + 3) * width] = static_cast<uint8_t>(v >> 32); + dest[stream + (i + 4) * width] = static_cast<uint8_t>(v >> 24); + dest[stream + (i + 5) * width] = static_cast<uint8_t>(v >> 16); + dest[stream + (i + 6) * width] = static_cast<uint8_t>(v >> 8); + dest[stream + (i + 7) * width] = static_cast<uint8_t>(v); +#endif + } + src_streams[stream] += kBlockSize; + } + dest += width * kBlockSize; + nvalues -= kBlockSize; + } + + // Epilog + for (int stream = 0; stream < width; ++stream) { + const uint8_t* src = src_streams[stream]; + for (int64_t i = 0; i < nvalues; ++i) { + dest[stream + i * width] = src[i]; + } + } +} + +template <int kNumStreams> +void byte_stream_split_decode_scalar(const uint8_t* src, int width, int64_t offset, + int64_t num_values, int64_t stride, uint8_t* dest) { + assert(width == kNumStreams); + std::array<const uint8_t*, kNumStreams> src_streams; + for (int stream = 0; stream < kNumStreams; ++stream) { + src_streams[stream] = &src[stream * stride + offset]; + } + do_merge_streams(src_streams.data(), kNumStreams, num_values, dest); Review Comment: warning: use of undeclared identifier 'src_streams' [clang-diagnostic-error] ```cpp do_merge_streams(src_streams.data(), kNumStreams, num_values, dest); ^ ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org