[Moims-sc] Binary encoding of lists
Serge Lacourte
serge.lacourte at scalagent.com
Fri Oct 23 05:16:36 EDT 2026
Dear WG members,
we discussed several optimizations proposed by Stefan for the binary
encoding. One of them concerns the encoding of lists. I understood the
proposal as the possible encoding of a list holding elements of a single
concrete type with a single encoding of the type instead of repeating
the encoding of this type for all the elements of the list. This
bothered me, and I try to discuss it more formally here.
I explain in the following my understanding of the MAL requirements. I
would like to have your opinion on this.
There is no formal API of an encoding. An informal API of the encoding
could be to convert a MAL data into an array of bytes(*1), and the
reverse. I would go one step further, asserting that the decoding of the
array of bytes which results from the encoding of a MAL data should be
the exact copy of the original MAL data, including its exact MAL type.
With MAL v1 this was clear and obvious. However MALv2 introduces grey
cases that have probably not been cleared enough, and I believe that
some ambiguity may remain. The heterogeneous list is such a case.
The MAL specifies Abstract and Concrete types. An operation may declare
an Abstract type in an operation parameter. At runtime, this parameter
will be filled with a Concrete type that "derives" from the Abstract
type. The "derivation" rules is clear for Composite types, it is less
clear for List types. The MAL specification never tells the Abstract or
Concrete type of a List. It does define List as a way to define a MAL
type from the Abstract or Concrete type of the list elements. Il also
defines the concepts of Homogeneous and Heterogeneous lists, both
concepts being assigned a Short Form Part. It never formally defines
what List types are Abstract or Concrete. My understanding is the
following :
* a List of Concrete element type is a Concrete type. Its Short Form
Part is the negative value of the SFP of the element type.
* an Homogeneous List is a global naming for all the lists defined
from a Concrete element type
* a List of Abstract element type is an Abstract type
* an Heterogeneous List is a concrete type. It may hold elements of
any MAL type. It is given 0 as SFP.
* the statement 4.2.6.1.6 "If the type of the List is Abstract, then
the List shall be a Heterogeneous List." is ambiguous. It could be
interpreted as : If a service specification specifies a List type
from an abstract element type as the parameter of a service
operation, then, at runtime, an Heterogeneous List shall be used.
However this interpretation of statement 4.2.6.1.6 is clearly too
restrictive. If concrete composite type C extends abstract composite
type A, then List<C> can be used in place of a List<A> declared
parameter. And list<C> is an Homegeneous List. There are then 2 options
matching a List<A> declared parameter :
1. Homogeneous List<C>, where C extends A
2. Heterogeneous List holding only elements which extend A (runtime check)
In the case 1 above, the parameter will obviously be decoded as a
List<C>. The question we have to answer now, which is not considered in
the MAL specification, is : in the case 2 above, where an heterogeneous
list is provided, should it always be decoded as an heterogeneous list,
even if all the enclosed elements are of the same type C? My answer is
yes, it should. This is why I reacted to the encoding proposal to allow
encoding it as a List<C>. I agree that this optimization is still
possible, as long as we agree that the parameter is eventually converted
into an heterogeneous list. This is possible as the encoder knows the
declared type of the operation.
Serge
(*1) with the split binary, this is not exactly true. It is true for the
overall encoding of the MAL message, however the encoding usually refers
to the encoding of each individual MAL data type in the MAL message
body. The encoding of the MAL header is defined in the transport, with a
specific encoding which may not follow the encoding of the body. So the
split binary encoding transforms a MAL data into 2 separate arrays of
bytes, one for the included booleans, and another for all other included
data types.
--
Serge Lacourte
Directeur general
ScalAgent Distributed Technologies SA
tel. +33 4 76 29 79 81
mobile. +33 6 86 47 41 06
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ccsds.org/pipermail/moims-sc/attachments/20261023/15d05138/attachment.htm>
More information about the MOIMS-SC
mailing list