Skip to content

Commit

Permalink
Merge pull request #2204 from kuzudb/fix-mac-build
Browse files Browse the repository at this point in the history
Fix mac build
  • Loading branch information
acquamarin committed Oct 13, 2023
2 parents f18499f + 34b6f5b commit a755f57
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
18 changes: 14 additions & 4 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)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 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 Expand Up @@ -156,10 +158,18 @@ endfunction()
function(add_kuzu_api_test TEST_NAME)
set(SRCS ${ARGN})
add_executable(${TEST_NAME} ${SRCS})
target_link_libraries(${TEST_NAME} PRIVATE api_graph_test api_test_helper)
if(APPLE)
target_link_libraries(${TEST_NAME} PRIVATE test_helper test_runner graph_test)
else()
target_link_libraries(${TEST_NAME} PRIVATE api_graph_test api_test_helper)
endif()
target_include_directories(${TEST_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/test/include)
include(GoogleTest)
gtest_discover_tests(${TEST_NAME})
if(APPLE)
gtest_discover_tests(${TEST_NAME} DISCOVERY_TIMEOUT 600 DISCOVERY_MODE PRE_TEST)
else()
gtest_discover_tests(${TEST_NAME})
endif()
endfunction()

add_definitions(-DKUZU_ROOT_DIRECTORY="${PROJECT_SOURCE_DIR}")
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 a755f57

Please sign in to comment.