paleolimbot commented on code in PR #12:
URL: https://github.com/apache/arrow-nanoarrow/pull/12#discussion_r940456577
##########
src/nanoarrow/metadata.c:
##########
@@ -114,8 +114,156 @@ ArrowErrorCode ArrowMetadataGetValue(const char*
metadata, const char* key,
return NANOARROW_OK;
}
+ArrowErrorCode ArrowMetadataGetValue(const char* metadata, const char* key,
+ const char* default_value,
+ struct ArrowStringView* value_out) {
+ struct ArrowStringView key_view = {key, strlen(key)};
+ return ArrowMetadataGetValueView(metadata, &key_view, default_value,
value_out);
+}
+
char ArrowMetadataHasKey(const char* metadata, const char* key) {
struct ArrowStringView value;
ArrowMetadataGetValue(metadata, key, NULL, &value);
return value.data != NULL;
}
+
+ArrowErrorCode ArrowMetadataBuilderInit(struct ArrowBuffer* buffer,
+ const char* metadata) {
+ ArrowBufferInit(buffer);
+ int result = ArrowBufferAppend(buffer, metadata,
ArrowMetadataSizeOf(metadata));
+ if (result != NANOARROW_OK) {
+ return result;
+ }
+
+ return NANOARROW_OK;
+}
+
+ArrowErrorCode ArrowMetadataBuilderAppendView(struct ArrowBuffer* buffer,
+ struct ArrowStringView* key,
+ struct ArrowStringView* value) {
+ if (value == NULL) {
+ return NANOARROW_OK;
+ }
Review Comment:
I moved these to be internal implementation details...the `NULL` mostly just
helps with minimizing the number of times one has to copy a metadata string
(correspondingly, I added `ArrowMetadatBuilderRemove()` to make it more
explicit).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]