Skip to content

Commit beab600

Browse files
committed
fix
1 parent e14fefd commit beab600

16 files changed

+58
-55
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ repos:
7777
args:
7878
- "--quiet"
7979
- "--verbose=2"
80-
- "--filter=-whitespace/line_length,-whitespace/parens,-whitespace/indent_namespace,-build/include_what_you_use,-build/c++11,-readability/nolint,-runtime/references"
80+
- "--filter=-whitespace/line_length,-whitespace/parens,-whitespace/indent_namespace,-build/include_what_you_use,-build/c++11,-build/c++17,-readability/nolint,-runtime/references"
8181

8282
types_or:
8383
- c++

src/paimon/common/data/binary_row_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ TEST_F(BinaryRowTest, TestBasic) {
7474
row.SetInt(0, 5);
7575
row.SetDouble(1, 5.8);
7676
ASSERT_EQ(5, row.GetInt(0));
77-
ASSERT_EQ((double)5.8, row.GetDouble(1));
77+
ASSERT_EQ(static_cast<double>(5.8), row.GetDouble(1));
7878

7979
row.Clear();
8080
std::shared_ptr<Bytes> bytes1 = Bytes::AllocateBytes(100, pool.get());
@@ -405,10 +405,10 @@ TEST_F(BinaryRowTest, TestCompatibleWithJava) {
405405
int32_t arity = 1;
406406
BinaryRow row(arity);
407407
BinaryRowWriter writer(&row, 0, pool.get());
408-
writer.WriteInt(0, static_cast<int32_t>(18));
408+
writer.WriteInt(0, 18);
409409
writer.Complete();
410410

411-
ASSERT_EQ(row.GetInt(0), (int32_t)18);
411+
ASSERT_EQ(row.GetInt(0), 18);
412412

413413
auto bytes = SerializationUtils::SerializeBinaryRow(row, pool.get());
414414
std::string bytes_view(bytes->data(), bytes->size());
@@ -418,7 +418,7 @@ TEST_F(BinaryRowTest, TestCompatibleWithJava) {
418418
ASSERT_EQ(bytes_view, expect_view);
419419
ASSERT_OK_AND_ASSIGN(auto de_row, SerializationUtils::DeserializeBinaryRow(bytes));
420420
ASSERT_EQ(1, de_row.GetFieldCount());
421-
ASSERT_EQ(de_row.GetInt(0), (int32_t)18);
421+
ASSERT_EQ(de_row.GetInt(0), 18);
422422
}
423423
}
424424

src/paimon/common/data/generic_row_test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ TEST(GenericRowTest, TestSimple) {
7878
// test get
7979
ASSERT_FALSE(row.IsNullAt(0));
8080
ASSERT_EQ(row.GetBoolean(0), true);
81-
ASSERT_EQ(row.GetByte(1), (char)1);
82-
ASSERT_EQ(row.GetShort(2), (int16_t)2);
83-
ASSERT_EQ(row.GetInt(3), (int32_t)3);
84-
ASSERT_EQ(row.GetDate(3), (int32_t)3);
85-
ASSERT_EQ(row.GetLong(4), (int64_t)4);
86-
ASSERT_EQ(row.GetFloat(5), (float)5.1);
87-
ASSERT_EQ(row.GetDouble(6), (double)6.12);
81+
ASSERT_EQ(row.GetByte(1), static_cast<char>(1));
82+
ASSERT_EQ(row.GetShort(2), static_cast<int16_t>(2));
83+
ASSERT_EQ(row.GetInt(3), static_cast<int32_t>(3));
84+
ASSERT_EQ(row.GetDate(3), static_cast<int32_t>(3));
85+
ASSERT_EQ(row.GetLong(4), static_cast<int64_t>(4));
86+
ASSERT_EQ(row.GetFloat(5), static_cast<float>(5.1));
87+
ASSERT_EQ(row.GetDouble(6), static_cast<double>(6.12));
8888
ASSERT_EQ(row.GetString(7), str);
8989
ASSERT_EQ(*row.GetBinary(8), *bytes);
9090
ASSERT_EQ(std::string(row.GetStringView(9)), str9);

src/paimon/common/data/record_batch_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ TEST(RecordBatchTest, TestSimple) {
5858
ASSERT_TRUE(struct_builder.Append().ok());
5959
ASSERT_TRUE(string_builder->Append("20240813").ok());
6060
ASSERT_TRUE(int_builder->Append(23).ok());
61-
ASSERT_TRUE(long_builder->Append((int64_t)1722848484308ll + i).ok());
61+
ASSERT_TRUE(long_builder->Append(static_cast<int64_t>(1722848484308ll + i)).ok());
6262
ASSERT_TRUE(bool_builder->Append(static_cast<bool>(i % 2)).ok());
6363
}
6464
std::shared_ptr<arrow::Array> array;

src/paimon/common/memory/memory_segment.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ class PAIMON_EXPORT MemorySegment {
7373
template <typename T>
7474
inline void Get(int32_t index, T* dst, int32_t offset, int32_t length) const {
7575
// check the byte array offset and length and the status
76-
assert((int32_t)dst->size() >= (offset + length));
77-
assert((int32_t)heap_memory_->size() >= (index + length));
76+
assert(static_cast<int32_t>(dst->size()) >= (offset + length));
77+
assert(static_cast<int32_t>(heap_memory_->size()) >= (index + length));
7878
std::memcpy(const_cast<char*>(dst->data()) + offset, heap_memory_->data() + index, length);
7979
}
8080

8181
template <typename T>
8282
inline void Put(int32_t index, const T& src, int32_t offset, int32_t length) {
8383
// check the byte array offset and length
84-
assert((int32_t)src.size() >= (offset + length));
85-
assert((int32_t)heap_memory_->size() >= (index + length));
84+
assert(static_cast<int32_t>(src.size()) >= (offset + length));
85+
assert(static_cast<int32_t>(heap_memory_->size()) >= (index + length));
8686
std::memcpy(heap_memory_->data() + index, src.data() + offset, length);
8787
}
8888

src/paimon/common/memory/memory_segment_test.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ TEST(MemorySegmentTest, TestByteAccess) {
4040
}
4141
std::srand(seed);
4242
for (int32_t i = 0; i < page_size; i++) {
43-
ASSERT_EQ(segment.Get(i), (char)std::rand()) << "seed: " << seed << ", idx: " << i;
43+
ASSERT_EQ(segment.Get(i), static_cast<char>(std::rand()))
44+
<< "seed: " << seed << ", idx: " << i;
4445
}
4546

4647
// test expected correct behavior, random access
@@ -72,7 +73,8 @@ TEST(MemorySegmentTest, TestByteAccess) {
7273
occupied[pos] = true;
7374
}
7475

75-
ASSERT_EQ(segment.Get(pos), (char)std::rand()) << "seed: " << seed << ", idx: " << pos;
76+
ASSERT_EQ(segment.Get(pos), static_cast<char>(std::rand()))
77+
<< "seed: " << seed << ", idx: " << pos;
7678
}
7779
delete[] occupied;
7880
}
@@ -197,7 +199,7 @@ TEST(MemorySegmentTest, TestCharAccess) {
197199

198200
std::srand(seed);
199201
for (int32_t i = 0; i <= page_size - 2; i += 2) {
200-
ASSERT_EQ(segment.GetValue<char16_t>(i), (char)(std::rand() % (CHAR_MAX)))
202+
ASSERT_EQ(segment.GetValue<char16_t>(i), static_cast<char>(std::rand() % (CHAR_MAX)))
201203
<< "seed: " << seed << ", idx: " << i;
202204
}
203205

@@ -231,7 +233,7 @@ TEST(MemorySegmentTest, TestCharAccess) {
231233
occupied[pos + 1] = true;
232234
}
233235

234-
ASSERT_EQ(segment.GetValue<char16_t>(pos), (char)(std::rand() % (CHAR_MAX)))
236+
ASSERT_EQ(segment.GetValue<char16_t>(pos), static_cast<char>(std::rand() % (CHAR_MAX)))
235237
<< "seed: " << seed << ", idx:" << pos;
236238
}
237239
delete[] occupied;
@@ -251,7 +253,7 @@ TEST(MemorySegmentTest, TestShortAccess) {
251253

252254
std::srand(seed);
253255
for (int32_t i = 0; i <= page_size - 2; i += 2) {
254-
ASSERT_EQ(segment.GetValue<int16_t>(i), (int16_t)std::rand())
256+
ASSERT_EQ(segment.GetValue<int16_t>(i), static_cast<int16_t>(std::rand()))
255257
<< "seed: " << seed << ", idx:" << i;
256258
}
257259

@@ -285,7 +287,7 @@ TEST(MemorySegmentTest, TestShortAccess) {
285287
occupied[pos + 1] = true;
286288
}
287289

288-
ASSERT_EQ(segment.GetValue<int16_t>(pos), (int16_t)std::rand())
290+
ASSERT_EQ(segment.GetValue<int16_t>(pos), static_cast<int16_t>(std::rand()))
289291
<< "seed: " << seed << ", idx:" << pos;
290292
}
291293
delete[] occupied;
@@ -305,7 +307,7 @@ TEST(MemorySegmentTest, TestIntAccess) {
305307

306308
std::srand(seed);
307309
for (int32_t i = 0; i <= page_size - 4; i += 4) {
308-
ASSERT_EQ(segment.GetValue<int32_t>(i), (int32_t)std::rand())
310+
ASSERT_EQ(segment.GetValue<int32_t>(i), static_cast<int32_t>(std::rand()))
309311
<< "seed: " << seed << ", idx:" << i;
310312
}
311313

@@ -343,7 +345,7 @@ TEST(MemorySegmentTest, TestIntAccess) {
343345
occupied[pos + 3] = true;
344346
}
345347

346-
ASSERT_EQ(segment.GetValue<int32_t>(pos), (int32_t)std::rand())
348+
ASSERT_EQ(segment.GetValue<int32_t>(pos), static_cast<int32_t>(std::rand()))
347349
<< "seed: " << seed << ", idx:" << pos;
348350
}
349351
delete[] occupied;

src/paimon/common/predicate/predicate_validator_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ TEST(PredicateValidatorTest, TestValidateSchema) {
150150
PredicateBuilder::Equal(/*field_index=*/7, /*field_name=*/"f7", FieldType::BINARY,
151151
Literal(FieldType::BINARY, str.data(), str.size())),
152152
PredicateBuilder::Equal(/*field_index=*/8, /*field_name=*/"f8", FieldType::TINYINT,
153-
Literal((int8_t)20)),
153+
Literal(static_cast<int8_t>(20))),
154154
}));
155155
ASSERT_OK(PredicateValidator::ValidatePredicateWithSchema(*schema, predicate,
156156
/*validate_field_idx=*/true));

