Field Names and Field Identifiers
In Rendezvous 5 and earlier releases, programs would specify fields within a message using a field name. In Rendezvous 6 and later releases, programs can specify fields in two ways:
• | A field name is a character string. Each field can have at most one name. Several fields can have the same name. |
• | A field identifier is a 16-bit unsigned integer, which must be unique within the message. That is, two fields in the same message cannot have the same identifier. However, a nested submessage is considered a separate identifier space from its enclosing parent message and any sibling submessages. |
Java presents these identifiers as 32-bit integers, padding the high bytes with zero.
Message methods specify fields using a combination of a field name and a unique field identifier. When absent, the default field identifier is zero.
To compare the speed and space characteristics of these two options, see Search Characteristics.
Rules and Restrictions
NULL
is a legal field name only when the identifier is zero. It is illegal for a field to have both a non-zero identifier and a NULL
field name.
Note that in Java, NULL
is not the same as ""
(the empty string). It is legal for a field to have a non-zero identifier and the empty string as its field name. However, we generally recommend against using the empty string as a field name.
Adding a New Field
When a program adds a new field to a message, it can attach a field name, a field identifier, or both. If the program supplies an identifier, Rendezvous software checks that it is unique within the message; if the identifier is already in use, the operation fails with the status code TibrvStatus.ID_IN_USE.
Search Characteristics
In general, an identifier search completes in constant time. In contrast, a name search completes in linear time proportional to the number of fields in the message. Name search is quite fast for messages with 16 fields or fewer; for messages with more than 16 fields, identifier search is faster.
Space Characteristics
The smallest field name is a one-character string, which occupies three bytes in Rendezvous wire format. That one ASCII character yields a name space of 127 possible field names; a larger range requires additional characters.
Field identifiers are 16 bits, which also occupy three bytes in Rendezvous wire format. However, those 16 bits yield a space of 65535 possible field identifiers; that range is fixed, and cannot be extended.
Finding a Field Instance
When a message contains several field instances with the same field name, these methods find a specific instance by name and number (they do not use field identifiers):
• | TibrvMsg.removeFieldInstance(). |
• | TibrvMsg.getFieldInstance(). |