trxcllnt commented on code in PR #361:
URL: https://github.com/apache/arrow-js/pull/361#discussion_r2828808035
##########
src/ipc/metadata/message.ts:
##########
@@ -98,22 +99,35 @@ export class Message<T extends MessageHeader = any> {
} else if (message.isDictionaryBatch()) {
headerOffset = DictionaryBatch.encode(b, message.header() as
DictionaryBatch);
}
+
+ // Encode custom metadata if present (must be done before startMessage)
+ const customMetadataOffset = !(message.metadata &&
message.metadata.size > 0) ? -1 :
+ _Message.createCustomMetadataVector(b,
[...message.metadata].map(([k, v]) => {
+ const key = b.createString(`${k}`);
+ const val = b.createString(`${v}`);
+ _KeyValue.startKeyValue(b);
+ _KeyValue.addKey(b, key);
+ _KeyValue.addValue(b, val);
+ return _KeyValue.endKeyValue(b);
+ }));
+
_Message.startMessage(b);
_Message.addVersion(b, MetadataVersion.V5);
_Message.addHeader(b, headerOffset);
_Message.addHeaderType(b, message.headerType);
_Message.addBodyLength(b, BigInt(message.bodyLength));
+ if (customMetadataOffset !== -1) { _Message.addCustomMetadata(b,
customMetadataOffset); }
_Message.finishMessageBuffer(b, _Message.endMessage(b));
return b.asUint8Array();
}
/** @nocollapse */
- public static from(header: Schema | RecordBatch | DictionaryBatch,
bodyLength = 0) {
+ public static from(header: Schema | RecordBatch | DictionaryBatch,
bodyLength = 0, metadata?: Map<string, string>) {
Review Comment:
Thanks!
--
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]