Skip to content

Commit

Permalink
Merge branch 'standalone-sequence-3' into standalone-sequence-4
Browse files Browse the repository at this point in the history
  • Loading branch information
aliddell committed Sep 20, 2024
2 parents cb5414f + 42a4940 commit 9a6212f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 213 deletions.
223 changes: 17 additions & 206 deletions include/acquire.zarr.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef H_ACQUIRE_ZARR_V0
#define H_ACQUIRE_ZARR_V0
#pragma once

#include "zarr.types.h"

Expand All @@ -8,7 +7,19 @@ extern "C"
{
#endif

typedef struct ZarrStreamSettings_s ZarrStreamSettings;
typedef struct ZarrStreamSettings_s
{
ZarrS3Settings s3_settings;
ZarrCompressionSettings compression_settings;
ZarrDimensionProperties* dimensions;
size_t dimension_count;
char* store_path;
char* custom_metadata;
ZarrDataType data_type;
ZarrVersion version;
bool multiscale;
} ZarrStreamSettings;

typedef struct ZarrStream_s ZarrStream;

/**
Expand All @@ -22,7 +33,7 @@ extern "C"
* @param level The log level.
* @return ZarrStatus_Success on success, or an error code on failure.
*/
ZarrStatus Zarr_set_log_level(ZarrLogLevel level);
ZarrStatusCode Zarr_set_log_level(ZarrLogLevel level);

/**
* @brief Get the log level for the Zarr API.
Expand All @@ -35,191 +46,7 @@ extern "C"
* @param status The status code.
* @return A human-readable status message.
*/
const char* Zarr_get_error_message(ZarrStatus status);

/**
* @brief Create a Zarr stream settings struct.
* @return A pointer to the Zarr stream settings struct, or NULL on failure.
*/
ZarrStreamSettings* ZarrStreamSettings_create();

/**
* @brief Destroy a Zarr stream settings struct.
* @details This function frees the memory allocated for the Zarr stream
* settings struct.
* @param[in] settings The Zarr stream settings struct.
*/
void ZarrStreamSettings_destroy(ZarrStreamSettings* settings);

/**
* @brief Copy a Zarr stream settings struct.
* @param[in] settings The Zarr stream settings struct to copy.
* @return A copy of the Zarr stream settings struct.
*/
ZarrStreamSettings* ZarrStreamSettings_copy(
const ZarrStreamSettings* settings);

/**
* @brief Set store path and S3 settings for the Zarr stream.
* @param[in, out] settings
* @param[in] store_path The store path for the Zarr stream. Directory path
* when acquiring to the filesystem, key prefix when acquiring to S3.
* @param[in] bytes_of_store_path The length of @p store_path in bytes,
* including the null terminator.
* @param[in] s3_settings Optional S3 settings. If NULL, the store path is
* assumed to be a directory path.
* @return ZarrStatus_Success on success, or an error code on failure.
*/
ZarrStatus ZarrStreamSettings_set_store(ZarrStreamSettings* settings,
const char* store_path,
size_t bytes_of_store_path,
const ZarrS3Settings* s3_settings);

/**
* @brief Set the data type, compressor, codec, compression_settings level,
* and shuffle for the Zarr stream.
* @param[in, out] settings The Zarr stream settings struct.
* @param[in] compression_settings The compression_settings settings.
* @return ZarrStatus_Success on success, or an error code on failure.
*/
ZarrStatus ZarrStreamSettings_set_compression(
ZarrStreamSettings* settings,
const ZarrCompressionSettings* compression_settings);

/**
* @brief Set the data type for the Zarr stream.
* @param[in, out] settings The Zarr stream settings struct.
* @param[in] data_type The data type.
* @return ZarrStatus_Success on success, or an error code on failure.
*/
ZarrStatus ZarrStreamSettings_set_data_type(ZarrStreamSettings* settings,
ZarrDataType data_type);

/**
* @brief Reserve space for dimensions in the Zarr stream settings struct.
* @detail *Must* precede calls to ZarrStreamSettings_set_dimension. We
* require at least 3 dimensions to validate settings, but you may set up to
* 32 dimensions.
* @param[in, out] settings The Zarr stream settings struct.
* @param[in] count The number of dimensions to reserve space for.
* @return ZarrStatus_Success on success, or an error code on failure.
*/
ZarrStatus ZarrStreamSettings_reserve_dimensions(
ZarrStreamSettings* settings,
size_t count);

/**
* @brief Set properties for an acquisition dimension.
* @detail The order of the dimensions in the Zarr stream is the order in
* which they are set. The first dimension set is the slowest varying
* dimension, and the last dimension set is the fastest varying dimension.
* For example, if the dimensions are set in the order z, y, x, the fastest
* varying dimension is x, the next fastest varying dimension is y, and the
* slowest varying dimension is z.
* @param[in, out] settings The Zarr stream settings struct.
* @param[in] index The index of the dimension to set. Must be less than the
* number of dimensions reserved with ZarrStreamSettings_reserve_dimensions.
* @param[in] dimension The dimension's settings.
*/
ZarrStatus ZarrStreamSettings_set_dimension(
ZarrStreamSettings* settings,
size_t index,
const ZarrDimensionProperties* dimension);

/**
* @brief Set the multiscale flag for the Zarr stream.
* @param[in, out] settings The Zarr stream settings struct.
* @param[in] multiscale A flag indicating whether to stream to multiple
* levels of detail.
* @return ZarrStatus_Success on success, or an error code on failure.
*/
ZarrStatus ZarrStreamSettings_set_multiscale(ZarrStreamSettings* settings,
uint8_t multiscale);

/**
* @brief Set JSON-formatted custom metadata for the Zarr stream.
* @details This metadata will be written to acquire-zarr.json in the
* metadata directory of the Zarr store. This parameter is optional.
* @param settings[in, out] settings The Zarr stream settings struct.
* @param external_metadata JSON-formatted external metadata.
* @param bytes_of_external_metadata The length of @p custom_metadata in
* bytes, including the null terminator.
* @return ZarrStatus_Success on success, or an error code on failure.
*/
ZarrStatus ZarrStreamSettings_set_custom_metadata(
ZarrStreamSettings* settings,
const char* external_metadata,
size_t bytes_of_external_metadata);

/**
* @brief Get the store path for the Zarr stream.
* @param settings The Zarr stream settings struct.
* @return The store path for the Zarr stream, or NULL on failure.
*/
const char* ZarrStreamSettings_get_store_path(
const ZarrStreamSettings* settings);

/**
* @brief Get the S3 settings for the Zarr stream.
* @param settings The Zarr stream settings struct.
* @return The S3 settings for the Zarr stream, or an uninitialized struct on
* failure.
*/
ZarrS3Settings ZarrStreamSettings_get_s3_settings(
const ZarrStreamSettings* settings);

/**
* @brief Get the compression settings for the Zarr stream.
* @param settings The Zarr stream settings struct.
* @return The compression settings for the Zarr stream, or an uninitialized
* struct on failure.
*/
ZarrCompressionSettings ZarrStreamSettings_get_compression(
const ZarrStreamSettings* settings);

/**
* @brief Get the data type for the Zarr stream.
* @param settings The Zarr stream settings struct.
* @return The data type for the Zarr stream, or ZarrDataType_uint8 on failure.
*/
ZarrDataType ZarrStreamSettings_get_data_type(
const ZarrStreamSettings* settings);

/**
* @brief Get the number of dimensions in the Zarr stream settings struct.
* @param settings The Zarr stream settings struct.
* @return The number of dimensions in the Zarr stream settings struct, or 0 on
* failure.
*/
size_t ZarrStreamSettings_get_dimension_count(
const ZarrStreamSettings* settings);

/**
* @brief Get the properties for an acquisition dimension.
* @param settings The Zarr stream settings struct.
* @param index The index of the dimension to get.
* @return The properties for the @p index th dimension, or an uninitialized struct on
* failure.
*/
ZarrDimensionProperties ZarrStreamSettings_get_dimension(
const ZarrStreamSettings* settings,
size_t index);

/**
* @brief Get the multiscale flag for the Zarr stream.
* @param settings The Zarr stream settings struct.
* @return The multiscale flag for the Zarr stream, or false on failure.
*/
bool ZarrStreamSettings_get_multiscale(const ZarrStreamSettings* settings);

/**
* @brief Get the JSON-formatted custom metadata for the Zarr stream.
* @param settings The Zarr stream settings struct.
* @return The JSON-formatted custom metadata for the Zarr stream, or NULL on
* failure.
*/
const char* ZarrStreamSettings_get_custom_metadata(
const ZarrStreamSettings* settings);
const char* Zarr_get_status_message(ZarrStatusCode status);

/**
* @brief Create a Zarr stream.
Expand Down Expand Up @@ -248,27 +75,11 @@ extern "C"
* @param[out] bytes_out The number of bytes written to the stream.
* @return ZarrStatus_Success on success, or an error code on failure.
*/
ZarrStatus ZarrStream_append(ZarrStream* stream,
ZarrStatusCode ZarrStream_append(ZarrStream* stream,
const void* data,
size_t bytes_in,
size_t* bytes_out);

/**
* @brief Get the version (i.e., 2 or 3) of the Zarr stream.
* @param stream The Zarr stream struct.
* @return The version of the Zarr stream.
*/
ZarrVersion ZarrStream_get_version(const ZarrStream* stream);

/**
* @brief Get a copy of the settings for the Zarr stream.
* @param stream The Zarr stream struct.
* @return A copy of the settings for the Zarr stream.
*/
ZarrStreamSettings* ZarrStream_get_settings(const ZarrStream* stream);

#ifdef __cplusplus
}
#endif

#endif // H_ACQUIRE_ZARR_V0
10 changes: 3 additions & 7 deletions include/zarr.types.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C"
ZarrStatus_CompressionError,
ZarrStatus_InvalidSettings,
ZarrStatusCount,
} ZarrStatus;
} ZarrStatusCode;

typedef enum
{
Expand All @@ -34,7 +34,7 @@ extern "C"

typedef enum
{
ZarrLogLevel_Debug,
ZarrLogLevel_Debug = 0,
ZarrLogLevel_Info,
ZarrLogLevel_Warning,
ZarrLogLevel_Error,
Expand All @@ -44,7 +44,7 @@ extern "C"

typedef enum
{
ZarrDataType_uint8,
ZarrDataType_uint8 = 0,
ZarrDataType_uint16,
ZarrDataType_uint32,
ZarrDataType_uint64,
Expand Down Expand Up @@ -87,13 +87,9 @@ extern "C"
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;

/**
Expand Down

0 comments on commit 9a6212f

Please sign in to comment.