From 0040c4a27d5b488922c2947bd670deb835169cef Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Mon, 9 Oct 2023 12:18:25 +0530 Subject: [PATCH 01/43] partially complete changes to templatize data structures --- .gitignore | 2 + .../gRPC Server and Client Template [2].vipb | 5 +- .../build spec/LabVIEW gRPC Servicer.vipb | 33 +++-- .../build spec/LabVIEW gRPC Library.vipb | 15 +-- src/cluster_copier.cc | 16 +-- src/grpc_client.cc | 29 +++-- src/lv_message.cc | 122 +++++++++++------- src/lv_message.h | 112 ++++++++++++++++ src/lv_message_value.cc | 27 ++-- src/message_value.h | 99 ++++---------- 10 files changed, 278 insertions(+), 182 deletions(-) diff --git a/.gitignore b/.gitignore index 5014afe2..ef4d9ec7 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ labview source/Servers/Generated Server/ *.so tests/gRPC_ATS/TimeStamp.txt + +*.srctrl* \ No newline at end of file diff --git a/labview source/Client Server Support New/build spec/gRPC Server and Client Template [2].vipb b/labview source/Client Server Support New/build spec/gRPC Server and Client Template [2].vipb index ed9355e0..9fdb4486 100644 --- a/labview source/Client Server Support New/build spec/gRPC Server and Client Template [2].vipb +++ b/labview source/Client Server Support New/build spec/gRPC Server and Client Template [2].vipb @@ -1,7 +1,7 @@ - + NI_lib_gRPC_Server_and_Client_Template[2] - 1.0.1.1 + 1.0.1.2 false .. ..\..\Builds @@ -199,7 +199,6 @@ This library also provides a scripting tool to auto generate the server and clie false false false - false false diff --git a/labview source/gRPC lv Servicer/build spec/LabVIEW gRPC Servicer.vipb b/labview source/gRPC lv Servicer/build spec/LabVIEW gRPC Servicer.vipb index 879f16f7..3dfdc72c 100644 --- a/labview source/gRPC lv Servicer/build spec/LabVIEW gRPC Servicer.vipb +++ b/labview source/gRPC lv Servicer/build spec/LabVIEW gRPC Servicer.vipb @@ -1,7 +1,7 @@ - + NI_lib_LabVIEW_gRPC_Servicer - 1.0.1.1 + 1.0.1.2 false .. ..\..\Builds @@ -183,7 +183,6 @@ false false false - false false @@ -241,7 +240,7 @@ ..\Servicer - E258AB59039E221C07E347EBB9699215 + 387AF6CDBB628F980AEF9CCBFA20FB16 0 @@ -290,7 +289,7 @@ ..\iService\Server API - 5073D000D4753811F0B1A31515DA66CB + B26E57398A70958E4A6DB3B1B0DF72E9 0 @@ -353,7 +352,7 @@ ..\Servicer\Run Servicer.vi - D03E1B6640AE9BF3DA7FD676117F3539 + DB2A2374C54E450B358D090BB1D4C1F7 1 @@ -402,7 +401,7 @@ ..\ServiceBase\Accessors\Read Server Stop.vi - C7DB15FE8DB82DD0DBB1B511580F5FAA + 859612ABBFB9D2DFC7875937DF2DC8FF 1 @@ -507,7 +506,7 @@ ..\ServiceBase\Server API\Start.vi - 14D0FCC9DB65233816C156219D1DC543 + E6E45F212258EC90A8E628EA701F515E 2 @@ -598,7 +597,7 @@ ..\Servicer\Accessors\Server State - ABAC22B0E9CE862598F099BCB828F826 + 04329BA34EFDC3F564CA0FFF83C81738 2 @@ -675,7 +674,7 @@ ..\Servicer\Server API\Stop Server.vi - DB0010F6446A55F61E8C0DF1E35CACE5 + E6FB2F38D93B68121728AD7C6914BFA9 5 @@ -724,7 +723,7 @@ ..\Servicer\Accessors\gRPC ID\Set gRPC ID.vi - 0E840B7FEB4E044C5EB5C998343FEED9 + F7B71959EB148E0E48B2F04EB92A0876 5 @@ -773,7 +772,7 @@ ..\Servicer\Accessors\Server Address\Set Server Address.vi - E139FAE7D8D69691C0573E8852B5ADB8 + B42BE6C5A9945B91700126B421A6C774 5 @@ -822,7 +821,7 @@ ..\Servicer\Accessors\Server Certificate File\Set Server Certificate File.vi - 643EAD5C2CF01A88D1CDCE4DBB04CA44 + C412EE5B14ED1A1BEA8903F62543BA1E 5 @@ -871,7 +870,7 @@ ..\Servicer\Accessors\Server Key File\Set Server Key File.vi - BFE1B359E13F51B39B57B079613F7F13 + 5EC1B985C5FA600E5D2A72F6FF0EBB58 5 @@ -948,7 +947,7 @@ ..\Servicer\Accessors\Server State\Set Server State.vi - 36F14BECBD42F8A01726C0EDC9071A92 + 0045CB18C5B362EE3A96D706F135EACC 11 @@ -997,7 +996,7 @@ ..\Servicer\Accessors\Server State\State Ref\Set Server State Ref.vi - 10B658C1218C3F73336CAC3E5878A73D + B316EFE0097AB679B940276354195B3A 11 @@ -1046,7 +1045,7 @@ ..\Servicer\Accessors\Server State\State UE\Set Server State UE.vi - 9C1D936C2E34998849D24C6675D644C8 + 9E1A00A694A96FFB16216E53AAD37BB8 \ No newline at end of file diff --git a/labview source/gRPC lv Support/build spec/LabVIEW gRPC Library.vipb b/labview source/gRPC lv Support/build spec/LabVIEW gRPC Library.vipb index 38a3f7e2..08cb09cb 100644 --- a/labview source/gRPC lv Support/build spec/LabVIEW gRPC Library.vipb +++ b/labview source/gRPC lv Support/build spec/LabVIEW gRPC Library.vipb @@ -1,7 +1,7 @@ - + NI_lib_LabVIEW_gRPC_Library - 1.0.1.1 + 1.0.1.2 false .. ..\..\Builds @@ -194,7 +194,6 @@ https://github.com/ni/grpc-labview false false false - false false @@ -252,7 +251,7 @@ https://github.com/ni/grpc-labview ..\Server API - 7D3594FB023515B3C4B797CE1271EC95 + DD3F698A9A534D6DAF1A7D6E5427E138 0 @@ -371,7 +370,7 @@ https://github.com/ni/grpc-labview ..\Client API\Client Cancel Call.vi - A1E958DD29F8790A61C7D31C4AF8F130 + 7B4EABFEF4BDC1EB7D4F23E37214A8AB 0 @@ -490,7 +489,7 @@ https://github.com/ni/grpc-labview ..\Server API\UnpackFromBuffer.vim - B7DB67D7F0B456B3FF6B479ED284382D + 404A4A1A9D9B9F34659817788601537B 2 @@ -721,7 +720,7 @@ https://github.com/ni/grpc-labview ..\Server API\Message Requests\Write Call Response.vim - B117FE54528E29A25B075EC86AF8053B + 3F72B180A332296A67A9CE202B5205FF 2 @@ -840,7 +839,7 @@ https://github.com/ni/grpc-labview ..\Server API\Server\Stop Server.vi - 3D9875481763CF81CA00A742D3D62483 + 233818A94A97E283602044DD86FD166F \ No newline at end of file diff --git a/src/cluster_copier.cc b/src/cluster_copier.cc index f8ca5523..c923325b 100644 --- a/src/cluster_copier.cc +++ b/src/cluster_copier.cc @@ -284,7 +284,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedString = static_cast(*value); + auto repeatedString = static_cast&>(*value); if (repeatedString._value.size() != 0) { NumericArrayResize(0x08, 1, start, repeatedString._value.size()); @@ -356,7 +356,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedInt32 = std::static_pointer_cast(value); + auto repeatedInt32 = std::static_pointer_cast>(value); if (repeatedInt32->_value.size() != 0) { NumericArrayResize(0x03, 1, start, repeatedInt32->_value.size()); @@ -378,7 +378,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedUInt32 = std::static_pointer_cast(value); + auto repeatedUInt32 = std::static_pointer_cast>(value); if (repeatedUInt32->_value.size() != 0) { NumericArrayResize(0x03, 1, start, repeatedUInt32->_value.size()); @@ -479,7 +479,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedBoolean = std::static_pointer_cast(value); + auto repeatedBoolean = std::static_pointer_cast>(value); if (repeatedBoolean->_value.size() != 0) { NumericArrayResize(0x01, 1, start, repeatedBoolean->_value.size()); @@ -681,7 +681,7 @@ namespace grpc_labview { auto array = *(LV1DArrayHandle*)start; if (array && *array && ((*array)->cnt != 0)) { - auto repeatedStringValue = std::make_shared(metadata->protobufIndex); + auto repeatedStringValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedStringValue); auto lvStr = (*array)->bytes(); for (int x = 0; x < (*array)->cnt; ++x) @@ -717,7 +717,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); @@ -742,7 +742,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); @@ -767,7 +767,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 2eeb48b2..6aae3178 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -274,7 +274,8 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( int8_t* requestCluster, grpc_labview::gRPCid** callId, int32_t timeoutMs, - grpc_labview::gRPCid* contextId) + grpc_labview::gRPCid* contextId, + int8_t* responseCluster) { auto client = clientId->CastTo(); if (!client) @@ -310,6 +311,8 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( clientCall->_request = std::make_shared(requestMetadata); clientCall->_response = std::make_shared(responseMetadata); clientCall->_context = clientContext; + clientCall->_request->setLVClusterHandle(requestCluster); + clientCall->_response->setLVClusterHandle(responseCluster); try { @@ -354,18 +357,18 @@ LIBRARY_EXPORT int32_t CompleteClientUnaryCall2( int32_t result = 0; if (call->_status.ok()) { - try - { - grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); - } - catch (grpc_labview::InvalidEnumValueException& e) - { - if (errorMessage != nullptr) - { - grpc_labview::SetLVString(errorMessage, e.what()); - } - return e.code; - } + // try + // { + // grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + // } + // catch (grpc_labview::InvalidEnumValueException& e) + // { + // if (errorMessage != nullptr) + // { + // grpc_labview::SetLVString(errorMessage, e.what()); + // } + // return e.code; + // } } else { diff --git a/src/lv_message.cc b/src/lv_message.cc index 6395da1b..a68e5aee 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -12,7 +12,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- LVMessage::LVMessage(std::shared_ptr metadata) : - _metadata(metadata) + _metadata(metadata), _use_hardcoded_parse(true) { } @@ -183,7 +183,7 @@ namespace grpc_labview { if (fieldInfo.isRepeated) { - auto v = std::make_shared(index); + auto v = std::make_shared>(index); ptr = PackedBoolParser(&(v->_value), ptr, ctx); _values.emplace(index, v); } @@ -201,18 +201,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) + if (_use_hardcoded_parse) { - auto v = std::make_shared(index); - ptr = PackedInt32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + // SinglePassMessageParser parser(*this); + // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int32_t result; - ptr = ReadINT32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedInt32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int32_t result; + ptr = ReadINT32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -221,18 +228,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseUInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) + if (_use_hardcoded_parse) { - auto v = std::make_shared(index); - ptr = PackedUInt32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + // SinglePassMessageParser parser(*this); + // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - uint32_t result; - ptr = ReadUINT32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedUInt32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + uint32_t result; + ptr = ReadUINT32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -261,18 +275,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) + if (_use_hardcoded_parse) { - auto v = std::make_shared(index); - ptr = PackedInt64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + // SinglePassMessageParser parser(*this); + // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int64_t result; - ptr = ReadINT64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedInt64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int64_t result; + ptr = ReadINT64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -280,19 +301,26 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- const char *LVMessage::ParseUInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if (fieldInfo.isRepeated) + { + if (_use_hardcoded_parse) { - auto v = std::make_shared(index); - ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - uint64_t result; - ptr = ReadUINT64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + // SinglePassMessageParser parser(*this); + // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + } + else { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + uint64_t result; + ptr = ReadUINT64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -343,16 +371,16 @@ namespace grpc_labview { if (fieldInfo.isRepeated) { - std::shared_ptr v; + std::shared_ptr> v; auto it = _values.find(index); if (it == _values.end()) { - v = std::make_shared(index); + v = std::make_shared>(index); _values.emplace(index, v); } else { - v = std::static_pointer_cast((*it).second); + v = std::static_pointer_cast>((*it).second); } ptr -= 1; do { diff --git a/src/lv_message.h b/src/lv_message.h index 9961ec27..9b75b63c 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -8,6 +8,8 @@ #include #include +using namespace google::protobuf::internal; + namespace grpc_labview { //--------------------------------------------------------------------- @@ -48,10 +50,20 @@ namespace grpc_labview public: std::map> _values; std::shared_ptr _metadata; + bool _use_hardcoded_parse; + + void setLVClusterHandle(int8_t* lvClusterHandle) { + _LVClusterHandle = std::make_shared(lvClusterHandle); + }; + + std::shared_ptr getLVClusterHandleSharedPtr() { + return _LVClusterHandle; + }; private: mutable google::protobuf::internal::CachedSize _cached_size_; google::protobuf::UnknownFieldSet _unknownFields; + std::shared_ptr _LVClusterHandle; const char *ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); const char *ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); @@ -71,5 +83,105 @@ namespace grpc_labview const char *ParseBytes(unsigned int tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); const char *ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); bool ExpectTag(google::protobuf::uint32 tag, const char* ptr); + + /*public: + template + class SinglePassMessageParser { + private: + LVMessage& _message; + public: + // Constructor and other necessary member functions + SinglePassMessageParser(LVMessage& message) : _message(message) {} + + // Parse and copy message in a single pass. + void ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { + if (fieldInfo.isRepeated) + { + // Read the repeated elements into a temporary vector + uint64_t numElements; + auto v = PackedMessageType(ptr, ctx, &numElements); + // get the LVClusterHandle + auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + + // copy into LVCluster + if (numElements != 0) + { + NumericArrayResize(0x08, 1, start, numElements); + auto array = *(LV1DArrayHandle*)start; + (*array)->cnt = numElements; + auto byteCount = numElements * sizeof(MessageType); + std::memcpy((*array)->bytes(), v->_value.data(), byteCount); + } + } + else + { + auto _lv_ptr = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + ptr = ReadMessageType(ptr, reinterpret_cast(_lv_ptr)); + } + } + + const char* ReadMessageType(const char* ptr, MessageType* lv_ptr) + { + return nullptr; + } + + LVRepeatedMessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) + { + return nullptr; + } + + // const char* ReadMessageType(const char* ptr, int32_t* lv_ptr) + // { + // return ReadINT32(ptr, _lv_ptr); + // } + + // LVRepeatedMessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) + // { + // auto v = std::make_shared>(index); + // ptr = PackedInt32Parser(&(v->_value), ptr, ctx); + // *numElements = v->_value.size(); + // return v; + // } + + // const char* ReadMessageType(const char* ptr, int32_t* lv_ptr) + // { + // return ReadINT32(ptr, _lv_ptr); + // } + + // LVRepeatedInt64MessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) + // { + // auto v = std::make_shared>(index); + // ptr = PackedInt32Parser(&(v->_value), ptr, ctx); + // *numElements = v->_value.size(); + // return v; + // } + + // const char* ReadMessageType(const char* ptr, int32_t* lv_ptr) + // { + // return ReadUINT32(ptr, _lv_ptr); + // } + + // LVRepeatedMessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) + // { + // auto v = std::make_shared>(index); + // ptr = PackedUInt32Parser(&(v->_value), ptr, ctx); + // *numElements = v->_value.size(); + // return v; + // } + + // const char* ReadMessageType(const char* ptr, int32_t* lv_ptr) + // { + // return ReadUINT64(ptr, _lv_ptr); + // } + + // LVRepeatedUInt64MessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) + // { + // auto v = std::make_shared(index); + // ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); + // *numElements = v->_value.size(); + // return v; + // } + };*/ + }; } diff --git a/src/lv_message_value.cc b/src/lv_message_value.cc index d59b49ad..46ed47a2 100644 --- a/src/lv_message_value.cc +++ b/src/lv_message_value.cc @@ -2,6 +2,7 @@ //--------------------------------------------------------------------- #include #include +#include //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -96,14 +97,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedStringMessageValue::LVRepeatedStringMessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedStringMessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; totalSize += 1 * FromIntSize(_value.size()); @@ -116,7 +117,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedStringMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { for (int i = 0, n = _value.size(); i < n; i++) { @@ -151,14 +152,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedBooleanMessageValue::LVRepeatedBooleanMessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedBooleanMessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; unsigned int count = static_cast(_value.size()); @@ -174,7 +175,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedBooleanMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_value.size() > 0) { @@ -300,14 +301,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedInt32MessageValue::LVRepeatedInt32MessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedInt32MessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; size_t dataSize = WireFormatLite::Int32Size(_value); @@ -323,7 +324,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedInt32MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) { @@ -334,14 +335,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedUInt32MessageValue::LVRepeatedUInt32MessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedUInt32MessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; size_t dataSize = WireFormatLite::UInt32Size(_value); @@ -357,7 +358,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedUInt32MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) { @@ -369,7 +370,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- LVRepeatedEnumMessageValue::LVRepeatedEnumMessageValue(int protobufId) : - LVMessageValue(protobufId) + LVRepeatedMessageValue(protobufId) { } diff --git a/src/message_value.h b/src/message_value.h index 184c2c31..cd61969d 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -74,20 +74,23 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - class LVRepeatedStringMessageValue : public LVMessageValue + template + class LVRepeatedMessageValue : public LVMessageValue { public: - LVRepeatedStringMessageValue(int protobufId); + LVRepeatedMessageValue(int protobufId); + + google::protobuf::RepeatedField _value; - public: - google::protobuf::RepeatedField _value; - - public: void* RawValue() override { return &_value; }; size_t ByteSizeLong() override; google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; + + protected: + int _cachedSize; }; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVBooleanMessageValue : public LVMessageValue @@ -103,20 +106,6 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedBooleanMessageValue : public LVMessageValue - { - public: - LVRepeatedBooleanMessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -148,12 +137,13 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVEnumMessageValue : public LVMessageValue { public: - LVEnumMessageValue(int protobufId, int value); + LVEnumMessageValue(int protobufId, int _value); public: int _value; @@ -163,91 +153,54 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVInt64MessageValue : public LVMessageValue - { - public: - LVInt64MessageValue(int protobufId, int64_t value); - - public: - int64_t _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- - class LVUInt64MessageValue : public LVMessageValue + class LVRepeatedEnumMessageValue : public LVRepeatedMessageValue { - public: - LVUInt64MessageValue(int protobufId, uint64_t value); + public: + LVRepeatedEnumMessageValue(int protobufId); - public: - uint64_t _value; + google::protobuf::RepeatedField _value; - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; + void* RawValue() override { return &_value; }; + size_t ByteSizeLong() override; + google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedInt32MessageValue : public LVMessageValue - { - public: - LVRepeatedInt32MessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- - class LVRepeatedUInt32MessageValue : public LVMessageValue + class LVInt64MessageValue : public LVMessageValue { public: - LVRepeatedUInt32MessageValue(int protobufId); + LVInt64MessageValue(int protobufId, int64_t value); public: - google::protobuf::RepeatedField _value; + int64_t _value; void* RawValue() override { return &_value; }; size_t ByteSizeLong() override; google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- - class LVRepeatedEnumMessageValue : public LVMessageValue + class LVUInt64MessageValue : public LVMessageValue { public: - LVRepeatedEnumMessageValue(int protobufId); + LVUInt64MessageValue(int protobufId, uint64_t value); public: - google::protobuf::RepeatedField _value; + uint64_t _value; + public: void* RawValue() override { return &_value; }; size_t ByteSizeLong() override; google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; }; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVRepeatedInt64MessageValue : public LVMessageValue From 8ab9c50c1aadaf5a39351fe4224e5ef07355d560 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Tue, 10 Oct 2023 11:34:58 +0530 Subject: [PATCH 02/43] not using the messagevalueclasses --- src/lv_message.cc | 113 +++++++++++++++++++++++++++++++++++----------- src/lv_message.h | 1 + 2 files changed, 87 insertions(+), 27 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index a68e5aee..106bf042 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -12,7 +12,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- LVMessage::LVMessage(std::shared_ptr metadata) : - _metadata(metadata), _use_hardcoded_parse(true) + _metadata(metadata), _use_hardcoded_parse(true), _skipCopyOnFirstParse(false) { } @@ -546,42 +546,101 @@ namespace grpc_labview return ptr; } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + struct LVCluster + { + }; // TODO: Do not check this in. + + //--------------------------------------------------------------------- //--------------------------------------------------------------------- const char *LVMessage::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { auto metadata = fieldInfo._owner->FindMetadata(fieldInfo.embeddedMessageName); - if (fieldInfo.isRepeated) + if (_use_hardcoded_parse) { - ptr -= 1; - do { - std::shared_ptr v; - auto it = _values.find(index); - if (it == _values.end()) - { - v = std::make_shared(index); - _values.emplace(index, v); - } - else + if (fieldInfo.isRepeated){ + // backup ptr + auto _backup_ptr = ptr; + auto _backup_ctx = ctx; + + // Call parse on the nested message + // get the count + uint64_t numElements = 0; + + ptr -= 1; + do{ + ptr += 1; + auto nestedMessage = std::make_shared(metadata, true, true); + ptr = ctx->ParseMessage(nestedMessage.get(), ptr); + if (!ctx->DataAvailable(ptr)) + { + break; + } + numElements++; + } while (ExpectTag(tag, ptr)); + + // restore ptr + ptr = _backup_ptr; + ctx = _backup_ctx; + auto start = reinterpret_cast(*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + auto array = *(LV1DArrayHandle*)start; + (*array)->cnt = numElements; + + int i = 0; + while (i < numElements) { - v = std::static_pointer_cast((*it).second); + ptr = i ? ptr + 1 : ptr; + auto nestedMessage = std::make_shared(metadata); // check if we can avoid this! + + auto next_ptr = (LVCluster**)(*array)->bytes(i * clusterSize, alignment); + nestedMessage->SetCurLVPtr(reinterpret_cast(next_ptr)); + ptr = ctx->ParseMessage(nestedMessage.get(), ptr); + i++; + + if (!ctx->DataAvailable(ptr)){ + break; + } } - ptr += 1; + } + else { + } + } + else { + if (fieldInfo.isRepeated) + { + ptr -= 1; + do { + std::shared_ptr v; + auto it = _values.find(index); + if (it == _values.end()) + { + v = std::make_shared(index); + _values.emplace(index, v); + } + else + { + v = std::static_pointer_cast((*it).second); + } + ptr += 1; + auto nestedMessage = std::make_shared(metadata); + ptr = ctx->ParseMessage(nestedMessage.get(), ptr); + v->_value.push_back(nestedMessage); + if (!ctx->DataAvailable(ptr)) + { + break; + } + } while (ExpectTag(tag, ptr)); + } + else + { auto nestedMessage = std::make_shared(metadata); ptr = ctx->ParseMessage(nestedMessage.get(), ptr); - v->_value.push_back(nestedMessage); - if (!ctx->DataAvailable(ptr)) - { - break; - } - } while (ExpectTag(tag, ptr)); - } - else - { - auto nestedMessage = std::make_shared(metadata); - ptr = ctx->ParseMessage(nestedMessage.get(), ptr); - auto v = std::make_shared(index, nestedMessage); - _values.emplace(index, v); + auto v = std::make_shared(index, nestedMessage); + _values.emplace(index, v); + } } return ptr; } diff --git a/src/lv_message.h b/src/lv_message.h index 9b75b63c..c6558f48 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -51,6 +51,7 @@ namespace grpc_labview std::map> _values; std::shared_ptr _metadata; bool _use_hardcoded_parse; + bool _skipCopyOnFirstParse; void setLVClusterHandle(int8_t* lvClusterHandle) { _LVClusterHandle = std::make_shared(lvClusterHandle); From 55c77712ae6f595482eb8fc2652433feccf385ae Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Fri, 13 Oct 2023 14:12:20 +0530 Subject: [PATCH 03/43] resizing LVArray dynamically --- src/grpc_client.cc | 4 +-- src/lv_message.cc | 72 ++++++++++++++++++++++++--------------------- src/lv_message.h | 15 ++++++---- src/message_value.h | 22 ++++++++++++++ 4 files changed, 71 insertions(+), 42 deletions(-) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 6aae3178..787dac5f 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -311,8 +311,8 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( clientCall->_request = std::make_shared(requestMetadata); clientCall->_response = std::make_shared(responseMetadata); clientCall->_context = clientContext; - clientCall->_request->setLVClusterHandle(requestCluster); - clientCall->_response->setLVClusterHandle(responseCluster); + clientCall->_request->setLVClusterHandle(reinterpret_cast(requestCluster)); + clientCall->_response->setLVClusterHandle(reinterpret_cast(responseCluster)); try { diff --git a/src/lv_message.cc b/src/lv_message.cc index 106bf042..466c2d04 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -16,6 +16,11 @@ namespace grpc_labview { } + LVMessage::LVMessage(std::shared_ptr metadata, bool use_hardcoded_parse, bool skipCopyOnFirstParse) : + _metadata(metadata), _use_hardcoded_parse(use_hardcoded_parse), _skipCopyOnFirstParse(skipCopyOnFirstParse) + { + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- LVMessage::~LVMessage() @@ -306,6 +311,8 @@ namespace grpc_labview { // SinglePassMessageParser parser(*this); // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + auto _lv_ptr = reinterpret_cast(*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + ptr = ReadUINT64(ptr, const_cast(reinterpret_cast(_lv_ptr))); } else { if (fieldInfo.isRepeated) @@ -562,48 +569,45 @@ namespace grpc_labview if (_use_hardcoded_parse) { if (fieldInfo.isRepeated){ - // backup ptr - auto _backup_ptr = ptr; - auto _backup_ctx = ctx; - - // Call parse on the nested message - // get the count - uint64_t numElements = 0; + // start with numElements = 16 + // if the array is not big enough, resize it to 2x the size + auto num_elements = 16; + auto element_count = 0; + + auto clusterSize = metadata->clusterSize; + auto alignment = metadata->alignmentRequirement; + + const char* val_ptr = (*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + NumericArrayResize(0x08, 1, (void**)val_ptr, num_elements * 4 * sizeof(uint64_t)); + auto array = *(LV1DArrayHandle*)val_ptr; + (*array)->cnt = num_elements; + + do + { + ptr = element_count ? ptr + 1 : ptr; + auto nestedMessage = std::make_shared(metadata); - ptr -= 1; - do{ - ptr += 1; - auto nestedMessage = std::make_shared(metadata, true, true); - ptr = ctx->ParseMessage(nestedMessage.get(), ptr); - if (!ctx->DataAvailable(ptr)) - { - break; + if (element_count == num_elements) { + num_elements *= 2; + NumericArrayResize(0x08, 1, (void**)val_ptr, num_elements * 4 * sizeof(uint64_t)); + array = *(LV1DArrayHandle*)val_ptr; + (*array)->cnt = num_elements; } - numElements++; - } while (ExpectTag(tag, ptr)); - // restore ptr - ptr = _backup_ptr; - ctx = _backup_ctx; - auto start = reinterpret_cast(*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; - auto array = *(LV1DArrayHandle*)start; - (*array)->cnt = numElements; - - int i = 0; - while (i < numElements) - { - ptr = i ? ptr + 1 : ptr; - auto nestedMessage = std::make_shared(metadata); // check if we can avoid this! - - auto next_ptr = (LVCluster**)(*array)->bytes(i * clusterSize, alignment); - nestedMessage->SetCurLVPtr(reinterpret_cast(next_ptr)); + auto next_ptr = (LVCluster**)(*array)->bytes(element_count * clusterSize, alignment); + nestedMessage->setLVClusterHandle(reinterpret_cast(next_ptr)); ptr = ctx->ParseMessage(nestedMessage.get(), ptr); - i++; + + element_count++; if (!ctx->DataAvailable(ptr)){ break; } - } + } while (ExpectTag(tag, ptr)); + + NumericArrayResize(0x08, 1, (void**)val_ptr, (element_count - 1) * 4 * sizeof(uint64_t)); + array = *(LV1DArrayHandle*)val_ptr; + (*array)->cnt = element_count; } else { } diff --git a/src/lv_message.h b/src/lv_message.h index c6558f48..7d1d4703 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -18,6 +18,7 @@ namespace grpc_labview { public: LVMessage(std::shared_ptr metadata); + LVMessage(std::shared_ptr metadata, bool use_hardcoded_parse, bool skipCopyOnFirstParse); ~LVMessage(); google::protobuf::UnknownFieldSet& UnknownFields(); @@ -50,21 +51,23 @@ namespace grpc_labview public: std::map> _values; std::shared_ptr _metadata; + // std::vector _messageValues; + // std::vector<> _repeatedMessageValues; bool _use_hardcoded_parse; bool _skipCopyOnFirstParse; - void setLVClusterHandle(int8_t* lvClusterHandle) { - _LVClusterHandle = std::make_shared(lvClusterHandle); + void setLVClusterHandle(const char* lvClusterHandle) { + _LVClusterHandle = std::make_shared(lvClusterHandle); }; - std::shared_ptr getLVClusterHandleSharedPtr() { + std::shared_ptr getLVClusterHandleSharedPtr() { return _LVClusterHandle; }; private: mutable google::protobuf::internal::CachedSize _cached_size_; google::protobuf::UnknownFieldSet _unknownFields; - std::shared_ptr _LVClusterHandle; + std::shared_ptr _LVClusterHandle; const char *ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); const char *ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); @@ -102,7 +105,7 @@ namespace grpc_labview uint64_t numElements; auto v = PackedMessageType(ptr, ctx, &numElements); // get the LVClusterHandle - auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; // copy into LVCluster if (numElements != 0) @@ -116,7 +119,7 @@ namespace grpc_labview } else { - auto _lv_ptr = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + auto _lv_ptr = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; ptr = ReadMessageType(ptr, reinterpret_cast(_lv_ptr)); } } diff --git a/src/message_value.h b/src/message_value.h index cd61969d..a1020bf8 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -8,6 +8,28 @@ namespace grpc_labview //--------------------------------------------------------------------- class LVMessage; + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + class LVMessageValueBase + {}; + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + template + class LVRepeatedMessage : public LVMessageValueBase + { + public: + LVRepeatedMessage(int protobufId); + + public: + google::protobuf::RepeatedField _value; + + public: + void* RawValue() override { return &_value; }; + size_t ByteSizeLong() override; + void Serialize(google::protobuf::io::CodedOutputStream* output) const override; + }; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVMessageValue From 4c2b942a62b4daea64b703fadb6b840d2b9935c6 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Tue, 17 Oct 2023 16:17:23 +0530 Subject: [PATCH 04/43] resize array as and when required, template-specialization for uint64 --- src/cluster_copier.cc | 4 +- src/lv_message.cc | 66 +++++++++-------- src/lv_message.h | 157 ++++++++++++++++------------------------ src/lv_message_value.cc | 6 +- src/message_value.h | 76 +++++-------------- 5 files changed, 123 insertions(+), 186 deletions(-) diff --git a/src/cluster_copier.cc b/src/cluster_copier.cc index c923325b..e3fe6f13 100644 --- a/src/cluster_copier.cc +++ b/src/cluster_copier.cc @@ -457,7 +457,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedUInt64 = std::static_pointer_cast(value); + auto repeatedUInt64 = std::static_pointer_cast>(value); if (repeatedUInt64->_value.size() != 0) { NumericArrayResize(0x08, 1, start, repeatedUInt64->_value.size()); @@ -858,7 +858,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); diff --git a/src/lv_message.cc b/src/lv_message.cc index 466c2d04..e8ba9189 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -208,8 +208,8 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - // SinglePassMessageParser parser(*this); - // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { if (fieldInfo.isRepeated) @@ -235,8 +235,8 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - // SinglePassMessageParser parser(*this); - // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { if (fieldInfo.isRepeated) @@ -309,15 +309,13 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - // SinglePassMessageParser parser(*this); - // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); - auto _lv_ptr = reinterpret_cast(*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; - ptr = ReadUINT64(ptr, const_cast(reinterpret_cast(_lv_ptr))); + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { if (fieldInfo.isRepeated) { - auto v = std::make_shared(index); + auto v = std::make_shared>(index); ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); _values.emplace(index, v); } @@ -563,11 +561,13 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + const char *LVMessage::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) { auto metadata = fieldInfo._owner->FindMetadata(fieldInfo.embeddedMessageName); if (_use_hardcoded_parse) { + const char* lv_ptr = (*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + if (fieldInfo.isRepeated){ // start with numElements = 16 // if the array is not big enough, resize it to 2x the size @@ -577,45 +577,49 @@ namespace grpc_labview auto clusterSize = metadata->clusterSize; auto alignment = metadata->alignmentRequirement; - const char* val_ptr = (*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; - NumericArrayResize(0x08, 1, (void**)val_ptr, num_elements * 4 * sizeof(uint64_t)); - auto array = *(LV1DArrayHandle*)val_ptr; + NumericArrayResize(0x08, 1, (void**)lv_ptr, num_elements * clusterSize); + auto array = *(LV1DArrayHandle*)lv_ptr; (*array)->cnt = num_elements; do { - ptr = element_count ? ptr + 1 : ptr; + protobuf_ptr = element_count ? protobuf_ptr + 1 : protobuf_ptr; auto nestedMessage = std::make_shared(metadata); - if (element_count == num_elements) { + if (element_count * clusterSize >= num_elements) { num_elements *= 2; - NumericArrayResize(0x08, 1, (void**)val_ptr, num_elements * 4 * sizeof(uint64_t)); - array = *(LV1DArrayHandle*)val_ptr; + NumericArrayResize(0x08, 1, (void**)lv_ptr, num_elements * clusterSize); + array = *(LV1DArrayHandle*)lv_ptr; (*array)->cnt = num_elements; } - auto next_ptr = (LVCluster**)(*array)->bytes(element_count * clusterSize, alignment); - nestedMessage->setLVClusterHandle(reinterpret_cast(next_ptr)); - ptr = ctx->ParseMessage(nestedMessage.get(), ptr); + auto lv_elem_ptr = (LVCluster**)(*array)->bytes(element_count * clusterSize, alignment); + nestedMessage->setLVClusterHandle(reinterpret_cast(lv_elem_ptr)); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); element_count++; - if (!ctx->DataAvailable(ptr)){ + if (!ctx->DataAvailable(protobuf_ptr)){ break; } - } while (ExpectTag(tag, ptr)); + } while (ExpectTag(tag, protobuf_ptr)); - NumericArrayResize(0x08, 1, (void**)val_ptr, (element_count - 1) * 4 * sizeof(uint64_t)); - array = *(LV1DArrayHandle*)val_ptr; + // shrink the array to the correct size + NumericArrayResize(0x08, 1, (void**)lv_ptr, (element_count - 1) * clusterSize); + array = *(LV1DArrayHandle*)lv_ptr; (*array)->cnt = element_count; } else { + auto nestedMessage = std::make_shared(metadata); + auto val_ptr = lv_ptr + fieldInfo.clusterOffset; + nestedMessage->setLVClusterHandle(val_ptr); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); } } else { if (fieldInfo.isRepeated) { - ptr -= 1; + protobuf_ptr -= 1; do { std::shared_ptr v; auto it = _values.find(index); @@ -628,25 +632,25 @@ namespace grpc_labview { v = std::static_pointer_cast((*it).second); } - ptr += 1; + protobuf_ptr += 1; auto nestedMessage = std::make_shared(metadata); - ptr = ctx->ParseMessage(nestedMessage.get(), ptr); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); v->_value.push_back(nestedMessage); - if (!ctx->DataAvailable(ptr)) + if (!ctx->DataAvailable(protobuf_ptr)) { break; } - } while (ExpectTag(tag, ptr)); + } while (ExpectTag(tag, protobuf_ptr)); } else { auto nestedMessage = std::make_shared(metadata); - ptr = ctx->ParseMessage(nestedMessage.get(), ptr); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); auto v = std::make_shared(index, nestedMessage); _values.emplace(index, v); } } - return ptr; + return protobuf_ptr; } //--------------------------------------------------------------------- diff --git a/src/lv_message.h b/src/lv_message.h index 7d1d4703..3a8f38dc 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -87,105 +87,74 @@ namespace grpc_labview const char *ParseBytes(unsigned int tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); const char *ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); bool ExpectTag(google::protobuf::uint32 tag, const char* ptr); - - /*public: - template - class SinglePassMessageParser { - private: - LVMessage& _message; - public: - // Constructor and other necessary member functions - SinglePassMessageParser(LVMessage& message) : _message(message) {} - - // Parse and copy message in a single pass. - void ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) - { - // Read the repeated elements into a temporary vector - uint64_t numElements; - auto v = PackedMessageType(ptr, ctx, &numElements); - // get the LVClusterHandle - auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; - - // copy into LVCluster - if (numElements != 0) - { - NumericArrayResize(0x08, 1, start, numElements); - auto array = *(LV1DArrayHandle*)start; - (*array)->cnt = numElements; - auto byteCount = numElements * sizeof(MessageType); - std::memcpy((*array)->bytes(), v->_value.data(), byteCount); - } - } - else - { - auto _lv_ptr = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; - ptr = ReadMessageType(ptr, reinterpret_cast(_lv_ptr)); - } - } + }; - const char* ReadMessageType(const char* ptr, MessageType* lv_ptr) + template + class SinglePassMessageParser { + private: + LVMessage& _message; + public: + // Constructor and other necessary member functions + SinglePassMessageParser(LVMessage& message) : _message(message) {} + + // Parse and copy message in a single pass. + const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { + if (fieldInfo.isRepeated) { - return nullptr; + // Read the repeated elements into a temporary vector + uint64_t numElements; + auto v = std::make_shared>(index); + ptr = PackedMessageType(ptr, ctx, index, &(v->_value)); + numElements = v->_value.size(); + // get the LVClusterHandle + auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + + // copy into LVCluster + if (numElements != 0) + { + NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(start)), numElements); + auto array = *(LV1DArrayHandle*)start; + (*array)->cnt = numElements; + auto byteCount = numElements * sizeof(MessageType); + std::memcpy((*array)->bytes(), v->_value.data(), byteCount); + } } - - LVRepeatedMessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) + else { - return nullptr; + auto _lv_ptr = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + ptr = ReadMessageType(ptr, reinterpret_cast(const_cast(_lv_ptr))); } + return ptr; + } + + const char* ReadMessageType(const char* ptr, MessageType* lv_ptr) + { + return nullptr; + } + + const char* PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return nullptr; + } + }; - // const char* ReadMessageType(const char* ptr, int32_t* lv_ptr) - // { - // return ReadINT32(ptr, _lv_ptr); - // } - - // LVRepeatedMessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) - // { - // auto v = std::make_shared>(index); - // ptr = PackedInt32Parser(&(v->_value), ptr, ctx); - // *numElements = v->_value.size(); - // return v; - // } - - // const char* ReadMessageType(const char* ptr, int32_t* lv_ptr) - // { - // return ReadINT32(ptr, _lv_ptr); - // } - - // LVRepeatedInt64MessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) - // { - // auto v = std::make_shared>(index); - // ptr = PackedInt32Parser(&(v->_value), ptr, ctx); - // *numElements = v->_value.size(); - // return v; - // } - - // const char* ReadMessageType(const char* ptr, int32_t* lv_ptr) - // { - // return ReadUINT32(ptr, _lv_ptr); - // } - - // LVRepeatedMessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) - // { - // auto v = std::make_shared>(index); - // ptr = PackedUInt32Parser(&(v->_value), ptr, ctx); - // *numElements = v->_value.size(); - // return v; - // } - - // const char* ReadMessageType(const char* ptr, int32_t* lv_ptr) - // { - // return ReadUINT64(ptr, _lv_ptr); - // } - - // LVRepeatedUInt64MessageValue* PackedMessageType(const char* ptr, ParseContext* ctx, uint64_t* numElements) - // { - // auto v = std::make_shared(index); - // ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); - // *numElements = v->_value.size(); - // return v; - // } - };*/ + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, int32_t* lv_ptr) + { + return ReadINT32(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedInt32Parser(value, ptr, ctx); + } - }; + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, uint64_t* lv_ptr) + { + return ReadUINT64(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedUInt64Parser(value, ptr, ctx); + } } diff --git a/src/lv_message_value.cc b/src/lv_message_value.cc index 46ed47a2..5a696468 100644 --- a/src/lv_message_value.cc +++ b/src/lv_message_value.cc @@ -437,14 +437,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedUInt64MessageValue::LVRepeatedUInt64MessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedUInt64MessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; size_t dataSize = WireFormatLite::UInt64Size(_value); @@ -460,7 +460,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedUInt64MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) { diff --git a/src/message_value.h b/src/message_value.h index a1020bf8..59e9e870 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -8,27 +8,6 @@ namespace grpc_labview //--------------------------------------------------------------------- class LVMessage; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVMessageValueBase - {}; - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - template - class LVRepeatedMessage : public LVMessageValueBase - { - public: - LVRepeatedMessage(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - void Serialize(google::protobuf::io::CodedOutputStream* output) const override; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -46,6 +25,26 @@ namespace grpc_labview virtual google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const = 0; }; + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + template + class LVRepeatedMessageValue : public LVMessageValue + { + public: + LVRepeatedMessageValue(int protobufId); + + google::protobuf::RepeatedField _value; + + void* RawValue() override { return &_value; }; + size_t ByteSizeLong() override; + google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; + + protected: + int _cachedSize; + }; + + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVNestedMessageMessageValue : public LVMessageValue @@ -94,24 +93,6 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - template - class LVRepeatedMessageValue : public LVMessageValue - { - public: - LVRepeatedMessageValue(int protobufId); - - google::protobuf::RepeatedField _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - protected: - int _cachedSize; - }; - //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -241,23 +222,6 @@ namespace grpc_labview int _cachedSize; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedUInt64MessageValue : public LVMessageValue - { - public: - LVRepeatedUInt64MessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- From 7ab9a655be33d16fc6c2e4177b6babc53aca0fb4 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Wed, 25 Oct 2023 08:21:58 +0530 Subject: [PATCH 05/43] Chakith changes --- src/cluster_copier.cc | 20 ++-- src/grpc_client.cc | 29 ++--- src/lv_message.cc | 247 +++++++++++++++++++++++++++------------- src/lv_message.h | 85 ++++++++++++++ src/lv_message_value.cc | 33 +++--- src/message_value.h | 137 +++++++--------------- 6 files changed, 337 insertions(+), 214 deletions(-) diff --git a/src/cluster_copier.cc b/src/cluster_copier.cc index f8ca5523..e3fe6f13 100644 --- a/src/cluster_copier.cc +++ b/src/cluster_copier.cc @@ -284,7 +284,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedString = static_cast(*value); + auto repeatedString = static_cast&>(*value); if (repeatedString._value.size() != 0) { NumericArrayResize(0x08, 1, start, repeatedString._value.size()); @@ -356,7 +356,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedInt32 = std::static_pointer_cast(value); + auto repeatedInt32 = std::static_pointer_cast>(value); if (repeatedInt32->_value.size() != 0) { NumericArrayResize(0x03, 1, start, repeatedInt32->_value.size()); @@ -378,7 +378,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedUInt32 = std::static_pointer_cast(value); + auto repeatedUInt32 = std::static_pointer_cast>(value); if (repeatedUInt32->_value.size() != 0) { NumericArrayResize(0x03, 1, start, repeatedUInt32->_value.size()); @@ -457,7 +457,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedUInt64 = std::static_pointer_cast(value); + auto repeatedUInt64 = std::static_pointer_cast>(value); if (repeatedUInt64->_value.size() != 0) { NumericArrayResize(0x08, 1, start, repeatedUInt64->_value.size()); @@ -479,7 +479,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedBoolean = std::static_pointer_cast(value); + auto repeatedBoolean = std::static_pointer_cast>(value); if (repeatedBoolean->_value.size() != 0) { NumericArrayResize(0x01, 1, start, repeatedBoolean->_value.size()); @@ -681,7 +681,7 @@ namespace grpc_labview { auto array = *(LV1DArrayHandle*)start; if (array && *array && ((*array)->cnt != 0)) { - auto repeatedStringValue = std::make_shared(metadata->protobufIndex); + auto repeatedStringValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedStringValue); auto lvStr = (*array)->bytes(); for (int x = 0; x < (*array)->cnt; ++x) @@ -717,7 +717,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); @@ -742,7 +742,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); @@ -767,7 +767,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); @@ -858,7 +858,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 2eeb48b2..787dac5f 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -274,7 +274,8 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( int8_t* requestCluster, grpc_labview::gRPCid** callId, int32_t timeoutMs, - grpc_labview::gRPCid* contextId) + grpc_labview::gRPCid* contextId, + int8_t* responseCluster) { auto client = clientId->CastTo(); if (!client) @@ -310,6 +311,8 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( clientCall->_request = std::make_shared(requestMetadata); clientCall->_response = std::make_shared(responseMetadata); clientCall->_context = clientContext; + clientCall->_request->setLVClusterHandle(reinterpret_cast(requestCluster)); + clientCall->_response->setLVClusterHandle(reinterpret_cast(responseCluster)); try { @@ -354,18 +357,18 @@ LIBRARY_EXPORT int32_t CompleteClientUnaryCall2( int32_t result = 0; if (call->_status.ok()) { - try - { - grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); - } - catch (grpc_labview::InvalidEnumValueException& e) - { - if (errorMessage != nullptr) - { - grpc_labview::SetLVString(errorMessage, e.what()); - } - return e.code; - } + // try + // { + // grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + // } + // catch (grpc_labview::InvalidEnumValueException& e) + // { + // if (errorMessage != nullptr) + // { + // grpc_labview::SetLVString(errorMessage, e.what()); + // } + // return e.code; + // } } else { diff --git a/src/lv_message.cc b/src/lv_message.cc index 6395da1b..e8ba9189 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -12,7 +12,12 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- LVMessage::LVMessage(std::shared_ptr metadata) : - _metadata(metadata) + _metadata(metadata), _use_hardcoded_parse(true), _skipCopyOnFirstParse(false) + { + } + + LVMessage::LVMessage(std::shared_ptr metadata, bool use_hardcoded_parse, bool skipCopyOnFirstParse) : + _metadata(metadata), _use_hardcoded_parse(use_hardcoded_parse), _skipCopyOnFirstParse(skipCopyOnFirstParse) { } @@ -183,7 +188,7 @@ namespace grpc_labview { if (fieldInfo.isRepeated) { - auto v = std::make_shared(index); + auto v = std::make_shared>(index); ptr = PackedBoolParser(&(v->_value), ptr, ctx); _values.emplace(index, v); } @@ -201,18 +206,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) + if (_use_hardcoded_parse) { - auto v = std::make_shared(index); - ptr = PackedInt32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int32_t result; - ptr = ReadINT32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedInt32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int32_t result; + ptr = ReadINT32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -221,18 +233,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseUInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) + if (_use_hardcoded_parse) { - auto v = std::make_shared(index); - ptr = PackedUInt32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - uint32_t result; - ptr = ReadUINT32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedUInt32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + uint32_t result; + ptr = ReadUINT32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -261,18 +280,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) + if (_use_hardcoded_parse) { - auto v = std::make_shared(index); - ptr = PackedInt64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + // SinglePassMessageParser parser(*this); + // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int64_t result; - ptr = ReadINT64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedInt64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int64_t result; + ptr = ReadINT64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -280,19 +306,26 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- const char *LVMessage::ParseUInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if (fieldInfo.isRepeated) + { + if (_use_hardcoded_parse) { - auto v = std::make_shared(index); - ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - uint64_t result; - ptr = ReadUINT64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + } + else { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + uint64_t result; + ptr = ReadUINT64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -343,16 +376,16 @@ namespace grpc_labview { if (fieldInfo.isRepeated) { - std::shared_ptr v; + std::shared_ptr> v; auto it = _values.find(index); if (it == _values.end()) { - v = std::make_shared(index); + v = std::make_shared>(index); _values.emplace(index, v); } else { - v = std::static_pointer_cast((*it).second); + v = std::static_pointer_cast>((*it).second); } ptr -= 1; do { @@ -518,44 +551,106 @@ namespace grpc_labview return ptr; } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + struct LVCluster + { + }; // TODO: Do not check this in. + + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + const char *LVMessage::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) { auto metadata = fieldInfo._owner->FindMetadata(fieldInfo.embeddedMessageName); - if (fieldInfo.isRepeated) + if (_use_hardcoded_parse) { - ptr -= 1; - do { - std::shared_ptr v; - auto it = _values.find(index); - if (it == _values.end()) - { - v = std::make_shared(index); - _values.emplace(index, v); - } - else + const char* lv_ptr = (*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + + if (fieldInfo.isRepeated){ + // start with numElements = 16 + // if the array is not big enough, resize it to 2x the size + auto num_elements = 16; + auto element_count = 0; + + auto clusterSize = metadata->clusterSize; + auto alignment = metadata->alignmentRequirement; + + NumericArrayResize(0x08, 1, (void**)lv_ptr, num_elements * clusterSize); + auto array = *(LV1DArrayHandle*)lv_ptr; + (*array)->cnt = num_elements; + + do { - v = std::static_pointer_cast((*it).second); - } - ptr += 1; + protobuf_ptr = element_count ? protobuf_ptr + 1 : protobuf_ptr; + auto nestedMessage = std::make_shared(metadata); + + if (element_count * clusterSize >= num_elements) { + num_elements *= 2; + NumericArrayResize(0x08, 1, (void**)lv_ptr, num_elements * clusterSize); + array = *(LV1DArrayHandle*)lv_ptr; + (*array)->cnt = num_elements; + } + + auto lv_elem_ptr = (LVCluster**)(*array)->bytes(element_count * clusterSize, alignment); + nestedMessage->setLVClusterHandle(reinterpret_cast(lv_elem_ptr)); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); + + element_count++; + + if (!ctx->DataAvailable(protobuf_ptr)){ + break; + } + } while (ExpectTag(tag, protobuf_ptr)); + + // shrink the array to the correct size + NumericArrayResize(0x08, 1, (void**)lv_ptr, (element_count - 1) * clusterSize); + array = *(LV1DArrayHandle*)lv_ptr; + (*array)->cnt = element_count; + } + else { auto nestedMessage = std::make_shared(metadata); - ptr = ctx->ParseMessage(nestedMessage.get(), ptr); - v->_value.push_back(nestedMessage); - if (!ctx->DataAvailable(ptr)) - { - break; - } - } while (ExpectTag(tag, ptr)); + auto val_ptr = lv_ptr + fieldInfo.clusterOffset; + nestedMessage->setLVClusterHandle(val_ptr); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); + } } - else - { - auto nestedMessage = std::make_shared(metadata); - ptr = ctx->ParseMessage(nestedMessage.get(), ptr); - auto v = std::make_shared(index, nestedMessage); - _values.emplace(index, v); + else { + if (fieldInfo.isRepeated) + { + protobuf_ptr -= 1; + do { + std::shared_ptr v; + auto it = _values.find(index); + if (it == _values.end()) + { + v = std::make_shared(index); + _values.emplace(index, v); + } + else + { + v = std::static_pointer_cast((*it).second); + } + protobuf_ptr += 1; + auto nestedMessage = std::make_shared(metadata); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); + v->_value.push_back(nestedMessage); + if (!ctx->DataAvailable(protobuf_ptr)) + { + break; + } + } while (ExpectTag(tag, protobuf_ptr)); + } + else + { + auto nestedMessage = std::make_shared(metadata); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); + auto v = std::make_shared(index, nestedMessage); + _values.emplace(index, v); + } } - return ptr; + return protobuf_ptr; } //--------------------------------------------------------------------- diff --git a/src/lv_message.h b/src/lv_message.h index 9961ec27..3a8f38dc 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -8,6 +8,8 @@ #include #include +using namespace google::protobuf::internal; + namespace grpc_labview { //--------------------------------------------------------------------- @@ -16,6 +18,7 @@ namespace grpc_labview { public: LVMessage(std::shared_ptr metadata); + LVMessage(std::shared_ptr metadata, bool use_hardcoded_parse, bool skipCopyOnFirstParse); ~LVMessage(); google::protobuf::UnknownFieldSet& UnknownFields(); @@ -48,10 +51,23 @@ namespace grpc_labview public: std::map> _values; std::shared_ptr _metadata; + // std::vector _messageValues; + // std::vector<> _repeatedMessageValues; + bool _use_hardcoded_parse; + bool _skipCopyOnFirstParse; + + void setLVClusterHandle(const char* lvClusterHandle) { + _LVClusterHandle = std::make_shared(lvClusterHandle); + }; + + std::shared_ptr getLVClusterHandleSharedPtr() { + return _LVClusterHandle; + }; private: mutable google::protobuf::internal::CachedSize _cached_size_; google::protobuf::UnknownFieldSet _unknownFields; + std::shared_ptr _LVClusterHandle; const char *ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); const char *ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); @@ -72,4 +88,73 @@ namespace grpc_labview const char *ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); bool ExpectTag(google::protobuf::uint32 tag, const char* ptr); }; + + template + class SinglePassMessageParser { + private: + LVMessage& _message; + public: + // Constructor and other necessary member functions + SinglePassMessageParser(LVMessage& message) : _message(message) {} + + // Parse and copy message in a single pass. + const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { + if (fieldInfo.isRepeated) + { + // Read the repeated elements into a temporary vector + uint64_t numElements; + auto v = std::make_shared>(index); + ptr = PackedMessageType(ptr, ctx, index, &(v->_value)); + numElements = v->_value.size(); + // get the LVClusterHandle + auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + + // copy into LVCluster + if (numElements != 0) + { + NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(start)), numElements); + auto array = *(LV1DArrayHandle*)start; + (*array)->cnt = numElements; + auto byteCount = numElements * sizeof(MessageType); + std::memcpy((*array)->bytes(), v->_value.data(), byteCount); + } + } + else + { + auto _lv_ptr = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + ptr = ReadMessageType(ptr, reinterpret_cast(const_cast(_lv_ptr))); + } + return ptr; + } + + const char* ReadMessageType(const char* ptr, MessageType* lv_ptr) + { + return nullptr; + } + + const char* PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return nullptr; + } + }; + + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, int32_t* lv_ptr) + { + return ReadINT32(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedInt32Parser(value, ptr, ctx); + } + + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, uint64_t* lv_ptr) + { + return ReadUINT64(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedUInt64Parser(value, ptr, ctx); + } } diff --git a/src/lv_message_value.cc b/src/lv_message_value.cc index d59b49ad..5a696468 100644 --- a/src/lv_message_value.cc +++ b/src/lv_message_value.cc @@ -2,6 +2,7 @@ //--------------------------------------------------------------------- #include #include +#include //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -96,14 +97,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedStringMessageValue::LVRepeatedStringMessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedStringMessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; totalSize += 1 * FromIntSize(_value.size()); @@ -116,7 +117,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedStringMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { for (int i = 0, n = _value.size(); i < n; i++) { @@ -151,14 +152,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedBooleanMessageValue::LVRepeatedBooleanMessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedBooleanMessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; unsigned int count = static_cast(_value.size()); @@ -174,7 +175,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedBooleanMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_value.size() > 0) { @@ -300,14 +301,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedInt32MessageValue::LVRepeatedInt32MessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedInt32MessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; size_t dataSize = WireFormatLite::Int32Size(_value); @@ -323,7 +324,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedInt32MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) { @@ -334,14 +335,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedUInt32MessageValue::LVRepeatedUInt32MessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedUInt32MessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; size_t dataSize = WireFormatLite::UInt32Size(_value); @@ -357,7 +358,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedUInt32MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) { @@ -369,7 +370,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- LVRepeatedEnumMessageValue::LVRepeatedEnumMessageValue(int protobufId) : - LVMessageValue(protobufId) + LVRepeatedMessageValue(protobufId) { } @@ -436,14 +437,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedUInt64MessageValue::LVRepeatedUInt64MessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedUInt64MessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; size_t dataSize = WireFormatLite::UInt64Size(_value); @@ -459,7 +460,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedUInt64MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) { diff --git a/src/message_value.h b/src/message_value.h index 184c2c31..59e9e870 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -8,6 +8,7 @@ namespace grpc_labview //--------------------------------------------------------------------- class LVMessage; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVMessageValue @@ -24,6 +25,26 @@ namespace grpc_labview virtual google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const = 0; }; + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + template + class LVRepeatedMessageValue : public LVMessageValue + { + public: + LVRepeatedMessageValue(int protobufId); + + google::protobuf::RepeatedField _value; + + void* RawValue() override { return &_value; }; + size_t ByteSizeLong() override; + google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; + + protected: + int _cachedSize; + }; + + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVNestedMessageMessageValue : public LVMessageValue @@ -72,21 +93,6 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedStringMessageValue : public LVMessageValue - { - public: - LVRepeatedStringMessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -103,20 +109,6 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedBooleanMessageValue : public LVMessageValue - { - public: - LVRepeatedBooleanMessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -148,12 +140,13 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVEnumMessageValue : public LVMessageValue { public: - LVEnumMessageValue(int protobufId, int value); + LVEnumMessageValue(int protobufId, int _value); public: int _value; @@ -163,91 +156,54 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVInt64MessageValue : public LVMessageValue - { - public: - LVInt64MessageValue(int protobufId, int64_t value); - - public: - int64_t _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- - class LVUInt64MessageValue : public LVMessageValue + class LVRepeatedEnumMessageValue : public LVRepeatedMessageValue { - public: - LVUInt64MessageValue(int protobufId, uint64_t value); + public: + LVRepeatedEnumMessageValue(int protobufId); - public: - uint64_t _value; + google::protobuf::RepeatedField _value; - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; + void* RawValue() override { return &_value; }; + size_t ByteSizeLong() override; + google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedInt32MessageValue : public LVMessageValue - { - public: - LVRepeatedInt32MessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- - class LVRepeatedUInt32MessageValue : public LVMessageValue + class LVInt64MessageValue : public LVMessageValue { public: - LVRepeatedUInt32MessageValue(int protobufId); + LVInt64MessageValue(int protobufId, int64_t value); public: - google::protobuf::RepeatedField _value; + int64_t _value; void* RawValue() override { return &_value; }; size_t ByteSizeLong() override; google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- - class LVRepeatedEnumMessageValue : public LVMessageValue + class LVUInt64MessageValue : public LVMessageValue { public: - LVRepeatedEnumMessageValue(int protobufId); + LVUInt64MessageValue(int protobufId, uint64_t value); public: - google::protobuf::RepeatedField _value; + uint64_t _value; + public: void* RawValue() override { return &_value; }; size_t ByteSizeLong() override; google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; }; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVRepeatedInt64MessageValue : public LVMessageValue @@ -266,23 +222,6 @@ namespace grpc_labview int _cachedSize; }; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedUInt64MessageValue : public LVMessageValue - { - public: - LVRepeatedUInt64MessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; - }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- From e9fb8414d4b32a5e343c1f75953c839aa59f63fa Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Wed, 25 Oct 2023 11:29:17 +0530 Subject: [PATCH 06/43] updated gitignore to add build_bak --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5014afe2..a22a5ab3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ grpc Builds build +build_bak .vs .vscode __pycache__ From 5ef415986d70ce4957c29abcb0c91100e797a1f8 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Wed, 25 Oct 2023 14:07:17 +0530 Subject: [PATCH 07/43] Added variable check --- src/lv_message.cc | 301 +++++++++++++++++++++++++++++----------------- 1 file changed, 189 insertions(+), 112 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index e8ba9189..34a95ccd 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -186,18 +186,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = PackedBoolParser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - bool result; - ptr = ReadBOOL(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedBoolParser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + bool result; + ptr = ReadBOOL(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -260,18 +267,24 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseEnum(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedEnumParser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int32_t result; - ptr = ReadENUM(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedEnumParser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int32_t result; + ptr = ReadENUM(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -282,8 +295,8 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - // SinglePassMessageParser parser(*this); - // parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + SinglePassMessageParser parser(*this); + parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { if (fieldInfo.isRepeated) @@ -334,18 +347,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseFloat(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedFloatParser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - float result; - ptr = ReadFLOAT(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedFloatParser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + float result; + ptr = ReadFLOAT(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -354,18 +374,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseDouble(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedDoubleParser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - double result; - ptr = ReadDOUBLE(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedDoubleParser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + double result; + ptr = ReadDOUBLE(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -374,6 +401,14 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseString(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + } + else{ + + } if (fieldInfo.isRepeated) { std::shared_ptr> v; @@ -434,18 +469,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char* LVMessage::ParseSInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedSInt32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int32_t result; - ptr = ReadSINT32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedSInt32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int32_t result; + ptr = ReadSINT32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -454,18 +496,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char* LVMessage::ParseSInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedSInt64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int64_t result; - ptr = ReadSINT64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedSInt64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int64_t result; + ptr = ReadSINT64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -474,18 +523,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char* LVMessage::ParseFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedFixed32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - uint32_t result; - ptr = ReadFIXED32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedFixed32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + uint32_t result; + ptr = ReadFIXED32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -495,18 +551,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char* LVMessage::ParseFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedFixed64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - uint64_t result; - ptr = ReadFIXED64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedFixed64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + uint64_t result; + ptr = ReadFIXED64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -515,18 +578,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char* LVMessage::ParseSFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedSFixed32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int32_t result; - ptr = ReadSFIXED32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedSFixed32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int32_t result; + ptr = ReadSFIXED32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } @@ -535,18 +605,25 @@ namespace grpc_labview //--------------------------------------------------------------------- const char* LVMessage::ParseSFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedSFixed64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); + if(_use_hardcoded_parse){ + + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } - else - { - int64_t result; - ptr = ReadSFIXED64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); + else{ + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedSFixed64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + int64_t result; + ptr = ReadSFIXED64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); + } } return ptr; } From 4a914510c3419ee4efca95bb4e02ad76f5561ff3 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Wed, 25 Oct 2023 17:47:51 +0530 Subject: [PATCH 08/43] Added templates for basic datatypes --- src/cluster_copier.cc | 40 ++++----- src/lv_message.cc | 61 ++++++-------- src/lv_message.h | 53 +++++++++++- src/lv_message_value.cc | 62 +++++++------- src/message_value.h | 183 +++++----------------------------------- 5 files changed, 148 insertions(+), 251 deletions(-) diff --git a/src/cluster_copier.cc b/src/cluster_copier.cc index e3fe6f13..57ad8265 100644 --- a/src/cluster_copier.cc +++ b/src/cluster_copier.cc @@ -368,7 +368,7 @@ namespace grpc_labview { } else { - *(int*)start = ((LVInt32MessageValue*)value.get())->_value; + *(int*)start = ((LVVariableMessageValue*)value.get())->_value; } } @@ -390,7 +390,7 @@ namespace grpc_labview { } else { - *(int*)start = ((LVUInt32MessageValue*)value.get())->_value; + *(int*)start = ((LVVariableMessageValue*)value.get())->_value; } } @@ -435,7 +435,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedInt64 = std::static_pointer_cast(value); + auto repeatedInt64 = std::static_pointer_cast>(value); if (repeatedInt64->_value.size() != 0) { NumericArrayResize(0x04, 1, start, repeatedInt64->_value.size()); @@ -447,7 +447,7 @@ namespace grpc_labview { } else { - *(int64_t*)start = ((LVInt64MessageValue*)value.get())->_value; + *(int64_t*)start = ((LVVariableMessageValue*)value.get())->_value; } } @@ -469,7 +469,7 @@ namespace grpc_labview { } else { - *(uint64_t*)start = ((LVUInt64MessageValue*)value.get())->_value; + *(uint64_t*)start = ((LVVariableMessageValue*)value.get())->_value; } } @@ -491,7 +491,7 @@ namespace grpc_labview { } else { - *(bool*)start = ((LVBooleanMessageValue*)value.get())->_value; + *(bool*)start = ((LVVariableMessageValue*)value.get())->_value; } } @@ -501,7 +501,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedDouble = std::static_pointer_cast(value); + auto repeatedDouble = std::static_pointer_cast>(value); if (repeatedDouble->_value.size() != 0) { auto array = *(LV1DArrayHandle*)start; @@ -514,7 +514,7 @@ namespace grpc_labview { } else { - *(double*)start = ((LVDoubleMessageValue*)value.get())->_value; + *(double*)start = ((LVVariableMessageValue*)value.get())->_value; } } @@ -524,7 +524,7 @@ namespace grpc_labview { { if (metadata->isRepeated) { - auto repeatedFloat = std::static_pointer_cast(value); + auto repeatedFloat = std::static_pointer_cast>(value); if (repeatedFloat->_value.size() != 0) { NumericArrayResize(0x03, 1, start, repeatedFloat->_value.size()); @@ -536,7 +536,7 @@ namespace grpc_labview { } else { - *(float*)start = ((LVFloatMessageValue*)value.get())->_value; + *(float*)start = ((LVVariableMessageValue*)value.get())->_value; } } @@ -727,7 +727,7 @@ namespace grpc_labview { } else { - auto value = std::make_shared(metadata->protobufIndex, *(bool*)start); + auto value = std::make_shared>(metadata->protobufIndex, *(bool*)start); message._values.emplace(metadata->protobufIndex, value); } } @@ -752,7 +752,7 @@ namespace grpc_labview { } else { - auto value = std::make_shared(metadata->protobufIndex, *(int*)start); + auto value = std::make_shared>(metadata->protobufIndex, *(int*)start); message._values.emplace(metadata->protobufIndex, value); } } @@ -777,7 +777,7 @@ namespace grpc_labview { } else { - auto value = std::make_shared(metadata->protobufIndex, *(uint32_t*)start); + auto value = std::make_shared>(metadata->protobufIndex, *(uint32_t*)start); message._values.emplace(metadata->protobufIndex, value); } } @@ -833,7 +833,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); @@ -843,7 +843,7 @@ namespace grpc_labview { } else { - auto value = std::make_shared(metadata->protobufIndex, *(int64_t*)start); + auto value = std::make_shared>(metadata->protobufIndex, *(int64_t*)start); message._values.emplace(metadata->protobufIndex, value); } } @@ -868,7 +868,7 @@ namespace grpc_labview { } else { - auto value = std::make_shared(metadata->protobufIndex, *(uint64_t*)start); + auto value = std::make_shared>(metadata->protobufIndex, *(uint64_t*)start); message._values.emplace(metadata->protobufIndex, value); } } @@ -883,7 +883,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); @@ -893,7 +893,7 @@ namespace grpc_labview { } else { - auto value = std::make_shared(metadata->protobufIndex, *(double*)start); + auto value = std::make_shared>(metadata->protobufIndex, *(double*)start); message._values.emplace(metadata->protobufIndex, value); } } @@ -908,7 +908,7 @@ namespace grpc_labview { if (array && *array && ((*array)->cnt != 0)) { auto count = (*array)->cnt; - auto repeatedValue = std::make_shared(metadata->protobufIndex); + auto repeatedValue = std::make_shared>(metadata->protobufIndex); message._values.emplace(metadata->protobufIndex, repeatedValue); auto data = (*array)->bytes(); repeatedValue->_value.Reserve(count); @@ -918,7 +918,7 @@ namespace grpc_labview { } else { - auto value = std::make_shared(metadata->protobufIndex, *(float*)start); + auto value = std::make_shared>(metadata->protobufIndex, *(float*)start); message._values.emplace(metadata->protobufIndex, value); } } diff --git a/src/lv_message.cc b/src/lv_message.cc index 34a95ccd..17a4c680 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -202,7 +202,7 @@ namespace grpc_labview { bool result; ptr = ReadBOOL(ptr, &result); - auto v = std::make_shared(index, result); + auto v = std::make_shared>(index, result); _values.emplace(index, v); } } @@ -229,7 +229,7 @@ namespace grpc_labview { int32_t result; ptr = ReadINT32(ptr, &result); - auto v = std::make_shared(index, result); + auto v = std::make_shared>(index, result); _values.emplace(index, v); } } @@ -256,7 +256,7 @@ namespace grpc_labview { uint32_t result; ptr = ReadUINT32(ptr, &result); - auto v = std::make_shared(index, result); + auto v = std::make_shared>(index, result); _values.emplace(index, v); } } @@ -268,8 +268,8 @@ namespace grpc_labview const char *LVMessage::ParseEnum(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + /* grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ } else{ if (fieldInfo.isRepeated) @@ -301,7 +301,7 @@ namespace grpc_labview else { if (fieldInfo.isRepeated) { - auto v = std::make_shared(index); + auto v = std::make_shared>(index); ptr = PackedInt64Parser(&(v->_value), ptr, ctx); _values.emplace(index, v); } @@ -309,7 +309,7 @@ namespace grpc_labview { int64_t result; ptr = ReadINT64(ptr, &result); - auto v = std::make_shared(index, result); + auto v = std::make_shared>(index, result); _values.emplace(index, v); } } @@ -336,7 +336,7 @@ namespace grpc_labview { uint64_t result; ptr = ReadUINT64(ptr, &result); - auto v = std::make_shared(index, result); + auto v = std::make_shared>(index, result); _values.emplace(index, v); } } @@ -348,14 +348,13 @@ namespace grpc_labview const char *LVMessage::ParseFloat(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else{ if (fieldInfo.isRepeated) { - auto v = std::make_shared(index); + auto v = std::make_shared>(index); ptr = PackedFloatParser(&(v->_value), ptr, ctx); _values.emplace(index, v); } @@ -363,7 +362,7 @@ namespace grpc_labview { float result; ptr = ReadFLOAT(ptr, &result); - auto v = std::make_shared(index, result); + auto v = std::make_shared>(index, result); _values.emplace(index, v); } } @@ -375,14 +374,13 @@ namespace grpc_labview const char *LVMessage::ParseDouble(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else{ if (fieldInfo.isRepeated) { - auto v = std::make_shared(index); + auto v = std::make_shared>(index); ptr = PackedDoubleParser(&(v->_value), ptr, ctx); _values.emplace(index, v); } @@ -390,7 +388,7 @@ namespace grpc_labview { double result; ptr = ReadDOUBLE(ptr, &result); - auto v = std::make_shared(index, result); + auto v = std::make_shared>(index, result); _values.emplace(index, v); } } @@ -402,9 +400,8 @@ namespace grpc_labview const char *LVMessage::ParseString(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - - grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + /* grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ } else{ @@ -470,9 +467,8 @@ namespace grpc_labview const char* LVMessage::ParseSInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - - grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + //grpc_labview::SinglePassMessageParser parser(*this); + //ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else{ if (fieldInfo.isRepeated) @@ -497,9 +493,8 @@ namespace grpc_labview const char* LVMessage::ParseSInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - - grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + /*grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ } else{ if (fieldInfo.isRepeated) @@ -524,9 +519,8 @@ namespace grpc_labview const char* LVMessage::ParseFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - - grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + /*grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ } else{ if (fieldInfo.isRepeated) @@ -552,9 +546,8 @@ namespace grpc_labview const char* LVMessage::ParseFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - - grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + /*grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ } else{ if (fieldInfo.isRepeated) @@ -579,9 +572,8 @@ namespace grpc_labview const char* LVMessage::ParseSFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - - grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + /*grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ } else{ if (fieldInfo.isRepeated) @@ -606,9 +598,8 @@ namespace grpc_labview const char* LVMessage::ParseSFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - - grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + /* grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ } else{ if (fieldInfo.isRepeated) diff --git a/src/lv_message.h b/src/lv_message.h index 3a8f38dc..e62261a4 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -148,13 +148,64 @@ namespace grpc_labview return PackedInt32Parser(value, ptr, ctx); } + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, uint32_t* lv_ptr) + { + return ReadUINT32(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedUInt32Parser(value, ptr, ctx); + } + + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, int64_t* lv_ptr) + { + return ReadINT64(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedInt64Parser(value, ptr, ctx); + } + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, uint64_t* lv_ptr) { return ReadUINT64(ptr, lv_ptr); } - + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) { return PackedUInt64Parser(value, ptr, ctx); } + + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, bool* lv_ptr) + { + return ReadBOOL(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedBoolParser(value, ptr, ctx); + } + + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, float* lv_ptr) + { + return ReadFLOAT(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedFloatParser(value, ptr, ctx); + } + + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, double* lv_ptr) + { + return ReadDOUBLE(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedDoubleParser(value, ptr, ctx); + } + } diff --git a/src/lv_message_value.cc b/src/lv_message_value.cc index 5a696468..467854f3 100644 --- a/src/lv_message_value.cc +++ b/src/lv_message_value.cc @@ -14,7 +14,7 @@ namespace grpc_labview //--------------------------------------------------------------------- LVMessageValue::LVMessageValue(int protobufId) : _protobufId(protobufId) - { + { } //--------------------------------------------------------------------- @@ -129,7 +129,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVBooleanMessageValue::LVBooleanMessageValue(int protobufId, bool value) : + LVVariableMessageValue::LVVariableMessageValue(int protobufId, bool value) : LVMessageValue(protobufId), _value(value) { @@ -137,14 +137,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVBooleanMessageValue::ByteSizeLong() + size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::TYPE_BOOL) + WireFormatLite::kBoolSize; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVBooleanMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); return WireFormatLite::WriteBoolToArray(_protobufId, _value, target); @@ -186,7 +186,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVInt32MessageValue::LVInt32MessageValue(int protobufId, int value) : + LVVariableMessageValue::LVVariableMessageValue(int protobufId, int value) : LVMessageValue(protobufId), _value(value) { @@ -194,14 +194,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVInt32MessageValue::ByteSizeLong() + size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_INT32) + WireFormatLite::Int32Size(_value); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVInt32MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); return WireFormatLite::WriteInt32ToArray(_protobufId, _value, target); @@ -209,7 +209,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVUInt32MessageValue::LVUInt32MessageValue(int protobufId, uint32_t value) : + LVVariableMessageValue::LVVariableMessageValue(int protobufId, uint32_t value) : LVMessageValue(protobufId), _value(value) { @@ -217,14 +217,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVUInt32MessageValue::ByteSizeLong() + size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_UINT32) + WireFormatLite::UInt32Size(_value); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVUInt32MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); return WireFormatLite::WriteUInt32ToArray(_protobufId, _value, target); @@ -255,7 +255,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVInt64MessageValue::LVInt64MessageValue(int protobufId, int64_t value) : + LVVariableMessageValue::LVVariableMessageValue(int protobufId, int64_t value) : LVMessageValue(protobufId), _value(value) { @@ -263,14 +263,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVInt64MessageValue::ByteSizeLong() + size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_INT64) + WireFormatLite::Int64Size(_value); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVInt64MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); return WireFormatLite::WriteInt64ToArray(_protobufId, _value, target); @@ -278,7 +278,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVUInt64MessageValue::LVUInt64MessageValue(int protobufId, uint64_t value) : + LVVariableMessageValue::LVVariableMessageValue(int protobufId, uint64_t value) : LVMessageValue(protobufId), _value(value) { @@ -286,14 +286,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVUInt64MessageValue::ByteSizeLong() + size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_UINT64) + WireFormatLite::UInt64Size(_value); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVUInt64MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); return WireFormatLite::WriteUInt64ToArray(_protobufId, _value, target); @@ -403,14 +403,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedInt64MessageValue::LVRepeatedInt64MessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedInt64MessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; size_t dataSize = WireFormatLite::Int64Size(_value); @@ -426,7 +426,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedInt64MessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) { @@ -471,7 +471,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVFloatMessageValue::LVFloatMessageValue(int protobufId, float value) : + LVVariableMessageValue::LVVariableMessageValue(int protobufId, float value) : LVMessageValue(protobufId), _value(value) { @@ -479,14 +479,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVFloatMessageValue::ByteSizeLong() + size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::TYPE_STRING) + WireFormatLite::kFloatSize; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVFloatMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); return WireFormatLite::WriteFloatToArray(_protobufId, _value, target); @@ -494,14 +494,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedFloatMessageValue::LVRepeatedFloatMessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedFloatMessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; unsigned int count = static_cast(_value.size()); @@ -517,7 +517,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedFloatMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_value.size() > 0) { @@ -529,7 +529,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVDoubleMessageValue::LVDoubleMessageValue(int protobufId, double value) : + LVVariableMessageValue::LVVariableMessageValue(int protobufId, double value) : LVMessageValue(protobufId), _value(value) { @@ -537,14 +537,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVDoubleMessageValue::ByteSizeLong() + size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_DOUBLE) + WireFormatLite::kDoubleSize; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVDoubleMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); return WireFormatLite::WriteDoubleToArray(_protobufId, _value, target); @@ -552,14 +552,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedDoubleMessageValue::LVRepeatedDoubleMessageValue(int protobufId) : + LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - size_t LVRepeatedDoubleMessageValue::ByteSizeLong() + size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; unsigned int count = static_cast(_value.size()); @@ -575,7 +575,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::uint8* LVRepeatedDoubleMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const + google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_value.size() > 0) { diff --git a/src/message_value.h b/src/message_value.h index 59e9e870..03703db2 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -44,6 +44,24 @@ namespace grpc_labview int _cachedSize; }; + template + class LVVariableMessageValue : public LVMessageValue + { + public: + LVVariableMessageValue(int protobufId, T value) : + LVMessageValue(protobufId), + _value(value) + { + } + public: + T _value; + + public: + void* RawValue() override { return &_value; }; + size_t ByteSizeLong() override; + google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; + }; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -93,54 +111,6 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVBooleanMessageValue : public LVMessageValue - { - public: - LVBooleanMessageValue(int protobufId, bool value); - - public: - bool _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVInt32MessageValue : public LVMessageValue - { - public: - LVInt32MessageValue(int protobufId, int value); - - public: - int _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVUInt32MessageValue : public LVMessageValue - { - public: - LVUInt32MessageValue(int protobufId, uint32_t value); - - public: - uint32_t _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - - //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVEnumMessageValue : public LVMessageValue @@ -171,122 +141,6 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVInt64MessageValue : public LVMessageValue - { - public: - LVInt64MessageValue(int protobufId, int64_t value); - - public: - int64_t _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVUInt64MessageValue : public LVMessageValue - { - public: - LVUInt64MessageValue(int protobufId, uint64_t value); - - public: - uint64_t _value; - - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedInt64MessageValue : public LVMessageValue - { - public: - LVRepeatedInt64MessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - - private: - int _cachedSize; - }; - - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVFloatMessageValue : public LVMessageValue - { - public: - LVFloatMessageValue(int protobufId, float value); - - public: - float _value; - - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedFloatMessageValue : public LVMessageValue - { - public: - LVRepeatedFloatMessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVDoubleMessageValue : public LVMessageValue - { - public: - LVDoubleMessageValue(int protobufId, double value); - - public: - double _value; - - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - class LVRepeatedDoubleMessageValue : public LVMessageValue - { - public: - LVRepeatedDoubleMessageValue(int protobufId); - - public: - google::protobuf::RepeatedField _value; - - public: - void* RawValue() override { return &_value; }; - size_t ByteSizeLong() override; - google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; - }; - //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVSInt32MessageValue : public LVMessageValue @@ -303,6 +157,7 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVRepeatedSInt32MessageValue : public LVMessageValue From 4deb90503b82c43d12a676314cf62f43d1536650 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Fri, 27 Oct 2023 15:52:25 +0530 Subject: [PATCH 09/43] Removed redundant code --- src/lv_message_value.cc | 56 ++++++++++++++++++++--------------------- src/message_value.h | 7 ++++-- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/lv_message_value.cc b/src/lv_message_value.cc index 467854f3..34eb9c09 100644 --- a/src/lv_message_value.cc +++ b/src/lv_message_value.cc @@ -97,10 +97,10 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : + /*LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -129,11 +129,11 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVVariableMessageValue::LVVariableMessageValue(int protobufId, bool value) : + /*LVVariableMessageValue::LVVariableMessageValue(int protobufId, bool value) : LVMessageValue(protobufId), _value(value) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -152,10 +152,10 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : + /*LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -186,11 +186,11 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVVariableMessageValue::LVVariableMessageValue(int protobufId, int value) : + /*LVVariableMessageValue::LVVariableMessageValue(int protobufId, int value) : LVMessageValue(protobufId), _value(value) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -209,11 +209,11 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVVariableMessageValue::LVVariableMessageValue(int protobufId, uint32_t value) : + /*LVVariableMessageValue::LVVariableMessageValue(int protobufId, uint32_t value) : LVMessageValue(protobufId), _value(value) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -278,11 +278,11 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVVariableMessageValue::LVVariableMessageValue(int protobufId, uint64_t value) : + /*LVVariableMessageValue::LVVariableMessageValue(int protobufId, uint64_t value) : LVMessageValue(protobufId), _value(value) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -301,10 +301,10 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : + /*LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -335,10 +335,10 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : + /*LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -403,10 +403,10 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : + /*LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -437,10 +437,10 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : + /*LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -471,11 +471,11 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVVariableMessageValue::LVVariableMessageValue(int protobufId, float value) : + /*LVVariableMessageValue::LVVariableMessageValue(int protobufId, float value) : LVMessageValue(protobufId), _value(value) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -494,10 +494,10 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : + /*LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -529,11 +529,11 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVVariableMessageValue::LVVariableMessageValue(int protobufId, double value) : + /*LVVariableMessageValue::LVVariableMessageValue(int protobufId, double value) : LVMessageValue(protobufId), _value(value) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -552,10 +552,10 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : + /*LVRepeatedMessageValue::LVRepeatedMessageValue(int protobufId) : LVMessageValue(protobufId) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- diff --git a/src/message_value.h b/src/message_value.h index 03703db2..5384417a 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -32,7 +32,10 @@ namespace grpc_labview class LVRepeatedMessageValue : public LVMessageValue { public: - LVRepeatedMessageValue(int protobufId); + LVRepeatedMessageValue(int protobufId) : + LVMessageValue(protobufId) + { + } google::protobuf::RepeatedField _value; @@ -62,7 +65,7 @@ namespace grpc_labview google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - + //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVNestedMessageMessageValue : public LVMessageValue From bfb4ddb63a66ddf3800b60704d4c44d6ab2ff083 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Mon, 30 Oct 2023 08:22:23 +0530 Subject: [PATCH 10/43] Fixed int64 bug --- src/lv_message.cc | 2 +- src/lv_message_value.cc | 4 ++-- src/message_value.h | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index 17a4c680..4f29c535 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -296,7 +296,7 @@ namespace grpc_labview if (_use_hardcoded_parse) { SinglePassMessageParser parser(*this); - parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { if (fieldInfo.isRepeated) diff --git a/src/lv_message_value.cc b/src/lv_message_value.cc index 34eb9c09..f41ea572 100644 --- a/src/lv_message_value.cc +++ b/src/lv_message_value.cc @@ -255,11 +255,11 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVVariableMessageValue::LVVariableMessageValue(int protobufId, int64_t value) : + /*LVVariableMessageValue::LVVariableMessageValue(int protobufId, int64_t value) : LVMessageValue(protobufId), _value(value) { - } + }*/ //--------------------------------------------------------------------- //--------------------------------------------------------------------- diff --git a/src/message_value.h b/src/message_value.h index 5384417a..f8e990bc 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -56,16 +56,15 @@ namespace grpc_labview _value(value) { } + public: T _value; - public: void* RawValue() override { return &_value; }; size_t ByteSizeLong() override; google::protobuf::uint8* Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override; }; - //--------------------------------------------------------------------- //--------------------------------------------------------------------- class LVNestedMessageMessageValue : public LVMessageValue From d574c459e3c6bc78a96601ec9a04c2e40ec1c661 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Mon, 30 Oct 2023 11:34:46 +0530 Subject: [PATCH 11/43] Fixed labview server crash --- src/lv_message.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index 4f29c535..0177096e 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -112,6 +112,12 @@ namespace grpc_labview { auto fieldInfo = (*fieldIt).second; LVMessageMetadataType dataType = fieldInfo->type; + if (_LVClusterHandle.get() == nullptr) { + _use_hardcoded_parse = false; + } + else { + _use_hardcoded_parse = true; + } switch (dataType) { case LVMessageMetadataType::Int32Value: @@ -187,7 +193,6 @@ namespace grpc_labview const char *LVMessage::ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } From 5500fe65c06b65109b78e95334a58c7d476e657c Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Thu, 2 Nov 2023 03:35:44 +0530 Subject: [PATCH 12/43] Included all repeated datatypes in the template as well --- src/lv_message.cc | 44 +++++++------- src/lv_message.h | 149 ++++++++++++++++++---------------------------- 2 files changed, 81 insertions(+), 112 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index 0177096e..1798cd7d 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -193,7 +193,7 @@ namespace grpc_labview const char *LVMessage::ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); + grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else{ @@ -220,7 +220,7 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - grpc_labview::SinglePassMessageParser parser(*this); + grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { @@ -247,7 +247,7 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - SinglePassMessageParser parser(*this); + SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { @@ -273,8 +273,8 @@ namespace grpc_labview const char *LVMessage::ParseEnum(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - /* grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "enum"); } else{ if (fieldInfo.isRepeated) @@ -300,7 +300,7 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - SinglePassMessageParser parser(*this); + SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { @@ -327,7 +327,7 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - grpc_labview::SinglePassMessageParser parser(*this); + grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else { @@ -353,7 +353,7 @@ namespace grpc_labview const char *LVMessage::ParseFloat(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); + grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else{ @@ -379,7 +379,7 @@ namespace grpc_labview const char *LVMessage::ParseDouble(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); + grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); } else{ @@ -472,8 +472,8 @@ namespace grpc_labview const char* LVMessage::ParseSInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - //grpc_labview::SinglePassMessageParser parser(*this); - //ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "sint32"); } else{ if (fieldInfo.isRepeated) @@ -498,8 +498,8 @@ namespace grpc_labview const char* LVMessage::ParseSInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - /*grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "sint64"); } else{ if (fieldInfo.isRepeated) @@ -524,8 +524,8 @@ namespace grpc_labview const char* LVMessage::ParseFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - /*grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "fixed32"); } else{ if (fieldInfo.isRepeated) @@ -551,8 +551,8 @@ namespace grpc_labview const char* LVMessage::ParseFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - /*grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "fixed64"); } else{ if (fieldInfo.isRepeated) @@ -577,13 +577,13 @@ namespace grpc_labview const char* LVMessage::ParseSFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - /*grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "sfixed32"); } else{ if (fieldInfo.isRepeated) { - auto v = std::make_shared(index); + auto v = std::make_shared(index); ptr = PackedSFixed32Parser(&(v->_value), ptr, ctx); _values.emplace(index, v); } @@ -603,8 +603,8 @@ namespace grpc_labview const char* LVMessage::ParseSFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - /* grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ + grpc_labview::SinglePassMessageParser parser(*this); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "sfixed64"); } else{ if (fieldInfo.isRepeated) diff --git a/src/lv_message.h b/src/lv_message.h index e62261a4..4e38091b 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -89,7 +89,7 @@ namespace grpc_labview bool ExpectTag(google::protobuf::uint32 tag, const char* ptr); }; - template + template class SinglePassMessageParser { private: LVMessage& _message; @@ -98,25 +98,45 @@ namespace grpc_labview SinglePassMessageParser(LVMessage& message) : _message(message) {} // Parse and copy message in a single pass. - const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { + const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx, const std::string type="") { if (fieldInfo.isRepeated) { // Read the repeated elements into a temporary vector - uint64_t numElements; - auto v = std::make_shared>(index); - ptr = PackedMessageType(ptr, ctx, index, &(v->_value)); - numElements = v->_value.size(); - // get the LVClusterHandle - auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; - - // copy into LVCluster - if (numElements != 0) - { - NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(start)), numElements); - auto array = *(LV1DArrayHandle*)start; - (*array)->cnt = numElements; - auto byteCount = numElements * sizeof(MessageType); - std::memcpy((*array)->bytes(), v->_value.data(), byteCount); + + if (type == "enum") { + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + } + else if (type == "sint32") { + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + } + else if (type == "sint64") { + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + } + else if (type == "fixed32") { + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + + } + else if (type == "fixed64") { + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + + } + else if (type == "sfixed32") { + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + } + else if (type == "sfixed64") { + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + + } + else { + auto v = std::make_shared>(index); + ptr = CopyRepeatedMessageToCluster>>(v, ptr, ctx, index, fieldInfo); } } else @@ -127,85 +147,34 @@ namespace grpc_labview return ptr; } + template + const char* CopyRepeatedMessageToCluster(RepeatedMessageType v, const char *ptr, ParseContext* ctx, uint32_t index, MessageElementMetadata fieldInfo) { + uint64_t numElements; + ptr = PackedMessageType(ptr, ctx, index, reinterpret_cast*>(&(v->_value))); + numElements = v->_value.size(); + // get the LVClusterHandle + auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + + // copy into LVCluster + if (numElements != 0) + { + NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(start)), numElements); + auto array = *(LV1DArrayHandle*)start; + (*array)->cnt = numElements; + auto byteCount = numElements * sizeof(MessageType); + std::memcpy((*array)->bytes(), v->_value.data(), byteCount); + } + return ptr; + } + const char* ReadMessageType(const char* ptr, MessageType* lv_ptr) { - return nullptr; + return ReadFunc(ptr, lv_ptr); } const char* PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) { - return nullptr; + return PackedFunc(value, ptr, ctx); } }; - - const char* SinglePassMessageParser::ReadMessageType(const char* ptr, int32_t* lv_ptr) - { - return ReadINT32(ptr, lv_ptr); - } - - const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) - { - return PackedInt32Parser(value, ptr, ctx); - } - - const char* SinglePassMessageParser::ReadMessageType(const char* ptr, uint32_t* lv_ptr) - { - return ReadUINT32(ptr, lv_ptr); - } - - const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) - { - return PackedUInt32Parser(value, ptr, ctx); - } - - const char* SinglePassMessageParser::ReadMessageType(const char* ptr, int64_t* lv_ptr) - { - return ReadINT64(ptr, lv_ptr); - } - - const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) - { - return PackedInt64Parser(value, ptr, ctx); - } - - const char* SinglePassMessageParser::ReadMessageType(const char* ptr, uint64_t* lv_ptr) - { - return ReadUINT64(ptr, lv_ptr); - } - - const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) - { - return PackedUInt64Parser(value, ptr, ctx); - } - - const char* SinglePassMessageParser::ReadMessageType(const char* ptr, bool* lv_ptr) - { - return ReadBOOL(ptr, lv_ptr); - } - - const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) - { - return PackedBoolParser(value, ptr, ctx); - } - - const char* SinglePassMessageParser::ReadMessageType(const char* ptr, float* lv_ptr) - { - return ReadFLOAT(ptr, lv_ptr); - } - - const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) - { - return PackedFloatParser(value, ptr, ctx); - } - - const char* SinglePassMessageParser::ReadMessageType(const char* ptr, double* lv_ptr) - { - return ReadDOUBLE(ptr, lv_ptr); - } - - const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) - { - return PackedDoubleParser(value, ptr, ctx); - } - } From 76472666946d07d3dc9fb0e715522d809105cdf7 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Thu, 2 Nov 2023 03:40:28 +0530 Subject: [PATCH 13/43] Using same old parsing method for strings --- src/lv_message.cc | 57 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index 1798cd7d..dcba51fb 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -408,41 +408,40 @@ namespace grpc_labview /* grpc_labview::SinglePassMessageParser parser(*this); ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ } - else{ - - } - if (fieldInfo.isRepeated) - { - std::shared_ptr> v; - auto it = _values.find(index); - if (it == _values.end()) + else { + if (fieldInfo.isRepeated) { - v = std::make_shared>(index); - _values.emplace(index, v); + std::shared_ptr> v; + auto it = _values.find(index); + if (it == _values.end()) + { + v = std::make_shared>(index); + _values.emplace(index, v); + } + else + { + v = std::static_pointer_cast>((*it).second); + } + ptr -= 1; + do { + ptr += 1; + auto str = v->_value.Add(); + ptr = InlineGreedyStringParser(str, ptr, ctx); + if (!ctx->DataAvailable(ptr)) + { + break; + } + } while (ExpectTag(tag, ptr)); } else { - v = std::static_pointer_cast>((*it).second); + auto str = std::string(); + ptr = InlineGreedyStringParser(&str, ptr, ctx); + auto v = std::make_shared(index, str); + _values.emplace(index, v); } - ptr -= 1; - do { - ptr += 1; - auto str = v->_value.Add(); - ptr = InlineGreedyStringParser(str, ptr, ctx); - if (!ctx->DataAvailable(ptr)) - { - break; - } - } while (ExpectTag(tag, ptr)); + return ptr; } - else - { - auto str = std::string(); - ptr = InlineGreedyStringParser(&str, ptr, ctx); - auto v = std::make_shared(index, str); - _values.emplace(index, v); - } - return ptr; } //--------------------------------------------------------------------- From aaee3cb8efd5585d719f9de5bc44fd5eca11e4c1 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Thu, 2 Nov 2023 03:42:05 +0530 Subject: [PATCH 14/43] fixed string parsing to return ptr --- src/lv_message.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index dcba51fb..afdf8575 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -440,8 +440,8 @@ namespace grpc_labview auto v = std::make_shared(index, str); _values.emplace(index, v); } - return ptr; } + return ptr; } //--------------------------------------------------------------------- From cc61d1a2ef7d5503bfa7966376e2f1e71c6cd6e0 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Thu, 2 Nov 2023 16:57:03 +0530 Subject: [PATCH 15/43] parse using google::protobuf::RepeatedField _repeatedMessageValues --- CMakeLists.txt | 4 ++ src/grpc_client.cc | 28 ++++++----- src/lv_interop.cc | 3 +- src/lv_interop.h | 2 + src/lv_message.cc | 121 +++++++++++++++++++++++++++++++++++---------- src/lv_message.h | 33 +++++++++---- 6 files changed, 142 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58a795ea..5c5a5e27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,10 @@ else() add_definitions(-D_WIN32_WINNT=0x600) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4244") + add_compile_options("$<$>:/Zi>") + add_link_options("$<$>:/DEBUG>") + add_link_options("$<$>:/OPT:REF>") + add_link_options("$<$>:/OPT:ICF>") endif() find_package(Threads REQUIRED) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 787dac5f..cf43fd7a 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -13,6 +13,8 @@ namespace grpc_labview { + extern bool g_use_hardcoded_parse; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- LabVIEWgRPCClient::LabVIEWgRPCClient() @@ -357,18 +359,20 @@ LIBRARY_EXPORT int32_t CompleteClientUnaryCall2( int32_t result = 0; if (call->_status.ok()) { - // try - // { - // grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); - // } - // catch (grpc_labview::InvalidEnumValueException& e) - // { - // if (errorMessage != nullptr) - // { - // grpc_labview::SetLVString(errorMessage, e.what()); - // } - // return e.code; - // } + if (grpc_labview::g_use_hardcoded_parse) { + try + { + grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + } + catch (grpc_labview::InvalidEnumValueException& e) + { + if (errorMessage != nullptr) + { + grpc_labview::SetLVString(errorMessage, e.what()); + } + return e.code; + } + } } else { diff --git a/src/lv_interop.cc b/src/lv_interop.cc index 1567eb71..29308db3 100644 --- a/src/lv_interop.cc +++ b/src/lv_interop.cc @@ -54,7 +54,8 @@ namespace grpc_labview { lvModule = GetModuleHandle("lvrt.dll"); } - NumericArrayResizeImp = (NumericArrayResize_T)GetProcAddress(lvModule, "NumericArrayResize"); + //NumericArrayResizeImp = (NumericArrayResize_T)GetProcAddress(lvModule, "NumericArrayResize"); + NumericArrayResizeImp = (NumericArrayResize_T)GetProcAddress(lvModule, "NumericArrayResizeNoInit"); PostLVUserEvent = (PostLVUserEvent_T)GetProcAddress(lvModule, "PostLVUserEvent"); Occur = (Occur_T)GetProcAddress(lvModule, "Occur"); RTSetCleanupProc = (RTSetCleanupProc_T)GetProcAddress(lvModule, "RTSetCleanupProc"); diff --git a/src/lv_interop.h b/src/lv_interop.h index e5b7e6d8..80b0398a 100644 --- a/src/lv_interop.h +++ b/src/lv_interop.h @@ -25,6 +25,8 @@ namespace grpc_labview { + extern bool g_use_hardcoded_parse; + class gRPCid; extern PointerManager gPointerManager; diff --git a/src/lv_message.cc b/src/lv_message.cc index e8ba9189..6fcd0015 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -2,6 +2,8 @@ //--------------------------------------------------------------------- #include #include +#include +#include //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -9,10 +11,12 @@ using namespace google::protobuf::internal; namespace grpc_labview { + bool g_use_hardcoded_parse = true; + //--------------------------------------------------------------------- //--------------------------------------------------------------------- LVMessage::LVMessage(std::shared_ptr metadata) : - _metadata(metadata), _use_hardcoded_parse(true), _skipCopyOnFirstParse(false) + _metadata(metadata), _use_hardcoded_parse(g_use_hardcoded_parse), _skipCopyOnFirstParse(false) { } @@ -566,54 +570,119 @@ namespace grpc_labview auto metadata = fieldInfo._owner->FindMetadata(fieldInfo.embeddedMessageName); if (_use_hardcoded_parse) { - const char* lv_ptr = (*(this->getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + const char* lv_ptr = (this->getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + LVMessage nestedMessage(metadata); if (fieldInfo.isRepeated){ // start with numElements = 16 // if the array is not big enough, resize it to 2x the size - auto num_elements = 16; - auto element_count = 0; + auto numElements = 128; + // auto numElements = 100000; + auto elementIndex = 0; auto clusterSize = metadata->clusterSize; auto alignment = metadata->alignmentRequirement; - NumericArrayResize(0x08, 1, (void**)lv_ptr, num_elements * clusterSize); - auto array = *(LV1DArrayHandle*)lv_ptr; - (*array)->cnt = num_elements; - + auto arraySize = numElements * clusterSize; + LV1DArrayHandle array; + // NumericArrayResize(0x08, 1, (void**)lv_ptr, arraySize); + // array = *(LV1DArrayHandle*)lv_ptr; + // (*array)->cnt = arraySize; + // We need to divide arraySize by 8 as we are allocating + // numElements * message_size of 8 byte elements. + // Element size of typecode 0x08 is 8 bytes. + + char _fillData = '\0'; + + auto _continueFromIndex = _repeatedField_continueIndex.find(metadata->messageName); + if (_continueFromIndex != _repeatedField_continueIndex.end()) { + elementIndex = _continueFromIndex->second; + _repeatedField_continueIndex.erase(_continueFromIndex); + // find next largest power of 2, as we assume that we previously resized it to a power of 2 + numElements = 1 << (int)ceil(log2(elementIndex)); + } + else { + _repeatedMessageValues.Resize(arraySize, _fillData); + } + auto _vectorPtr = _repeatedMessageValues.data(); + + protobuf_ptr -= 1; do { - protobuf_ptr = element_count ? protobuf_ptr + 1 : protobuf_ptr; - auto nestedMessage = std::make_shared(metadata); - - if (element_count * clusterSize >= num_elements) { - num_elements *= 2; - NumericArrayResize(0x08, 1, (void**)lv_ptr, num_elements * clusterSize); - array = *(LV1DArrayHandle*)lv_ptr; - (*array)->cnt = num_elements; + protobuf_ptr += 1; + //protobuf_ptr = elementIndex ? protobuf_ptr + 1 : protobuf_ptr; + //auto nestedMessage = std::make_shared(metadata); + + if (elementIndex >= numElements - 1) { + //std::string d_message = "elementIndex = " + std::to_string(elementIndex); + //d_message += " numElements = " + std::to_string(numElements); + ////d_message += "\nChanging numElements to = " + std::to_string(numElements*2); + //d_message += "\nChanging numElements to = " + std::to_string(numElements+1); + //std::ostringstream ss1; + //ss1 << std::hex << std::showbase << reinterpret_cast((void*)(*array)); + //d_message += "\nOld Array pointer = " + ss1.str() + "\n"; + //OutputDebugStringA(d_message.c_str()); + numElements *= 2; + //numElements += 1; + arraySize = numElements * clusterSize; + //NumericArrayResize(0x08, 1, (void**)lv_ptr, arraySize); + //array = *(LV1DArrayHandle*)lv_ptr; + //(*array)->cnt = arraySize; + // + //// print array pointer in hex + //std::ostringstream ss2; + //ss2 << std::hex << std::showbase << reinterpret_cast((void*)(*array)); + //d_message = "New Array pointer = " + ss2.str() + "\n"; + //OutputDebugStringA(d_message.c_str()); + + auto s = _repeatedMessageValues.size(); + _repeatedMessageValues.Resize(arraySize, _fillData); } - auto lv_elem_ptr = (LVCluster**)(*array)->bytes(element_count * clusterSize, alignment); - nestedMessage->setLVClusterHandle(reinterpret_cast(lv_elem_ptr)); - protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); + /*auto lv_elem_ptr = (LVCluster**)(*array)->bytes(elementIndex * clusterSize, alignment); + nestedMessage.setLVClusterHandle(reinterpret_cast(lv_elem_ptr)); + protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr);*/ + + /* initialize vector _repeatedMessageValues element with 0s + std::vector chunk(clusterSize, '0'); + this->_repeatedMessageValues.emplace_back(chunk);*/ - element_count++; + auto _vectorPtr = _repeatedMessageValues.data(); + _vectorPtr = _vectorPtr + (elementIndex * clusterSize); + nestedMessage.setLVClusterHandle(_vectorPtr); + protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); + auto s = _repeatedMessageValues.size(); + elementIndex++; + + //Sleep(100); if (!ctx->DataAvailable(protobuf_ptr)){ + /*std::string d_message = "Data unavailable! Send help...\n"; + OutputDebugStringA(d_message.c_str());*/ break; } } while (ExpectTag(tag, protobuf_ptr)); + /*std::cout << "Element Index while parsing repeated: " << elementIndex; + std::string d_message = "Element Index while parsing repeated: " + std::to_string(elementIndex) + "\n"; + OutputDebugStringA(d_message.c_str());*/ + // shrink the array to the correct size - NumericArrayResize(0x08, 1, (void**)lv_ptr, (element_count - 1) * clusterSize); + // elementIndex = this->_repeatedMessageValues.size(); + arraySize = elementIndex * clusterSize; + NumericArrayResize(0x08, 1, (void**)lv_ptr, arraySize); array = *(LV1DArrayHandle*)lv_ptr; - (*array)->cnt = element_count; + (*array)->cnt = elementIndex; + + auto _vectorDataPtr = _repeatedMessageValues.data(); + auto _lvArrayDataPtr = (*array)->bytes(0, alignment); + memcpy(_lvArrayDataPtr, _vectorDataPtr, arraySize); + + _repeatedField_continueIndex.emplace(metadata->messageName, elementIndex); } else { - auto nestedMessage = std::make_shared(metadata); - auto val_ptr = lv_ptr + fieldInfo.clusterOffset; - nestedMessage->setLVClusterHandle(val_ptr); - protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); + nestedMessage.setLVClusterHandle(lv_ptr); + protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); } } else { diff --git a/src/lv_message.h b/src/lv_message.h index 3a8f38dc..c9c29bf1 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -51,23 +51,26 @@ namespace grpc_labview public: std::map> _values; std::shared_ptr _metadata; + std::unordered_map _repeatedField_continueIndex; + // std::vector _messageValues; - // std::vector<> _repeatedMessageValues; + //std::vector _repeatedMessageValues; + google::protobuf::RepeatedField _repeatedMessageValues; bool _use_hardcoded_parse; bool _skipCopyOnFirstParse; void setLVClusterHandle(const char* lvClusterHandle) { - _LVClusterHandle = std::make_shared(lvClusterHandle); + _LVClusterHandle = lvClusterHandle; }; - std::shared_ptr getLVClusterHandleSharedPtr() { + const char* getLVClusterHandleSharedPtr() { return _LVClusterHandle; }; private: mutable google::protobuf::internal::CachedSize _cached_size_; google::protobuf::UnknownFieldSet _unknownFields; - std::shared_ptr _LVClusterHandle; + const char* _LVClusterHandle; const char *ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); const char *ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); @@ -99,6 +102,9 @@ namespace grpc_labview // Parse and copy message in a single pass. const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { + // get the LVClusterHandle + auto _lv_ptr = reinterpret_cast(_message.getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + if (fieldInfo.isRepeated) { // Read the repeated elements into a temporary vector @@ -106,14 +112,12 @@ namespace grpc_labview auto v = std::make_shared>(index); ptr = PackedMessageType(ptr, ctx, index, &(v->_value)); numElements = v->_value.size(); - // get the LVClusterHandle - auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; - + // copy into LVCluster if (numElements != 0) { - NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(start)), numElements); - auto array = *(LV1DArrayHandle*)start; + NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(_lv_ptr)), numElements); + auto array = *(LV1DArrayHandle*)_lv_ptr; (*array)->cnt = numElements; auto byteCount = numElements * sizeof(MessageType); std::memcpy((*array)->bytes(), v->_value.data(), byteCount); @@ -121,7 +125,6 @@ namespace grpc_labview } else { - auto _lv_ptr = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; ptr = ReadMessageType(ptr, reinterpret_cast(const_cast(_lv_ptr))); } return ptr; @@ -148,6 +151,16 @@ namespace grpc_labview return PackedInt32Parser(value, ptr, ctx); } + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, uint32_t* lv_ptr) + { + return ReadUINT32(ptr, lv_ptr); + } + + const char* SinglePassMessageParser::PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) + { + return PackedUInt32Parser(value, ptr, ctx); + } + const char* SinglePassMessageParser::ReadMessageType(const char* ptr, uint64_t* lv_ptr) { return ReadUINT64(ptr, lv_ptr); From 566274f95f590adb56dd426e52f0ce96f1e44039 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Mon, 6 Nov 2023 05:55:25 +0530 Subject: [PATCH 16/43] Added enum class for data types --- src/lv_message.cc | 14 ++++---- src/lv_message.h | 84 ++++++++++++++++++++++++++------------------- src/message_value.h | 19 ++++++++++ 3 files changed, 74 insertions(+), 43 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index afdf8575..b26aeab2 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -274,7 +274,7 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "enum"); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::ENUM); } else{ if (fieldInfo.isRepeated) @@ -472,7 +472,7 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "sint32"); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::SINT32); } else{ if (fieldInfo.isRepeated) @@ -498,7 +498,7 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "sint64"); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::SINT64); } else{ if (fieldInfo.isRepeated) @@ -524,7 +524,7 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "fixed32"); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::FIXED32); } else{ if (fieldInfo.isRepeated) @@ -551,7 +551,7 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "fixed64"); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::FIXED64); } else{ if (fieldInfo.isRepeated) @@ -577,7 +577,7 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "sfixed32"); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::SFIXED32); } else{ if (fieldInfo.isRepeated) @@ -603,7 +603,7 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, "sfixed64"); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::SFIXED64); } else{ if (fieldInfo.isRepeated) diff --git a/src/lv_message.h b/src/lv_message.h index 4e38091b..01982542 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -98,45 +98,57 @@ namespace grpc_labview SinglePassMessageParser(LVMessage& message) : _message(message) {} // Parse and copy message in a single pass. - const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx, const std::string type="") { + const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx, const LVMessageType type=LVMessageType::DEFAULT) { if (fieldInfo.isRepeated) { // Read the repeated elements into a temporary vector - - if (type == "enum") { - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - } - else if (type == "sint32") { - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - } - else if (type == "sint64") { - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - } - else if (type == "fixed32") { - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - - } - else if (type == "fixed64") { - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - - } - else if (type == "sfixed32") { - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - } - else if (type == "sfixed64") { - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - - } - else { - auto v = std::make_shared>(index); - ptr = CopyRepeatedMessageToCluster>>(v, ptr, ctx, index, fieldInfo); + switch (type) { + case LVMessageType::ENUM:{ + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + break; + } + + case LVMessageType::SINT32:{ + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + break; + } + + case LVMessageType::SINT64:{ + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + break; + } + + case LVMessageType::FIXED32:{ + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + break; + } + + case LVMessageType::FIXED64:{ + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + break; + } + + case LVMessageType::SFIXED32:{ + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + break; + } + + case LVMessageType::SFIXED64:{ + auto v = std::make_shared(index); + ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); + break; + } + + case LVMessageType::DEFAULT:{ + auto v = std::make_shared>(index); + ptr = CopyRepeatedMessageToCluster>>(v, ptr, ctx, index, fieldInfo); + } } } else diff --git a/src/message_value.h b/src/message_value.h index f8e990bc..459b2648 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -8,6 +8,25 @@ namespace grpc_labview //--------------------------------------------------------------------- class LVMessage; + enum class LVMessageType { + INT32 = 0, + INT64 = 1, + UINT32 = 2, + UINT64 = 3, + FLOAT = 4, + DOUBLE = 5, + BOOL = 6, + STRING = 7, + BYTES = 8, + ENUM = 9, + SINT32 = 10, + SINT64 = 11, + FIXED32 = 12, + FIXED64 = 13, + SFIXED32 = 14, + SFIXED64 = 15, + DEFAULT = 100, + }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- From c14f921fcc290db7db1d2c3236a2f1cdf2270842 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Mon, 6 Nov 2023 16:50:29 +0530 Subject: [PATCH 17/43] using grpc repeatedField as vectors --- src/lv_interop.cc | 31 ++++++++++++++++ src/lv_interop.h | 3 ++ src/lv_message.cc | 93 +++++++++++++++-------------------------------- src/lv_message.h | 3 +- 4 files changed, 64 insertions(+), 66 deletions(-) diff --git a/src/lv_interop.cc b/src/lv_interop.cc index 29308db3..6dfa5306 100644 --- a/src/lv_interop.cc +++ b/src/lv_interop.cc @@ -22,6 +22,10 @@ typedef int (*NumericArrayResize_T)(int32_t, int32_t, void* handle, size_t size) typedef int (*PostLVUserEvent_T)(grpc_labview::LVUserEventRef ref, void *data); typedef int (*Occur_T)(grpc_labview::MagicCookie occurrence); typedef int32_t(*RTSetCleanupProc_T)(grpc_labview::CleanupProcPtr cleanUpProc, grpc_labview::gRPCid* id, int32_t mode); +typedef unsigned char** (*DSNewHandlePtr_T)(size_t); +typedef int (*DSSetHandleSize_T)(void* h, size_t); +typedef long (*DSDisposeHandle_T)(void* h); + //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -29,6 +33,9 @@ static NumericArrayResize_T NumericArrayResizeImp = nullptr; static PostLVUserEvent_T PostLVUserEvent = nullptr; static Occur_T Occur = nullptr; static RTSetCleanupProc_T RTSetCleanupProc = nullptr; +static DSNewHandlePtr_T DSNewHandleImpl = nullptr; +static DSSetHandleSize_T DSSetHandleSizeImpl = nullptr; +static DSDisposeHandle_T DSDisposeHandleImpl = nullptr; namespace grpc_labview { @@ -59,6 +66,9 @@ namespace grpc_labview PostLVUserEvent = (PostLVUserEvent_T)GetProcAddress(lvModule, "PostLVUserEvent"); Occur = (Occur_T)GetProcAddress(lvModule, "Occur"); RTSetCleanupProc = (RTSetCleanupProc_T)GetProcAddress(lvModule, "RTSetCleanupProc"); + DSNewHandleImpl = (DSNewHandlePtr_T)GetProcAddress(lvModule, "DSNewHandle"); + DSSetHandleSizeImpl = (DSSetHandleSize_T)GetProcAddress(lvModule, "DSSetHandleSize"); + DSDisposeHandleImpl = (DSDisposeHandle_T)GetProcAddress(lvModule, "DSDisposeHandle"); } #else @@ -109,6 +119,27 @@ namespace grpc_labview return PostLVUserEvent(ref, data); } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + unsigned char** DSNewHandle(size_t n) + { + return DSNewHandleImpl(n); + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + int DSSetHandleSize(void* h, size_t n) + { + return DSSetHandleSizeImpl(h, n); + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + long DSDisposeHandle(void* h) + { + return DSDisposeHandleImpl(h); + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- void SetLVString(LStrHandle* lvString, std::string str) diff --git a/src/lv_interop.h b/src/lv_interop.h index 80b0398a..8d676346 100644 --- a/src/lv_interop.h +++ b/src/lv_interop.h @@ -116,6 +116,9 @@ namespace grpc_labview std::string GetLVString(LStrHandle lvString); int NumericArrayResize(int32_t typeCode, int32_t numDims, void* handle, size_t size); int PostUserEvent(LVUserEventRef ref, void *data); + unsigned char** DSNewHandle(size_t n); + int DSSetHandleSize(void* h, size_t n); + long DSDisposeHandle(void* h); int SignalOccurrence(MagicCookie occurrence); int32_t RegisterCleanupProc(CleanupProcPtr cleanUpProc, grpc_labview::gRPCid* id); int32_t DeregisterCleanupProc(CleanupProcPtr cleanUpProc, grpc_labview::gRPCid* id); diff --git a/src/lv_message.cc b/src/lv_message.cc index 6fcd0015..e123894d 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -573,109 +573,74 @@ namespace grpc_labview const char* lv_ptr = (this->getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; LVMessage nestedMessage(metadata); - if (fieldInfo.isRepeated){ - // start with numElements = 16 + if (fieldInfo.isRepeated) { // if the array is not big enough, resize it to 2x the size auto numElements = 128; - // auto numElements = 100000; auto elementIndex = 0; - auto clusterSize = metadata->clusterSize; auto alignment = metadata->alignmentRequirement; - auto arraySize = numElements * clusterSize; - LV1DArrayHandle array; - // NumericArrayResize(0x08, 1, (void**)lv_ptr, arraySize); - // array = *(LV1DArrayHandle*)lv_ptr; - // (*array)->cnt = arraySize; - // We need to divide arraySize by 8 as we are allocating - // numElements * message_size of 8 byte elements. - // Element size of typecode 0x08 is 8 bytes. - + LV1DArrayHandle arrayHandle; char _fillData = '\0'; + // Get the _repeatedMessageValues vector from the map + auto _repeatedMessageValuesIt = _repeatedMessageValuesMap.find(metadata->messageName); + if (_repeatedMessageValuesIt == _repeatedMessageValuesMap.end()) + { + _repeatedMessageValuesIt = _repeatedMessageValuesMap.emplace(metadata->messageName, google::protobuf::RepeatedField()).first; + } + + // There are situations where the protobuf message is not complete, and we need to continue from the last index. + // This function returns to _internalParse, and then gets back to this function. + // If we are continuing from a previous parse, then we need to continue from the last index auto _continueFromIndex = _repeatedField_continueIndex.find(metadata->messageName); if (_continueFromIndex != _repeatedField_continueIndex.end()) { elementIndex = _continueFromIndex->second; _repeatedField_continueIndex.erase(_continueFromIndex); // find next largest power of 2, as we assume that we previously resized it to a power of 2 - numElements = 1 << (int)ceil(log2(elementIndex)); + auto _size = (int)ceil(log2(elementIndex)); + numElements = ((1 << _size) > 128) ? (1 << _size) : 128; } else { - _repeatedMessageValues.Resize(arraySize, _fillData); + // occurs on the first time this function is called + _repeatedMessageValuesIt->second.Resize(arraySize, _fillData); } - auto _vectorPtr = _repeatedMessageValues.data(); protobuf_ptr -= 1; do { protobuf_ptr += 1; - //protobuf_ptr = elementIndex ? protobuf_ptr + 1 : protobuf_ptr; - //auto nestedMessage = std::make_shared(metadata); + // Resize the vector if we need more memory if (elementIndex >= numElements - 1) { - //std::string d_message = "elementIndex = " + std::to_string(elementIndex); - //d_message += " numElements = " + std::to_string(numElements); - ////d_message += "\nChanging numElements to = " + std::to_string(numElements*2); - //d_message += "\nChanging numElements to = " + std::to_string(numElements+1); - //std::ostringstream ss1; - //ss1 << std::hex << std::showbase << reinterpret_cast((void*)(*array)); - //d_message += "\nOld Array pointer = " + ss1.str() + "\n"; - //OutputDebugStringA(d_message.c_str()); numElements *= 2; - //numElements += 1; arraySize = numElements * clusterSize; - //NumericArrayResize(0x08, 1, (void**)lv_ptr, arraySize); - //array = *(LV1DArrayHandle*)lv_ptr; - //(*array)->cnt = arraySize; - // - //// print array pointer in hex - //std::ostringstream ss2; - //ss2 << std::hex << std::showbase << reinterpret_cast((void*)(*array)); - //d_message = "New Array pointer = " + ss2.str() + "\n"; - //OutputDebugStringA(d_message.c_str()); - - auto s = _repeatedMessageValues.size(); - _repeatedMessageValues.Resize(arraySize, _fillData); + auto s = _repeatedMessageValuesIt->second.size(); + _repeatedMessageValuesIt->second.Resize(arraySize, _fillData); } - /*auto lv_elem_ptr = (LVCluster**)(*array)->bytes(elementIndex * clusterSize, alignment); - nestedMessage.setLVClusterHandle(reinterpret_cast(lv_elem_ptr)); - protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr);*/ - - /* initialize vector _repeatedMessageValues element with 0s - std::vector chunk(clusterSize, '0'); - this->_repeatedMessageValues.emplace_back(chunk);*/ - - auto _vectorPtr = _repeatedMessageValues.data(); + auto _vectorPtr = _repeatedMessageValuesIt->second.data(); _vectorPtr = _vectorPtr + (elementIndex * clusterSize); nestedMessage.setLVClusterHandle(_vectorPtr); protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); - auto s = _repeatedMessageValues.size(); elementIndex++; - //Sleep(100); - if (!ctx->DataAvailable(protobuf_ptr)){ - /*std::string d_message = "Data unavailable! Send help...\n"; - OutputDebugStringA(d_message.c_str());*/ + if (!ctx->DataAvailable(protobuf_ptr)) { break; } } while (ExpectTag(tag, protobuf_ptr)); - /*std::cout << "Element Index while parsing repeated: " << elementIndex; - std::string d_message = "Element Index while parsing repeated: " + std::to_string(elementIndex) + "\n"; - OutputDebugStringA(d_message.c_str());*/ - // shrink the array to the correct size - // elementIndex = this->_repeatedMessageValues.size(); arraySize = elementIndex * clusterSize; - NumericArrayResize(0x08, 1, (void**)lv_ptr, arraySize); - array = *(LV1DArrayHandle*)lv_ptr; - (*array)->cnt = elementIndex; - - auto _vectorDataPtr = _repeatedMessageValues.data(); - auto _lvArrayDataPtr = (*array)->bytes(0, alignment); + auto old_arrayHandle = *(void**)lv_ptr; + DSDisposeHandle(old_arrayHandle); + *(void**)lv_ptr = DSNewHandle(arraySize); + arrayHandle = *(LV1DArrayHandle*)lv_ptr; + (*arrayHandle)->cnt = elementIndex; + + auto _vectorDataPtr = _repeatedMessageValuesIt->second.data(); + auto _lvArrayDataPtr = (*arrayHandle)->bytes(0, alignment); memcpy(_lvArrayDataPtr, _vectorDataPtr, arraySize); _repeatedField_continueIndex.emplace(metadata->messageName, elementIndex); diff --git a/src/lv_message.h b/src/lv_message.h index c9c29bf1..ac0946bf 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -52,10 +52,9 @@ namespace grpc_labview std::map> _values; std::shared_ptr _metadata; std::unordered_map _repeatedField_continueIndex; - + std::unordered_map> _repeatedMessageValuesMap; // std::vector _messageValues; //std::vector _repeatedMessageValues; - google::protobuf::RepeatedField _repeatedMessageValues; bool _use_hardcoded_parse; bool _skipCopyOnFirstParse; From 6304aab27e3a29a28375126644d97081a170409b Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Thu, 9 Nov 2023 03:36:09 +0530 Subject: [PATCH 18/43] Removed case structure and extra comparision overhead --- src/lv_message.cc | 98 +++++++++++++++++++++++++---------------------- src/lv_message.h | 85 ++++++++-------------------------------- 2 files changed, 69 insertions(+), 114 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index b26aeab2..e2d575e9 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -194,7 +194,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -221,7 +222,8 @@ namespace grpc_labview if (_use_hardcoded_parse) { grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else { if (fieldInfo.isRepeated) @@ -248,7 +250,8 @@ namespace grpc_labview if (_use_hardcoded_parse) { SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else { if (fieldInfo.isRepeated) @@ -274,7 +277,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::ENUM); + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -301,7 +305,8 @@ namespace grpc_labview if (_use_hardcoded_parse) { SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else { if (fieldInfo.isRepeated) @@ -328,7 +333,8 @@ namespace grpc_labview if (_use_hardcoded_parse) { grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else { if (fieldInfo.isRepeated) @@ -354,7 +360,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -380,7 +387,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx); + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -404,42 +412,36 @@ namespace grpc_labview //--------------------------------------------------------------------- const char *LVMessage::ParseString(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if(_use_hardcoded_parse){ - /* grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx);*/ - } - else { - if (fieldInfo.isRepeated) + if (fieldInfo.isRepeated) + { + std::shared_ptr> v; + auto it = _values.find(index); + if (it == _values.end()) { - std::shared_ptr> v; - auto it = _values.find(index); - if (it == _values.end()) - { - v = std::make_shared>(index); - _values.emplace(index, v); - } - else - { - v = std::static_pointer_cast>((*it).second); - } - ptr -= 1; - do { - ptr += 1; - auto str = v->_value.Add(); - ptr = InlineGreedyStringParser(str, ptr, ctx); - if (!ctx->DataAvailable(ptr)) - { - break; - } - } while (ExpectTag(tag, ptr)); + v = std::make_shared>(index); + _values.emplace(index, v); } else { - auto str = std::string(); - ptr = InlineGreedyStringParser(&str, ptr, ctx); - auto v = std::make_shared(index, str); - _values.emplace(index, v); + v = std::static_pointer_cast>((*it).second); } + ptr -= 1; + do { + ptr += 1; + auto str = v->_value.Add(); + ptr = InlineGreedyStringParser(str, ptr, ctx); + if (!ctx->DataAvailable(ptr)) + { + break; + } + } while (ExpectTag(tag, ptr)); + } + else + { + auto str = std::string(); + ptr = InlineGreedyStringParser(&str, ptr, ctx); + auto v = std::make_shared(index, str); + _values.emplace(index, v); } return ptr; } @@ -472,7 +474,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::SINT32); + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -498,7 +501,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::SINT64); + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -524,7 +528,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::FIXED32); + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -551,7 +556,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::FIXED64); + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -577,7 +583,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::SFIXED32); + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) @@ -603,7 +610,8 @@ namespace grpc_labview { if(_use_hardcoded_parse){ grpc_labview::SinglePassMessageParser parser(*this); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, LVMessageType::SFIXED64); + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); } else{ if (fieldInfo.isRepeated) diff --git a/src/lv_message.h b/src/lv_message.h index 01982542..6fda4a1a 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -98,57 +98,24 @@ namespace grpc_labview SinglePassMessageParser(LVMessage& message) : _message(message) {} // Parse and copy message in a single pass. - const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx, const LVMessageType type=LVMessageType::DEFAULT) { + template + const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx, RepeatedMessageValuePointer v, const LVMessageType type=LVMessageType::DEFAULT) { if (fieldInfo.isRepeated) { - // Read the repeated elements into a temporary vector - switch (type) { - case LVMessageType::ENUM:{ - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - break; - } - - case LVMessageType::SINT32:{ - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - break; - } - - case LVMessageType::SINT64:{ - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - break; - } - - case LVMessageType::FIXED32:{ - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - break; - } - - case LVMessageType::FIXED64:{ - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - break; - } - - case LVMessageType::SFIXED32:{ - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - break; - } - - case LVMessageType::SFIXED64:{ - auto v = std::make_shared(index); - ptr = CopyRepeatedMessageToCluster>(v, ptr, ctx, index, fieldInfo); - break; - } - - case LVMessageType::DEFAULT:{ - auto v = std::make_shared>(index); - ptr = CopyRepeatedMessageToCluster>>(v, ptr, ctx, index, fieldInfo); - } + uint64_t numElements; + ptr = PackedMessageType(ptr, ctx, index, reinterpret_cast*>(&(v->_value))); + numElements = v->_value.size(); + // get the LVClusterHandle + auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; + + // copy into LVCluster + if (numElements != 0) + { + NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(start)), numElements); + auto array = *(LV1DArrayHandle*)start; + (*array)->cnt = numElements; + auto byteCount = numElements * sizeof(MessageType); + std::memcpy((*array)->bytes(), v->_value.data(), byteCount); } } else @@ -159,26 +126,6 @@ namespace grpc_labview return ptr; } - template - const char* CopyRepeatedMessageToCluster(RepeatedMessageType v, const char *ptr, ParseContext* ctx, uint32_t index, MessageElementMetadata fieldInfo) { - uint64_t numElements; - ptr = PackedMessageType(ptr, ctx, index, reinterpret_cast*>(&(v->_value))); - numElements = v->_value.size(); - // get the LVClusterHandle - auto start = reinterpret_cast(*(_message.getLVClusterHandleSharedPtr().get())) + fieldInfo.clusterOffset; - - // copy into LVCluster - if (numElements != 0) - { - NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(start)), numElements); - auto array = *(LV1DArrayHandle*)start; - (*array)->cnt = numElements; - auto byteCount = numElements * sizeof(MessageType); - std::memcpy((*array)->bytes(), v->_value.data(), byteCount); - } - return ptr; - } - const char* ReadMessageType(const char* ptr, MessageType* lv_ptr) { return ReadFunc(ptr, lv_ptr); From ab0ea6af3782bfcd89c647639ba006abc2d85093 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Fri, 10 Nov 2023 06:01:17 +0530 Subject: [PATCH 19/43] Made changes for all streaming cases --- src/grpc_client.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 787dac5f..4997889e 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -564,11 +564,11 @@ LIBRARY_EXPORT int32_t ClientBeginBidiStreamingCall( //--------------------------------------------------------------------- //--------------------------------------------------------------------- -LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr) +LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr, int8_t* responseCluster) { auto reader = callId->CastTo(); auto call = callId->CastTo(); - + call->_response->setLVClusterHandle(reinterpret_cast(responseCluster)); auto occurrence = *occurrencePtr; if (!reader || !call) @@ -605,14 +605,14 @@ LIBRARY_EXPORT int32_t ClientCompleteReadFromStream(grpc_labview::gRPCid* callId *success = reader->_readFuture.get(); if (*success) { - try + /*try { grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); } catch (grpc_labview::InvalidEnumValueException& e) { return e.code; - } + }*/ } return 0; } @@ -672,7 +672,7 @@ LIBRARY_EXPORT int32_t FinishClientCompleteClientStreamingCall( int32_t result = 0; if (call->_status.ok()) { - try + /*try { grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); } @@ -683,7 +683,7 @@ LIBRARY_EXPORT int32_t FinishClientCompleteClientStreamingCall( { grpc_labview::SetLVString(errorMessage, e.what()); } - } + }*/ } else { @@ -706,9 +706,10 @@ LIBRARY_EXPORT int32_t FinishClientCompleteClientStreamingCall( //--------------------------------------------------------------------- //--------------------------------------------------------------------- -LIBRARY_EXPORT int32_t ClientCompleteClientStreamingCall(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr) +LIBRARY_EXPORT int32_t ClientCompleteClientStreamingCall(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr, int8_t* responseCluster) { auto call = callId->CastTo(); + call->_response->setLVClusterHandle(reinterpret_cast(responseCluster)); if (!call) { return -1; From 88903f4eee96c7a763412508c8408109cd563752 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Fri, 10 Nov 2023 12:31:54 +0530 Subject: [PATCH 20/43] Made changes to all rpc vim files --- .../Client Complete Client Streaming Call.vim | Bin 21790 -> 22366 bytes .../Client API/Client Read From Stream.vim | Bin 13420 -> 14000 bytes .../Client API/Client Unary Call.vim | Bin 20046 -> 20366 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/labview source/gRPC lv Support/Client API/Client Complete Client Streaming Call.vim b/labview source/gRPC lv Support/Client API/Client Complete Client Streaming Call.vim index a4435df466f2273633dfa866c9d86aeabf3be8bc..f3c62c884ee3f69b0925a242b34e4cda30c01bb2 100644 GIT binary patch delta 5428 zcmaKwbyQSa`^Sfna*&dc?(Xge3F($01{gYqh7mk;!vI4`suv^#bSNn$LTKdA|Fcway=V7gk`*Rbwz38X2k(5`eHCm}=@iP&PFK zfsAHBAgl-w2*h}!ThkcLjnxdiS0?NZl?qTaj?}`#hBtHIn;^ak5VN!m*a3qvLOBm|*ie4>I< zB79JBdqF;XaS<2{CMYfhvl9bhnrfPAf>6X%nmo7uDiarmO4-4L1o?!8U{ZXdq9S&D zQqY^5q%hQ8)LukPP+Z&&HHKje;QW~n`n$z1OArR5nvai{52K2^zpo$6hf&?f%i~|j z%K^q8-~!S&))2hORJaLjT-g8@cNaT(Tob>W(JvSu_N$uT-QDhAMgP4I2)OBh`+t{! zL22aT0e6S}U9SQ4ba03H-1z=&EB^o6{gr%_W` zQU5OZ3CVM&c~*5kx4_!m=f$p8R(um9`x8KAReIGCk+!Rq1%6NxZXB(07RhbG`yQGe ze6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(7I_U`Bb$p0ZlgC{DFU|rS~bpfGs+QeR=7Y z&HK3i$@eBxVE5cxf{jM{WewO)&W7tgo8!#gj2Po~p^B^Y1eS&Dhqt9&)cO{GX`3^c z^(xongElrgw6;nJ&Vhe1?ZY%}A#tBfJ02QZQJ%@B?<1}P>6RvK{t^1ZQ7mILRf zIQvO=L*5}1{e*WoPw`t{#wR8bska&TRCb3VACL{7Jgu0KEwN(ANV=M@9j+Pg5Lxt- zze8Y@IQ4OI6|(tsl{Uif&__!JQD(ey6V@X#m(V2jp-ZEWOX|ydT_wNC5qqj=8R_(` zq6tq})mE{1;!h;VZtER4zwADdflGk189u9p_`bf7_|2sX4+CUmD&&5Xy55n+)6}&T zGPW#)MHJ2d{aa}`vlt-&2&XPC^q+QqVSg#`#by7?{)Z*}n~|pchCTc@BQyLBga65Z zi}9aB7$5w*kTLf+tn}ZE8TK3I`)|g7^1tlvUxC1X+5a?SEcsvfPlLwtzhP>>VSn!n Piuz}*8C{m7jre~6>9Vkv diff --git a/labview source/gRPC lv Support/Client API/Client Read From Stream.vim b/labview source/gRPC lv Support/Client API/Client Read From Stream.vim index 3722bd983548a02d8639cceca9e3107e4fbcecb3..51e8df37f028986d0c3fb3e3c67991badbecea5e 100644 GIT binary patch delta 4320 zcmaKv2UJtr5{3hWUZsN)xD+YUOC%6_2Zb1lRH-qP&_O9;1Og&OI!cjHH4v&Gs1&7m zsZsV+zi(cQl?>>ER)|zwXe0yg9d!4iPS$o#qYrF;E=5QTGIsnB5D;_2`2>0gt!jM$61&boMjB%vISa`Ff&9vA*Zs&% zD!An6%g2NyNBI)RlL3!`E4OIxukUN${Fw$=zlCu^b_iZ{y7Tm?^0w4Wmjc+d1qy*^RmuL zQi`$=1u18+tE`kOSOI}R$b#h%E=uV(+o0Ykb9Xio|Ljs_%4mD)oY)2{KSRS_q0&=u z2@!AB(ib_3FN`y|gcG8;jaf8oi>xo=HH*KP;f;@so}e~duPsV8xu(Dpm9NZvTU1?| zJe&&L;K6vJ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_0N?dydFvbP83`X^P0737 z8C1yn!jd1HBCL&`SZgM%enR_qoUp4nEo`sK5VsChb%@O^__yNu=}-OJG?cxh)HP^w zK}cS+SYdynK*7ySFru}fSSLD}B}rJ9XUOKy=|0guhFQ+4OwN@$56IF;o|G58xa+3( zc2Au0crj2(=CCzATE5b};!JZEOMY7goX#DHHnz!P%C=n?x{m zxvOzz`H8Ymn+Nd3`sfe!y|ld}B}IBQT>JW$0>_=ur~AmbX$z{Qz)1Hv(rakdqa4D= zXhb$Tu@0hZv>M8&2SS$Gjwpe<$yA8%rT!t~;BO#Rx`pLWO5^;@SyX1l1ns;Qwv_NI zKdw~5v4jjN6Np^KG?ZP=*+3m{g_l5q@%go|M6xlf;)}|)4?PY0Qk(-!%^6z_p&%{! zYa}D5hbvG&Z&_6YVgsDcPhvYEt15qA z?cyX2K)DY zhv__E^U6*>CPU@@vHsuRTI#42W)K0S^ydcfFME2ne@FjxfPdS67_!R$W~dtfn_=ku z7iRol*x0`q@I3x!6O4a4(!cCKjM(nKFt`80eE&Bi<^C^B;eWD!_J1~}U;m!}rx>Px zD|}A;M~w78?ebstKN$OeVf_Dvng3rF@Sn9G|E-Wv!p<7v;6|nCVB+FUC1GM`_s+xG G{{H|@W6Fd8 From bcb13ef47e5aa4e21819d7228892e3810c3d4a30 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Fri, 10 Nov 2023 12:58:11 +0530 Subject: [PATCH 21/43] Removed extra enum parameter --- src/lv_message.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_message.h b/src/lv_message.h index 6fda4a1a..bc653557 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -99,7 +99,7 @@ namespace grpc_labview // Parse and copy message in a single pass. template - const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx, RepeatedMessageValuePointer v, const LVMessageType type=LVMessageType::DEFAULT) { + const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx, RepeatedMessageValuePointer v) { if (fieldInfo.isRepeated) { uint64_t numElements; From 1bed38e1a1c631559944ba1fdac4f252d2ef8737 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Fri, 10 Nov 2023 15:26:55 +0530 Subject: [PATCH 22/43] String parse --- src/lv_message.cc | 99 ++++++++++++++++++++++++++++++++++------------- src/lv_message.h | 1 + 2 files changed, 74 insertions(+), 26 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index e123894d..16b4b7cb 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -376,40 +376,87 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseString(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + const char *LVMessage::ParseString(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) { - if (fieldInfo.isRepeated) + const char* lv_ptr = (this->getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + + if (_use_hardcoded_parse) { - std::shared_ptr> v; - auto it = _values.find(index); - if (it == _values.end()) + if (fieldInfo.isRepeated) { - v = std::make_shared>(index); - _values.emplace(index, v); + // Get the _repeatedMessageValues vector from the map + auto _repeatedStringValuesIt = _repeatedStringValuesMap.find(fieldInfo.fieldName); + if (_repeatedStringValuesIt == _repeatedStringValuesMap.end()) + { + _repeatedStringValuesIt = _repeatedStringValuesMap.emplace(fieldInfo.fieldName, google::protobuf::RepeatedField()).first; + } + + protobuf_ptr -= 1; + do { + protobuf_ptr += 1; + auto str = _repeatedStringValuesIt->second.Add(); + protobuf_ptr = InlineGreedyStringParser(str, protobuf_ptr, ctx); + if (!ctx->DataAvailable(protobuf_ptr)) + { + break; + } + } while (ExpectTag(tag, protobuf_ptr)); + + auto arraySize = sizeof(void*) * _repeatedStringValuesIt->second.size(); + auto _lvProvidedArrayHandle = *(void**)lv_ptr; + *(void**)lv_ptr = DSNewHandle(arraySize); + auto arrayHandle = *(LV1DArrayHandle*)lv_ptr; + (*arrayHandle)->cnt = _repeatedStringValuesIt->second.size(); + + // Copy the repeated string values into the LabVIEW array + auto lvStringPtr = (*arrayHandle)->bytes(); + for (auto str:_repeatedStringValuesIt->second) + { + *lvStringPtr = nullptr; + SetLVString(lvStringPtr, str); + lvStringPtr++; + } } - else - { - v = std::static_pointer_cast>((*it).second); + else { + auto str = std::string(); + protobuf_ptr = InlineGreedyStringParser(&str, protobuf_ptr, ctx); + SetLVString((LStrHandle*)lv_ptr, str); } - ptr -= 1; - do { - ptr += 1; - auto str = v->_value.Add(); - ptr = InlineGreedyStringParser(str, ptr, ctx); - if (!ctx->DataAvailable(ptr)) + } + else { + if (fieldInfo.isRepeated) + { + std::shared_ptr> v; + auto it = _values.find(index); + if (it == _values.end()) { - break; + v = std::make_shared>(index); + _values.emplace(index, v); } - } while (ExpectTag(tag, ptr)); - } - else - { - auto str = std::string(); - ptr = InlineGreedyStringParser(&str, ptr, ctx); - auto v = std::make_shared(index, str); - _values.emplace(index, v); + else + { + v = std::static_pointer_cast>((*it).second); + } + protobuf_ptr -= 1; + do { + protobuf_ptr += 1; + auto str = v->_value.Add(); + protobuf_ptr = InlineGreedyStringParser(str, protobuf_ptr, ctx); + if (!ctx->DataAvailable(protobuf_ptr)) + { + break; + } + } while (ExpectTag(tag, protobuf_ptr)); + } + else + { + auto str = std::string(); + protobuf_ptr = InlineGreedyStringParser(&str, protobuf_ptr, ctx); + auto v = std::make_shared(index, str); + _values.emplace(index, v); + } } - return ptr; + return protobuf_ptr; } //--------------------------------------------------------------------- diff --git a/src/lv_message.h b/src/lv_message.h index ac0946bf..981cef44 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -53,6 +53,7 @@ namespace grpc_labview std::shared_ptr _metadata; std::unordered_map _repeatedField_continueIndex; std::unordered_map> _repeatedMessageValuesMap; + std::unordered_map> _repeatedStringValuesMap; // std::vector _messageValues; //std::vector _repeatedMessageValues; bool _use_hardcoded_parse; From 425b9919635463b27287dcfc569daf3894f378a2 Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Fri, 10 Nov 2023 16:31:23 +0530 Subject: [PATCH 23/43] Changed lvClusterHandle to raw pointer instead of shared pointer --- src/lv_message.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index 472c8112..2b2862b5 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -116,7 +116,7 @@ namespace grpc_labview { auto fieldInfo = (*fieldIt).second; LVMessageMetadataType dataType = fieldInfo->type; - if (_LVClusterHandle.get() == nullptr) { + if (_LVClusterHandle == nullptr) { _use_hardcoded_parse = false; } else { From 84b5b7b6eea7ec35d9113427ef54433f1b85dc8b Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Mon, 20 Nov 2023 23:47:30 +0530 Subject: [PATCH 24/43] Reverted build spec --- .../gRPC Server and Client Template [2].vipb | 5 +-- .../build spec/LabVIEW gRPC Servicer.vipb | 33 ++++++++++--------- .../build spec/LabVIEW gRPC Library.vipb | 15 +++++---- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/labview source/Client Server Support New/build spec/gRPC Server and Client Template [2].vipb b/labview source/Client Server Support New/build spec/gRPC Server and Client Template [2].vipb index 9fdb4486..ed9355e0 100644 --- a/labview source/Client Server Support New/build spec/gRPC Server and Client Template [2].vipb +++ b/labview source/Client Server Support New/build spec/gRPC Server and Client Template [2].vipb @@ -1,7 +1,7 @@ - + NI_lib_gRPC_Server_and_Client_Template[2] - 1.0.1.2 + 1.0.1.1 false .. ..\..\Builds @@ -199,6 +199,7 @@ This library also provides a scripting tool to auto generate the server and clie false false false + false false diff --git a/labview source/gRPC lv Servicer/build spec/LabVIEW gRPC Servicer.vipb b/labview source/gRPC lv Servicer/build spec/LabVIEW gRPC Servicer.vipb index 3dfdc72c..879f16f7 100644 --- a/labview source/gRPC lv Servicer/build spec/LabVIEW gRPC Servicer.vipb +++ b/labview source/gRPC lv Servicer/build spec/LabVIEW gRPC Servicer.vipb @@ -1,7 +1,7 @@ - + NI_lib_LabVIEW_gRPC_Servicer - 1.0.1.2 + 1.0.1.1 false .. ..\..\Builds @@ -183,6 +183,7 @@ false false false + false false @@ -240,7 +241,7 @@ ..\Servicer - 387AF6CDBB628F980AEF9CCBFA20FB16 + E258AB59039E221C07E347EBB9699215 0 @@ -289,7 +290,7 @@ ..\iService\Server API - B26E57398A70958E4A6DB3B1B0DF72E9 + 5073D000D4753811F0B1A31515DA66CB 0 @@ -352,7 +353,7 @@ ..\Servicer\Run Servicer.vi - DB2A2374C54E450B358D090BB1D4C1F7 + D03E1B6640AE9BF3DA7FD676117F3539 1 @@ -401,7 +402,7 @@ ..\ServiceBase\Accessors\Read Server Stop.vi - 859612ABBFB9D2DFC7875937DF2DC8FF + C7DB15FE8DB82DD0DBB1B511580F5FAA 1 @@ -506,7 +507,7 @@ ..\ServiceBase\Server API\Start.vi - E6E45F212258EC90A8E628EA701F515E + 14D0FCC9DB65233816C156219D1DC543 2 @@ -597,7 +598,7 @@ ..\Servicer\Accessors\Server State - 04329BA34EFDC3F564CA0FFF83C81738 + ABAC22B0E9CE862598F099BCB828F826 2 @@ -674,7 +675,7 @@ ..\Servicer\Server API\Stop Server.vi - E6FB2F38D93B68121728AD7C6914BFA9 + DB0010F6446A55F61E8C0DF1E35CACE5 5 @@ -723,7 +724,7 @@ ..\Servicer\Accessors\gRPC ID\Set gRPC ID.vi - F7B71959EB148E0E48B2F04EB92A0876 + 0E840B7FEB4E044C5EB5C998343FEED9 5 @@ -772,7 +773,7 @@ ..\Servicer\Accessors\Server Address\Set Server Address.vi - B42BE6C5A9945B91700126B421A6C774 + E139FAE7D8D69691C0573E8852B5ADB8 5 @@ -821,7 +822,7 @@ ..\Servicer\Accessors\Server Certificate File\Set Server Certificate File.vi - C412EE5B14ED1A1BEA8903F62543BA1E + 643EAD5C2CF01A88D1CDCE4DBB04CA44 5 @@ -870,7 +871,7 @@ ..\Servicer\Accessors\Server Key File\Set Server Key File.vi - 5EC1B985C5FA600E5D2A72F6FF0EBB58 + BFE1B359E13F51B39B57B079613F7F13 5 @@ -947,7 +948,7 @@ ..\Servicer\Accessors\Server State\Set Server State.vi - 0045CB18C5B362EE3A96D706F135EACC + 36F14BECBD42F8A01726C0EDC9071A92 11 @@ -996,7 +997,7 @@ ..\Servicer\Accessors\Server State\State Ref\Set Server State Ref.vi - B316EFE0097AB679B940276354195B3A + 10B658C1218C3F73336CAC3E5878A73D 11 @@ -1045,7 +1046,7 @@ ..\Servicer\Accessors\Server State\State UE\Set Server State UE.vi - 9E1A00A694A96FFB16216E53AAD37BB8 + 9C1D936C2E34998849D24C6675D644C8 \ No newline at end of file diff --git a/labview source/gRPC lv Support/build spec/LabVIEW gRPC Library.vipb b/labview source/gRPC lv Support/build spec/LabVIEW gRPC Library.vipb index 08cb09cb..38a3f7e2 100644 --- a/labview source/gRPC lv Support/build spec/LabVIEW gRPC Library.vipb +++ b/labview source/gRPC lv Support/build spec/LabVIEW gRPC Library.vipb @@ -1,7 +1,7 @@ - + NI_lib_LabVIEW_gRPC_Library - 1.0.1.2 + 1.0.1.1 false .. ..\..\Builds @@ -194,6 +194,7 @@ https://github.com/ni/grpc-labview false false false + false false @@ -251,7 +252,7 @@ https://github.com/ni/grpc-labview ..\Server API - DD3F698A9A534D6DAF1A7D6E5427E138 + 7D3594FB023515B3C4B797CE1271EC95 0 @@ -370,7 +371,7 @@ https://github.com/ni/grpc-labview ..\Client API\Client Cancel Call.vi - 7B4EABFEF4BDC1EB7D4F23E37214A8AB + A1E958DD29F8790A61C7D31C4AF8F130 0 @@ -489,7 +490,7 @@ https://github.com/ni/grpc-labview ..\Server API\UnpackFromBuffer.vim - 404A4A1A9D9B9F34659817788601537B + B7DB67D7F0B456B3FF6B479ED284382D 2 @@ -720,7 +721,7 @@ https://github.com/ni/grpc-labview ..\Server API\Message Requests\Write Call Response.vim - 3F72B180A332296A67A9CE202B5205FF + B117FE54528E29A25B075EC86AF8053B 2 @@ -839,7 +840,7 @@ https://github.com/ni/grpc-labview ..\Server API\Server\Stop Server.vi - 233818A94A97E283602044DD86FD166F + 3D9875481763CF81CA00A742D3D62483 \ No newline at end of file From c53d19c33e6bebec32662a816faf4f12d734783b Mon Sep 17 00:00:00 2001 From: Yash Chauhan Date: Tue, 21 Nov 2023 14:33:35 +0530 Subject: [PATCH 25/43] Commented datatype enum --- src/grpc_client.cc | 38 +++++++++++++++++++++----------------- src/message_value.h | 39 ++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index f46210cf..73509aec 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -609,14 +609,16 @@ LIBRARY_EXPORT int32_t ClientCompleteReadFromStream(grpc_labview::gRPCid* callId *success = reader->_readFuture.get(); if (*success) { - /*try - { - grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + if (!grpc_labview::g_use_hardcoded_parse) { + try + { + grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + } + catch (grpc_labview::InvalidEnumValueException& e) + { + return e.code; + } } - catch (grpc_labview::InvalidEnumValueException& e) - { - return e.code; - }*/ } return 0; } @@ -676,18 +678,20 @@ LIBRARY_EXPORT int32_t FinishClientCompleteClientStreamingCall( int32_t result = 0; if (call->_status.ok()) { - /*try - { - grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); - } - catch (grpc_labview::InvalidEnumValueException& e) - { - result = e.code; - if (errorMessage != nullptr) + if (!grpc_labview::g_use_hardcoded_parse) { + try + { + grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + } + catch (grpc_labview::InvalidEnumValueException& e) { - grpc_labview::SetLVString(errorMessage, e.what()); + result = e.code; + if (errorMessage != nullptr) + { + grpc_labview::SetLVString(errorMessage, e.what()); + } } - }*/ + } } else { diff --git a/src/message_value.h b/src/message_value.h index 1c788dae..eed579f0 100644 --- a/src/message_value.h +++ b/src/message_value.h @@ -8,25 +8,26 @@ namespace grpc_labview //--------------------------------------------------------------------- class LVMessage; - enum class LVMessageType { - INT32 = 0, - INT64 = 1, - UINT32 = 2, - UINT64 = 3, - FLOAT = 4, - DOUBLE = 5, - BOOL = 6, - STRING = 7, - BYTES = 8, - ENUM = 9, - SINT32 = 10, - SINT64 = 11, - FIXED32 = 12, - FIXED64 = 13, - SFIXED32 = 14, - SFIXED64 = 15, - DEFAULT = 100, - }; + // This enum contains all the gRPC datatypes. Might be useful in future. + // enum class LVMessageType { + // INT32 = 0, + // INT64 = 1, + // UINT32 = 2, + // UINT64 = 3, + // FLOAT = 4, + // DOUBLE = 5, + // BOOL = 6, + // STRING = 7, + // BYTES = 8, + // ENUM = 9, + // SINT32 = 10, + // SINT64 = 11, + // FIXED32 = 12, + // FIXED64 = 13, + // SFIXED32 = 14, + // SFIXED64 = 15, + // DEFAULT = 100, + // }; //--------------------------------------------------------------------- //--------------------------------------------------------------------- From 1016ec01bb692012bb54b0ef2f207a79adbbcfd8 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 3 Jan 2024 12:08:37 +0530 Subject: [PATCH 26/43] split ParseAndCopyMessage into single and repeated --- src/lv_message.cc | 182 ++++++++++++++++++++++++++++++---------- src/lv_message.h | 46 +++++----- src/lv_message_value.cc | 30 +++++++ src/message_metadata.h | 3 +- src/metadata_owner.h | 4 +- 5 files changed, 198 insertions(+), 67 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index 2b2862b5..8a00d0a5 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -197,9 +197,16 @@ namespace grpc_labview const char *LVMessage::ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -225,9 +232,16 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else { if (fieldInfo.isRepeated) @@ -253,9 +267,16 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - SinglePassMessageParser parser(*this); - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else { if (fieldInfo.isRepeated) @@ -280,9 +301,16 @@ namespace grpc_labview const char *LVMessage::ParseEnum(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -308,9 +336,16 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - SinglePassMessageParser parser(*this); - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else { if (fieldInfo.isRepeated) @@ -336,9 +371,16 @@ namespace grpc_labview { if (_use_hardcoded_parse) { - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else { if (fieldInfo.isRepeated) @@ -363,9 +405,16 @@ namespace grpc_labview const char *LVMessage::ParseFloat(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -390,9 +439,16 @@ namespace grpc_labview const char *LVMessage::ParseDouble(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -524,9 +580,16 @@ namespace grpc_labview const char* LVMessage::ParseSInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -551,9 +614,16 @@ namespace grpc_labview const char* LVMessage::ParseSInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -578,9 +648,16 @@ namespace grpc_labview const char* LVMessage::ParseFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -606,9 +683,16 @@ namespace grpc_labview const char* LVMessage::ParseFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -633,9 +717,16 @@ namespace grpc_labview const char* LVMessage::ParseSFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) @@ -660,9 +751,16 @@ namespace grpc_labview const char* LVMessage::ParseSFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) { if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this); - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyMessage(fieldInfo, index, ptr, ctx, v); + grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); + } + else + { + ptr = parser.ParseAndCopyMessage(ptr); + } } else{ if (fieldInfo.isRepeated) diff --git a/src/lv_message.h b/src/lv_message.h index 4fe7ad9a..6a2bbfd7 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -96,35 +96,37 @@ namespace grpc_labview class SinglePassMessageParser { private: LVMessage& _message; + const char* _lv_ptr; public: // Constructor and other necessary member functions - SinglePassMessageParser(LVMessage& message) : _message(message) {} + SinglePassMessageParser(LVMessage& message, const MessageElementMetadata& fieldInfo) : _message(message) { + _lv_ptr = reinterpret_cast(_message.getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + } // Parse and copy message in a single pass. template - const char* ParseAndCopyMessage(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx, RepeatedMessageValuePointer v) { - auto _lv_ptr = reinterpret_cast(_message.getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; - if (fieldInfo.isRepeated) - { - uint64_t numElements; - ptr = PackedMessageType(ptr, ctx, index, reinterpret_cast*>(&(v->_value))); - numElements = v->_value.size(); - // get the LVClusterHandle - - // copy into LVCluster - if (numElements != 0) - { - NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(_lv_ptr)), numElements); - auto array = *(LV1DArrayHandle*)_lv_ptr; - (*array)->cnt = numElements; - auto byteCount = numElements * sizeof(MessageType); - std::memcpy((*array)->bytes(), v->_value.data(), byteCount); - } - } - else + const char* ParseAndCopyRepeatedMessage(uint32_t index, const char *ptr, ParseContext *ctx, RepeatedMessageValuePointer v) { + + uint64_t numElements; + ptr = PackedMessageType(ptr, ctx, index, reinterpret_cast*>(&(v->_value))); + numElements = v->_value.size(); + // get the LVClusterHandle + + // copy into LVCluster + if (numElements != 0) { - ptr = ReadMessageType(ptr, reinterpret_cast(const_cast(_lv_ptr))); + NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(_lv_ptr)), numElements); + auto array = *(LV1DArrayHandle*)_lv_ptr; + (*array)->cnt = numElements; + auto byteCount = numElements * sizeof(MessageType); + std::memcpy((*array)->bytes(), v->_value.data(), byteCount); } + + return ptr; + } + + const char* ParseAndCopyMessage(const char *ptr) { + ptr = ReadMessageType(ptr, reinterpret_cast(const_cast(_lv_ptr))); return ptr; } diff --git a/src/lv_message_value.cc b/src/lv_message_value.cc index f41ea572..74927e6a 100644 --- a/src/lv_message_value.cc +++ b/src/lv_message_value.cc @@ -104,6 +104,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; @@ -117,6 +118,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { for (int i = 0, n = _value.size(); i < n; i++) @@ -137,6 +139,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::TYPE_BOOL) + WireFormatLite::kBoolSize; @@ -144,6 +147,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); @@ -159,6 +163,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; @@ -175,6 +180,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_value.size() > 0) @@ -194,6 +200,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_INT32) + WireFormatLite::Int32Size(_value); @@ -201,6 +208,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); @@ -217,6 +225,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_UINT32) + WireFormatLite::UInt32Size(_value); @@ -224,6 +233,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); @@ -263,6 +273,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_INT64) + WireFormatLite::Int64Size(_value); @@ -270,6 +281,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); @@ -286,6 +298,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_UINT64) + WireFormatLite::UInt64Size(_value); @@ -293,6 +306,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); @@ -308,6 +322,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; @@ -324,6 +339,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) @@ -342,6 +358,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; @@ -358,6 +375,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) @@ -410,6 +428,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; @@ -426,6 +445,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) @@ -444,6 +464,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; @@ -460,6 +481,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_cachedSize > 0) @@ -479,6 +501,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::TYPE_STRING) + WireFormatLite::kFloatSize; @@ -486,6 +509,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); @@ -501,6 +525,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; @@ -517,6 +542,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_value.size() > 0) @@ -537,6 +563,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVVariableMessageValue::ByteSizeLong() { return WireFormatLite::TagSize(_protobufId, WireFormatLite::FieldType::TYPE_DOUBLE) + WireFormatLite::kDoubleSize; @@ -544,6 +571,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVVariableMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { target = stream->EnsureSpace(target); @@ -559,6 +587,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> size_t LVRepeatedMessageValue::ByteSizeLong() { size_t totalSize = 0; @@ -575,6 +604,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- + template <> google::protobuf::uint8* LVRepeatedMessageValue::Serialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const { if (_value.size() > 0) diff --git a/src/message_metadata.h b/src/message_metadata.h index 4c6d188b..7e2f0b8c 100644 --- a/src/message_metadata.h +++ b/src/message_metadata.h @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace grpc_labview @@ -91,7 +92,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - using LVMessageMetadataMap = std::map>; + using LVMessageMetadataMap = std::unordered_map>; using LVMessageMetadataList = std::vector>; //--------------------------------------------------------------------- diff --git a/src/metadata_owner.h b/src/metadata_owner.h index cbbbad8b..5e97d681 100644 --- a/src/metadata_owner.h +++ b/src/metadata_owner.h @@ -31,8 +31,8 @@ namespace grpc_labview private: std::mutex _mutex; - std::map> _registeredMessageMetadata; - std::map> _registeredEnumMetadata; + std::unordered_map> _registeredMessageMetadata; + std::unordered_map> _registeredEnumMetadata; void UpdateMetadataClusterLayout(std::shared_ptr& metadata); }; } From 42805cd03649497b624932377783ffcd2c195a28 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 3 Jan 2024 12:22:06 +0530 Subject: [PATCH 27/43] clearing local gitignore changes --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index eb00a27b..5014afe2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ grpc Builds build -build_bak .vs .vscode __pycache__ @@ -34,5 +33,3 @@ labview source/Servers/Generated Server/ *.so tests/gRPC_ATS/TimeStamp.txt - -*.srctrl* \ No newline at end of file From ef329dd61761775b13fa3becd5bc8cd24870a02a Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 3 Jan 2024 13:00:37 +0530 Subject: [PATCH 28/43] removing windows header which was used for debugging --- src/lv_message.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index 8a00d0a5..98606970 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -2,7 +2,6 @@ //--------------------------------------------------------------------- #include #include -#include #include //--------------------------------------------------------------------- From 7b2f5dd7dde507a1cb2a03046eaf7c609a2270fb Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 10 Jan 2024 16:38:50 +0530 Subject: [PATCH 29/43] Adding debug symbols for release build, adding feature toggle class --- CMakeLists.txt | 4 +++ src/feature_toggles.cc | 65 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/feature_toggles.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 58a795ea..5c5a5e27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,10 @@ else() add_definitions(-D_WIN32_WINNT=0x600) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4244") + add_compile_options("$<$>:/Zi>") + add_link_options("$<$>:/DEBUG>") + add_link_options("$<$>:/OPT:REF>") + add_link_options("$<$>:/OPT:ICF>") endif() find_package(Threads REQUIRED) diff --git a/src/feature_toggles.cc b/src/feature_toggles.cc new file mode 100644 index 00000000..f8c8ea85 --- /dev/null +++ b/src/feature_toggles.cc @@ -0,0 +1,65 @@ +#include +#include +#include +#include + +class FeatureConfig { +private: + std::map featureFlags; + + // Constructor to initialize with default values + FeatureConfig() { + featureFlags["gRPC"] = true; // Enable gRPC by default as an example, this will never be overridden by config file + } + +public: + // Singleton instance + static FeatureConfig& getInstance() { + static FeatureConfig instance; + return instance; + } + + // Function to read feature configurations from an INI file + void readConfigFromFile(const std::string& filePath) { + std::ifstream configFile(filePath); + if (!configFile.is_open()) { + return; + } + + std::string line; + std::string currentSection; // For handling INI sections + + while (std::getline(configFile, line)) { + // Trim leading and trailing whitespaces + line.erase(line.find_last_not_of(" \t") + 1); + line.erase(0, line.find_first_not_of(" \t")); + + // Skip comments and empty lines + if (line.empty() || line[0] == ';') { + continue; + } + + // Check for section header + if (line[0] == '[' && line[line.length() - 1] == ']') { + currentSection = line.substr(1, line.length() - 2); + } else { + // Parse key-value pairs + std::istringstream iss(line); + std::string key, value; + if (std::getline(iss, key, '=') && std::getline(iss, value)) { + // Append section name to key for uniqueness + std::string fullKey = currentSection.empty() ? key : currentSection + "_" + key; + featureFlags[fullKey] = (value == "true"); + } + } + } + + configFile.close(); + } + + // Function to check if a feature is enabled + bool isFeatureEnabled(const std::string& featureName) const { + auto it = featureFlags.find(featureName); + return (it != featureFlags.end()) ? it->second : false; + } +}; \ No newline at end of file From ea4291372f885c6f76783bb0806100b344ff890b Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Thu, 11 Jan 2024 16:03:33 +0530 Subject: [PATCH 30/43] Adding files to cmake, and using the feature toggle class --- CMakeLists.txt | 20 +++++----- src/feature_toggles.cc | 86 +++++++++++++++++------------------------- src/feature_toggles.h | 27 +++++++++++++ src/grpc_client.cc | 22 +++++++++++ src/grpc_server.cc | 4 ++ src/lv_interop.cc | 4 ++ 6 files changed, 103 insertions(+), 60 deletions(-) create mode 100644 src/feature_toggles.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c5a5e27..571a65df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,21 +59,22 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}" "./src" "./third_party/grpc" " # LabVIEW support for grpc and protobuf #---------------------------------------------------------------------- add_library(labview_grpc_server SHARED - src/grpc_client.cc - src/grpc_server.cc - src/grpc_interop.cc + src/any_support.cc src/cluster_copier.cc src/event_data.cc + src/feature_toggles.cc + src/grpc_client.cc + src/grpc_interop.cc + src/grpc_load.cc + src/grpc_server.cc src/lv_interop.cc src/lv_message.cc src/lv_message_value.cc + src/lv_proto_server_reflection_plugin.cc + src/lv_proto_server_reflection_service.cc src/message_element_metadata_owner.cc - src/any_support.cc src/unpacked_fields.cc - src/grpc_load.cc - src/lv_proto_server_reflection_service.cc - src/lv_proto_server_reflection_plugin.cc - ) +) target_link_libraries(labview_grpc_server ${_REFLECTION} ${_GRPC_GRPCPP} @@ -84,8 +85,9 @@ target_link_libraries(labview_grpc_server # server VIs from a .proto file #---------------------------------------------------------------------- add_library(labview_grpc_generator SHARED - src/proto_parser.cc + src/feature_toggles.cc src/lv_interop.cc + src/proto_parser.cc ) target_link_libraries(labview_grpc_generator ${_REFLECTION} diff --git a/src/feature_toggles.cc b/src/feature_toggles.cc index f8c8ea85..820177da 100644 --- a/src/feature_toggles.cc +++ b/src/feature_toggles.cc @@ -1,65 +1,49 @@ +#include "feature_toggles.h" #include #include #include #include -class FeatureConfig { -private: - std::map featureFlags; - - // Constructor to initialize with default values - FeatureConfig() { - featureFlags["gRPC"] = true; // Enable gRPC by default as an example, this will never be overridden by config file - } - -public: - // Singleton instance - static FeatureConfig& getInstance() { - static FeatureConfig instance; - return instance; +// Function to read feature configurations from an INI file +void FeatureConfig::readConfigFromFile(const std::string& filePath) { + std::ifstream configFile(filePath); + if (!configFile.is_open()) { + return; } - // Function to read feature configurations from an INI file - void readConfigFromFile(const std::string& filePath) { - std::ifstream configFile(filePath); - if (!configFile.is_open()) { - return; - } - - std::string line; - std::string currentSection; // For handling INI sections + std::string line; + std::string currentSection; // For handling INI sections - while (std::getline(configFile, line)) { - // Trim leading and trailing whitespaces - line.erase(line.find_last_not_of(" \t") + 1); - line.erase(0, line.find_first_not_of(" \t")); + while (std::getline(configFile, line)) { + // Trim leading and trailing whitespaces + line.erase(line.find_last_not_of(" \t") + 1); + line.erase(0, line.find_first_not_of(" \t")); - // Skip comments and empty lines - if (line.empty() || line[0] == ';') { - continue; - } + // Skip comments and empty lines + if (line.empty() || line[0] == ';') { + continue; + } - // Check for section header - if (line[0] == '[' && line[line.length() - 1] == ']') { - currentSection = line.substr(1, line.length() - 2); - } else { - // Parse key-value pairs - std::istringstream iss(line); - std::string key, value; - if (std::getline(iss, key, '=') && std::getline(iss, value)) { - // Append section name to key for uniqueness - std::string fullKey = currentSection.empty() ? key : currentSection + "_" + key; - featureFlags[fullKey] = (value == "true"); - } + // Check for section header + if (line[0] == '[' && line[line.length() - 1] == ']') { + currentSection = line.substr(1, line.length() - 2); + } else { + // Parse key-value pairs + std::istringstream iss(line); + std::string key, value; + if (std::getline(iss, key, '=') && std::getline(iss, value)) { + // Append section name to key for uniqueness + std::string fullKey = currentSection.empty() ? key : currentSection + "_" + key; + featureFlags[fullKey] = (value == "true"); } } - - configFile.close(); } - // Function to check if a feature is enabled - bool isFeatureEnabled(const std::string& featureName) const { - auto it = featureFlags.find(featureName); - return (it != featureFlags.end()) ? it->second : false; - } -}; \ No newline at end of file + configFile.close(); +} + +// Function to check if a feature is enabled +bool FeatureConfig::isFeatureEnabled(const std::string& featureName) const { + auto it = featureFlags.find(featureName); + return (it != featureFlags.end()) ? it->second : false; +} \ No newline at end of file diff --git a/src/feature_toggles.h b/src/feature_toggles.h new file mode 100644 index 00000000..2fa253a9 --- /dev/null +++ b/src/feature_toggles.h @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +class FeatureConfig { +private: + std::map featureFlags; + + // Constructor to initialize with default values + FeatureConfig() { + featureFlags["gRPC"] = true; // Enable gRPC by default as an example, this will never be overridden by config file + } + +public: + // Singleton instance + static FeatureConfig& getInstance() { + static FeatureConfig instance; + return instance; + } + + // Function to read feature configurations from an INI file + void readConfigFromFile(const std::string& filePath); + + // Function to check if a feature is enabled + bool isFeatureEnabled(const std::string& featureName) const; +}; \ No newline at end of file diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 2eeb48b2..d8940abc 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -10,6 +10,7 @@ #include #include #include +#include "feature_toggles.h" namespace grpc_labview { @@ -276,6 +277,9 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( int32_t timeoutMs, grpc_labview::gRPCid* contextId) { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + auto client = clientId->CastTo(); if (!client) { @@ -401,6 +405,9 @@ LIBRARY_EXPORT int32_t ClientBeginClientStreamingCall( int32_t timeoutMs, grpc_labview::gRPCid* contextId) { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + auto client = clientId->CastTo(); if (!client) { @@ -455,6 +462,9 @@ LIBRARY_EXPORT int32_t ClientBeginServerStreamingCall( int32_t timeoutMs, grpc_labview::gRPCid* contextId) { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + auto client = clientId->CastTo(); if (!client) { @@ -517,6 +527,9 @@ LIBRARY_EXPORT int32_t ClientBeginBidiStreamingCall( int32_t timeoutMs, grpc_labview::gRPCid* contextId) { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + auto client = clientId->CastTo(); if (!client) { @@ -563,6 +576,9 @@ LIBRARY_EXPORT int32_t ClientBeginBidiStreamingCall( //--------------------------------------------------------------------- LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr) { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + auto reader = callId->CastTo(); auto call = callId->CastTo(); @@ -592,6 +608,9 @@ LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, g //--------------------------------------------------------------------- LIBRARY_EXPORT int32_t ClientCompleteReadFromStream(grpc_labview::gRPCid* callId, int* success, int8_t* responseCluster) { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + auto reader = callId->CastTo(); auto call = callId->CastTo(); if (!reader || !call) @@ -618,6 +637,9 @@ LIBRARY_EXPORT int32_t ClientCompleteReadFromStream(grpc_labview::gRPCid* callId //--------------------------------------------------------------------- LIBRARY_EXPORT int32_t ClientWriteToStream(grpc_labview::gRPCid* callId, int8_t* requestCluster, int* success) { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + auto writer = callId->CastTo(); if (!writer) { diff --git a/src/grpc_server.cc b/src/grpc_server.cc index a132e32e..993ee9fe 100644 --- a/src/grpc_server.cc +++ b/src/grpc_server.cc @@ -9,6 +9,7 @@ #include #include #include "lv_proto_server_reflection_plugin.h" +#include "feature_toggles.h" //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -178,6 +179,9 @@ namespace grpc_labview std::string serverKeyPath, ServerStartEventData *serverStarted) { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + std::string server_address; if (address.length() != 0) { diff --git a/src/lv_interop.cc b/src/lv_interop.cc index 1567eb71..9d69d908 100644 --- a/src/lv_interop.cc +++ b/src/lv_interop.cc @@ -5,6 +5,7 @@ #include #include #include +#include "feature_toggles.h" #ifndef _WIN32 #include @@ -40,6 +41,9 @@ namespace grpc_labview //--------------------------------------------------------------------- void InitCallbacks() { + // Instantiating the feature toggles singleton that will read the feature configuration file + FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); + if (NumericArrayResizeImp != nullptr) { return; From cc24a0146d4724dab13ed2427385ea2bb57d792e Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Fri, 12 Jan 2024 14:50:13 +0530 Subject: [PATCH 31/43] Code cleanup --- CMakeLists.txt | 1 + src/feature_toggles.cc | 2 +- src/feature_toggles.h | 1 + src/grpc_client.cc | 66 ++- src/grpc_server.cc | 2 +- src/lv_interop.cc | 2 +- src/lv_interop.h | 2 - src/lv_message.cc | 922 +++++++++++------------------------- src/lv_message.h | 104 +--- src/lv_message_efficient.cc | 202 ++++++++ src/lv_message_efficient.h | 99 ++++ 11 files changed, 665 insertions(+), 738 deletions(-) create mode 100644 src/lv_message_efficient.cc create mode 100644 src/lv_message_efficient.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 571a65df..751f72b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ add_library(labview_grpc_server SHARED src/grpc_server.cc src/lv_interop.cc src/lv_message.cc + src/lv_message_efficient.cc src/lv_message_value.cc src/lv_proto_server_reflection_plugin.cc src/lv_proto_server_reflection_service.cc diff --git a/src/feature_toggles.cc b/src/feature_toggles.cc index 820177da..f926da64 100644 --- a/src/feature_toggles.cc +++ b/src/feature_toggles.cc @@ -1,4 +1,4 @@ -#include "feature_toggles.h" +#include #include #include #include diff --git a/src/feature_toggles.h b/src/feature_toggles.h index 2fa253a9..c276e10c 100644 --- a/src/feature_toggles.h +++ b/src/feature_toggles.h @@ -10,6 +10,7 @@ class FeatureConfig { // Constructor to initialize with default values FeatureConfig() { featureFlags["gRPC"] = true; // Enable gRPC by default as an example, this will never be overridden by config file + featureFlags["EfficientMessageCopy"] = true; } public: diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 40a7847c..69f427eb 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -10,12 +11,10 @@ #include #include #include -#include "feature_toggles.h" +#include namespace grpc_labview { - extern bool g_use_hardcoded_parse; - //--------------------------------------------------------------------- //--------------------------------------------------------------------- LabVIEWgRPCClient::LabVIEWgRPCClient() @@ -314,11 +313,18 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( clientCall->_client = client; clientCall->_methodName = methodName; clientCall->_occurrence = *occurrence; - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); clientCall->_context = clientContext; - clientCall->_request->setLVClusterHandle(reinterpret_cast(requestCluster)); - clientCall->_response->setLVClusterHandle(reinterpret_cast(responseCluster)); + + if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")){ + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + } + else { + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + clientCall->_request->SetLVClusterHandle(reinterpret_cast(requestCluster)); + clientCall->_response->SetLVClusterHandle(reinterpret_cast(responseCluster)); + } try { @@ -363,7 +369,7 @@ LIBRARY_EXPORT int32_t CompleteClientUnaryCall2( int32_t result = 0; if (call->_status.ok()) { - if (!grpc_labview::g_use_hardcoded_parse) { + if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")) { try { grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); @@ -444,8 +450,16 @@ LIBRARY_EXPORT int32_t ClientBeginClientStreamingCall( auto clientCall = new grpc_labview::ClientStreamingClientCall(); *callId = grpc_labview::gPointerManager.RegisterPointer(clientCall); clientCall->_client = client; - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); + + if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")){ + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + } + else { + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + } + clientCall->_context = clientContext; grpc::internal::RpcMethod method(methodName, grpc::internal::RpcMethod::CLIENT_STREAMING); @@ -501,8 +515,16 @@ LIBRARY_EXPORT int32_t ClientBeginServerStreamingCall( auto clientCall = new grpc_labview::ServerStreamingClientCall(); *callId = grpc_labview::gPointerManager.RegisterPointer(clientCall); clientCall->_client = client; - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); + + if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")){ + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + } + else { + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + } + clientCall->_context = clientContext; try @@ -566,8 +588,16 @@ LIBRARY_EXPORT int32_t ClientBeginBidiStreamingCall( auto clientCall = new grpc_labview::BidiStreamingClientCall(); *callId = grpc_labview::gPointerManager.RegisterPointer(clientCall); clientCall->_client = client; - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); + + if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")){ + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + } + else { + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + } + clientCall->_context = clientContext; grpc::internal::RpcMethod method(methodName, grpc::internal::RpcMethod::BIDI_STREAMING); @@ -588,7 +618,7 @@ LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, g auto reader = callId->CastTo(); auto call = callId->CastTo(); - call->_response->setLVClusterHandle(reinterpret_cast(responseCluster)); + call->_response->SetLVClusterHandle(reinterpret_cast(responseCluster)); auto occurrence = *occurrencePtr; if (!reader || !call) @@ -628,7 +658,7 @@ LIBRARY_EXPORT int32_t ClientCompleteReadFromStream(grpc_labview::gRPCid* callId *success = reader->_readFuture.get(); if (*success) { - if (!grpc_labview::g_use_hardcoded_parse) { + if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")) { try { grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); @@ -700,7 +730,7 @@ LIBRARY_EXPORT int32_t FinishClientCompleteClientStreamingCall( int32_t result = 0; if (call->_status.ok()) { - if (!grpc_labview::g_use_hardcoded_parse) { + if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")) { try { grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); @@ -739,7 +769,7 @@ LIBRARY_EXPORT int32_t FinishClientCompleteClientStreamingCall( LIBRARY_EXPORT int32_t ClientCompleteClientStreamingCall(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr, int8_t* responseCluster) { auto call = callId->CastTo(); - call->_response->setLVClusterHandle(reinterpret_cast(responseCluster)); + call->_response->SetLVClusterHandle(reinterpret_cast(responseCluster)); if (!call) { return -1; diff --git a/src/grpc_server.cc b/src/grpc_server.cc index 993ee9fe..a6ecf879 100644 --- a/src/grpc_server.cc +++ b/src/grpc_server.cc @@ -9,7 +9,7 @@ #include #include #include "lv_proto_server_reflection_plugin.h" -#include "feature_toggles.h" +#include //--------------------------------------------------------------------- //--------------------------------------------------------------------- diff --git a/src/lv_interop.cc b/src/lv_interop.cc index 328268f3..49e6a7b7 100644 --- a/src/lv_interop.cc +++ b/src/lv_interop.cc @@ -5,7 +5,7 @@ #include #include #include -#include "feature_toggles.h" +#include #ifndef _WIN32 #include diff --git a/src/lv_interop.h b/src/lv_interop.h index 8d676346..ef174b3b 100644 --- a/src/lv_interop.h +++ b/src/lv_interop.h @@ -25,8 +25,6 @@ namespace grpc_labview { - extern bool g_use_hardcoded_parse; - class gRPCid; extern PointerManager gPointerManager; diff --git a/src/lv_message.cc b/src/lv_message.cc index 98606970..bbf0dac2 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -10,17 +10,9 @@ using namespace google::protobuf::internal; namespace grpc_labview { - bool g_use_hardcoded_parse = true; - //--------------------------------------------------------------------- //--------------------------------------------------------------------- - LVMessage::LVMessage(std::shared_ptr metadata) : - _metadata(metadata), _use_hardcoded_parse(g_use_hardcoded_parse), _skipCopyOnFirstParse(false) - { - } - - LVMessage::LVMessage(std::shared_ptr metadata, bool use_hardcoded_parse, bool skipCopyOnFirstParse) : - _metadata(metadata), _use_hardcoded_parse(use_hardcoded_parse), _skipCopyOnFirstParse(skipCopyOnFirstParse) + LVMessage::LVMessage(std::shared_ptr metadata) : _metadata(metadata) { } @@ -32,14 +24,14 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::UnknownFieldSet& LVMessage::UnknownFields() + google::protobuf::UnknownFieldSet &LVMessage::UnknownFields() { return _unknownFields; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - bool LVMessage::ParseFromByteBuffer(const grpc::ByteBuffer& buffer) + bool LVMessage::ParseFromByteBuffer(const grpc::ByteBuffer &buffer) { Clear(); @@ -66,7 +58,7 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - google::protobuf::Message* LVMessage::New(google::protobuf::Arena* arena) const + google::protobuf::Message *LVMessage::New(google::protobuf::Arena *arena) const { assert(false); // not expected to be called return nullptr; @@ -115,71 +107,66 @@ namespace grpc_labview { auto fieldInfo = (*fieldIt).second; LVMessageMetadataType dataType = fieldInfo->type; - if (_LVClusterHandle == nullptr) { - _use_hardcoded_parse = false; - } - else { - _use_hardcoded_parse = true; - } switch (dataType) { - case LVMessageMetadataType::Int32Value: - ptr = ParseInt32(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::FloatValue: - ptr = ParseFloat(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::DoubleValue: - ptr = ParseDouble(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::BoolValue: - ptr = ParseBoolean(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::StringValue: - ptr = ParseString(tag, *fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::BytesValue: - ptr = ParseBytes(tag, *fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::MessageValue: - ptr = ParseNestedMessage(tag, *fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::Int64Value: - ptr = ParseInt64(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::UInt32Value: - ptr = ParseUInt32(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::UInt64Value: - ptr = ParseUInt64(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::EnumValue: - ptr = ParseEnum(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::SInt32Value: - ptr = ParseSInt32(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::SInt64Value: - ptr = ParseSInt64(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::Fixed32Value: - ptr = ParseFixed32(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::Fixed64Value: - ptr = ParseFixed64(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::SFixed32Value: - ptr = ParseSFixed32(*fieldInfo, index, ptr, ctx); - break; - case LVMessageMetadataType::SFixed64Value: - ptr = ParseSFixed64(*fieldInfo, index, ptr, ctx); - break; + case LVMessageMetadataType::Int32Value: + ptr = ParseInt32(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::FloatValue: + ptr = ParseFloat(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::DoubleValue: + ptr = ParseDouble(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::BoolValue: + ptr = ParseBoolean(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::StringValue: + ptr = ParseString(tag, *fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::BytesValue: + ptr = ParseBytes(tag, *fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::MessageValue: + ptr = ParseNestedMessage(tag, *fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::Int64Value: + ptr = ParseInt64(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::UInt32Value: + ptr = ParseUInt32(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::UInt64Value: + ptr = ParseUInt64(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::EnumValue: + ptr = ParseEnum(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::SInt32Value: + ptr = ParseSInt32(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::SInt64Value: + ptr = ParseSInt64(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::Fixed32Value: + ptr = ParseFixed32(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::Fixed64Value: + ptr = ParseFixed64(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::SFixed32Value: + ptr = ParseSFixed32(*fieldInfo, index, ptr, ctx); + break; + case LVMessageMetadataType::SFixed64Value: + ptr = ParseSFixed64(*fieldInfo, index, ptr, ctx); + break; } assert(ptr != nullptr); } else { - if (tag == 0 || WireFormatLite::GetTagWireType(tag) == WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0 || WireFormatLite::GetTagWireType(tag) == WireFormatLite::WIRETYPE_END_GROUP) + { ctx->SetLastTag(tag); return ptr; } @@ -193,380 +180,218 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + const char *LVMessage::ParseBoolean(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedBoolParser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = PackedBoolParser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - bool result; - ptr = ReadBOOL(ptr, &result); - auto v = std::make_shared>(index, result); - _values.emplace(index, v); - } + else + { + bool result; + ptr = ReadBOOL(ptr, &result); + auto v = std::make_shared>(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if (_use_hardcoded_parse) + const char *LVMessage::ParseInt32(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + { + if (fieldInfo.isRepeated) { - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + auto v = std::make_shared>(index); + ptr = PackedInt32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = PackedInt32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - int32_t result; - ptr = ReadINT32(ptr, &result); - auto v = std::make_shared>(index, result); - _values.emplace(index, v); - } + else + { + int32_t result; + ptr = ReadINT32(ptr, &result); + auto v = std::make_shared>(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseUInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if (_use_hardcoded_parse) + const char *LVMessage::ParseUInt32(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + { + if (fieldInfo.isRepeated) { - SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + auto v = std::make_shared>(index); + ptr = PackedUInt32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = PackedUInt32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - uint32_t result; - ptr = ReadUINT32(ptr, &result); - auto v = std::make_shared>(index, result); - _values.emplace(index, v); - } + else + { + uint32_t result; + ptr = ReadUINT32(ptr, &result); + auto v = std::make_shared>(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseEnum(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + const char *LVMessage::ParseEnum(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedEnumParser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedEnumParser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - int32_t result; - ptr = ReadENUM(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); - } + else + { + int32_t result; + ptr = ReadENUM(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if (_use_hardcoded_parse) + const char *LVMessage::ParseInt64(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + { + if (fieldInfo.isRepeated) { - SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + auto v = std::make_shared>(index); + ptr = PackedInt64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = PackedInt64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - int64_t result; - ptr = ReadINT64(ptr, &result); - auto v = std::make_shared>(index, result); - _values.emplace(index, v); - } + else + { + int64_t result; + ptr = ReadINT64(ptr, &result); + auto v = std::make_shared>(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseUInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if (_use_hardcoded_parse) + const char *LVMessage::ParseUInt64(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + { + if (fieldInfo.isRepeated) { - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } - } - else { - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - uint64_t result; - ptr = ReadUINT64(ptr, &result); - auto v = std::make_shared>(index, result); - _values.emplace(index, v); - } + auto v = std::make_shared>(index); + ptr = PackedUInt64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); + } + else + { + uint64_t result; + ptr = ReadUINT64(ptr, &result); + auto v = std::make_shared>(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseFloat(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + const char *LVMessage::ParseFloat(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedFloatParser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = PackedFloatParser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - float result; - ptr = ReadFLOAT(ptr, &result); - auto v = std::make_shared>(index, result); - _values.emplace(index, v); - } + else + { + float result; + ptr = ReadFLOAT(ptr, &result); + auto v = std::make_shared>(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseDouble(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) - { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + const char *LVMessage::ParseDouble(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + { + if (fieldInfo.isRepeated) + { + auto v = std::make_shared>(index); + ptr = PackedDoubleParser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared>(index); - ptr = PackedDoubleParser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - double result; - ptr = ReadDOUBLE(ptr, &result); - auto v = std::make_shared>(index, result); - _values.emplace(index, v); - } + else + { + double result; + ptr = ReadDOUBLE(ptr, &result); + auto v = std::make_shared>(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseString(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) - { - const char* lv_ptr = (this->getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; - - if (_use_hardcoded_parse) + const char *LVMessage::ParseString(google::protobuf::uint32 tag, const MessageElementMetadata &fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) + { + if (fieldInfo.isRepeated) { - if (fieldInfo.isRepeated) + std::shared_ptr> v; + auto it = _values.find(index); + if (it == _values.end()) { - // Get the _repeatedMessageValues vector from the map - auto _repeatedStringValuesIt = _repeatedStringValuesMap.find(fieldInfo.fieldName); - if (_repeatedStringValuesIt == _repeatedStringValuesMap.end()) - { - _repeatedStringValuesIt = _repeatedStringValuesMap.emplace(fieldInfo.fieldName, google::protobuf::RepeatedField()).first; - } - - protobuf_ptr -= 1; - do { - protobuf_ptr += 1; - auto str = _repeatedStringValuesIt->second.Add(); - protobuf_ptr = InlineGreedyStringParser(str, protobuf_ptr, ctx); - if (!ctx->DataAvailable(protobuf_ptr)) - { - break; - } - } while (ExpectTag(tag, protobuf_ptr)); - - auto arraySize = sizeof(void*) * _repeatedStringValuesIt->second.size(); - auto _lvProvidedArrayHandle = *(void**)lv_ptr; - *(void**)lv_ptr = DSNewHandle(arraySize); - auto arrayHandle = *(LV1DArrayHandle*)lv_ptr; - (*arrayHandle)->cnt = _repeatedStringValuesIt->second.size(); - - // Copy the repeated string values into the LabVIEW array - auto lvStringPtr = (*arrayHandle)->bytes(); - for (auto str:_repeatedStringValuesIt->second) - { - *lvStringPtr = nullptr; - SetLVString(lvStringPtr, str); - lvStringPtr++; - } + v = std::make_shared>(index); + _values.emplace(index, v); } - else { - auto str = std::string(); - protobuf_ptr = InlineGreedyStringParser(&str, protobuf_ptr, ctx); - SetLVString((LStrHandle*)lv_ptr, str); + else + { + v = std::static_pointer_cast>((*it).second); } - } - else { - if (fieldInfo.isRepeated) + protobuf_ptr -= 1; + do { - std::shared_ptr> v; - auto it = _values.find(index); - if (it == _values.end()) - { - v = std::make_shared>(index); - _values.emplace(index, v); - } - else + protobuf_ptr += 1; + auto str = v->_value.Add(); + protobuf_ptr = InlineGreedyStringParser(str, protobuf_ptr, ctx); + if (!ctx->DataAvailable(protobuf_ptr)) { - v = std::static_pointer_cast>((*it).second); + break; } - protobuf_ptr -= 1; - do { - protobuf_ptr += 1; - auto str = v->_value.Add(); - protobuf_ptr = InlineGreedyStringParser(str, protobuf_ptr, ctx); - if (!ctx->DataAvailable(protobuf_ptr)) - { - break; - } - } while (ExpectTag(tag, protobuf_ptr)); - } - else - { - auto str = std::string(); - protobuf_ptr = InlineGreedyStringParser(&str, protobuf_ptr, ctx); - auto v = std::make_shared(index, str); - _values.emplace(index, v); - } + } while (ExpectTag(tag, protobuf_ptr)); + } + else + { + auto str = std::string(); + protobuf_ptr = InlineGreedyStringParser(&str, protobuf_ptr, ctx); + auto v = std::make_shared(index, str); + _values.emplace(index, v); } return protobuf_ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseBytes(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + const char *LVMessage::ParseBytes(google::protobuf::uint32 tag, const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - return ParseString(tag, fieldInfo, index, ptr, ctx); + return ParseString(tag, fieldInfo, index, ptr, ctx); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - bool LVMessage::ExpectTag(google::protobuf::uint32 tag, const char* ptr) + bool LVMessage::ExpectTag(google::protobuf::uint32 tag, const char *ptr) { if (tag < 128) { return *ptr == tag; - } + } else { char buf[2] = {static_cast(tag | 0x80), static_cast(tag >> 7)}; @@ -576,337 +401,167 @@ namespace grpc_labview //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char* LVMessage::ParseSInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) + const char *LVMessage::ParseSInt32(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedSInt32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedSInt32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - int32_t result; - ptr = ReadSINT32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); - } + else + { + int32_t result; + ptr = ReadSINT32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char* LVMessage::ParseSInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) + const char *LVMessage::ParseSInt64(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedSInt64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedSInt64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - int64_t result; - ptr = ReadSINT64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); - } + else + { + int64_t result; + ptr = ReadSINT64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char* LVMessage::ParseFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) + const char *LVMessage::ParseFixed32(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedFixed32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedFixed32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - uint32_t result; - ptr = ReadFIXED32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); - } + else + { + uint32_t result; + ptr = ReadFIXED32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); } return ptr; } - //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char* LVMessage::ParseFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) + const char *LVMessage::ParseFixed64(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedFixed64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedFixed64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - uint64_t result; - ptr = ReadFIXED64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); - } + else + { + uint64_t result; + ptr = ReadFIXED64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char* LVMessage::ParseSFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) + const char *LVMessage::ParseSFixed32(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedSFixed32Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedSFixed32Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - int32_t result; - ptr = ReadSFIXED32(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); - } + else + { + int32_t result; + ptr = ReadSFIXED32(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); } return ptr; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char* LVMessage::ParseSFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, ParseContext* ctx) + const char *LVMessage::ParseSFixed64(const MessageElementMetadata &fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) { - if(_use_hardcoded_parse){ - grpc_labview::SinglePassMessageParser parser(*this, fieldInfo); - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = parser.ParseAndCopyRepeatedMessage(index, ptr, ctx, v); - } - else - { - ptr = parser.ParseAndCopyMessage(ptr); - } + if (fieldInfo.isRepeated) + { + auto v = std::make_shared(index); + ptr = PackedSFixed64Parser(&(v->_value), ptr, ctx); + _values.emplace(index, v); } - else{ - if (fieldInfo.isRepeated) - { - auto v = std::make_shared(index); - ptr = PackedSFixed64Parser(&(v->_value), ptr, ctx); - _values.emplace(index, v); - } - else - { - int64_t result; - ptr = ReadSFIXED64(ptr, &result); - auto v = std::make_shared(index, result); - _values.emplace(index, v); - } + else + { + int64_t result; + ptr = ReadSFIXED64(ptr, &result); + auto v = std::make_shared(index, result); + _values.emplace(index, v); } return ptr; } - //--------------------------------------------------------------------- //--------------------------------------------------------------------- struct LVCluster { }; // TODO: Do not check this in. - //--------------------------------------------------------------------- //--------------------------------------------------------------------- - const char *LVMessage::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) - { + const char *LVMessage::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata &fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) + { auto metadata = fieldInfo._owner->FindMetadata(fieldInfo.embeddedMessageName); - if (_use_hardcoded_parse) - { - const char* lv_ptr = (this->getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; - LVMessage nestedMessage(metadata); - - if (fieldInfo.isRepeated) { - // if the array is not big enough, resize it to 2x the size - auto numElements = 128; - auto elementIndex = 0; - auto clusterSize = metadata->clusterSize; - auto alignment = metadata->alignmentRequirement; - auto arraySize = numElements * clusterSize; - LV1DArrayHandle arrayHandle; - char _fillData = '\0'; - - // Get the _repeatedMessageValues vector from the map - auto _repeatedMessageValuesIt = _repeatedMessageValuesMap.find(metadata->messageName); - if (_repeatedMessageValuesIt == _repeatedMessageValuesMap.end()) + if (fieldInfo.isRepeated) + { + protobuf_ptr -= 1; + do + { + std::shared_ptr v; + auto it = _values.find(index); + if (it == _values.end()) { - _repeatedMessageValuesIt = _repeatedMessageValuesMap.emplace(metadata->messageName, google::protobuf::RepeatedField()).first; - } - - // There are situations where the protobuf message is not complete, and we need to continue from the last index. - // This function returns to _internalParse, and then gets back to this function. - // If we are continuing from a previous parse, then we need to continue from the last index - auto _continueFromIndex = _repeatedField_continueIndex.find(metadata->messageName); - if (_continueFromIndex != _repeatedField_continueIndex.end()) { - elementIndex = _continueFromIndex->second; - _repeatedField_continueIndex.erase(_continueFromIndex); - // find next largest power of 2, as we assume that we previously resized it to a power of 2 - auto _size = (int)ceil(log2(elementIndex)); - numElements = ((1 << _size) > 128) ? (1 << _size) : 128; - } - else { - // occurs on the first time this function is called - _repeatedMessageValuesIt->second.Resize(arraySize, _fillData); + v = std::make_shared(index); + _values.emplace(index, v); } - - protobuf_ptr -= 1; - do + else { - protobuf_ptr += 1; - - // Resize the vector if we need more memory - if (elementIndex >= numElements - 1) { - numElements *= 2; - arraySize = numElements * clusterSize; - auto s = _repeatedMessageValuesIt->second.size(); - _repeatedMessageValuesIt->second.Resize(arraySize, _fillData); - } - - auto _vectorPtr = _repeatedMessageValuesIt->second.data(); - _vectorPtr = _vectorPtr + (elementIndex * clusterSize); - nestedMessage.setLVClusterHandle(_vectorPtr); - protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); - - elementIndex++; - - if (!ctx->DataAvailable(protobuf_ptr)) { - break; - } - } while (ExpectTag(tag, protobuf_ptr)); - - // shrink the array to the correct size - arraySize = elementIndex * clusterSize; - auto old_arrayHandle = *(void**)lv_ptr; - DSDisposeHandle(old_arrayHandle); - *(void**)lv_ptr = DSNewHandle(arraySize); - arrayHandle = *(LV1DArrayHandle*)lv_ptr; - (*arrayHandle)->cnt = elementIndex; - - auto _vectorDataPtr = _repeatedMessageValuesIt->second.data(); - auto _lvArrayDataPtr = (*arrayHandle)->bytes(0, alignment); - memcpy(_lvArrayDataPtr, _vectorDataPtr, arraySize); - - _repeatedField_continueIndex.emplace(metadata->messageName, elementIndex); - } - else { - nestedMessage.setLVClusterHandle(lv_ptr); - protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); - } - } - else { - if (fieldInfo.isRepeated) - { - protobuf_ptr -= 1; - do { - std::shared_ptr v; - auto it = _values.find(index); - if (it == _values.end()) - { - v = std::make_shared(index); - _values.emplace(index, v); - } - else - { - v = std::static_pointer_cast((*it).second); - } - protobuf_ptr += 1; - auto nestedMessage = std::make_shared(metadata); - protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); - v->_value.push_back(nestedMessage); - if (!ctx->DataAvailable(protobuf_ptr)) - { - break; - } - } while (ExpectTag(tag, protobuf_ptr)); - } - else - { + v = std::static_pointer_cast((*it).second); + } + protobuf_ptr += 1; auto nestedMessage = std::make_shared(metadata); protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); - auto v = std::make_shared(index, nestedMessage); - _values.emplace(index, v); - } + v->_value.push_back(nestedMessage); + if (!ctx->DataAvailable(protobuf_ptr)) + { + break; + } + } while (ExpectTag(tag, protobuf_ptr)); + } + else + { + auto nestedMessage = std::make_shared(metadata); + protobuf_ptr = ctx->ParseMessage(nestedMessage.get(), protobuf_ptr); + auto v = std::make_shared(index, nestedMessage); + _values.emplace(index, v); } return protobuf_ptr; } @@ -1015,4 +670,3 @@ namespace grpc_labview return google::protobuf::Metadata(); } } - diff --git a/src/lv_message.h b/src/lv_message.h index 6a2bbfd7..0cf89c0d 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -18,7 +18,6 @@ namespace grpc_labview { public: LVMessage(std::shared_ptr metadata); - LVMessage(std::shared_ptr metadata, bool use_hardcoded_parse, bool skipCopyOnFirstParse); ~LVMessage(); google::protobuf::UnknownFieldSet& UnknownFields(); @@ -48,96 +47,39 @@ namespace grpc_labview bool ParseFromByteBuffer(const grpc::ByteBuffer& buffer); std::unique_ptr SerializeToByteBuffer(); - public: - std::map> _values; - std::shared_ptr _metadata; - std::unordered_map _repeatedField_continueIndex; - std::unordered_map> _repeatedMessageValuesMap; - std::unordered_map> _repeatedStringValuesMap; - // std::vector _messageValues; - //std::vector _repeatedMessageValues; - bool _use_hardcoded_parse; - bool _skipCopyOnFirstParse; - - void setLVClusterHandle(const char* lvClusterHandle) { + void SetLVClusterHandle(const char* lvClusterHandle) { _LVClusterHandle = lvClusterHandle; }; - const char* getLVClusterHandleSharedPtr() { + const char* GetLVClusterHandleSharedPtr() { return _LVClusterHandle; }; - private: + std::map> _values; + std::shared_ptr _metadata; + + protected: mutable google::protobuf::internal::CachedSize _cached_size_; google::protobuf::UnknownFieldSet _unknownFields; const char* _LVClusterHandle; - const char *ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseUInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseEnum(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseUInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseFloat(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseDouble(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char* ParseSInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); - const char* ParseSInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); - const char* ParseFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); - const char* ParseFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); - const char* ParseSFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); - const char* ParseSFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); - const char *ParseString(unsigned int tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseBytes(unsigned int tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); - const char *ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseUInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseEnum(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseUInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseFloat(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseDouble(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char* ParseSInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + virtual const char* ParseSInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + virtual const char* ParseFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + virtual const char* ParseFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + virtual const char* ParseSFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + virtual const char* ParseSFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + virtual const char *ParseString(unsigned int tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseBytes(unsigned int tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + virtual const char *ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); bool ExpectTag(google::protobuf::uint32 tag, const char* ptr); }; - - template - class SinglePassMessageParser { - private: - LVMessage& _message; - const char* _lv_ptr; - public: - // Constructor and other necessary member functions - SinglePassMessageParser(LVMessage& message, const MessageElementMetadata& fieldInfo) : _message(message) { - _lv_ptr = reinterpret_cast(_message.getLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; - } - - // Parse and copy message in a single pass. - template - const char* ParseAndCopyRepeatedMessage(uint32_t index, const char *ptr, ParseContext *ctx, RepeatedMessageValuePointer v) { - - uint64_t numElements; - ptr = PackedMessageType(ptr, ctx, index, reinterpret_cast*>(&(v->_value))); - numElements = v->_value.size(); - // get the LVClusterHandle - - // copy into LVCluster - if (numElements != 0) - { - NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(_lv_ptr)), numElements); - auto array = *(LV1DArrayHandle*)_lv_ptr; - (*array)->cnt = numElements; - auto byteCount = numElements * sizeof(MessageType); - std::memcpy((*array)->bytes(), v->_value.data(), byteCount); - } - - return ptr; - } - - const char* ParseAndCopyMessage(const char *ptr) { - ptr = ReadMessageType(ptr, reinterpret_cast(const_cast(_lv_ptr))); - return ptr; - } - - const char* ReadMessageType(const char* ptr, MessageType* lv_ptr) - { - return ReadFunc(ptr, lv_ptr); - } - - const char* PackedMessageType(const char* ptr, ParseContext* ctx, int index, google::protobuf::RepeatedField* value) - { - return PackedFunc(value, ptr, ctx); - } - }; } diff --git a/src/lv_message_efficient.cc b/src/lv_message_efficient.cc new file mode 100644 index 00000000..1670fb30 --- /dev/null +++ b/src/lv_message_efficient.cc @@ -0,0 +1,202 @@ +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +#include +#include "lv_message_efficient.h" +#include + +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +using namespace google::protobuf::internal; + +namespace grpc_labview +{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + google::protobuf::Message* LVMessageEfficient::New(google::protobuf::Arena* arena) const + { + assert(false); // not expected to be called + return nullptr; + } + +#define DEFINE_PARSE_FUNCTION(Type, TypeName, ReadType, ParserType) \ + const char *LVMessageEfficient::Parse##TypeName(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) \ + { \ + SinglePassMessageParser parser(*this, fieldInfo); \ + if (fieldInfo.isRepeated) \ + { \ + auto v = std::make_shared>(index); \ + ptr = parser.ParseAndCopyRepeatedMessage(ptr, ctx, v); \ + } \ + else \ + { \ + ptr = parser.ParseAndCopyMessage(ptr); \ + } \ + return ptr; \ + } + +#define DEFINE_PARSE_FUNCTION_SPECIAL(Type, TypeName, ReadType, ParserType) \ + const char *LVMessageEfficient::Parse##TypeName(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) \ + { \ + SinglePassMessageParser parser(*this, fieldInfo); \ + if (fieldInfo.isRepeated) \ + { \ + auto v = std::make_shared(index); \ + ptr = parser.ParseAndCopyRepeatedMessage(ptr, ctx, v); \ + } \ + else \ + { \ + ptr = parser.ParseAndCopyMessage(ptr); \ + } \ + return ptr; \ + } + + DEFINE_PARSE_FUNCTION(bool, Boolean, BOOL, Bool) + DEFINE_PARSE_FUNCTION(int32_t, Int32, INT32, Int32) + DEFINE_PARSE_FUNCTION(uint32_t, UInt32, UINT32, UInt32) + DEFINE_PARSE_FUNCTION(int64_t, Int64, INT64, Int64) + DEFINE_PARSE_FUNCTION(uint64_t, UInt64, UINT64, UInt64) + DEFINE_PARSE_FUNCTION(float, Float, FLOAT, Float) + DEFINE_PARSE_FUNCTION(double, Double, DOUBLE, Double) + DEFINE_PARSE_FUNCTION_SPECIAL(int32_t, Enum, ENUM, Enum) + DEFINE_PARSE_FUNCTION_SPECIAL(int32_t, SInt32, SINT32, SInt32) + DEFINE_PARSE_FUNCTION_SPECIAL(int64_t, SInt64, SINT64, SInt64) + DEFINE_PARSE_FUNCTION_SPECIAL(uint32_t, Fixed32, FIXED32, Fixed32) + DEFINE_PARSE_FUNCTION_SPECIAL(uint64_t, Fixed64, FIXED64, Fixed64) + DEFINE_PARSE_FUNCTION_SPECIAL(int32_t, SFixed32, SFIXED32, SFixed32) + DEFINE_PARSE_FUNCTION_SPECIAL(int64_t, SFixed64, SFIXED64, SFixed64) + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + const char *LVMessageEfficient::ParseString(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) + { + const char* lv_ptr = (this->GetLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + + if (fieldInfo.isRepeated) + { + // Get the _repeatedMessageValues vector from the map + auto _repeatedStringValuesIt = _repeatedStringValuesMap.find(fieldInfo.fieldName); + if (_repeatedStringValuesIt == _repeatedStringValuesMap.end()) + { + _repeatedStringValuesIt = _repeatedStringValuesMap.emplace(fieldInfo.fieldName, google::protobuf::RepeatedField()).first; + } + + protobuf_ptr -= 1; + do { + protobuf_ptr += 1; + auto str = _repeatedStringValuesIt->second.Add(); + protobuf_ptr = InlineGreedyStringParser(str, protobuf_ptr, ctx); + if (!ctx->DataAvailable(protobuf_ptr)) + { + break; + } + } while (ExpectTag(tag, protobuf_ptr)); + + auto arraySize = sizeof(void*) * _repeatedStringValuesIt->second.size(); + auto _lvProvidedArrayHandle = *(void**)lv_ptr; + *(void**)lv_ptr = DSNewHandle(arraySize); + auto arrayHandle = *(LV1DArrayHandle*)lv_ptr; + (*arrayHandle)->cnt = _repeatedStringValuesIt->second.size(); + + // Copy the repeated string values into the LabVIEW array + auto lvStringPtr = (*arrayHandle)->bytes(); + for (auto str:_repeatedStringValuesIt->second) + { + *lvStringPtr = nullptr; + SetLVString(lvStringPtr, str); + lvStringPtr++; + } + } + else { + auto str = std::string(); + protobuf_ptr = InlineGreedyStringParser(&str, protobuf_ptr, ctx); + SetLVString((LStrHandle*)lv_ptr, str); + } + return protobuf_ptr; + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + const char *LVMessageEfficient::ParseBytes(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, ParseContext *ctx) + { + return ParseString(tag, fieldInfo, index, ptr, ctx); + } + + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + struct LVCluster + { + }; // TODO: Do not check this in. + + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + const char *LVMessageEfficient::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) + { + auto metadata = fieldInfo._owner->FindMetadata(fieldInfo.embeddedMessageName); + + const char* lv_ptr = (this->GetLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + LVMessageEfficient nestedMessage(metadata); + + if (fieldInfo.isRepeated) { + // if the array is not big enough, resize it to 2x the size + auto numElements = 128; + auto elementIndex = 0; + auto clusterSize = metadata->clusterSize; + auto alignment = metadata->alignmentRequirement; + auto arraySize = numElements * clusterSize; + LV1DArrayHandle arrayHandle; + char _fillData = '\0'; + + // Get the _repeatedMessageValues vector from the map + auto _repeatedMessageValuesIt = _repeatedMessageValuesMap.find(metadata->messageName); + if (_repeatedMessageValuesIt == _repeatedMessageValuesMap.end()) + { + _repeatedMessageValuesIt = _repeatedMessageValuesMap.emplace(metadata->messageName, google::protobuf::RepeatedField()).first; + } + + protobuf_ptr -= 1; + do + { + protobuf_ptr += 1; + + // Resize the vector if we need more memory + if (elementIndex >= numElements - 1) { + numElements *= 2; + arraySize = numElements * clusterSize; + auto s = _repeatedMessageValuesIt->second.size(); + _repeatedMessageValuesIt->second.Resize(arraySize, _fillData); + } + + auto _vectorPtr = _repeatedMessageValuesIt->second.data(); + _vectorPtr = _vectorPtr + (elementIndex * clusterSize); + nestedMessage.SetLVClusterHandle(_vectorPtr); + protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); + + elementIndex++; + + if (!ctx->DataAvailable(protobuf_ptr)) { + break; + } + } while (ExpectTag(tag, protobuf_ptr)); + + // shrink the array to the correct size + arraySize = elementIndex * clusterSize; + auto old_arrayHandle = *(void**)lv_ptr; + DSDisposeHandle(old_arrayHandle); + *(void**)lv_ptr = DSNewHandle(arraySize); + arrayHandle = *(LV1DArrayHandle*)lv_ptr; + (*arrayHandle)->cnt = elementIndex; + + auto _vectorDataPtr = _repeatedMessageValuesIt->second.data(); + auto _lvArrayDataPtr = (*arrayHandle)->bytes(0, alignment); + memcpy(_lvArrayDataPtr, _vectorDataPtr, arraySize); + } + else { + nestedMessage.SetLVClusterHandle(lv_ptr); + protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); + } + return protobuf_ptr; + } +} + diff --git a/src/lv_message_efficient.h b/src/lv_message_efficient.h new file mode 100644 index 00000000..d5292b17 --- /dev/null +++ b/src/lv_message_efficient.h @@ -0,0 +1,99 @@ +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +#pragma once + +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +#include +#include +#include +#include "lv_message.h" + +using namespace google::protobuf::internal; + +namespace grpc_labview +{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + class LVMessageEfficient : public LVMessage + { + public: + LVMessageEfficient(std::shared_ptr metadata) : LVMessage(metadata) {} + ~LVMessageEfficient() {} + + Message* New(google::protobuf::Arena* arena) const override; + + public: + std::unordered_map _repeatedField_continueIndex; + std::unordered_map> _repeatedMessageValuesMap; + std::unordered_map> _repeatedStringValuesMap; + + protected: + const char *ParseBoolean(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseUInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseEnum(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseUInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseFloat(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseDouble(const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char* ParseSInt32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + const char* ParseSInt64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + const char* ParseFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + const char* ParseFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + const char* ParseSFixed32(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + const char* ParseSFixed64(const MessageElementMetadata& fieldInfo, uint32_t index, const char* ptr, google::protobuf::internal::ParseContext* ctx); + const char *ParseString(unsigned int tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseBytes(unsigned int tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + const char *ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *ptr, google::protobuf::internal::ParseContext *ctx); + }; + + template + class SinglePassMessageParser { + private: + LVMessage& _message; + const char* _lv_ptr; + public: + // Constructor and other necessary member functions + SinglePassMessageParser(LVMessage& message, const MessageElementMetadata& fieldInfo) : _message(message) { + _lv_ptr = reinterpret_cast(_message.GetLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + } + + // Parse and copy message in a single pass. + template + const char* ParseAndCopyRepeatedMessage(const char *ptr, ParseContext *ctx, RepeatedMessageValuePointer v) { + + uint64_t numElements; + ptr = PackedMessageType(ptr, ctx, reinterpret_cast*>(&(v->_value))); + numElements = v->_value.size(); + // get the LVClusterHandle + + // copy into LVCluster + if (numElements != 0) + { + NumericArrayResize(0x08, 1, reinterpret_cast(const_cast(_lv_ptr)), numElements); + auto array = *(LV1DArrayHandle*)_lv_ptr; + (*array)->cnt = numElements; + auto byteCount = numElements * sizeof(MessageType); + std::memcpy((*array)->bytes(), v->_value.data(), byteCount); + } + + return ptr; + } + + const char* PackedMessageType(const char* ptr, ParseContext* ctx, google::protobuf::RepeatedField* value) + { + return PackedFunc(value, ptr, ctx); + } + + const char* ParseAndCopyMessage(const char *ptr) { + ptr = ReadMessageType(ptr, reinterpret_cast(const_cast(_lv_ptr))); + return ptr; + } + + const char* ReadMessageType(const char* ptr, MessageType* lv_ptr) + { + return ReadFunc(ptr, lv_ptr); + } + }; +} From 9c20e5da4935f8f0ebba005a8bee682317cf6e0e Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 17 Jan 2024 11:41:42 +0530 Subject: [PATCH 32/43] Continue index required for nested message type only. --- src/lv_message_efficient.cc | 16 ++++++++++++++++ src/lv_message_efficient.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/lv_message_efficient.cc b/src/lv_message_efficient.cc index 1670fb30..7f55fd4c 100644 --- a/src/lv_message_efficient.cc +++ b/src/lv_message_efficient.cc @@ -155,6 +155,22 @@ namespace grpc_labview _repeatedMessageValuesIt = _repeatedMessageValuesMap.emplace(metadata->messageName, google::protobuf::RepeatedField()).first; } + // There are situations where the protobuf message is not complete, and we need to continue from the last index. + // This function returns to _internalParse, and then gets back to this function. + // If we are continuing from a previous parse, then we need to continue from the last index + auto _continueFromIndex = _repeatedField_continueIndex.find(metadata->messageName); + if (_continueFromIndex != _repeatedField_continueIndex.end()) { + elementIndex = _continueFromIndex->second; + _repeatedField_continueIndex.erase(_continueFromIndex); + // find next largest power of 2, as we assume that we previously resized it to a power of 2 + auto _size = (int)ceil(log2(elementIndex)); + numElements = ((1 << _size) > 128) ? (1 << _size) : 128; + } + else { + // occurs on the first time this function is called + _repeatedMessageValuesIt->second.Resize(arraySize, _fillData); + } + protobuf_ptr -= 1; do { diff --git a/src/lv_message_efficient.h b/src/lv_message_efficient.h index d5292b17..0e175b50 100644 --- a/src/lv_message_efficient.h +++ b/src/lv_message_efficient.h @@ -68,6 +68,9 @@ namespace grpc_labview numElements = v->_value.size(); // get the LVClusterHandle + // ContinueIndex is not required here as the _value vector created is of the corresponding type, and is not being used a buffer. + // PackedMessageType will just be able to push_back or add the later parsed data to the type vector. + // copy into LVCluster if (numElements != 0) { From bd77565f1c1134f593587d8eb52764c9bcef0c3c Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 17 Jan 2024 12:49:54 +0530 Subject: [PATCH 33/43] Config file read in InitCallback is enough --- src/grpc_client.cc | 21 --------------------- src/grpc_server.cc | 3 --- 2 files changed, 24 deletions(-) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index d8940abc..e25c86f9 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -277,9 +277,6 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( int32_t timeoutMs, grpc_labview::gRPCid* contextId) { - // Instantiating the feature toggles singleton that will read the feature configuration file - FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); - auto client = clientId->CastTo(); if (!client) { @@ -405,9 +402,6 @@ LIBRARY_EXPORT int32_t ClientBeginClientStreamingCall( int32_t timeoutMs, grpc_labview::gRPCid* contextId) { - // Instantiating the feature toggles singleton that will read the feature configuration file - FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); - auto client = clientId->CastTo(); if (!client) { @@ -462,9 +456,6 @@ LIBRARY_EXPORT int32_t ClientBeginServerStreamingCall( int32_t timeoutMs, grpc_labview::gRPCid* contextId) { - // Instantiating the feature toggles singleton that will read the feature configuration file - FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); - auto client = clientId->CastTo(); if (!client) { @@ -527,9 +518,6 @@ LIBRARY_EXPORT int32_t ClientBeginBidiStreamingCall( int32_t timeoutMs, grpc_labview::gRPCid* contextId) { - // Instantiating the feature toggles singleton that will read the feature configuration file - FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); - auto client = clientId->CastTo(); if (!client) { @@ -576,9 +564,6 @@ LIBRARY_EXPORT int32_t ClientBeginBidiStreamingCall( //--------------------------------------------------------------------- LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr) { - // Instantiating the feature toggles singleton that will read the feature configuration file - FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); - auto reader = callId->CastTo(); auto call = callId->CastTo(); @@ -608,9 +593,6 @@ LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, g //--------------------------------------------------------------------- LIBRARY_EXPORT int32_t ClientCompleteReadFromStream(grpc_labview::gRPCid* callId, int* success, int8_t* responseCluster) { - // Instantiating the feature toggles singleton that will read the feature configuration file - FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); - auto reader = callId->CastTo(); auto call = callId->CastTo(); if (!reader || !call) @@ -637,9 +619,6 @@ LIBRARY_EXPORT int32_t ClientCompleteReadFromStream(grpc_labview::gRPCid* callId //--------------------------------------------------------------------- LIBRARY_EXPORT int32_t ClientWriteToStream(grpc_labview::gRPCid* callId, int8_t* requestCluster, int* success) { - // Instantiating the feature toggles singleton that will read the feature configuration file - FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); - auto writer = callId->CastTo(); if (!writer) { diff --git a/src/grpc_server.cc b/src/grpc_server.cc index 993ee9fe..4c0598f1 100644 --- a/src/grpc_server.cc +++ b/src/grpc_server.cc @@ -179,9 +179,6 @@ namespace grpc_labview std::string serverKeyPath, ServerStartEventData *serverStarted) { - // Instantiating the feature toggles singleton that will read the feature configuration file - FeatureConfig::getInstance().readConfigFromFile("feature_config.ini"); - std::string server_address; if (address.length() != 0) { From fe5e0f29610cd378258897ac36b2ca6dce8057f2 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 17 Jan 2024 14:49:56 +0530 Subject: [PATCH 34/43] remove empty LVCluster declaration --- src/lv_message.cc | 6 ------ src/lv_message_efficient.cc | 8 -------- 2 files changed, 14 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index bbf0dac2..c398f3c0 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -519,12 +519,6 @@ namespace grpc_labview return ptr; } - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - struct LVCluster - { - }; // TODO: Do not check this in. - //--------------------------------------------------------------------- //--------------------------------------------------------------------- const char *LVMessage::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata &fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) diff --git a/src/lv_message_efficient.cc b/src/lv_message_efficient.cc index 7f55fd4c..e1267cb2 100644 --- a/src/lv_message_efficient.cc +++ b/src/lv_message_efficient.cc @@ -121,14 +121,6 @@ namespace grpc_labview return ParseString(tag, fieldInfo, index, ptr, ctx); } - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - struct LVCluster - { - }; // TODO: Do not check this in. - - //--------------------------------------------------------------------- //--------------------------------------------------------------------- const char *LVMessageEfficient::ParseNestedMessage(google::protobuf::uint32 tag, const MessageElementMetadata& fieldInfo, uint32_t index, const char *protobuf_ptr, ParseContext *ctx) From 2132292084854e15090d868058e0b0f4d60bcc94 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 17 Jan 2024 14:51:05 +0530 Subject: [PATCH 35/43] Removing feature toggle header --- src/grpc_client.cc | 1 - src/grpc_server.cc | 1 - 2 files changed, 2 deletions(-) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index e25c86f9..2eeb48b2 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -10,7 +10,6 @@ #include #include #include -#include "feature_toggles.h" namespace grpc_labview { diff --git a/src/grpc_server.cc b/src/grpc_server.cc index 4c0598f1..a132e32e 100644 --- a/src/grpc_server.cc +++ b/src/grpc_server.cc @@ -9,7 +9,6 @@ #include #include #include "lv_proto_server_reflection_plugin.h" -#include "feature_toggles.h" //--------------------------------------------------------------------- //--------------------------------------------------------------------- From d93084a205708d83708032a7d974766d3ca0046c Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Thu, 18 Jan 2024 14:27:26 +0530 Subject: [PATCH 36/43] Adding a PostParseAction to enable custom post action. In this case, copying into LV cluster when required. --- src/lv_message.cc | 1 + src/lv_message.h | 3 ++- src/lv_message_efficient.cc | 52 +++++++++++++++++++++++++------------ src/lv_message_efficient.h | 13 +++++++++- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/lv_message.cc b/src/lv_message.cc index c398f3c0..9a7bd520 100644 --- a/src/lv_message.cc +++ b/src/lv_message.cc @@ -175,6 +175,7 @@ namespace grpc_labview } } } + PostInteralParseAction(); return ptr; } diff --git a/src/lv_message.h b/src/lv_message.h index 0cf89c0d..e75eb7ea 100644 --- a/src/lv_message.h +++ b/src/lv_message.h @@ -31,11 +31,12 @@ namespace grpc_labview void Clear() final; bool IsInitialized() const final; - const char* _InternalParse(const char *ptr, google::protobuf::internal::ParseContext *ctx) override final; + const char* _InternalParse(const char* ptr, google::protobuf::internal::ParseContext* ctx) override final; google::protobuf::uint8* _InternalSerialize(google::protobuf::uint8* target, google::protobuf::io::EpsCopyOutputStream* stream) const override final; void SetCachedSize(int size) const final; int GetCachedSize(void) const final; size_t ByteSizeLong() const final; + virtual void PostInteralParseAction() {}; void MergeFrom(const google::protobuf::Message &from) final; void MergeFrom(const LVMessage &from); diff --git a/src/lv_message_efficient.cc b/src/lv_message_efficient.cc index e1267cb2..a988ad90 100644 --- a/src/lv_message_efficient.cc +++ b/src/lv_message_efficient.cc @@ -127,7 +127,6 @@ namespace grpc_labview { auto metadata = fieldInfo._owner->FindMetadata(fieldInfo.embeddedMessageName); - const char* lv_ptr = (this->GetLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; LVMessageEfficient nestedMessage(metadata); if (fieldInfo.isRepeated) { @@ -137,14 +136,14 @@ namespace grpc_labview auto clusterSize = metadata->clusterSize; auto alignment = metadata->alignmentRequirement; auto arraySize = numElements * clusterSize; - LV1DArrayHandle arrayHandle; char _fillData = '\0'; // Get the _repeatedMessageValues vector from the map auto _repeatedMessageValuesIt = _repeatedMessageValuesMap.find(metadata->messageName); if (_repeatedMessageValuesIt == _repeatedMessageValuesMap.end()) { - _repeatedMessageValuesIt = _repeatedMessageValuesMap.emplace(metadata->messageName, google::protobuf::RepeatedField()).first; + auto m_val = std::make_shared(fieldInfo, google::protobuf::RepeatedField()); + _repeatedMessageValuesIt = _repeatedMessageValuesMap.emplace(metadata->messageName, m_val).first; } // There are situations where the protobuf message is not complete, and we need to continue from the last index. @@ -160,7 +159,7 @@ namespace grpc_labview } else { // occurs on the first time this function is called - _repeatedMessageValuesIt->second.Resize(arraySize, _fillData); + _repeatedMessageValuesIt->second.get()->_buffer.Resize(arraySize, _fillData); } protobuf_ptr -= 1; @@ -172,11 +171,11 @@ namespace grpc_labview if (elementIndex >= numElements - 1) { numElements *= 2; arraySize = numElements * clusterSize; - auto s = _repeatedMessageValuesIt->second.size(); - _repeatedMessageValuesIt->second.Resize(arraySize, _fillData); + auto s = _repeatedMessageValuesIt->second.get()->_buffer.size(); + _repeatedMessageValuesIt->second.get()->_buffer.Resize(arraySize, _fillData); } - auto _vectorPtr = _repeatedMessageValuesIt->second.data(); + auto _vectorPtr = _repeatedMessageValuesIt->second.get()->_buffer.data(); _vectorPtr = _vectorPtr + (elementIndex * clusterSize); nestedMessage.SetLVClusterHandle(_vectorPtr); protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); @@ -187,24 +186,45 @@ namespace grpc_labview break; } } while (ExpectTag(tag, protobuf_ptr)); + + _repeatedMessageValuesIt->second.get()->_numElements = elementIndex; + _repeatedField_continueIndex.emplace(metadata->messageName, elementIndex); + } + else { + const char* lv_ptr = (this->GetLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + nestedMessage.SetLVClusterHandle(lv_ptr); + protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); + } + return protobuf_ptr; + } + + void LVMessageEfficient::PostInteralParseAction() + { + for each (auto nestedMessage in _repeatedMessageValuesMap) + { + auto fieldInfo = nestedMessage.second.get()->_fieldInfo; + auto buffer = nestedMessage.second.get()->_buffer; + auto numElements = nestedMessage.second.get()->_numElements; + + auto metadata = fieldInfo._owner->FindMetadata(fieldInfo.embeddedMessageName); + const char* lv_ptr = (this->GetLVClusterHandleSharedPtr()) + fieldInfo.clusterOffset; + auto clusterSize = metadata->clusterSize; + auto alignment = metadata->alignmentRequirement; + // shrink the array to the correct size - arraySize = elementIndex * clusterSize; + auto arraySize = numElements * clusterSize; auto old_arrayHandle = *(void**)lv_ptr; DSDisposeHandle(old_arrayHandle); *(void**)lv_ptr = DSNewHandle(arraySize); - arrayHandle = *(LV1DArrayHandle*)lv_ptr; - (*arrayHandle)->cnt = elementIndex; + auto arrayHandle = *(LV1DArrayHandle*)lv_ptr; + (*arrayHandle)->cnt = numElements; - auto _vectorDataPtr = _repeatedMessageValuesIt->second.data(); + auto _vectorDataPtr = buffer.data(); auto _lvArrayDataPtr = (*arrayHandle)->bytes(0, alignment); memcpy(_lvArrayDataPtr, _vectorDataPtr, arraySize); } - else { - nestedMessage.SetLVClusterHandle(lv_ptr); - protobuf_ptr = ctx->ParseMessage(&nestedMessage, protobuf_ptr); - } - return protobuf_ptr; } + } diff --git a/src/lv_message_efficient.h b/src/lv_message_efficient.h index 0e175b50..dab6b718 100644 --- a/src/lv_message_efficient.h +++ b/src/lv_message_efficient.h @@ -22,10 +22,21 @@ namespace grpc_labview ~LVMessageEfficient() {} Message* New(google::protobuf::Arena* arena) const override; + void PostInteralParseAction() override; + protected: + struct RepeatedMessageValue { + const MessageElementMetadata& _fieldInfo; + google::protobuf::RepeatedField _buffer; + uint64_t _numElements = 0; + + RepeatedMessageValue(const MessageElementMetadata& fieldInfo, google::protobuf::RepeatedField buffer) : + _fieldInfo(fieldInfo), _buffer(buffer) {} + }; + public: std::unordered_map _repeatedField_continueIndex; - std::unordered_map> _repeatedMessageValuesMap; + std::unordered_map> _repeatedMessageValuesMap; std::unordered_map> _repeatedStringValuesMap; protected: From 2ab27d5f412bae863122fdcbed5be646b7467998 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Fri, 19 Jan 2024 13:09:44 +0530 Subject: [PATCH 37/43] Removing efficient copy for streaming clients --- src/grpc_client.cc | 89 +++++++++++++++++++++++++++------------------- src/grpc_client.h | 1 + 2 files changed, 53 insertions(+), 37 deletions(-) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 9a97d84c..9e14c2a9 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -264,6 +264,23 @@ LIBRARY_EXPORT int32_t CloseClientContext(grpc_labview::gRPCid* contextId) return 0; } +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +LIBRARY_EXPORT int32_t ClientUnaryCall( + grpc_labview::gRPCid* clientId, + grpc_labview::MagicCookie* occurrence, + const char* methodName, + const char* requestMessageName, + const char* responseMessageName, + int8_t* requestCluster, + grpc_labview::gRPCid** callId, + int32_t timeoutMs, + grpc_labview::gRPCid* contextId) +{ + ClientUnaryCall(clientId, occurrence, methodName, requestMessageName, responseMessageName, requestCluster, callId, timeoutMs, contextId, nullptr); +} + + //--------------------------------------------------------------------- //--------------------------------------------------------------------- LIBRARY_EXPORT int32_t ClientUnaryCall( @@ -311,16 +328,20 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( clientCall->_occurrence = *occurrence; clientCall->_context = clientContext; - if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")){ - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); + if (FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy") && responseCluster != nullptr){ + clientCall->_useLVEfficientMessage = false; } - else { + + if (clientCall->_useLVEfficientMessage){ clientCall->_request = std::make_shared(requestMetadata); clientCall->_response = std::make_shared(responseMetadata); clientCall->_request->SetLVClusterHandle(reinterpret_cast(requestCluster)); clientCall->_response->SetLVClusterHandle(reinterpret_cast(responseCluster)); } + else { + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); + } try { @@ -354,8 +375,8 @@ LIBRARY_EXPORT int32_t CompleteClientUnaryCall2( grpc_labview::LStrHandle* errorMessage, grpc_labview::AnyCluster* errorDetailsCluster) { - auto call = callId->CastTo(); - if (!call) + auto clientCall = callId->CastTo(); + if (!clientCall) { return -1; } @@ -363,12 +384,12 @@ LIBRARY_EXPORT int32_t CompleteClientUnaryCall2( grpc_labview::gPointerManager.UnregisterPointer(callId); int32_t result = 0; - if (call->_status.ok()) + if (clientCall->_status.ok()) { - if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")) { + if (!clientCall->_useLVEfficientMessage) { try { - grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + grpc_labview::ClusterDataCopier::CopyToCluster(*clientCall->_response.get(), responseCluster); } catch (grpc_labview::InvalidEnumValueException& e) { @@ -382,17 +403,17 @@ LIBRARY_EXPORT int32_t CompleteClientUnaryCall2( } else { - result = -(1000 + call->_status.error_code()); + result = -(1000 + clientCall->_status.error_code()); if (errorMessage != nullptr) { - grpc_labview::SetLVString(errorMessage, call->_status.error_message()); + grpc_labview::SetLVString(errorMessage, clientCall->_status.error_message()); } if (errorDetailsCluster != nullptr) { } } - std::lock_guard lock(call->_client->clientLock); - call->_client->ActiveClientCalls.remove(call.get()); + std::lock_guard lock(clientCall->_client->clientLock); + clientCall->_client->ActiveClientCalls.remove(clientCall.get()); return result; } @@ -598,11 +619,10 @@ LIBRARY_EXPORT int32_t ClientBeginBidiStreamingCall( //--------------------------------------------------------------------- //--------------------------------------------------------------------- -LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr, int8_t* responseCluster) +LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr) { auto reader = callId->CastTo(); auto call = callId->CastTo(); - call->_response->SetLVClusterHandle(reinterpret_cast(responseCluster)); auto occurrence = *occurrencePtr; if (!reader || !call) @@ -639,15 +659,13 @@ LIBRARY_EXPORT int32_t ClientCompleteReadFromStream(grpc_labview::gRPCid* callId *success = reader->_readFuture.get(); if (*success) { - if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")) { - try - { - grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); - } - catch (grpc_labview::InvalidEnumValueException& e) - { - return e.code; - } + try + { + grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + } + catch (grpc_labview::InvalidEnumValueException& e) + { + return e.code; } } return 0; @@ -708,18 +726,16 @@ LIBRARY_EXPORT int32_t FinishClientCompleteClientStreamingCall( int32_t result = 0; if (call->_status.ok()) { - if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")) { - try - { - grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); - } - catch (grpc_labview::InvalidEnumValueException& e) + try + { + grpc_labview::ClusterDataCopier::CopyToCluster(*call->_response.get(), responseCluster); + } + catch (grpc_labview::InvalidEnumValueException& e) + { + result = e.code; + if (errorMessage != nullptr) { - result = e.code; - if (errorMessage != nullptr) - { - grpc_labview::SetLVString(errorMessage, e.what()); - } + grpc_labview::SetLVString(errorMessage, e.what()); } } } @@ -744,10 +760,9 @@ LIBRARY_EXPORT int32_t FinishClientCompleteClientStreamingCall( //--------------------------------------------------------------------- //--------------------------------------------------------------------- -LIBRARY_EXPORT int32_t ClientCompleteClientStreamingCall(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr, int8_t* responseCluster) +LIBRARY_EXPORT int32_t ClientCompleteClientStreamingCall(grpc_labview::gRPCid* callId, grpc_labview::MagicCookie* occurrencePtr) { auto call = callId->CastTo(); - call->_response->SetLVClusterHandle(reinterpret_cast(responseCluster)); if (!call) { return -1; diff --git a/src/grpc_client.h b/src/grpc_client.h index 41b91e03..c0a62384 100644 --- a/src/grpc_client.h +++ b/src/grpc_client.h @@ -61,6 +61,7 @@ namespace grpc_labview std::shared_ptr _response; grpc::Status _status; std::future _runFuture; + bool _useLVEfficientMessage; }; //--------------------------------------------------------------------- From c417c3dd8399dfeb25f4c5b227cb834faf51fa75 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Fri, 19 Jan 2024 13:16:48 +0530 Subject: [PATCH 38/43] Cleaning up code from streaming calls --- src/grpc_client.cc | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 9e14c2a9..ad3bf9e4 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -464,16 +464,8 @@ LIBRARY_EXPORT int32_t ClientBeginClientStreamingCall( auto clientCall = new grpc_labview::ClientStreamingClientCall(); *callId = grpc_labview::gPointerManager.RegisterPointer(clientCall); clientCall->_client = client; - - if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")){ - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); - } - else { - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); - } - + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); clientCall->_context = clientContext; grpc::internal::RpcMethod method(methodName, grpc::internal::RpcMethod::CLIENT_STREAMING); @@ -526,16 +518,8 @@ LIBRARY_EXPORT int32_t ClientBeginServerStreamingCall( auto clientCall = new grpc_labview::ServerStreamingClientCall(); *callId = grpc_labview::gPointerManager.RegisterPointer(clientCall); clientCall->_client = client; - - if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")){ - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); - } - else { - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); - } - + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); clientCall->_context = clientContext; try @@ -596,16 +580,8 @@ LIBRARY_EXPORT int32_t ClientBeginBidiStreamingCall( auto clientCall = new grpc_labview::BidiStreamingClientCall(); *callId = grpc_labview::gPointerManager.RegisterPointer(clientCall); clientCall->_client = client; - - if (!FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy")){ - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); - } - else { - clientCall->_request = std::make_shared(requestMetadata); - clientCall->_response = std::make_shared(responseMetadata); - } - + clientCall->_request = std::make_shared(requestMetadata); + clientCall->_response = std::make_shared(responseMetadata); clientCall->_context = clientContext; grpc::internal::RpcMethod method(methodName, grpc::internal::RpcMethod::BIDI_STREAMING); @@ -623,6 +599,7 @@ LIBRARY_EXPORT int32_t ClientBeginReadFromStream(grpc_labview::gRPCid* callId, g { auto reader = callId->CastTo(); auto call = callId->CastTo(); + auto occurrence = *occurrencePtr; if (!reader || !call) From 9228be38c514b3c6b7990e0992eddee60a8addfc Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Fri, 19 Jan 2024 15:08:24 +0530 Subject: [PATCH 39/43] reverting the VI changes for streaming --- .../Client Complete Client Streaming Call.vim | Bin 22366 -> 21790 bytes .../Client API/Client Read From Stream.vim | Bin 14000 -> 13420 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/labview source/gRPC lv Support/Client API/Client Complete Client Streaming Call.vim b/labview source/gRPC lv Support/Client API/Client Complete Client Streaming Call.vim index f3c62c884ee3f69b0925a242b34e4cda30c01bb2..a4435df466f2273633dfa866c9d86aeabf3be8bc 100644 GIT binary patch delta 4857 zcmZvgby(C**T)x@ZUyP3TS_FQ8K^QvMd@azpRqEsRR(uPek z9362i2*kIYHO9gTL0)qB_L8h=Ixa+`Vh2LDCr#$7ZxxF>ep0X%a2AvpKc4 zX`*Jm*^xYezQ6gP&|4@0f3LgDqnC7HLlSJ#yY9)M6ivFNOHb&SwlMKNB#$!0_fndY zW1YjgKJ$*FxL@~oRu7)0yijetF27|CNoCDVe(s^ZB>@c;6H{pIu+Kni;+MBlJ5w7p zJ_@?FI<6>F1?GL1!G$x`e(mZ`zhKC4$0UwlMx`n&bt6 z`pM`=?1zM_E~~XdlQgboyO^$V62WOVgQe~Fh&Z+9?;C|K$aASKbrn3c0c0}DSOX!Z zjfC4TqeqhXiy-xN#r*BTyW1&W`xmO3i;+(wY;@<-_;-tn@D#OUtfwL7Ue|H93xr^d zeGuSfRKcC6=c@44xv4`ONq*k1yZ6DIrCh3Hgy(doTMfxDJA%iU$CKP1zhm3gK~t~} zHkWPE3pESX4^=p(SdLg2G=MUPU%Fgv$VvDN=J-@@Di9K%p~JB_oR4FeHU!V&N;YDi zU_Yz$%06S;%l9b9I9NeD!Uh@kdR^;_^#D83Rkmc^JxF}@~2@| zT_q&8wkofrfH+*3$gA+RDCfu`oFWuMv~2IaoDNg~lS>xa**UE7gs$_?PVCVj zMGdEn$2@~|ol@c&@Aw$Y*b?KM&aNCZw+t&a!)Gfm!yj;GtM_YG9ZiW?73h?r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6}9kXp>6iI$0+6E8NbI8VuH4IMV3m1F3k89eXZ^o zb`yrU%nNz7a5;aiQV`pXcw~rrWw7IR1L1+|UgWk#L4X-w7tqHAblvcr9;C?xozv=U zY-&1e25)7PXwz@*O}7B;`C$))jI0^y-s(V~uYVHEFadFDzpzL0oU_)8*(augMtazq zQznloUY1$o0O<*`Xr_O5%yryyy<}*L?!WdX0B}OGzha7`Um5V$uZ#xs8yFJJ&jQ;`}mu~U^ From e47104a4e6c4ee665aeb3c993adf2ce086c70115 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Mon, 22 Jan 2024 15:27:56 +0530 Subject: [PATCH 40/43] cannot overload a function with 'extern "C"' linkage, ClientUnaryCall2 is born --- .../Client API/Client Unary Call.vim | Bin 20366 -> 19762 bytes src/feature_toggles.cc | 71 ++++---- src/feature_toggles.h | 40 ++--- src/grpc_client.cc | 40 ++--- .../testcases/ExportedFunctionList.json | 151 ++++++++++-------- 5 files changed, 164 insertions(+), 138 deletions(-) diff --git a/labview source/gRPC lv Support/Client API/Client Unary Call.vim b/labview source/gRPC lv Support/Client API/Client Unary Call.vim index 80de8747e2dc3e489909ae8fbe9099e9f41f086d..68281da969bf720b7228a59823a5927999d2850f 100644 GIT binary patch delta 7087 zcmZvhWl&t(vVaE-I=I_lVbI|2?h+h=2Mcb41Q-bJ5Zv7*Sc1C`E(r+f&x&VMe5deS?3jhE> z&wg+MNKdN?(tQf@wp7jcu1&?$H<)>jVLU7LvjVE%TJ8{)ycFxRmS!6#0ef>4(Ldq< z^@#fcsA)&HlK%gj22c|duoBKIlWuVz{H-I+ik&b;pVi8Oi-*gC&(hMu zoU=g#-V%-%;ZH;C|G$HwjQY2v>CT?pD^~gw3bbORfU_d}TFq`gv2R%1X#J)QdWZ?g za43lfXn}B%4ff~*$nYTR1|Hl3IOysj9`{l3<4#BCfEzfj1Y-`x{?6Eo?ohlZu(3n5 zi?qvIX(t9* zQsT8PN;O`4ZxdOtjl2zENNo5XQHD^6dZP@+=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;S7RsHSBT9R^ru!Q1xw&B=B`3UC%e%7^Rf@(PS!t#6aNbq)AF|;RctF?IBv&xdVq(okRxHK~+#fY1m_XdM> z2vgb}lSbp_bFWR)9W6?~9HJl|lFvK)l!(ErS4uQ7+2m^9wY~ywh9o==ZeANL-TY>| z74)Q0RX7w=QAoBSu^I62=%vo^#dW4iubnZk4A)~}aP=!y(9yHG>tyTY*|S`$VaCvdNvJ@fL> z{3Hr^>wCD`&*x0YTg0biyfv*KX2LVz`)Ju1$chbPY5{bFw(DoaHhJz1D4$!4tIBlveUIuq9MTkoMzv&0g@D~2Uf>>FkwWctgRgi(vXVF!t9aXIHkvyKE3$#OzbI&H zgwk*#d;}OpI_hoP=}<$Obdso*Rjuh6`1`z4Y?7F}H4GWCg~xj6d+k<*Kda|`ckb;A z)b|d+z^_3Koa-r2n=@m=*R1djeLpARMdq-{_#{xB43|drqj%1SiKAM+-h+hogaExY z>h>9?QJ*6BuXD&01OtM7>2$rEMj$B==8K4zm$rB%_wxAPMqo{k^fU|r|Ci6-eHvfek{F4#?{1^6r z74ld7m%-@#ANjwNVf6kdlbHM$_Ad!a{7Zt8f45g(-uL@&!Lr1E2gVb#wlKAICRevL Qbo3w>GqkpT`6Sr #include -// Function to read feature configurations from an INI file -void FeatureConfig::readConfigFromFile(const std::string& filePath) { - std::ifstream configFile(filePath); - if (!configFile.is_open()) { - return; - } +namespace grpc_labview { + // Function to read feature configurations from an INI file + void FeatureConfig::readConfigFromFile(const std::string& filePath) { + std::ifstream configFile(filePath); + if (!configFile.is_open()) { + return; + } - std::string line; - std::string currentSection; // For handling INI sections + std::string line; + std::string currentSection; // For handling INI sections - while (std::getline(configFile, line)) { - // Trim leading and trailing whitespaces - line.erase(line.find_last_not_of(" \t") + 1); - line.erase(0, line.find_first_not_of(" \t")); + while (std::getline(configFile, line)) { + // Trim leading and trailing whitespaces + line.erase(line.find_last_not_of(" \t") + 1); + line.erase(0, line.find_first_not_of(" \t")); - // Skip comments and empty lines - if (line.empty() || line[0] == ';') { - continue; - } + // Skip comments and empty lines + if (line.empty() || line[0] == ';') { + continue; + } - // Check for section header - if (line[0] == '[' && line[line.length() - 1] == ']') { - currentSection = line.substr(1, line.length() - 2); - } else { - // Parse key-value pairs - std::istringstream iss(line); - std::string key, value; - if (std::getline(iss, key, '=') && std::getline(iss, value)) { - // Append section name to key for uniqueness - std::string fullKey = currentSection.empty() ? key : currentSection + "_" + key; - featureFlags[fullKey] = (value == "true"); + // Check for section header + if (line[0] == '[' && line[line.length() - 1] == ']') { + currentSection = line.substr(1, line.length() - 2); + } + else { + // Parse key-value pairs + std::istringstream iss(line); + std::string key, value; + if (std::getline(iss, key, '=') && std::getline(iss, value)) { + // Append section name to key for uniqueness + std::string fullKey = currentSection.empty() ? key : currentSection + "_" + key; + featureFlags[fullKey] = (value == "true"); + } } } - } - configFile.close(); -} + configFile.close(); + } -// Function to check if a feature is enabled -bool FeatureConfig::isFeatureEnabled(const std::string& featureName) const { - auto it = featureFlags.find(featureName); - return (it != featureFlags.end()) ? it->second : false; + // Function to check if a feature is enabled + bool FeatureConfig::isFeatureEnabled(const std::string& featureName) const { + auto it = featureFlags.find(featureName); + return (it != featureFlags.end()) ? it->second : false; + } } \ No newline at end of file diff --git a/src/feature_toggles.h b/src/feature_toggles.h index c276e10c..e23ad679 100644 --- a/src/feature_toggles.h +++ b/src/feature_toggles.h @@ -3,26 +3,28 @@ #include #include -class FeatureConfig { -private: - std::map featureFlags; +namespace grpc_labview { + class FeatureConfig { + private: + std::map featureFlags; - // Constructor to initialize with default values - FeatureConfig() { - featureFlags["gRPC"] = true; // Enable gRPC by default as an example, this will never be overridden by config file - featureFlags["EfficientMessageCopy"] = true; - } + // Constructor to initialize with default values + FeatureConfig() { + featureFlags["gRPC"] = true; // Enable gRPC by default as an example, this will never be overridden by config file + featureFlags["EfficientMessageCopy"] = true; + } -public: - // Singleton instance - static FeatureConfig& getInstance() { - static FeatureConfig instance; - return instance; - } + public: + // Singleton instance + static FeatureConfig& getInstance() { + static FeatureConfig instance; + return instance; + } - // Function to read feature configurations from an INI file - void readConfigFromFile(const std::string& filePath); + // Function to read feature configurations from an INI file + void readConfigFromFile(const std::string& filePath); - // Function to check if a feature is enabled - bool isFeatureEnabled(const std::string& featureName) const; -}; \ No newline at end of file + // Function to check if a feature is enabled + bool isFeatureEnabled(const std::string& featureName) const; + }; +} \ No newline at end of file diff --git a/src/grpc_client.cc b/src/grpc_client.cc index ad3bf9e4..907e8be0 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -11,6 +11,7 @@ #include #include #include +#include namespace grpc_labview { @@ -264,26 +265,10 @@ LIBRARY_EXPORT int32_t CloseClientContext(grpc_labview::gRPCid* contextId) return 0; } -//--------------------------------------------------------------------- -//--------------------------------------------------------------------- -LIBRARY_EXPORT int32_t ClientUnaryCall( - grpc_labview::gRPCid* clientId, - grpc_labview::MagicCookie* occurrence, - const char* methodName, - const char* requestMessageName, - const char* responseMessageName, - int8_t* requestCluster, - grpc_labview::gRPCid** callId, - int32_t timeoutMs, - grpc_labview::gRPCid* contextId) -{ - ClientUnaryCall(clientId, occurrence, methodName, requestMessageName, responseMessageName, requestCluster, callId, timeoutMs, contextId, nullptr); -} - //--------------------------------------------------------------------- //--------------------------------------------------------------------- -LIBRARY_EXPORT int32_t ClientUnaryCall( +LIBRARY_EXPORT int32_t ClientUnaryCall2( grpc_labview::gRPCid* clientId, grpc_labview::MagicCookie* occurrence, const char* methodName, @@ -328,7 +313,8 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( clientCall->_occurrence = *occurrence; clientCall->_context = clientContext; - if (FeatureConfig::getInstance().isFeatureEnabled("EfficientMessageCopy") && responseCluster != nullptr){ + auto featureConfig = grpc_labview::FeatureConfig::getInstance(); + if (featureConfig.isFeatureEnabled("EfficientMessageCopy") && responseCluster != nullptr){ clientCall->_useLVEfficientMessage = false; } @@ -367,6 +353,24 @@ LIBRARY_EXPORT int32_t ClientUnaryCall( return 0; } + +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +LIBRARY_EXPORT int32_t ClientUnaryCall( + grpc_labview::gRPCid* clientId, + grpc_labview::MagicCookie* occurrence, + const char* methodName, + const char* requestMessageName, + const char* responseMessageName, + int8_t* requestCluster, + grpc_labview::gRPCid** callId, + int32_t timeoutMs, + grpc_labview::gRPCid* contextId) +{ + return ClientUnaryCall2(clientId, occurrence, methodName, requestMessageName, responseMessageName, requestCluster, callId, timeoutMs, contextId, nullptr); +} + + //--------------------------------------------------------------------- //--------------------------------------------------------------------- LIBRARY_EXPORT int32_t CompleteClientUnaryCall2( diff --git a/tests/CMakeTests/testcases/ExportedFunctionList.json b/tests/CMakeTests/testcases/ExportedFunctionList.json index acdaba71..58b005d8 100644 --- a/tests/CMakeTests/testcases/ExportedFunctionList.json +++ b/tests/CMakeTests/testcases/ExportedFunctionList.json @@ -1,5 +1,5 @@ { - "size": 84, + "size": 85, "signatures": [ { "id": 0, @@ -187,6 +187,23 @@ }, { "id": 17, + "function_name": "ClientUnaryCall2", + "return_type": "int32_t", + "parameter_list": [ + "grpc_labview::gRPCid*", + "grpc_labview::MagicCookie*", + "const char*", + "const char*", + "const char*", + "int8_t*", + "grpc_labview::gRPCid**", + "int32_t", + "grpc_labview::gRPCid*", + "int8_t*" + ] + }, + { + "id": 18, "function_name": "ClientWriteToStream", "return_type": "int32_t", "parameter_list": [ @@ -196,7 +213,7 @@ ] }, { - "id": 18, + "id": 19, "function_name": "ClientWritesComplete", "return_type": "int32_t", "parameter_list": [ @@ -204,7 +221,7 @@ ] }, { - "id": 19, + "id": 20, "function_name": "CloseClient", "return_type": "int32_t", "parameter_list": [ @@ -212,7 +229,7 @@ ] }, { - "id": 20, + "id": 21, "function_name": "CloseClientContext", "return_type": "int32_t", "parameter_list": [ @@ -220,7 +237,7 @@ ] }, { - "id": 21, + "id": 22, "function_name": "CloseServerEvent", "return_type": "int32_t", "parameter_list": [ @@ -228,7 +245,7 @@ ] }, { - "id": 22, + "id": 23, "function_name": "CompleteClientUnaryCall", "return_type": "int32_t", "parameter_list": [ @@ -237,7 +254,7 @@ ] }, { - "id": 23, + "id": 24, "function_name": "CompleteClientUnaryCall2", "return_type": "int32_t", "parameter_list": [ @@ -248,7 +265,7 @@ ] }, { - "id": 24, + "id": 25, "function_name": "CompleteMetadataRegistration", "return_type": "int32_t", "parameter_list": [ @@ -256,7 +273,7 @@ ] }, { - "id": 25, + "id": 26, "function_name": "CreateClient", "return_type": "int32_t", "parameter_list": [ @@ -266,7 +283,7 @@ ] }, { - "id": 26, + "id": 27, "function_name": "CreateClientContext", "return_type": "int32_t", "parameter_list": [ @@ -274,7 +291,7 @@ ] }, { - "id": 27, + "id": 28, "function_name": "CreateSerializationSession", "return_type": "int32_t", "parameter_list": [ @@ -282,7 +299,7 @@ ] }, { - "id": 28, + "id": 29, "function_name": "DeserializeReflectionInfo", "return_type": "void", "parameter_list": [ @@ -290,7 +307,7 @@ ] }, { - "id": 29, + "id": 30, "function_name": "FinishClientCompleteClientStreamingCall", "return_type": "int32_t", "parameter_list": [ @@ -301,7 +318,7 @@ ] }, { - "id": 30, + "id": 31, "function_name": "FreeSerializationSession", "return_type": "int32_t", "parameter_list": [ @@ -309,7 +326,7 @@ ] }, { - "id": 31, + "id": 32, "function_name": "FreeUnpackedFields", "return_type": "int32_t", "parameter_list": [ @@ -317,7 +334,7 @@ ] }, { - "id": 32, + "id": 33, "function_name": "GetEnumInfo", "return_type": "int", "parameter_list": [ @@ -326,7 +343,7 @@ ] }, { - "id": 33, + "id": 34, "function_name": "GetLVEnumValueFromProtoValue", "return_type": "uint32_t", "parameter_list": [ @@ -337,7 +354,7 @@ ] }, { - "id": 34, + "id": 35, "function_name": "GetProtoValueFromLVEnumValue", "return_type": "int32_t", "parameter_list": [ @@ -348,7 +365,7 @@ ] }, { - "id": 35, + "id": 36, "function_name": "GetRequestData", "return_type": "int32_t", "parameter_list": [ @@ -357,7 +374,7 @@ ] }, { - "id": 36, + "id": 37, "function_name": "GetUnpackedField", "return_type": "int32_t", "parameter_list": [ @@ -369,7 +386,7 @@ ] }, { - "id": 37, + "id": 38, "function_name": "GetUnpackedMessageField", "return_type": "int32_t", "parameter_list": [ @@ -379,7 +396,7 @@ ] }, { - "id": 38, + "id": 39, "function_name": "IsAnyOfType", "return_type": "int32_t", "parameter_list": [ @@ -389,7 +406,7 @@ ] }, { - "id": 39, + "id": 40, "function_name": "IsCancelled", "return_type": "int32_t", "parameter_list": [ @@ -397,7 +414,7 @@ ] }, { - "id": 40, + "id": 41, "function_name": "LVAddParserSearchPath", "return_type": "int", "parameter_list": [ @@ -406,7 +423,7 @@ ] }, { - "id": 41, + "id": 42, "function_name": "LVCreateParser", "return_type": "int", "parameter_list": [ @@ -414,7 +431,7 @@ ] }, { - "id": 42, + "id": 43, "function_name": "LVCreateServer", "return_type": "int32_t", "parameter_list": [ @@ -422,7 +439,7 @@ ] }, { - "id": 43, + "id": 44, "function_name": "LVEnumName", "return_type": "int", "parameter_list": [ @@ -431,7 +448,7 @@ ] }, { - "id": 44, + "id": 45, "function_name": "LVEnumTypeUrl", "return_type": "int", "parameter_list": [ @@ -440,7 +457,7 @@ ] }, { - "id": 45, + "id": 46, "function_name": "LVFieldInfo", "return_type": "int", "parameter_list": [ @@ -449,7 +466,7 @@ ] }, { - "id": 46, + "id": 47, "function_name": "LVGetEnums", "return_type": "int", "parameter_list": [ @@ -459,7 +476,7 @@ ] }, { - "id": 47, + "id": 48, "function_name": "LVGetErrorString", "return_type": "int", "parameter_list": [ @@ -468,7 +485,7 @@ ] }, { - "id": 48, + "id": 49, "function_name": "LVGetFields", "return_type": "int", "parameter_list": [ @@ -477,7 +494,7 @@ ] }, { - "id": 49, + "id": 50, "function_name": "LVGetMessages", "return_type": "int", "parameter_list": [ @@ -486,7 +503,7 @@ ] }, { - "id": 50, + "id": 51, "function_name": "LVGetMethodFullName", "return_type": "int", "parameter_list": [ @@ -495,7 +512,7 @@ ] }, { - "id": 51, + "id": 52, "function_name": "LVGetMethodInput", "return_type": "int", "parameter_list": [ @@ -504,7 +521,7 @@ ] }, { - "id": 52, + "id": 53, "function_name": "LVGetMethodName", "return_type": "int", "parameter_list": [ @@ -513,7 +530,7 @@ ] }, { - "id": 53, + "id": 54, "function_name": "LVGetMethodOutput", "return_type": "int", "parameter_list": [ @@ -522,7 +539,7 @@ ] }, { - "id": 54, + "id": 55, "function_name": "LVGetServerListeningPort", "return_type": "int32_t", "parameter_list": [ @@ -531,7 +548,7 @@ ] }, { - "id": 55, + "id": 56, "function_name": "LVGetServiceMethods", "return_type": "int", "parameter_list": [ @@ -540,7 +557,7 @@ ] }, { - "id": 56, + "id": 57, "function_name": "LVGetServiceName", "return_type": "int", "parameter_list": [ @@ -549,7 +566,7 @@ ] }, { - "id": 57, + "id": 58, "function_name": "LVGetServices", "return_type": "int", "parameter_list": [ @@ -558,7 +575,7 @@ ] }, { - "id": 58, + "id": 59, "function_name": "LVGetgRPCAPIVersion", "return_type": "int", "parameter_list": [ @@ -566,7 +583,7 @@ ] }, { - "id": 59, + "id": 60, "function_name": "LVImportProto", "return_type": "int", "parameter_list": [ @@ -576,7 +593,7 @@ ] }, { - "id": 60, + "id": 61, "function_name": "LVImportProto2", "return_type": "int", "parameter_list": [ @@ -586,7 +603,7 @@ ] }, { - "id": 61, + "id": 62, "function_name": "LVIsMethodClientStreaming", "return_type": "int", "parameter_list": [ @@ -595,7 +612,7 @@ ] }, { - "id": 62, + "id": 63, "function_name": "LVIsMethodServerStreaming", "return_type": "int", "parameter_list": [ @@ -604,7 +621,7 @@ ] }, { - "id": 63, + "id": 64, "function_name": "LVMessageHasOneof", "return_type": "int", "parameter_list": [ @@ -613,7 +630,7 @@ ] }, { - "id": 64, + "id": 65, "function_name": "LVMessageName", "return_type": "int", "parameter_list": [ @@ -622,7 +639,7 @@ ] }, { - "id": 65, + "id": 66, "function_name": "LVMessageTypeUrl", "return_type": "int", "parameter_list": [ @@ -631,7 +648,7 @@ ] }, { - "id": 66, + "id": 67, "function_name": "LVStartServer", "return_type": "int32_t", "parameter_list": [ @@ -642,7 +659,7 @@ ] }, { - "id": 67, + "id": 68, "function_name": "LVStopServer", "return_type": "int32_t", "parameter_list": [ @@ -650,7 +667,7 @@ ] }, { - "id": 68, + "id": 69, "function_name": "PackToAny", "return_type": "int32_t", "parameter_list": [ @@ -661,7 +678,7 @@ ] }, { - "id": 69, + "id": 70, "function_name": "PackToBuffer", "return_type": "int32_t", "parameter_list": [ @@ -672,7 +689,7 @@ ] }, { - "id": 70, + "id": 71, "function_name": "RegisterEnumMetadata2", "return_type": "int32_t", "parameter_list": [ @@ -681,7 +698,7 @@ ] }, { - "id": 71, + "id": 72, "function_name": "RegisterGenericMethodServerEvent", "return_type": "int32_t", "parameter_list": [ @@ -690,7 +707,7 @@ ] }, { - "id": 72, + "id": 73, "function_name": "RegisterMessageMetadata", "return_type": "int32_t", "parameter_list": [ @@ -699,7 +716,7 @@ ] }, { - "id": 73, + "id": 74, "function_name": "RegisterMessageMetadata2", "return_type": "int32_t", "parameter_list": [ @@ -708,7 +725,7 @@ ] }, { - "id": 74, + "id": 75, "function_name": "RegisterServerEvent", "return_type": "int32_t", "parameter_list": [ @@ -720,7 +737,7 @@ ] }, { - "id": 75, + "id": 76, "function_name": "SerializeReflectionInfo", "return_type": "void", "parameter_list": [ @@ -729,7 +746,7 @@ ] }, { - "id": 76, + "id": 77, "function_name": "SetCallStatus", "return_type": "int32_t", "parameter_list": [ @@ -739,7 +756,7 @@ ] }, { - "id": 77, + "id": 78, "function_name": "SetLVRTModulePath", "return_type": "int32_t", "parameter_list": [ @@ -747,7 +764,7 @@ ] }, { - "id": 78, + "id": 79, "function_name": "SetResponseData", "return_type": "int32_t", "parameter_list": [ @@ -756,7 +773,7 @@ ] }, { - "id": 79, + "id": 80, "function_name": "TryUnpackFromAny", "return_type": "int32_t", "parameter_list": [ @@ -767,7 +784,7 @@ ] }, { - "id": 80, + "id": 81, "function_name": "UnpackFieldsFromAny", "return_type": "int32_t", "parameter_list": [ @@ -776,7 +793,7 @@ ] }, { - "id": 81, + "id": 82, "function_name": "UnpackFieldsFromBuffer", "return_type": "int32_t", "parameter_list": [ @@ -785,7 +802,7 @@ ] }, { - "id": 82, + "id": 83, "function_name": "UnpackFromAny", "return_type": "int32_t", "parameter_list": [ @@ -796,7 +813,7 @@ ] }, { - "id": 83, + "id": 84, "function_name": "UnpackFromBuffer", "return_type": "int32_t", "parameter_list": [ From 30e08c9fa118b0470381912d8c9f00a7376103fa Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Mon, 22 Jan 2024 16:21:06 +0530 Subject: [PATCH 41/43] minor bug fix --- src/grpc_client.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grpc_client.cc b/src/grpc_client.cc index 907e8be0..28bd5ee6 100644 --- a/src/grpc_client.cc +++ b/src/grpc_client.cc @@ -315,7 +315,7 @@ LIBRARY_EXPORT int32_t ClientUnaryCall2( auto featureConfig = grpc_labview::FeatureConfig::getInstance(); if (featureConfig.isFeatureEnabled("EfficientMessageCopy") && responseCluster != nullptr){ - clientCall->_useLVEfficientMessage = false; + clientCall->_useLVEfficientMessage = true; } if (clientCall->_useLVEfficientMessage){ From f380fcdcc8386196afef0ed28aa8410041fedb5d Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Mon, 22 Jan 2024 17:13:21 +0530 Subject: [PATCH 42/43] fixing for each loop, as "for each" isn't available on linux --- src/lv_message_efficient.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_message_efficient.cc b/src/lv_message_efficient.cc index a988ad90..1a058c4e 100644 --- a/src/lv_message_efficient.cc +++ b/src/lv_message_efficient.cc @@ -200,7 +200,7 @@ namespace grpc_labview void LVMessageEfficient::PostInteralParseAction() { - for each (auto nestedMessage in _repeatedMessageValuesMap) + for (auto nestedMessage : _repeatedMessageValuesMap) { auto fieldInfo = nestedMessage.second.get()->_fieldInfo; auto buffer = nestedMessage.second.get()->_buffer; From 2b66ff1c11939b125dd439fa5d6be2f5a490dff0 Mon Sep 17 00:00:00 2001 From: Chakith Pattar Date: Wed, 24 Jan 2024 12:17:28 +0530 Subject: [PATCH 43/43] changing back NumericArrayResize from noinit --- src/lv_interop.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_interop.cc b/src/lv_interop.cc index 4be39c7b..51f9371b 100644 --- a/src/lv_interop.cc +++ b/src/lv_interop.cc @@ -85,7 +85,7 @@ namespace grpc_labview lvModule = GetModuleHandle("lvrt.dll"); } } - NumericArrayResizeImp = (NumericArrayResize_T)GetProcAddress(lvModule, "NumericArrayResizeNoInit"); + NumericArrayResizeImp = (NumericArrayResize_T)GetProcAddress(lvModule, "NumericArrayResize"); PostLVUserEvent = (PostLVUserEvent_T)GetProcAddress(lvModule, "PostLVUserEvent"); Occur = (Occur_T)GetProcAddress(lvModule, "Occur"); RTSetCleanupProc = (RTSetCleanupProc_T)GetProcAddress(lvModule, "RTSetCleanupProc");