From 529b460fdbadabba19932b84d41155f8b5ba8dd0 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Mon, 17 Jun 2024 22:59:21 -0400 Subject: [PATCH] cleanups --- meson.build | 29 ++- .../integration/c_data_integration.cc | 8 +- .../integration/c_data_integration.h | 10 +- src/nanoarrow/nanoarrow.h | 206 +++++++++--------- src/nanoarrow/nanoarrow_device.h | 54 ++--- src/nanoarrow/nanoarrow_ipc.h | 48 ++-- src/nanoarrow/nanoarrow_types.h | 16 +- 7 files changed, 192 insertions(+), 179 deletions(-) diff --git a/meson.build b/meson.build index e758c8412..07198da1a 100644 --- a/meson.build +++ b/meson.build @@ -53,23 +53,28 @@ configure_file(input: 'src/nanoarrow/nanoarrow_config.h.in', output: 'nanoarrow_config.h', configuration: conf_data) -# Windows shared libraries are not exporting the right symbols -# See https://github.com/mesonbuild/wrapdb/pull/1536#issuecomment-2136011408 -# and https://github.com/apache/arrow-nanoarrow/issues/495 + if host_machine.system() == 'windows' - libtype = 'static_library' -else - libtype = 'library' + libtype = get_option('default_library') + if libtype == 'shared' # TODO: do we need to handle default_library=both? + if meson.is_subproject() + add_project_arguments('-DNANOARROW_CONSUME_DLL', language: 'c') + add_project_arguments('-DNANOARROW_CONSUME_DLL', language: 'cpp') + else + add_project_arguments('-DNANOARROW_BUILD_DLL', language: 'c') + add_project_arguments('-DNANOARROW_BUILD_DLL', language: 'cpp') + endif + endif endif -nanoarrow_lib = build_target( +nanoarrow_lib = library( 'nanoarrow', 'src/nanoarrow/array.c', 'src/nanoarrow/schema.c', 'src/nanoarrow/array_stream.c', 'src/nanoarrow/utils.c', install: true, - target_type: libtype, + gnu_symbol_visibility: 'hidden', ) incdir = include_directories('src/') @@ -80,13 +85,13 @@ nanoarrow_dep = declare_dependency(include_directories: [incdir], if get_option('ipc') flatcc_dep = dependency('flatcc') - nanoarrow_ipc_lib = build_target( + nanoarrow_ipc_lib = library( 'nanoarrow_ipc', 'src/nanoarrow/nanoarrow_ipc_decoder.c', 'src/nanoarrow/nanoarrow_ipc_reader.c', dependencies: [nanoarrow_dep, flatcc_dep], install: true, - target_type: libtype, + gnu_symbol_visibility: 'hidden', ) nanoarrow_ipc_dep = declare_dependency(include_directories: [incdir], link_with: nanoarrow_ipc_lib, @@ -112,13 +117,13 @@ if needs_device error('CUDA support with the Meson build system is not implemented') endif - nanoarrow_device_lib = build_target( + nanoarrow_device_lib = library( 'nanoarrow_device', sources: device_srcs, dependencies: device_deps, install: true, - target_type: libtype, cpp_args: device_defines, + gnu_symbol_visibility: 'hidden', ) endif diff --git a/src/nanoarrow/integration/c_data_integration.cc b/src/nanoarrow/integration/c_data_integration.cc index 3c523dbe9..579895b0a 100644 --- a/src/nanoarrow/integration/c_data_integration.cc +++ b/src/nanoarrow/integration/c_data_integration.cc @@ -209,25 +209,25 @@ static const char* ConvertError(ArrowErrorCode errno_code) { int64_t nanoarrow_BytesAllocated() { return kBytesAllocated; } -NANOARROW_DLL_EXPORT const char* nanoarrow_CDataIntegration_ExportSchemaFromJson( +NANOARROW_EXPORT const char* nanoarrow_CDataIntegration_ExportSchemaFromJson( const char* json_path, ArrowSchema* out) { ArrowErrorInit(&global_error); return ConvertError(ExportSchemaFromJson(json_path, out, &global_error)); } -NANOARROW_DLL_EXPORT const char* nanoarrow_CDataIntegration_ImportSchemaAndCompareToJson( +NANOARROW_EXPORT const char* nanoarrow_CDataIntegration_ImportSchemaAndCompareToJson( const char* json_path, ArrowSchema* schema) { ArrowErrorInit(&global_error); return ConvertError(ImportSchemaAndCompareToJson(json_path, schema, &global_error)); } -NANOARROW_DLL_EXPORT const char* nanoarrow_CDataIntegration_ExportBatchFromJson( +NANOARROW_EXPORT const char* nanoarrow_CDataIntegration_ExportBatchFromJson( const char* json_path, int num_batch, ArrowArray* out) { ArrowErrorInit(&global_error); return ConvertError(ExportBatchFromJson(json_path, num_batch, out, &global_error)); } -NANOARROW_DLL_EXPORT const char* nanoarrow_CDataIntegration_ImportBatchAndCompareToJson( +NANOARROW_EXPORT const char* nanoarrow_CDataIntegration_ImportBatchAndCompareToJson( const char* json_path, int num_batch, ArrowArray* batch) { ArrowErrorInit(&global_error); return ConvertError( diff --git a/src/nanoarrow/integration/c_data_integration.h b/src/nanoarrow/integration/c_data_integration.h index 0b7208f62..e63d6a427 100644 --- a/src/nanoarrow/integration/c_data_integration.h +++ b/src/nanoarrow/integration/c_data_integration.h @@ -71,19 +71,19 @@ struct ArrowArray { #endif // ARROW_C_DATA_INTERFACE #endif // ARROW_FLAG_DICTIONARY_ORDERED -NANOARROW_DLL_EXPORT const char* nanoarrow_CDataIntegration_ExportSchemaFromJson( +NANOARROW_EXPORT const char* nanoarrow_CDataIntegration_ExportSchemaFromJson( const char* json_path, struct ArrowSchema* out); -NANOARROW_DLL_EXPORT const char* nanoarrow_CDataIntegration_ImportSchemaAndCompareToJson( +NANOARROW_EXPORT const char* nanoarrow_CDataIntegration_ImportSchemaAndCompareToJson( const char* json_path, struct ArrowSchema* schema); -NANOARROW_DLL_EXPORT const char* nanoarrow_CDataIntegration_ExportBatchFromJson( +NANOARROW_EXPORT const char* nanoarrow_CDataIntegration_ExportBatchFromJson( const char* json_path, int num_batch, struct ArrowArray* out); -NANOARROW_DLL_EXPORT const char* nanoarrow_CDataIntegration_ImportBatchAndCompareToJson( +NANOARROW_EXPORT const char* nanoarrow_CDataIntegration_ImportBatchAndCompareToJson( const char* json_path, int num_batch, struct ArrowArray* batch); -NANOARROW_DLL_EXPORT int64_t nanoarrow_BytesAllocated(void); +NANOARROW_EXPORT int64_t nanoarrow_BytesAllocated(void); #ifdef __cplusplus } diff --git a/src/nanoarrow/nanoarrow.h b/src/nanoarrow/nanoarrow.h index a28d6c816..48e831eef 100644 --- a/src/nanoarrow/nanoarrow.h +++ b/src/nanoarrow/nanoarrow.h @@ -161,19 +161,19 @@ extern "C" { /// @{ /// \brief Allocate like malloc() -NANOARROW_DLL_EXPORT void* ArrowMalloc(int64_t size); +NANOARROW_EXPORT void* ArrowMalloc(int64_t size); /// \brief Reallocate like realloc() -NANOARROW_DLL_EXPORT void* ArrowRealloc(void* ptr, int64_t size); +NANOARROW_EXPORT void* ArrowRealloc(void* ptr, int64_t size); /// \brief Free a pointer allocated using ArrowMalloc() or ArrowRealloc(). -NANOARROW_DLL_EXPORT void ArrowFree(void* ptr); +NANOARROW_EXPORT void ArrowFree(void* ptr); /// \brief Return the default allocator /// /// The default allocator uses ArrowMalloc(), ArrowRealloc(), and /// ArrowFree(). -NANOARROW_DLL_EXPORT struct ArrowBufferAllocator ArrowBufferAllocatorDefault(void); +NANOARROW_EXPORT struct ArrowBufferAllocator ArrowBufferAllocatorDefault(void); /// \brief Create a custom deallocator /// @@ -181,7 +181,7 @@ NANOARROW_DLL_EXPORT struct ArrowBufferAllocator ArrowBufferAllocatorDefault(voi /// attach a custom deallocator to an ArrowBuffer. This may be used to /// avoid copying an existing buffer that was not allocated using the /// infrastructure provided here (e.g., by an R or Python object). -NANOARROW_DLL_EXPORT struct ArrowBufferAllocator ArrowBufferDeallocator( +NANOARROW_EXPORT struct ArrowBufferAllocator ArrowBufferDeallocator( ArrowBufferDeallocatorCallback, void* private_data); /// @} @@ -262,7 +262,7 @@ static inline void ArrowArrayStreamRelease(struct ArrowArrayStream* array_stream /// \brief Set the contents of an error using printf syntax. /// /// If error is NULL, this function does nothing and returns NANOARROW_OK. -NANOARROW_DLL_EXPORT NANOARROW_CHECK_PRINTF_ATTRIBUTE int ArrowErrorSet( +NANOARROW_EXPORT NANOARROW_CHECK_PRINTF_ATTRIBUTE int ArrowErrorSet( struct ArrowError* error, const char* fmt, ...); /// @} @@ -272,24 +272,24 @@ NANOARROW_DLL_EXPORT NANOARROW_CHECK_PRINTF_ATTRIBUTE int ArrowErrorSet( /// @{ /// \brief Return a version string in the form "major.minor.patch" -NANOARROW_DLL_EXPORT const char* ArrowNanoarrowVersion(void); +NANOARROW_EXPORT const char* ArrowNanoarrowVersion(void); /// \brief Return an integer that can be used to compare versions sequentially -NANOARROW_DLL_EXPORT int ArrowNanoarrowVersionInt(void); +NANOARROW_EXPORT int ArrowNanoarrowVersionInt(void); /// \brief Initialize a description of buffer arrangements from a storage type -NANOARROW_DLL_EXPORT void ArrowLayoutInit(struct ArrowLayout* layout, - enum ArrowType storage_type); +NANOARROW_EXPORT void ArrowLayoutInit(struct ArrowLayout* layout, + enum ArrowType storage_type); /// \brief Create a string view from a null-terminated string static inline struct ArrowStringView ArrowCharView(const char* value); /// \brief Sets the integer value of an ArrowDecimal from a string -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDecimalSetDigits(struct ArrowDecimal* decimal, - struct ArrowStringView value); +NANOARROW_EXPORT ArrowErrorCode ArrowDecimalSetDigits(struct ArrowDecimal* decimal, + struct ArrowStringView value); /// \brief Get the integer value of an ArrowDecimal as string -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDecimalAppendDigitsToBuffer( +NANOARROW_EXPORT ArrowErrorCode ArrowDecimalAppendDigitsToBuffer( const struct ArrowDecimal* decimal, struct ArrowBuffer* buffer); /// \brief Get the half float value of a float @@ -319,7 +319,7 @@ static inline int64_t ArrowResolveChunk64(int64_t index, const int64_t* offsets, /// Initializes the fields and release callback of schema_out. Caller /// is responsible for calling the schema->release callback if /// NANOARROW_OK is returned. -NANOARROW_DLL_EXPORT void ArrowSchemaInit(struct ArrowSchema* schema); +NANOARROW_EXPORT void ArrowSchemaInit(struct ArrowSchema* schema); /// \brief Initialize an ArrowSchema from an ArrowType /// @@ -327,8 +327,8 @@ NANOARROW_DLL_EXPORT void ArrowSchemaInit(struct ArrowSchema* schema); /// ArrowSchemaSetType() for the common case of constructing an /// unparameterized type. The caller is responsible for calling the schema->release /// callback if NANOARROW_OK is returned. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaInitFromType(struct ArrowSchema* schema, - enum ArrowType type); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaInitFromType(struct ArrowSchema* schema, + enum ArrowType type); /// \brief Get a human-readable summary of a Schema /// @@ -336,8 +336,8 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaInitFromType(struct ArrowSchema* /// and returns the number of characters required for the output if /// n were sufficiently large. If recursive is non-zero, the result will /// also include children. -NANOARROW_DLL_EXPORT int64_t ArrowSchemaToString(const struct ArrowSchema* schema, - char* out, int64_t n, char recursive); +NANOARROW_EXPORT int64_t ArrowSchemaToString(const struct ArrowSchema* schema, char* out, + int64_t n, char recursive); /// \brief Set the format field of a schema from an ArrowType /// @@ -347,16 +347,16 @@ NANOARROW_DLL_EXPORT int64_t ArrowSchemaToString(const struct ArrowSchema* schem /// allocated, initialized, and named; however, the caller must /// ArrowSchemaSetType() on the preinitialized children. Schema must have been initialized /// using ArrowSchemaInit() or ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetType(struct ArrowSchema* schema, - enum ArrowType type); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetType(struct ArrowSchema* schema, + enum ArrowType type); /// \brief Set the format field and initialize children of a struct schema /// /// The specified number of children are initialized; however, the caller is responsible /// for calling ArrowSchemaSetType() and ArrowSchemaSetName() on each child. /// Schema must have been initialized using ArrowSchemaInit() or ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetTypeStruct(struct ArrowSchema* schema, - int64_t n_children); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetTypeStruct(struct ArrowSchema* schema, + int64_t n_children); /// \brief Set the format field of a fixed-size schema /// @@ -366,18 +366,19 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetTypeStruct(struct ArrowSchema* /// allocated, initialized, and named; however, the caller must /// ArrowSchemaSetType() the first child. Schema must have been initialized using /// ArrowSchemaInit() or ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetTypeFixedSize( - struct ArrowSchema* schema, enum ArrowType type, int32_t fixed_size); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetTypeFixedSize(struct ArrowSchema* schema, + enum ArrowType type, + int32_t fixed_size); /// \brief Set the format field of a decimal schema /// /// Returns EINVAL for scale <= 0 or for type that is not /// NANOARROW_TYPE_DECIMAL128 or NANOARROW_TYPE_DECIMAL256. Schema must have been /// initialized using ArrowSchemaInit() or ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetTypeDecimal(struct ArrowSchema* schema, - enum ArrowType type, - int32_t decimal_precision, - int32_t decimal_scale); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetTypeDecimal(struct ArrowSchema* schema, + enum ArrowType type, + int32_t decimal_precision, + int32_t decimal_scale); /// \brief Set the format field of a run-end encoded schema /// @@ -387,7 +388,7 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetTypeDecimal(struct ArrowSchema /// The caller must call `ArrowSchemaSetTypeXXX(schema->children[1])` to /// set the value type. Note that when building arrays using the `ArrowArrayAppendXXX()` /// functions, the run-end encoded array's logical length must be updated manually. -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetTypeRunEndEncoded(struct ArrowSchema* schema, enum ArrowType run_end_type); /// \brief Set the format field of a time, timestamp, or duration schema @@ -397,60 +398,60 @@ ArrowSchemaSetTypeRunEndEncoded(struct ArrowSchema* schema, enum ArrowType run_e /// NANOARROW_TYPE_TIMESTAMP, or NANOARROW_TYPE_DURATION. The /// timezone parameter must be NULL for a non-timestamp type. Schema must have been /// initialized using ArrowSchemaInit() or ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowSchemaSetTypeDateTime(struct ArrowSchema* schema, enum ArrowType type, - enum ArrowTimeUnit time_unit, const char* timezone); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetTypeDateTime(struct ArrowSchema* schema, + enum ArrowType type, + enum ArrowTimeUnit time_unit, + const char* timezone); /// \brief Set the format field of a union schema /// /// Returns EINVAL for a type that is not NANOARROW_TYPE_DENSE_UNION /// or NANOARROW_TYPE_SPARSE_UNION. The specified number of children are /// allocated, and initialized. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetTypeUnion(struct ArrowSchema* schema, - enum ArrowType type, - int64_t n_children); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetTypeUnion(struct ArrowSchema* schema, + enum ArrowType type, + int64_t n_children); /// \brief Make a (recursive) copy of a schema /// /// Allocates and copies fields of schema into schema_out. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaDeepCopy(const struct ArrowSchema* schema, - struct ArrowSchema* schema_out); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaDeepCopy(const struct ArrowSchema* schema, + struct ArrowSchema* schema_out); /// \brief Copy format into schema->format /// /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetFormat(struct ArrowSchema* schema, - const char* format); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetFormat(struct ArrowSchema* schema, + const char* format); /// \brief Copy name into schema->name /// /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetName(struct ArrowSchema* schema, - const char* name); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetName(struct ArrowSchema* schema, + const char* name); /// \brief Copy metadata into schema->metadata /// /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowSchemaSetMetadata(struct ArrowSchema* schema, - const char* metadata); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaSetMetadata(struct ArrowSchema* schema, + const char* metadata); /// \brief Allocate the schema->children array /// /// Includes the memory for each child struct ArrowSchema. /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowSchemaAllocateChildren(struct ArrowSchema* schema, int64_t n_children); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaAllocateChildren(struct ArrowSchema* schema, + int64_t n_children); /// \brief Allocate the schema->dictionary member /// /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy(). -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowSchemaAllocateDictionary(struct ArrowSchema* schema); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaAllocateDictionary(struct ArrowSchema* schema); /// @} @@ -474,50 +475,52 @@ struct ArrowMetadataReader { }; /// \brief Initialize an ArrowMetadataReader -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowMetadataReaderInit(struct ArrowMetadataReader* reader, const char* metadata); /// \brief Read the next key/value pair from an ArrowMetadataReader -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowMetadataReaderRead( +NANOARROW_EXPORT ArrowErrorCode ArrowMetadataReaderRead( struct ArrowMetadataReader* reader, struct ArrowStringView* key_out, struct ArrowStringView* value_out); /// \brief The number of bytes in in a key/value metadata string -NANOARROW_DLL_EXPORT int64_t ArrowMetadataSizeOf(const char* metadata); +NANOARROW_EXPORT int64_t ArrowMetadataSizeOf(const char* metadata); /// \brief Check for a key in schema metadata -NANOARROW_DLL_EXPORT char ArrowMetadataHasKey(const char* metadata, - struct ArrowStringView key); +NANOARROW_EXPORT char ArrowMetadataHasKey(const char* metadata, + struct ArrowStringView key); /// \brief Extract a value from schema metadata /// /// If key does not exist in metadata, value_out is unmodified -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowMetadataGetValue( - const char* metadata, struct ArrowStringView key, struct ArrowStringView* value_out); +NANOARROW_EXPORT ArrowErrorCode ArrowMetadataGetValue(const char* metadata, + struct ArrowStringView key, + struct ArrowStringView* value_out); /// \brief Initialize a builder for schema metadata from key/value pairs /// /// metadata can be an existing metadata string or NULL to initialize /// an empty metadata string. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowMetadataBuilderInit(struct ArrowBuffer* buffer, - const char* metadata); +NANOARROW_EXPORT ArrowErrorCode ArrowMetadataBuilderInit(struct ArrowBuffer* buffer, + const char* metadata); /// \brief Append a key/value pair to a buffer containing serialized metadata -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowMetadataBuilderAppend( - struct ArrowBuffer* buffer, struct ArrowStringView key, struct ArrowStringView value); +NANOARROW_EXPORT ArrowErrorCode ArrowMetadataBuilderAppend(struct ArrowBuffer* buffer, + struct ArrowStringView key, + struct ArrowStringView value); /// \brief Set a key/value pair to a buffer containing serialized metadata /// /// Ensures that the only entry for key in the metadata is set to value. /// This function maintains the existing position of (the first instance of) /// key if present in the data. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowMetadataBuilderSet(struct ArrowBuffer* buffer, - struct ArrowStringView key, - struct ArrowStringView value); +NANOARROW_EXPORT ArrowErrorCode ArrowMetadataBuilderSet(struct ArrowBuffer* buffer, + struct ArrowStringView key, + struct ArrowStringView value); /// \brief Remove a key from a buffer containing serialized metadata -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowMetadataBuilderRemove(struct ArrowBuffer* buffer, struct ArrowStringView key); +NANOARROW_EXPORT ArrowErrorCode ArrowMetadataBuilderRemove(struct ArrowBuffer* buffer, + struct ArrowStringView key); /// @} @@ -615,9 +618,9 @@ struct ArrowSchemaView { }; /// \brief Initialize an ArrowSchemaView -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowSchemaViewInit(struct ArrowSchemaView* schema_view, const struct ArrowSchema* schema, - struct ArrowError* error); +NANOARROW_EXPORT ArrowErrorCode ArrowSchemaViewInit(struct ArrowSchemaView* schema_view, + const struct ArrowSchema* schema, + struct ArrowError* error); /// @} @@ -833,21 +836,22 @@ static inline void ArrowBitmapReset(struct ArrowBitmap* bitmap); /// Initializes the fields and release callback of array. Caller /// is responsible for calling the array->release callback if /// NANOARROW_OK is returned. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayInitFromType(struct ArrowArray* array, - enum ArrowType storage_type); +NANOARROW_EXPORT ArrowErrorCode ArrowArrayInitFromType(struct ArrowArray* array, + enum ArrowType storage_type); /// \brief Initialize the contents of an ArrowArray from an ArrowSchema /// /// Caller is responsible for calling the array->release callback if /// NANOARROW_OK is returned. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayInitFromSchema( - struct ArrowArray* array, const struct ArrowSchema* schema, struct ArrowError* error); +NANOARROW_EXPORT ArrowErrorCode ArrowArrayInitFromSchema(struct ArrowArray* array, + const struct ArrowSchema* schema, + struct ArrowError* error); /// \brief Initialize the contents of an ArrowArray from an ArrowArrayView /// /// Caller is responsible for calling the array->release callback if /// NANOARROW_OK is returned. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayInitFromArrayView( +NANOARROW_EXPORT ArrowErrorCode ArrowArrayInitFromArrayView( struct ArrowArray* array, const struct ArrowArrayView* array_view, struct ArrowError* error); @@ -857,8 +861,8 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayInitFromArrayView( /// whose members are marked as released and may be subsequently initialized /// with ArrowArrayInitFromType() or moved from an existing ArrowArray. /// schema must have been allocated using ArrowArrayInitFromType(). -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayAllocateChildren(struct ArrowArray* array, - int64_t n_children); +NANOARROW_EXPORT ArrowErrorCode ArrowArrayAllocateChildren(struct ArrowArray* array, + int64_t n_children); /// \brief Allocate the array->dictionary member /// @@ -866,21 +870,19 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayAllocateChildren(struct ArrowArray /// is marked as released and may be subsequently initialized /// with ArrowArrayInitFromType() or moved from an existing ArrowArray. /// array must have been allocated using ArrowArrayInitFromType() -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowArrayAllocateDictionary(struct ArrowArray* array); +NANOARROW_EXPORT ArrowErrorCode ArrowArrayAllocateDictionary(struct ArrowArray* array); /// \brief Set the validity bitmap of an ArrowArray /// /// array must have been allocated using ArrowArrayInitFromType() -NANOARROW_DLL_EXPORT void ArrowArraySetValidityBitmap(struct ArrowArray* array, - struct ArrowBitmap* bitmap); +NANOARROW_EXPORT void ArrowArraySetValidityBitmap(struct ArrowArray* array, + struct ArrowBitmap* bitmap); /// \brief Set a buffer of an ArrowArray /// /// array must have been allocated using ArrowArrayInitFromType() -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArraySetBuffer(struct ArrowArray* array, - int64_t i, - struct ArrowBuffer* buffer); +NANOARROW_EXPORT ArrowErrorCode ArrowArraySetBuffer(struct ArrowArray* array, int64_t i, + struct ArrowBuffer* buffer); /// \brief Get the validity bitmap of an ArrowArray /// @@ -906,8 +908,8 @@ static inline ArrowErrorCode ArrowArrayStartAppending(struct ArrowArray* array); /// child array sizes for non-fixed-size arrays), recursively reserve space for /// additional elements. This is useful for reducing the number of reallocations /// that occur using the item-wise appenders. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayReserve(struct ArrowArray* array, - int64_t additional_size_elements); +NANOARROW_EXPORT ArrowErrorCode ArrowArrayReserve(struct ArrowArray* array, + int64_t additional_size_elements); /// \brief Append a null value to an array static inline ArrowErrorCode ArrowArrayAppendNull(struct ArrowArray* array, int64_t n); @@ -1005,8 +1007,8 @@ static inline ArrowErrorCode ArrowArrayShrinkToFit(struct ArrowArray* array); /// into array->buffers and checks the actual size of the buffers /// against the expected size based on the final length. /// array must have been allocated using ArrowArrayInitFromType() -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowArrayFinishBuildingDefault(struct ArrowArray* array, struct ArrowError* error); +NANOARROW_EXPORT ArrowErrorCode ArrowArrayFinishBuildingDefault(struct ArrowArray* array, + struct ArrowError* error); /// \brief Finish building an ArrowArray with explicit validation /// @@ -1015,7 +1017,7 @@ ArrowArrayFinishBuildingDefault(struct ArrowArray* array, struct ArrowError* err /// buffer data access is not possible or more validation (i.e., /// NANOARROW_VALIDATION_LEVEL_FULL) if buffer content was obtained from an untrusted or /// corruptible source. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayFinishBuilding( +NANOARROW_EXPORT ArrowErrorCode ArrowArrayFinishBuilding( struct ArrowArray* array, enum ArrowValidationLevel validation_level, struct ArrowError* error); @@ -1028,8 +1030,8 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayFinishBuilding( /// @{ /// \brief Initialize the contents of an ArrowArrayView -NANOARROW_DLL_EXPORT void ArrowArrayViewInitFromType(struct ArrowArrayView* array_view, - enum ArrowType storage_type); +NANOARROW_EXPORT void ArrowArrayViewInitFromType(struct ArrowArrayView* array_view, + enum ArrowType storage_type); /// \brief Move an ArrowArrayView /// @@ -1039,32 +1041,32 @@ static inline void ArrowArrayViewMove(struct ArrowArrayView* src, struct ArrowArrayView* dst); /// \brief Initialize the contents of an ArrowArrayView from an ArrowSchema -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowArrayViewInitFromSchema(struct ArrowArrayView* array_view, const struct ArrowSchema* schema, struct ArrowError* error); /// \brief Allocate the array_view->children array /// /// Includes the memory for each child struct ArrowArrayView -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowArrayViewAllocateChildren(struct ArrowArrayView* array_view, int64_t n_children); /// \brief Allocate array_view->dictionary -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowArrayViewAllocateDictionary(struct ArrowArrayView* array_view); /// \brief Set data-independent buffer sizes from length -NANOARROW_DLL_EXPORT void ArrowArrayViewSetLength(struct ArrowArrayView* array_view, - int64_t length); +NANOARROW_EXPORT void ArrowArrayViewSetLength(struct ArrowArrayView* array_view, + int64_t length); /// \brief Set buffer sizes and data pointers from an ArrowArray -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowArrayViewSetArray(struct ArrowArrayView* array_view, const struct ArrowArray* array, - struct ArrowError* error); +NANOARROW_EXPORT ArrowErrorCode ArrowArrayViewSetArray(struct ArrowArrayView* array_view, + const struct ArrowArray* array, + struct ArrowError* error); /// \brief Set buffer sizes and data pointers from an ArrowArray except for those /// that require dereferencing buffer content. -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowArrayViewSetArrayMinimal(struct ArrowArrayView* array_view, const struct ArrowArray* array, struct ArrowError* error); @@ -1076,12 +1078,12 @@ ArrowArrayViewSetArrayMinimal(struct ArrowArrayView* array_view, /// and sizes otherwise, you may wish to perform checks at a different level. See /// documentation for ArrowValidationLevel for the details of checks performed /// at each level. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowArrayViewValidate( +NANOARROW_EXPORT ArrowErrorCode ArrowArrayViewValidate( struct ArrowArrayView* array_view, enum ArrowValidationLevel validation_level, struct ArrowError* error); /// \brief Reset the contents of an ArrowArrayView and frees resources -NANOARROW_DLL_EXPORT void ArrowArrayViewReset(struct ArrowArrayView* array_view); +NANOARROW_EXPORT void ArrowArrayViewReset(struct ArrowArrayView* array_view); /// \brief Check for a null element in an ArrowArrayView static inline int8_t ArrowArrayViewIsNull(const struct ArrowArrayView* array_view, @@ -1156,7 +1158,7 @@ static inline void ArrowArrayViewGetDecimalUnsafe(const struct ArrowArrayView* a /// This function moves the ownership of schema to the array_stream. If /// this function returns NANOARROW_OK, the caller is responsible for /// releasing the ArrowArrayStream. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowBasicArrayStreamInit( +NANOARROW_EXPORT ArrowErrorCode ArrowBasicArrayStreamInit( struct ArrowArrayStream* array_stream, struct ArrowSchema* schema, int64_t n_arrays); /// \brief Set the ith ArrowArray in this ArrowArrayStream. @@ -1166,15 +1168,15 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowBasicArrayStreamInit( /// be greater than zero and less than the value of n_arrays passed in /// ArrowBasicArrayStreamInit(). Callers are not required to fill all /// n_arrays members (i.e., n_arrays is a maximum bound). -NANOARROW_DLL_EXPORT void ArrowBasicArrayStreamSetArray( - struct ArrowArrayStream* array_stream, int64_t i, struct ArrowArray* array); +NANOARROW_EXPORT void ArrowBasicArrayStreamSetArray(struct ArrowArrayStream* array_stream, + int64_t i, struct ArrowArray* array); /// \brief Validate the contents of this ArrowArrayStream /// /// array_stream must have been initialized with ArrowBasicArrayStreamInit(). /// This function uses ArrowArrayStreamInitFromSchema() and ArrowArrayStreamSetArray() /// to validate the contents of the arrays. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowBasicArrayStreamValidate( +NANOARROW_EXPORT ArrowErrorCode ArrowBasicArrayStreamValidate( const struct ArrowArrayStream* array_stream, struct ArrowError* error); /// @} diff --git a/src/nanoarrow/nanoarrow_device.h b/src/nanoarrow/nanoarrow_device.h index b99d9abc8..72b0708ea 100644 --- a/src/nanoarrow/nanoarrow_device.h +++ b/src/nanoarrow/nanoarrow_device.h @@ -153,7 +153,7 @@ static inline void ArrowDeviceArrayMove(struct ArrowDeviceArray* src, /// @{ /// \brief Checks the nanoarrow runtime to make sure the run/build versions match -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceCheckRuntime(struct ArrowError* error); +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceCheckRuntime(struct ArrowError* error); /// \brief A Device wrapper with callbacks for basic memory management tasks /// @@ -239,7 +239,7 @@ struct ArrowDeviceArrayView { /// /// Given an ArrowArray whose buffers/release callback has been set appropriately, /// initialize an ArrowDeviceArray. -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceArrayInit(struct ArrowDevice* device, struct ArrowDeviceArray* device_array, struct ArrowArray* array, void* sync_event); @@ -248,18 +248,18 @@ ArrowDeviceArrayInit(struct ArrowDevice* device, struct ArrowDeviceArray* device /// Zeroes memory for the device array view struct. Callers must initialize the /// array_view member using nanoarrow core functions that can initialize from /// a type identifier or schema. -NANOARROW_DLL_EXPORT void ArrowDeviceArrayViewInit( +NANOARROW_EXPORT void ArrowDeviceArrayViewInit( struct ArrowDeviceArrayView* device_array_view); /// \brief Release the underlying ArrowArrayView -NANOARROW_DLL_EXPORT void ArrowDeviceArrayViewReset( +NANOARROW_EXPORT void ArrowDeviceArrayViewReset( struct ArrowDeviceArrayView* device_array_view); /// \brief Set minimal ArrowArrayView buffer information from a device array /// /// A thin wrapper around ArrowArrayViewSetArrayMinimal() that does not attempt /// to resolve buffer sizes of variable-length buffers by copying data from the device. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceArrayViewSetArrayMinimal( +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceArrayViewSetArrayMinimal( struct ArrowDeviceArrayView* device_array_view, struct ArrowDeviceArray* device_array, struct ArrowError* error); @@ -268,29 +268,29 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceArrayViewSetArrayMinimal( /// Runs ArrowDeviceArrayViewSetArrayMinimal() but also sets buffer sizes for /// variable-length buffers by copying data from the device. This function will block on /// the device_array's sync_event. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceArrayViewSetArray( +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceArrayViewSetArray( struct ArrowDeviceArrayView* device_array_view, struct ArrowDeviceArray* device_array, struct ArrowError* error); /// \brief Copy an ArrowDeviceArrayView to a device -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowDeviceArrayViewCopy(struct ArrowDeviceArrayView* src, struct ArrowDevice* device_dst, - struct ArrowDeviceArray* dst); +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceArrayViewCopy(struct ArrowDeviceArrayView* src, + struct ArrowDevice* device_dst, + struct ArrowDeviceArray* dst); /// \brief Move an ArrowDeviceArray to a device if possible /// /// Will attempt to move a device array to a device without copying buffers. /// This may result in a device array with different performance charateristics /// than an array that was copied. -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceArrayMoveToDevice(struct ArrowDeviceArray* src, struct ArrowDevice* device_dst, struct ArrowDeviceArray* dst); /// \brief Pointer to a statically-allocated CPU device singleton -NANOARROW_DLL_EXPORT struct ArrowDevice* ArrowDeviceCpu(void); +NANOARROW_EXPORT struct ArrowDevice* ArrowDeviceCpu(void); /// \brief Initialize a user-allocated device struct with a CPU device -NANOARROW_DLL_EXPORT void ArrowDeviceInitCpu(struct ArrowDevice* device); +NANOARROW_EXPORT void ArrowDeviceInitCpu(struct ArrowDevice* device); /// \brief Resolve a device pointer from a type + identifier /// @@ -298,23 +298,23 @@ NANOARROW_DLL_EXPORT void ArrowDeviceInitCpu(struct ArrowDevice* device); /// some device types may or may not be supported. The CPU type is always supported. /// Returns NULL for device that does not exist or cannot be returned as a singleton. /// Callers must not release the pointed-to device. -NANOARROW_DLL_EXPORT struct ArrowDevice* ArrowDeviceResolve(ArrowDeviceType device_type, - int64_t device_id); +NANOARROW_EXPORT struct ArrowDevice* ArrowDeviceResolve(ArrowDeviceType device_type, + int64_t device_id); -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceBufferInit(struct ArrowDevice* device_src, - struct ArrowBufferView src, - struct ArrowDevice* device_dst, - struct ArrowBuffer* dst); +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceBufferInit(struct ArrowDevice* device_src, + struct ArrowBufferView src, + struct ArrowDevice* device_dst, + struct ArrowBuffer* dst); -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceBufferMove(struct ArrowDevice* device_src, - struct ArrowBuffer* src, - struct ArrowDevice* device_dst, - struct ArrowBuffer* dst); +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceBufferMove(struct ArrowDevice* device_src, + struct ArrowBuffer* src, + struct ArrowDevice* device_dst, + struct ArrowBuffer* dst); -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceBufferCopy(struct ArrowDevice* device_src, - struct ArrowBufferView src, - struct ArrowDevice* device_dst, - struct ArrowBufferView dst); +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceBufferCopy(struct ArrowDevice* device_src, + struct ArrowBufferView src, + struct ArrowDevice* device_dst, + struct ArrowBufferView dst); /// \brief Initialize an ArrowDeviceArrayStream from an existing ArrowArrayStream /// @@ -322,7 +322,7 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceBufferCopy(struct ArrowDevice* de /// specified device as an ArrowDeviceArrayStream. This function moves the ownership of /// array_stream to the device_array_stream. If this function returns NANOARROW_OK, the /// caller is responsible for releasing the ArrowDeviceArrayStream. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowDeviceBasicArrayStreamInit( +NANOARROW_EXPORT ArrowErrorCode ArrowDeviceBasicArrayStreamInit( struct ArrowDeviceArrayStream* device_array_stream, struct ArrowArrayStream* array_stream, struct ArrowDevice* device); diff --git a/src/nanoarrow/nanoarrow_ipc.h b/src/nanoarrow/nanoarrow_ipc.h index f521f1e27..edbee8c00 100644 --- a/src/nanoarrow/nanoarrow_ipc.h +++ b/src/nanoarrow/nanoarrow_ipc.h @@ -115,7 +115,7 @@ enum ArrowIpcCompressionType { #define NANOARROW_IPC_FEATURE_COMPRESSED_BODY 2 /// \brief Checks the nanoarrow runtime to make sure the run/build versions match -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcCheckRuntime(struct ArrowError* error); +NANOARROW_EXPORT ArrowErrorCode ArrowIpcCheckRuntime(struct ArrowError* error); /// \brief A structure representing a reference-counted buffer that may be passed to /// ArrowIpcDecoderDecodeArrayFromShared(). @@ -127,7 +127,7 @@ struct ArrowIpcSharedBuffer { /// /// If NANOARROW_OK is returned, the ArrowIpcSharedBuffer takes ownership of /// src. -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowIpcSharedBufferInit(struct ArrowIpcSharedBuffer* shared, struct ArrowBuffer* src); /// \brief Release the caller's copy of the shared buffer @@ -135,14 +135,14 @@ ArrowIpcSharedBufferInit(struct ArrowIpcSharedBuffer* shared, struct ArrowBuffer /// When finished, the caller must relinquish its own copy of the shared data /// using this function. The original buffer will continue to exist until all /// ArrowArray objects that refer to it have also been released. -NANOARROW_DLL_EXPORT void ArrowIpcSharedBufferReset(struct ArrowIpcSharedBuffer* shared); +NANOARROW_EXPORT void ArrowIpcSharedBufferReset(struct ArrowIpcSharedBuffer* shared); /// \brief Check for shared buffer thread safety /// /// Thread-safe shared buffers require C11 and the stdatomic.h header. /// If either are unavailable, shared buffers are still possible but /// the resulting arrays must not be passed to other threads to be released. -NANOARROW_DLL_EXPORT int ArrowIpcSharedBufferIsThreadSafe(void); +NANOARROW_EXPORT int ArrowIpcSharedBufferIsThreadSafe(void); /// \brief Decoder for Arrow IPC messages /// @@ -183,10 +183,10 @@ struct ArrowIpcDecoder { }; /// \brief Initialize a decoder -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderInit(struct ArrowIpcDecoder* decoder); +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderInit(struct ArrowIpcDecoder* decoder); /// \brief Release all resources attached to a decoder -NANOARROW_DLL_EXPORT void ArrowIpcDecoderReset(struct ArrowIpcDecoder* decoder); +NANOARROW_EXPORT void ArrowIpcDecoderReset(struct ArrowIpcDecoder* decoder); /// \brief Peek at a message header /// @@ -195,9 +195,9 @@ NANOARROW_DLL_EXPORT void ArrowIpcDecoderReset(struct ArrowIpcDecoder* decoder); /// these bytes and returns ESPIPE if there are not enough remaining bytes in data to read /// the entire header message, EINVAL if the first 8 bytes are not valid, ENODATA if the /// Arrow end-of-stream indicator has been reached, or NANOARROW_OK otherwise. -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowIpcDecoderPeekHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, - struct ArrowError* error); +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderPeekHeader(struct ArrowIpcDecoder* decoder, + struct ArrowBufferView data, + struct ArrowError* error); /// \brief Verify a message header /// @@ -209,7 +209,7 @@ ArrowIpcDecoderPeekHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferVie /// /// Returns as ArrowIpcDecoderPeekHeader() and additionally will /// return EINVAL if flatbuffer verification fails. -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderVerifyHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error); @@ -228,7 +228,7 @@ ArrowIpcDecoderVerifyHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferV /// /// Returns EINVAL if the content of the message cannot be decoded or ENOTSUP if the /// content of the message uses features not supported by this library. -NANOARROW_DLL_EXPORT ArrowErrorCode +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error); @@ -239,7 +239,7 @@ ArrowIpcDecoderDecodeHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferV /// /// Returns EINVAL if the decoder did not just decode a schema message or /// NANOARROW_OK otherwise. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeSchema( +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeSchema( struct ArrowIpcDecoder* decoder, struct ArrowSchema* out, struct ArrowError* error); /// \brief Set the ArrowSchema used to decode future record batch messages @@ -251,9 +251,9 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeSchema( /// schema message applies to future record batch messages). /// /// Returns EINVAL if schema validation fails or NANOARROW_OK otherwise. -NANOARROW_DLL_EXPORT ArrowErrorCode -ArrowIpcDecoderSetSchema(struct ArrowIpcDecoder* decoder, struct ArrowSchema* schema, - struct ArrowError* error); +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderSetSchema(struct ArrowIpcDecoder* decoder, + struct ArrowSchema* schema, + struct ArrowError* error); /// \brief Set the endianness used to decode future record batch messages /// @@ -263,7 +263,7 @@ ArrowIpcDecoderSetSchema(struct ArrowIpcDecoder* decoder, struct ArrowSchema* sc /// schema message applies to future record batch messages). /// /// Returns NANOARROW_OK on success. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderSetEndianness( +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderSetEndianness( struct ArrowIpcDecoder* decoder, enum ArrowIpcEndianness endianness); /// \brief Decode an ArrowArrayView @@ -278,7 +278,7 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderSetEndianness( /// will not perform any heap allocations; however, the buffers referred to by the /// returned ArrowArrayView are only valid as long as the buffer referred to by body stays /// valid. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeArrayView( +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeArrayView( struct ArrowIpcDecoder* decoder, struct ArrowBufferView body, int64_t i, struct ArrowArrayView** out, struct ArrowError* error); @@ -293,7 +293,7 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeArrayView( /// Returns EINVAL if the decoder did not just decode a record batch message, ENOTSUP /// if the message uses features not supported by this library, or or NANOARROW_OK /// otherwise. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeArray( +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeArray( struct ArrowIpcDecoder* decoder, struct ArrowBufferView body, int64_t i, struct ArrowArray* out, enum ArrowValidationLevel validation_level, struct ArrowError* error); @@ -305,7 +305,7 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeArray( /// more calls to ArrowIpcDecoderDecodeArrayFromShared(). If /// ArrowIpcSharedBufferIsThreadSafe() returns 0, out must not be released by another /// thread. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeArrayFromShared( +NANOARROW_EXPORT ArrowErrorCode ArrowIpcDecoderDecodeArrayFromShared( struct ArrowIpcDecoder* decoder, struct ArrowIpcSharedBuffer* shared, int64_t i, struct ArrowArray* out, enum ArrowValidationLevel validation_level, struct ArrowError* error); @@ -332,11 +332,11 @@ struct ArrowIpcInputStream { }; /// \brief Transfer ownership of an ArrowIpcInputStream -NANOARROW_DLL_EXPORT void ArrowIpcInputStreamMove(struct ArrowIpcInputStream* src, - struct ArrowIpcInputStream* dst); +NANOARROW_EXPORT void ArrowIpcInputStreamMove(struct ArrowIpcInputStream* src, + struct ArrowIpcInputStream* dst); /// \brief Create an input stream from an ArrowBuffer -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcInputStreamInitBuffer( +NANOARROW_EXPORT ArrowErrorCode ArrowIpcInputStreamInitBuffer( struct ArrowIpcInputStream* stream, struct ArrowBuffer* input); /// \brief Create an input stream from a C FILE* pointer @@ -344,7 +344,7 @@ NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcInputStreamInitBuffer( /// Note that the ArrowIpcInputStream has no mechanism to communicate an error /// if file_ptr fails to close. If this behaviour is needed, pass false to /// close_on_release and handle closing the file independently from stream. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcInputStreamInitFile( +NANOARROW_EXPORT ArrowErrorCode ArrowIpcInputStreamInitFile( struct ArrowIpcInputStream* stream, void* file_ptr, int close_on_release); /// \brief Options for ArrowIpcArrayStreamReaderInit() @@ -372,7 +372,7 @@ struct ArrowIpcArrayStreamReaderOptions { /// format specification. Returns NANOARROW_OK on success. If NANOARROW_OK /// is returned, the ArrowArrayStream takes ownership of input_stream and /// the caller is responsible for releasing out. -NANOARROW_DLL_EXPORT ArrowErrorCode ArrowIpcArrayStreamReaderInit( +NANOARROW_EXPORT ArrowErrorCode ArrowIpcArrayStreamReaderInit( struct ArrowArrayStream* out, struct ArrowIpcInputStream* input_stream, struct ArrowIpcArrayStreamReaderOptions* options); diff --git a/src/nanoarrow/nanoarrow_types.h b/src/nanoarrow/nanoarrow_types.h index d5f43665a..fc1dc1ded 100644 --- a/src/nanoarrow/nanoarrow_types.h +++ b/src/nanoarrow/nanoarrow_types.h @@ -33,14 +33,20 @@ extern "C" { #endif #if defined _WIN32 || defined __CYGWIN__ -#define NANOARROW_DLL_EXPORT __declspec(dllexport) +#if defined(NANOARROW_BUILD_DLL) +#define NANOARROW_EXPORT __declspec(dllexport) +#elif defined(NANOARROW_CONSUME_DLL) +#define NANOARROW_EXPORT __declspec(dllimport) +#else +#define NANOARROW_EXPORT +#endif // defined(NANOARROW_BUILD_DLL) #else #if __GNUC__ >= 4 -#define NANOARROW_DLL_EXPORT __attribute__((visibility("default"))) +#define NANOARROW_EXPORT __attribute__((visibility("default"))) #else -#define NANOARROW_DLL_EXPORT -#endif -#endif +#define NANOARROW_EXPORT +#endif // __GNUC__ >= 4 +#endif // defined _WIN32 || defined __CYGWIN__ // Extra guard for versions of Arrow without the canonical guard #ifndef ARROW_FLAG_DICTIONARY_ORDERED