summaryrefslogtreecommitdiffstats
path: root/yql/essentials/public/udf/arrow/ut/bit_util_ut.cpp
diff options
context:
space:
mode:
authorAlexander Smirnov <[email protected]>2025-01-11 00:21:49 +0000
committerAlexander Smirnov <[email protected]>2025-01-11 00:21:49 +0000
commit457aacf7daabd8837feef98d1edcfe62420a1f47 (patch)
tree3f8ca7735aac2ab4574833bf4ea5e1881a02ef84 /yql/essentials/public/udf/arrow/ut/bit_util_ut.cpp
parentaf411bb10f1133d6e7f4c6324a89dde2f745d675 (diff)
parent2d3b7f1966f9716551a0d7db72a9608addab8ecf (diff)
Merge branch 'rightlib' into merge-libs-250111-0020
Diffstat (limited to 'yql/essentials/public/udf/arrow/ut/bit_util_ut.cpp')
-rw-r--r--yql/essentials/public/udf/arrow/ut/bit_util_ut.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/yql/essentials/public/udf/arrow/ut/bit_util_ut.cpp b/yql/essentials/public/udf/arrow/ut/bit_util_ut.cpp
new file mode 100644
index 00000000000..601d3be7c86
--- /dev/null
+++ b/yql/essentials/public/udf/arrow/ut/bit_util_ut.cpp
@@ -0,0 +1,41 @@
+#include <library/cpp/testing/unittest/registar.h>
+
+#include <yql/essentials/public/udf/arrow/bit_util.h>
+#include <util/random/random.h>
+
+#include <arrow/util/bit_util.h>
+
+using namespace NYql::NUdf;
+
+namespace {
+ void PerformTest(const ui8* testData, size_t offset, size_t length) {
+ std::vector<ui8> copied(arrow::BitUtil::BytesForBits(length) + 1, 0);
+ CopyDenseBitmap(copied.data(), testData, offset, length);
+
+ std::vector<ui8> origSparse(length), copiedSparse(length);
+ DecompressToSparseBitmap(origSparse.data(), testData, offset, length);
+ DecompressToSparseBitmap(copiedSparse.data(), copied.data(), 0, length);
+ for (size_t i = 0; i < length; i++) {
+ UNIT_ASSERT_EQUAL_C(origSparse[i], copiedSparse[i], "Expected the same data");
+ }
+ }
+}
+
+Y_UNIT_TEST_SUITE(CopyDenseBitmapTest) {
+ constexpr size_t testSize = 32;
+
+ Y_UNIT_TEST(Test) {
+ SetRandomSeed(0);
+
+ std::vector<ui8> testData(testSize);
+ for (size_t i = 0; i < testSize; i++) {
+ testData[i] = RandomNumber<ui8>();
+ }
+
+ for (size_t offset = 0; offset < testSize * 8; offset++) {
+ for (size_t length = 0; length <= testSize * 8 - offset; length++) {
+ PerformTest(testData.data(), offset, length);
+ }
+ }
+ }
+}