emkornfield commented on code in PR #595:
URL: https://github.com/apache/iceberg-cpp/pull/595#discussion_r2984801210


##########
src/iceberg/test/roaring_position_bitmap_test.cc:
##########
@@ -0,0 +1,490 @@
+/*
+ * 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, WITHOUT 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 "iceberg/deletes/roaring_position_bitmap.h"
+
+#include <cstdint>
+#include <filesystem>
+#include <fstream>
+#include <random>
+#include <set>
+#include <string>
+#include <vector>
+
+#include <gtest/gtest.h>
+
+#include "iceberg/test/matchers.h"
+#include "iceberg/test/test_config.h"
+
+namespace iceberg {
+
+namespace {
+
+constexpr int64_t kBitmapSize = 0xFFFFFFFFL;
+constexpr int64_t kBitmapOffset = kBitmapSize + 1L;
+constexpr int64_t kContainerSize = 0xFFFF;  // Character.MAX_VALUE
+constexpr int64_t kContainerOffset = kContainerSize + 1L;
+
+// Helper to construct a position from bitmap index, container index, and value
+int64_t Position(int32_t bitmap_index, int32_t container_index, int64_t value) 
{
+  return bitmap_index * kBitmapOffset + container_index * kContainerOffset + 
value;
+}
+
+std::string ReadTestResource(const std::string& filename) {
+  std::filesystem::path path = std::filesystem::path(ICEBERG_TEST_RESOURCES) / 
filename;
+  std::ifstream file(path, std::ios::binary);
+  EXPECT_TRUE(file.good()) << "Cannot open: " << path;
+  return {std::istreambuf_iterator<char>(file), 
std::istreambuf_iterator<char>()};
+}
+
+RoaringPositionBitmap RoundTripSerialize(const RoaringPositionBitmap& bitmap) {
+  auto serialized = bitmap.Serialize();
+  EXPECT_THAT(serialized, IsOk());
+  auto deserialized = RoaringPositionBitmap::Deserialize(serialized.value());
+  EXPECT_THAT(deserialized, IsOk());
+  return std::move(deserialized.value());
+}
+
+void AssertEqualContent(const RoaringPositionBitmap& bitmap,
+                        const std::set<int64_t>& positions) {
+  ASSERT_EQ(bitmap.Cardinality(), positions.size());
+  for (int64_t pos : positions) {
+    auto result = bitmap.Contains(pos);
+    ASSERT_THAT(result, IsOk()) << "Error for pos: " << pos;
+    ASSERT_TRUE(result.value()) << "Missing position: " << pos;
+  }
+  bitmap.ForEach([&](int64_t pos) {
+    ASSERT_TRUE(positions.count(pos) > 0) << "Unexpected position: " << pos;
+  });

Review Comment:
   did you intend to add a check here?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to