Skip to content

Commit

Permalink
Fix mac build
Browse files Browse the repository at this point in the history
  • Loading branch information
acquamarin committed Oct 12, 2023
1 parent f72b71f commit 4d2a3a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT APPLE)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
endif()

# Detect OS and architecture, copied from DuckDB
set(OS_NAME "unknown")
Expand Down
2 changes: 1 addition & 1 deletion src/processor/operator/persistent/reader/csv/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static bool tryCastStringToStruct(const char* input, uint64_t len, ValueVector*
skipWhitespace(++input, end);

copyStringToVector(StructVector::getFieldVector(vector, fieldIdx).get(), rowToAdd,
std::string_view{valStart, valEnd}, csvReaderConfig);
std::string_view{valStart, (size_t)(valEnd - valStart)}, csvReaderConfig);
}
return true;
}
Expand Down
25 changes: 14 additions & 11 deletions src/storage/store/column_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void ColumnChunk::initializeBuffer(offset_t capacity_) {
bufferSize = getBufferSize();
buffer = std::make_unique<uint8_t[]>(bufferSize);
if (nullChunk) {
static_cast<ColumnChunk*>(nullChunk.get())->initializeBuffer(capacity);
nullChunk->initializeBuffer(capacity_);
}
}

Expand Down Expand Up @@ -250,16 +250,19 @@ void ColumnChunk::write(const Value& val, uint64_t posToWrite) {
}

void ColumnChunk::resize(uint64_t newCapacity) {
capacity = newCapacity;
auto numBytesAfterResize = getBufferSize();
assert(numBytesAfterResize > bufferSize);
auto resizedBuffer = std::make_unique<uint8_t[]>(numBytesAfterResize);
if (dataType.getPhysicalType() == common::PhysicalTypeID::BOOL) {
memset(resizedBuffer.get(), 0 /* non null */, numBytesAfterResize);
}
memcpy(resizedBuffer.get(), buffer.get(), bufferSize);
bufferSize = numBytesAfterResize;
buffer = std::move(resizedBuffer);
if (numBytesPerValue != 0) {
// Avoid resizing struct/serial columns.
capacity = newCapacity;
auto numBytesAfterResize = getBufferSize();
assert(numBytesAfterResize > bufferSize);
auto resizedBuffer = std::make_unique<uint8_t[]>(numBytesAfterResize);
if (dataType.getPhysicalType() == common::PhysicalTypeID::BOOL) {
memset(resizedBuffer.get(), 0 /* non null */, numBytesAfterResize);
}
memcpy(resizedBuffer.get(), buffer.get(), bufferSize);
bufferSize = numBytesAfterResize;
buffer = std::move(resizedBuffer);
}
if (nullChunk) {
nullChunk->resize(newCapacity);
}
Expand Down

0 comments on commit 4d2a3a0

Please sign in to comment.