BewareMyPower commented on code in PR #22:
URL: https://github.com/apache/pulsar-client-cpp/pull/22#discussion_r1004246595
##########
lib/Schema.cc:
##########
@@ -90,6 +132,45 @@ SchemaInfo::SchemaInfo(SchemaType schemaType, const
std::string &name, const std
const StringMap &properties)
: impl_(std::make_shared<SchemaInfoImpl>(schemaType, name, schema,
properties)) {}
+SchemaInfo::SchemaInfo(const SchemaInfo &keySchema, const SchemaInfo
&valueSchema,
+ const KeyValueEncodingType &keyValueEncodingType) {
+ std::string keySchemaStr = keySchema.getSchema();
+ std::string valueSchemaStr = valueSchema.getSchema();
+ uint32_t keySize = keySchemaStr.size();
+ uint32_t valueSize = valueSchemaStr.size();
+
+ auto buffSize = sizeof keySize + keySize + sizeof valueSize + valueSize;
+ SharedBuffer buffer = SharedBuffer::allocate(buffSize);
+ buffer.writeUnsignedInt(keySize == 0 ? -1 :
static_cast<uint32_t>(keySize));
+ buffer.write(keySchemaStr.c_str(), static_cast<uint32_t>(keySize));
+ buffer.writeUnsignedInt(valueSize == 0 ? -1 :
static_cast<uint32_t>(valueSize));
+ buffer.write(valueSchemaStr.c_str(), static_cast<uint32_t>(valueSize));
Review Comment:
It's better to replace magic number -1 with `INVALID_SIZE`.
--
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]