paleolimbot commented on code in PR #12:
URL: https://github.com/apache/arrow-nanoarrow/pull/12#discussion_r940454918
##########
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,
Review Comment:
I pushed a compromise of sorts...all values are now `ArrowStringView` but
all keys stay `const char*`, which is somewhere inbetween the programmability
and non-null terminated-ness of the `ArrowStringView` and the reality that keys
are almost always `"a literal string"`. I tried having both be
`ArrowStringView` but that was rather painful to actually use.
--
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]