-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why strings for all datatypes? #386
Comments
The VISSv2 spec deals with the signals from that they are delivered by the underlying vehicle system to the VISSv2 server, and until they are delivered to the VISSv2 client. It is not so likely that signal processing is to be done during the period that VISSv2 "rules" over the signal format. A possible conclusion from that is that any format, e. g. the "native" format of the signal, would be fine, as well as a common format such as string format. However, from the VISSvs reference implementation (https://github.com/MEAE-GOT/W3C_VehicleSignalInterfaceImpl) it has been found that intermediate data base storage is likely both before entering the VISSv2 realm (statestorage), after leaving it (OVDS), and also during (historic value capturing). The DB implementation is simplified by having a common storage format. |
I am not 100% sure that answers the question, or is a strong argument. I still mainly see VISSv2 as a "protocol specification", i.e. it tells me what I can send, and what to expect to receive. Most of the time the goal of such specifications is to enable some interoperability, e.g. when I write a VISS client, I expect it to work with a VISS server, independent of which concrete server implementation it is (I do not even need to know). So when I transfer a datapoint that VSS says is "double", and VISS says, those points are all encoded as string, that is certainly doable, but I would need to now
I do think the argument
Of course it is possible to encode numbers as strings no problem, I mean that is what JSON is doing,when using a number, but in VISS I feel there is a missing reference HOW things are encoded to (JSON) strings, as there are different ways, and it should not be randomly according to which runtime I happen to choose to develop my code. Actually the "bool" example brought up by the IoTEA colleague above is a good example: We exactly have this kind of code in kuksa.val . I think we accept As a mere "user" I do not really advocate reversing the "everything is a string" decision in VISS (although I would be fine with it), but rather want to point out, that currently VISS seems underspecified in that regard to me, i.e. you can easily build 2 fully compliant implementations that are not necessarily interoperable. So to conclude, I fully agree to your point
But I feel, that is not the case for all possible VSS datatypes currently, or I missed it. |
You are right, the spec is currently under-specified regarding valid data type transformations. |
Can you just declare in documentation that "c locale" is only valid numbers representation? This is pretty acceptable since the most automotive software written in c/c++ and std::to_chars/std::from_chars are very fast to parse/build numbers. |
Do you have a link to this definition? |
c locale (actually is a default POSIX locale), take a look to paragraph 7.3.4 LC_NUMERIC.
|
Alternativery it can be taken from JSON RFC7159
|
I think the JSON RFC looks like a good reference to use. |
@SebastianSchildt : Are you fine with the JSON ref? |
I would prefer the ambiguity is instead resolved by leaving the "everything is a string" approach and use standard JSON RFC8259, in other words to encode numbers as numbers, without quotation marks. I believe that every standard JSON parser will understand the data as it is written when following the specification, and that parsers will most likely deliver the data as the "right type" (a number type if it is a number) back to the program that uses a JSON parsing library. In the end this seems to me to cause the most simplicity and expected behavior.
Yes, in a simple relational table only one value type is required. But it is also much less efficient to store numbers as strings. In other cases such as when it is desired to gather number data as numbers, because the database is able to manipulate and understand numbers[1], then it seems more appropriate to have numbers as soon as possible instead of having to convert. [1] https://docs.influxdata.com/influxdb/v1.8/query_language/functions/ |
Although there is not so much performance penalty because it does not matter who will parse the text representation of the number, the JSON library, or server code - just a good JSON library is required. The right use of JSON with its own type system looks more adequate. |
So this is an example of the south-bound interface towards a vehicle signal broker. It is written in Go, the actual type returned here is checked and then converted to the VISS v2 string, note that the broker in this case does not have values of type string. It is of course practical for the server implementation from here on to treat all values as of type string. But...
In this case the data structure that holds the values uses the native signal type and converts to string on access. So changing the south-bound interface to adhere to a number format should be straightforward. |
Text format for all data types defined by PR421 |
That probably has been discussed in the past, but as the question came up in COVESA/iot-event-analytics#109 and I could not find a rationale in the spec, I will just repost the main points here.
VISSv2 says "Regardless of its data type, a single data item is always represented as a string in message payloads."
and
Can somebody shed some light why the design decision was to use strings for everything?
The text was updated successfully, but these errors were encountered: