Skip to content

Commit 474f76b

Browse files
authored
fix: fix compile error on macOS with clang 21 (alibaba#237)
1 parent e9ccec0 commit 474f76b

4 files changed

Lines changed: 19 additions & 17 deletions

File tree

src/paimon/common/data/blob.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,6 @@ namespace paimon {
3333

3434
class MemoryPool;
3535

36-
Result<std::unique_ptr<Blob>> Blob::FromPath(const std::string& path) {
37-
return FromPath(path, /*offset=*/0, /*length=*/-1);
38-
}
39-
40-
Result<std::unique_ptr<Blob>> Blob::FromPath(const std::string& path, int64_t offset,
41-
int64_t length) {
42-
PAIMON_ASSIGN_OR_RAISE(std::string normalized_path, PathUtil::NormalizePath(path));
43-
PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<BlobDescriptor> descriptor,
44-
BlobDescriptor::Create(normalized_path, offset, length));
45-
auto impl = std::make_unique<Blob::Impl>(std::move(descriptor), descriptor->Uri());
46-
return std::unique_ptr<Blob>(new Blob(std::move(impl)));
47-
}
48-
4936
class Blob::Impl {
5037
public:
5138
Impl(std::unique_ptr<BlobDescriptor>&& descriptor, const std::string& uri)
@@ -68,6 +55,19 @@ class Blob::Impl {
6855
std::string uri_;
6956
};
7057

58+
Result<std::unique_ptr<Blob>> Blob::FromPath(const std::string& path) {
59+
return FromPath(path, /*offset=*/0, /*length=*/-1);
60+
}
61+
62+
Result<std::unique_ptr<Blob>> Blob::FromPath(const std::string& path, int64_t offset,
63+
int64_t length) {
64+
PAIMON_ASSIGN_OR_RAISE(std::string normalized_path, PathUtil::NormalizePath(path));
65+
PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<BlobDescriptor> descriptor,
66+
BlobDescriptor::Create(normalized_path, offset, length));
67+
auto impl = std::make_unique<Blob::Impl>(std::move(descriptor), descriptor->Uri());
68+
return std::unique_ptr<Blob>(new Blob(std::move(impl)));
69+
}
70+
7171
Blob::Blob(std::unique_ptr<Impl>&& impl) : impl_(std::move(impl)) {}
7272
Blob::~Blob() = default;
7373

src/paimon/common/memory/memory_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void* MemoryPoolImpl::Malloc(uint64_t size, uint64_t alignment) {
5555
return memptr;
5656
}
5757

58-
void* MemoryPoolImpl::Realloc(void* p, size_t old_size, size_t new_size, size_t alignment) {
58+
void* MemoryPoolImpl::Realloc(void* p, size_t old_size, size_t new_size, uint64_t alignment) {
5959
if (alignment == 0) {
6060
void* memptr = ::realloc(p, new_size);
6161
total_allocated_size.fetch_add(new_size - old_size);

src/paimon/format/avro/avro_input_stream_impl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ bool AvroInputStreamImpl::next(const uint8_t** data, size_t* len) {
6868
return false; // eof
6969
}
7070
auto read_length =
71-
in_->Read(reinterpret_cast<char*>(buffer_), std::min(buffer_size_, remaining));
71+
in_->Read(reinterpret_cast<char*>(buffer_),
72+
static_cast<uint32_t>(std::min<uint64_t>(buffer_size_, remaining)));
7273
if (!read_length.ok()) {
7374
throw ::avro::Exception("Read failed: {}", read_length.status().ToString());
7475
}

src/paimon/format/blob/blob_format_writer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Status BlobFormatWriter::WriteBlob(std::string_view blob_data) {
138138
}
139139
PAIMON_ASSIGN_OR_RAISE(uint64_t file_length, in->Length());
140140
uint64_t total_read_length = 0;
141-
uint32_t read_len = std::min(file_length, tmp_buffer_->size());
141+
auto read_len = static_cast<uint32_t>(std::min<uint64_t>(file_length, tmp_buffer_->size()));
142142
while (read_len > 0) {
143143
PAIMON_ASSIGN_OR_RAISE(int32_t actual_read_len, in->Read(tmp_buffer_->data(), read_len));
144144
if (static_cast<uint32_t>(actual_read_len) != read_len) {
@@ -147,7 +147,8 @@ Status BlobFormatWriter::WriteBlob(std::string_view blob_data) {
147147
}
148148
PAIMON_RETURN_NOT_OK(WriteWithCrc32(tmp_buffer_->data(), actual_read_len));
149149
total_read_length += actual_read_len;
150-
read_len = std::min(file_length - total_read_length, tmp_buffer_->size());
150+
read_len = static_cast<uint32_t>(
151+
std::min<uint64_t>(file_length - total_read_length, tmp_buffer_->size()));
151152
}
152153

153154
// write bin length

0 commit comments

Comments
 (0)