You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/05 11:57:52 UTC

[GitHub] [pulsar-client-cpp] RobertIndie commented on a diff in pull request #132: Add BatchedMessageIdImpl to acknowledge batched messages

RobertIndie commented on code in PR #132:
URL: https://github.com/apache/pulsar-client-cpp/pull/132#discussion_r1039372071


##########
tests/BitSetTest.cc:
##########
@@ -0,0 +1,96 @@
+/**
+ * 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 <gtest/gtest.h>
+
+#include <map>
+#include <vector>
+
+#include "lib/BatchMessageAcker.h"
+#include "lib/BitSet.h"
+
+using namespace pulsar;
+
+static std::vector<long> toLongVector(const BitSet& bitSet) {
+    std::vector<long> v;
+    for (long x : bitSet) {
+        v.emplace_back(x);
+    }
+    return v;
+}
+
+TEST(BitSetTest, testFill) {
+    // An int64_t has 64 bits, so we test 64*N + {-1, 0, 1}
+    std::map<int, std::vector<long>> expectedResults;
+    expectedResults[7] = {127L};
+    expectedResults[63] = {9223372036854775807L};
+    expectedResults[64] = {-1L};
+    expectedResults[65] = {-1L, 1L};
+    expectedResults[127] = {-1L, 9223372036854775807L};
+    expectedResults[128] = {-1L, -1L};
+    expectedResults[129] = {-1L, -1L, 1L};
+
+    std::map<int, std::vector<long>> actualResults;
+    for (const auto& kv : expectedResults) {
+        BitSet bitSet(kv.first);
+        ASSERT_TRUE(toLongVector(bitSet).empty());
+        bitSet.set(0, kv.first);
+        actualResults[kv.first] = toLongVector(bitSet);
+    }
+    ASSERT_EQ(actualResults, expectedResults);
+}
+
+TEST(BitSetTest, testSet) {
+    BitSet bitSet(64 * 5 + 1);  // 6 words
+    ASSERT_TRUE(toLongVector(bitSet).empty());
+
+    // range contains one word
+    bitSet.set(3, 29);
+    ASSERT_EQ(toLongVector(bitSet), std::vector<long>{536870904L});

Review Comment:
   Can we represent it in hexadecimal format?



##########
lib/MessageIdImpl.h:
##########
@@ -33,6 +33,8 @@ class MessageIdImpl {
           partition_(partition),
           batchIndex_(batchIndex),
           topicName_() {}
+    virtual ~MessageIdImpl() {}

Review Comment:
   It seems there is no subclass override implementation for it. Do we really need it?



-- 
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-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org