Hello, support team:
I'm implementing an index table class that can map the UaNodeId(principally String format) to integer ID, this index table is used to find the ID of a historian server tag or an IO server tag. And I prefer to use a hash table(boost unordered_map) instead of STL map. Because it is much more fast.
For a hash table, I need to implement the hash algorithm for the class UaNodeId, and the best way is to get the native OpcUa_NodeId inside the UaNodeId and hash it accord it's identity type(String, Integer or ByteString).
But I'm a little confused when I hash the struct type OpcUa_String:
typedef struct _OpcUa_String
{
OpcUa_UInt16 uReserved1;
OpcUa_UInt32 uReserved2;
OpcUa_Void* uReserved4;
} OpcUa_String, *OpcUa_pString;
What does each variable means?
And if you have some code to do this, can you please give me a hint?
Thanks a lot.
Hashmap and NodeId
Moderator: uasdkcpp
-
- Hero Member
- Posts: 73
- Joined: 15 Feb 2012, 21:43
Re:Hashmap and NodeId
I think the OpcUa_String structure is as following
#ifdef _DEBUG
typedef struct _OpcUa_String
{
OpcUa_UInt16 flags;
OpcUa_UInt32 uLength;
OpcUa_Char* strContent;
}OpcUa_String, *OpcUa_pString;
#else
typedef struct _OpcUa_String
{
OpcUa_UInt16 uReserved1;
OpcUa_UInt32 uReserved2;
OpcUa_Void* uReserved4;
} OpcUa_String, *OpcUa_pString;
#endif
So just define _DEBUG to 1 and you could use it a bit easily...
Regards.
CG
#ifdef _DEBUG
typedef struct _OpcUa_String
{
OpcUa_UInt16 flags;
OpcUa_UInt32 uLength;
OpcUa_Char* strContent;
}OpcUa_String, *OpcUa_pString;
#else
typedef struct _OpcUa_String
{
OpcUa_UInt16 uReserved1;
OpcUa_UInt32 uReserved2;
OpcUa_Void* uReserved4;
} OpcUa_String, *OpcUa_pString;
#endif
So just define _DEBUG to 1 and you could use it a bit easily...
Regards.
CG
- Support Team
- Hero Member
- Posts: 3068
- Joined: 18 Mar 2011, 15:09
Re:Hashmap and NodeId
Hello,
first of all, the members of an OpcUa_String should never be used directly, this is why the definition of the OpcUa_String is different in Debug and Release. Instead, only the string manipulation functions from 'opcua_string.h' should be used for working with OpcUa_String structures.
The different naming of the members in a debug configuration is for debugging purposes only. The _DEBUG define is set by the projects delivered with the SDK and should not be set in release configuration.
The SDK already includes a HashTable class (src/uabase/uabasecpp/hashtable.h) which is especially designed for hashing UaNodeIds. This should be the class you are looking for.
If the HashTable class does not meet your requirements you can retreive the string content of the OpcUa_String using the function 'OpcUa_String_GetRawString()'. Please note that a OpcUa_String is not guaranteed to be null-terminated, hence you must take the string length into account.
Best regards,
Unified Automation Support Team
first of all, the members of an OpcUa_String should never be used directly, this is why the definition of the OpcUa_String is different in Debug and Release. Instead, only the string manipulation functions from 'opcua_string.h' should be used for working with OpcUa_String structures.
The different naming of the members in a debug configuration is for debugging purposes only. The _DEBUG define is set by the projects delivered with the SDK and should not be set in release configuration.
The SDK already includes a HashTable class (src/uabase/uabasecpp/hashtable.h) which is especially designed for hashing UaNodeIds. This should be the class you are looking for.
If the HashTable class does not meet your requirements you can retreive the string content of the OpcUa_String using the function 'OpcUa_String_GetRawString()'. Please note that a OpcUa_String is not guaranteed to be null-terminated, hence you must take the string length into account.
Best regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Jr. Member
- Posts: 1
- Joined: 23 Aug 2019, 11:32
Re: Hashmap and NodeId
thanks
From the help of this link you will be able to learn the different things about the course. Just click down this link ultius reviews and you will go through this site.
-
- Jr. Member
- Posts: 1
- Joined: 14 Oct 2023, 15:20
Re: Hashmap and NodeId
thanks forpsoting