src/paimon/common/utils/bloom_filter64_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ TEST(BloomFilter64Test, TestSimple) {
5656
false_positives++;
5757
}
5858
}
59-
ASSERT_TRUE((double)false_positives / num < 0.03);
59+
ASSERT_TRUE(static_cast<double>(false_positives) / num < 0.03);
6060
}
6161

6262
TEST(BloomFilter64Test, TestCompatibleWithJava) {

src/paimon/common/utils/concurrent_hash_map_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ TEST(ConcurrentHashMapTest, TestMultiThreadInsertAndFindAndDelete) {
141141
thread3.join();
142142

143143
// check final states
144-
ASSERT_TRUE(hash_map.Size() >= 0 && hash_map.Size() <= (size_t)map_size);
144+
ASSERT_TRUE(hash_map.Size() >= 0 && hash_map.Size() <= static_cast<size_t>(map_size));
145145
for (int32_t i = 0; i < map_size; i++) {
146146
auto value = hash_map.Find(i);
147147
if (value) {

src/paimon/common/utils/projected_row_test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ TEST(ProjectedRowTest, TestSimple) {
8585
ASSERT_TRUE(projected_row.IsNullAt(16));
8686

8787
ASSERT_EQ(projected_row.GetBoolean(15), true);
88-
ASSERT_EQ(projected_row.GetByte(14), (char)1);
89-
ASSERT_EQ(projected_row.GetShort(13), (int16_t)2);
90-
ASSERT_EQ(projected_row.GetInt(12), (int32_t)3);
91-
ASSERT_EQ(projected_row.GetDate(12), (int32_t)3);
92-
ASSERT_EQ(projected_row.GetLong(11), (int64_t)4);
93-
ASSERT_EQ(projected_row.GetFloat(10), (float)5.1);
94-
ASSERT_EQ(projected_row.GetDouble(9), (double)6.12);
88+
ASSERT_EQ(projected_row.GetByte(14), static_cast<char>(1));
89+
ASSERT_EQ(projected_row.GetShort(13), static_cast<int16_t>(2));
90+
ASSERT_EQ(projected_row.GetInt(12), static_cast<int32_t>(3));
91+
ASSERT_EQ(projected_row.GetDate(12), static_cast<int32_t>(3));
92+
ASSERT_EQ(projected_row.GetLong(11), static_cast<int64_t>(4));
93+
ASSERT_EQ(projected_row.GetFloat(10), static_cast<float>(5.1));
94+
ASSERT_EQ(projected_row.GetDouble(9), static_cast<double>(6.12));
9595
ASSERT_EQ(projected_row.GetString(8), str);
9696
ASSERT_EQ(*projected_row.GetBinary(7), *bytes);
9797
ASSERT_EQ(std::string(projected_row.GetStringView(6)), str9);

0 commit comments

Comments
 (0)