From f1138e84f589e01df18a75cab8c1ddee6c43c48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Thu, 16 Dec 2021 18:20:40 -0500 Subject: [PATCH 1/5] Avoid undefined behavior by ensuring m_path is not empty Debug version crashes here, release version optimizes away the check. --- include/xtensor-zarr/xzarr_node.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xtensor-zarr/xzarr_node.hpp b/include/xtensor-zarr/xzarr_node.hpp index f4dab57..313bea7 100644 --- a/include/xtensor-zarr/xzarr_node.hpp +++ b/include/xtensor-zarr/xzarr_node.hpp @@ -68,7 +68,7 @@ namespace xt { m_path = '/' + m_path; } - while (m_path.back() == '/') + while (!m_path.empty() && m_path.back() == '/') { m_path = m_path.substr(0, m_path.size() - 1); } From 80b33694b92b464c9ad8c6156cea7f32754a04e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Thu, 23 Dec 2021 09:57:36 -0500 Subject: [PATCH 2/5] Do not compile tests of AWS and GSC if they are not enabled --- test/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 34f2d5d..928faf7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -79,11 +79,17 @@ include_directories(${GTEST_INCLUDE_DIRS} SYSTEM) set(XTENSOR_ZARR_TESTS main.cpp test_zarr.cpp - test_gcs.cpp - test_aws.cpp test_gdal.cpp ) +if(${storage_client_FOUND}) + list(APPEND XTENSOR_ZARR_TESTS test_gcs.cpp) +endif() + +if(${AWSSDK_FOUND}) + list(APPEND XTENSOR_ZARR_TESTS test_aws.cpp) +endif() + add_executable(test_xtensor_zarr ${XTENSOR_ZARR_TESTS} ${XTENSOR_ZARR_HEADERS}) if(DOWNLOAD_GTEST OR GTEST_SRC_DIR) add_dependencies(test_xtensor_zarr gtest_main) From 8c292bc81bed7954b0c0c6c83e77984200f29a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Thu, 23 Dec 2021 12:43:26 -0500 Subject: [PATCH 3/5] Update documentation, chapter Create an array --- docs/source/basic_usage.rst | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/source/basic_usage.rst b/docs/source/basic_usage.rst index e902ad8..3b90254 100644 --- a/docs/source/basic_usage.rst +++ b/docs/source/basic_usage.rst @@ -54,22 +54,25 @@ Create an array auto h = xt::get_zarr_hierarchy(store); // create an array in the hierarchy nlohmann::json attrs = {{"question", "life"}, {"answer", 42}}; - using S = std::vector; - S shape = {4, 4}; - S chunk_shape = {2, 2}; - xt::zarray a = h.create_array( + std::vector shape = {4, 4}; + std::vector chunk_shape = {2, 2}; + // specify options + xt::xzarr_create_array_options o; + o.chunk_memory_layout = 'C'; + o.chunk_separator = '/'; + o.attrs = attrs; + o.chunk_pool_size = 10; + o.fill_value = 0.0; + + xt::zarray z = h.create_array( "/arthur/dent", // path to the array in the store shape, // array shape chunk_shape, // chunk shape "(); a(2, 1) = 3.; } From 445945d59eea90feb9c519e93500893375873c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Thu, 23 Dec 2021 09:59:26 -0500 Subject: [PATCH 4/5] Update documentation regarding instantiation of compressors --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44b83d3..9f25a15 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Implementation of the Zarr core protocol (version 2 and 3) based on xtensor ## Installation -`xtensor-zarr` comes with a `libxtensor-zarr-gdal` shared library for accessing stores through GDAL's Virtual File System or the local file system. For all other stores, `xtensor-zarr` is a header-only library. +`xtensor-zarr` comes with a `libxtensor-zarr-gdal` shared library for accessing stores through GDAL's Virtual File System or the local file system. For all other stores, `xtensor-zarr` is a header-only library. If you do not link your project against `xtensor-zarr-gdal` target, you should add code from [xtensor-zarr-gdal.cpp](https://github.com/xtensor-stack/xtensor-zarr/blob/90f0acfbf74a4e3664b0861920409b6143600d67/src/xtensor-zarr-gdal.cpp#L3-L8) somewhere in your project to avoid linking errors. We provide a package for the mamba (or conda) package manager: From 6ebb29bb5fccfa87990f8de0c0c8d5f0e9a29dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Tue, 14 Dec 2021 14:52:16 -0500 Subject: [PATCH 5/5] Allow the library to be used from build directory The error was: CMake Error at C:/Libs/xtl-vs19/xtlConfig.cmake:26 (message): File or directory C://include referenced by variable xtensor_zarr_INCLUDE_DIRS does not exist ! Call Stack (most recent call first): C:/Libs/xtensor-zarr-vs19/xtensor-zarrConfig.cmake:49 (set_and_check) CMakeLists.txt:6 (find_package) --- xtensor-zarrConfig.cmake.in | 4 ---- 1 file changed, 4 deletions(-) diff --git a/xtensor-zarrConfig.cmake.in b/xtensor-zarrConfig.cmake.in index a26bcd5..674843f 100644 --- a/xtensor-zarrConfig.cmake.in +++ b/xtensor-zarrConfig.cmake.in @@ -21,10 +21,6 @@ find_dependency(xtensor-io @xtensor_io_REQUIRED_VERSION@) find_dependency(zarray @zarray_REQUIRED_VERSION@) find_dependency(nlohmann_json @nlohmann_json_REQUIRED_VERSION@) -set(PN xtensor_zarr) -set_and_check(${PN}_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@") -set(${PN}_LIBRARY "") -check_required_components(${PN}) if(NOT TARGET @PROJECT_NAME@) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")