void FullContainerKey::serialize(util::StackAllocator &alloc, const FullContainerKeyComponents &components, const BitArray &upperCaseBit) { try { util::XArray<char8_t> buf(alloc); buf.resize(static_cast<size_t>(components.getStringSize()), '\0'); util::XArray<uint8_t> binary(alloc); util::XArrayOutStream<> arrayOut(binary); ContainerKeyOutStream out(arrayOut); const size_t flagPos = out.base().position(); uint8_t flag = 0; out << flag; if (components.dbId_ != GS_PUBLIC_DB_ID) { flag |= DBID_EXISTS; out << components.dbId_; } { ValueProcessor::convertLowerCase( components.baseName_, components.baseNameSize_, buf.data()); encodeString(out, buf.data(), components.baseNameSize_); } if (components.largeContainerId_ != UNDEF_LARGE_CONTAINERID) { flag |= LARGE_CONTAINERID_EXISTS; encodeVarLong(out, components.largeContainerId_); } if (components.affinityNumber_ != UNDEF_NODE_AFFINITY_NUMBER) { flag |= NODE_AFFINITY_NUM; encodeVarLong(out, components.affinityNumber_); } else if (components.affinityStringSize_ > 0) { flag |= NODE_AFFINITY_STR; ValueProcessor::convertLowerCase( components.affinityString_, components.affinityStringSize_, buf.data()); encodeString(out, buf.data(), components.affinityStringSize_); } if (components.systemPartId_ != UNDEF_SYSTEM_PART_ID) { flag |= SYSTEM_PART_ID_NUM; encodeVarLong(out, components.systemPartId_); } else if (components.systemPartSize_ > 0) { flag |= SYSTEM_PART_ID_STR; ValueProcessor::convertLowerCase( components.systemPart_, components.systemPartSize_, buf.data()); encodeString(out, buf.data(), components.systemPartSize_); } out.writeAll(upperCaseBit.data(), upperCaseBit.byteLength()); const size_t lastPos = out.base().position(); out.base().position(flagPos); out << flag; out.base().position(lastPos); if (binary.size() >= static_cast<size_t>(UINT32_MAX)) { GS_THROW_USER_ERROR(GS_ERROR_CM_LIMITS_EXCEEDED, "size of serialized container/table name exceeds maximum size"); } body_ = binary.data(); size_ = binary.size(); } catch (std::exception &e) { GS_RETHROW_USER_ERROR_CODED(GS_ERROR_DS_DS_CONTAINER_NAME_INVALID, e, "failed to serialize container/table name"); } }