Skip to content

Commit

Permalink
Finish responding to PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
aliddell committed Sep 16, 2024
1 parent 250c661 commit 96b580a
Show file tree
Hide file tree
Showing 14 changed files with 1,131 additions and 1,333 deletions.
528 changes: 99 additions & 429 deletions include/zarr.h

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions include/zarr.types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#ifndef H_ACQUIRE_ZARR_TYPES_V0
#define H_ACQUIRE_ZARR_TYPES_V0

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C"
{
#endif

typedef enum
{
ZarrStatus_Success = 0,
ZarrStatus_InvalidArgument,
ZarrStatus_Overflow,
ZarrStatus_InvalidIndex,
ZarrStatus_NotYetImplemented,
ZarrStatus_InternalError,
ZarrStatus_OutOfMemory,
ZarrStatus_IOError,
ZarrStatus_CompressionError,
ZarrStatus_InvalidSettings,
ZarrStatusCount,
} ZarrStatus;

typedef enum
{
ZarrVersion_2 = 2,
ZarrVersion_3,
ZarrVersionCount
} ZarrVersion;

typedef enum
{
ZarrLogLevel_Debug,
ZarrLogLevel_Info,
ZarrLogLevel_Warning,
ZarrLogLevel_Error,
ZarrLogLevel_None,
ZarrLogLevelCount
} ZarrLogLevel;

typedef enum
{
ZarrDataType_uint8,
ZarrDataType_uint16,
ZarrDataType_uint32,
ZarrDataType_uint64,
ZarrDataType_int8,
ZarrDataType_int16,
ZarrDataType_int32,
ZarrDataType_int64,
ZarrDataType_float32,
ZarrDataType_float64,
ZarrDataTypeCount
} ZarrDataType;

typedef enum
{
ZarrCompressor_None = 0,
ZarrCompressor_Blosc1,
ZarrCompressorCount
} ZarrCompressor;

typedef enum
{
ZarrCompressionCodec_None = 0,
ZarrCompressionCodec_BloscLZ4,
ZarrCompressionCodec_BloscZstd,
ZarrCompressionCodecCount
} ZarrCompressionCodec;

typedef enum
{
ZarrDimensionType_Space = 0,
ZarrDimensionType_Channel,
ZarrDimensionType_Time,
ZarrDimensionType_Other,
ZarrDimensionTypeCount
} ZarrDimensionType;

/**
* @brief S3 settings for streaming to Zarr.
*/
typedef struct
{
const char* endpoint;
size_t bytes_of_endpoint;
const char* bucket_name;
size_t bytes_of_bucket_name;
const char* access_key_id;
size_t bytes_of_access_key_id;
const char* secret_access_key;
size_t bytes_of_secret_access_key;
} ZarrS3Settings;

/**
* @brief Compression settings for a Zarr array.
* @detail The compressor is not the same as the codec. A codec is
* a specific implementation of a compression algorithm, while a compressor
* is a library that implements one or more codecs.
*/
typedef struct
{
ZarrCompressor compressor; /**< Compressor to use */
ZarrCompressionCodec codec; /**< Codec to use */
uint8_t level; /**< Compression level */
uint8_t shuffle; /**< Whether to shuffle the data before compressing */
} ZarrCompressionSettings;

/**
* @brief Properties of a dimension of the Zarr array.
*/
typedef struct
{
const char* name; /**< Name of the dimension */
size_t bytes_of_name; /**< Bytes in @p name, including null terminator */
ZarrDimensionType kind; /**< Type of the dimension */
uint32_t array_size_px; /**< Size of the array along this dimension in
pixels */
uint32_t chunk_size_px; /**< Size of the chunks along this dimension in
pixels */
uint32_t shard_size_chunks; /**< Number of chunks in a shard along this
dimension */
} ZarrDimensionProperties;

#ifdef __cplusplus
}
#endif

#endif // H_ACQUIRE_ZARR_TYPES_V0
7 changes: 3 additions & 4 deletions src/streaming/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ add_library(${tgt}
zarr.stream.cpp
)

include(CMakePrintHelpers)
cmake_print_variables(CMAKE_SOURCE_DIR)
set(PUBLIC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include/)

target_include_directories(${tgt}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIR}>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
Expand All @@ -34,7 +33,7 @@ install(TARGETS ${tgt}
)

# Install public header files
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
install(DIRECTORY ${PUBLIC_INCLUDE_DIR}
DESTINATION include
FILES_MATCHING PATTERN "*.h"
)
18 changes: 9 additions & 9 deletions src/streaming/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
#include <iomanip>
#include <filesystem>

LogLevel Logger::current_level = LogLevel_Info;
ZarrLogLevel Logger::current_level = ZarrLogLevel_Info;

void
Logger::set_log_level(LogLevel level)
Logger::set_log_level(ZarrLogLevel level)
{
current_level = level;
}

LogLevel
ZarrLogLevel
Logger::get_log_level()
{
return current_level;
}

std::string
Logger::log(LogLevel level,
Logger::log(ZarrLogLevel level,
const char* file,
int line,
const char* func,
const char* format,
...)
{
if (current_level == LogLevel_None || level < current_level) {
if (current_level == ZarrLogLevel_None || level < current_level) {
return {}; // Suppress logs
}

Expand All @@ -39,17 +39,17 @@ Logger::log(LogLevel level,
std::ostream* stream = &std::cout;

switch (level) {
case LogLevel_Debug:
case ZarrLogLevel_Debug:
prefix = "[DEBUG] ";
break;
case LogLevel_Info:
case ZarrLogLevel_Info:
prefix = "[INFO] ";
break;
case LogLevel_Warning:
case ZarrLogLevel_Warning:
prefix = "[WARNING] ";
stream = &std::cerr;
break;
case LogLevel_Error:
case ZarrLogLevel_Error:
prefix = "[ERROR] ";
stream = &std::cerr;
break;
Expand Down
14 changes: 7 additions & 7 deletions src/streaming/logger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
class Logger
{
public:
static void set_log_level(LogLevel level);
static LogLevel get_log_level();
static void set_log_level(ZarrLogLevel level);
static ZarrLogLevel get_log_level();

static std::string log(LogLevel level,
static std::string log(ZarrLogLevel level,
const char* file,
int line,
const char* func,
const char* format,
...);

private:
static LogLevel current_level;
static ZarrLogLevel current_level;
};

#define LOG_DEBUG(...) \
Logger::log(LogLevel_Debug, __FILE__, __LINE__, __func__, __VA_ARGS__)
Logger::log(ZarrLogLevel_Debug, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define LOG_INFO(...) \
Logger::log(LogLevel_Info, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define LOG_WARNING(...) \
Logger::log(LogLevel_Warning, __FILE__, __LINE__, __func__, __VA_ARGS__)
Logger::log(ZarrLogLevel_Warning, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define LOG_ERROR(...) \
Logger::log(LogLevel_Error, __FILE__, __LINE__, __func__, __VA_ARGS__)
Logger::log(ZarrLogLevel_Error, __FILE__, __LINE__, __func__, __VA_ARGS__)

#define EXPECT(e, ...) \
do { \
Expand Down
Loading

0 comments on commit 96b580a

Please sign in to comment.