Open iariasleon opened 9 years ago
What do you think, @frbattid ? :)
If I remember well, Orion behaves as this: if an update context changes the type of an attribute, then it is changed in MongoDB. Thus... should we mimic this behaviour? As you can see, I'm not only talking about maintaining the field, but improving the functionality... and raising new questions xD
Possible scenarios:
integer
to float
. In this case, the change is easy since we are moving to a less restrictive type.float
to integer
. In this case, should we perform a casting on the already stored values? Or do we cast only when querying for the data (maintaining the old values as float
, and coexisting with the new integer
values)?integer
or float
to string
. In this case, nothing is stored from the moment the attribute changed.string
to integer
or float
. In this case, we start storing data from the moment the attribute changed.So, it seems the only problematic scenario is when moving from float
to integer
. What do you think, floks?
In my opinion, in case of moving from float
to integer
we should do nothing really... I mean, the new raw data would be stored with the new attributeType
and the aggregates would still be float
:) The point is if in case of retrieving the raw data we should include the attributeType
or not in the results :)
My vote would be for YES to align it with the responses provided by the Context Broker when querying for context (/queryContext
)... Currently:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "23"
},
{
"name": "pressure",
"type": "integer",
"value": "720"
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Although in most cases that information would be redundant... For most cases it would end up being:
"values": [
{
"recvTime":"2015-05-06T08:23:00.673Z",
"attributeType": "float",
"attrValue":"28.1"
},
{
"recvTime":"2015-05-06T08:23:44.386Z",
"attributeType": "float",
"attrValue":"28.2"
},
{
"recvTime":"2015-05-06T08:25:45.924Z",
"attributeType": "float",
"attrValue":"83.3"
}
]
As a developer, when retrieving raw data from the STH, I would always expect the values of the attributes to be a "Number", and probably I would go the for the broader case, this is float
. But it is true that since we are retrieving the raw data and the type may change, the developer may be interested on it :)
So, what do you think, should be add the `attributeType' to the data retrieved when asking for raw data?
Any thoughts @frbattid ? :)
+1, I already said that I'm not only talking about maintaining the field, but improving the functionality ;)
Neverthelees, related to what to have said: in case of moving from floatto integer we should do nothing really... I mean, the new raw data would be stored with the new attributeType and the aggregates would still be float. So, are we going to return an interger
type but a float
value?
Including the attributeType
in the results provided when the raw data is requested... ;)
No, no, I mean... Let's see it with an example. Let's imagine data about 2 temperature values reaches the STH component with the following shape:
{
"name" : "temperature",
"type" : "float",
"value" : "20.5"
}
and
{
"name" : "temperature",
"type" : "integer",
"value" : "20"
}
From what we just discussed, if the STH is asked for raw data, it would return something such as:
"values": [
{
"recvTime":"2015-05-06T08:23:00.673Z",
"attributeType": "float",
"attrValue":"20.5"
},
{
"recvTime":"2015-05-06T08:23:44.386Z",
"attributeType": "integer",
"attrValue":"20"
}
]
once the PR I am about to send lands :)
On the other hand and regarding aggregates, we are not currently returning any type information, anyhow developers should expect the information provided are normally floats... For example, the "sum" for the previous case would be "40.5" with "samples" equal to "2"... :)
I hope I made myself clear ;)
Only to remember, in previous discussions we agreed that in the raw would be stored all notifications received (numeric or not ) and the filter would be before aggregated operations, therefore the attribute type can be anything.
Hi @iariasleon , according to https://github.com/telefonicaid/IoT-STH/issues/54#issuecomment-99890934 : "The attribute type changes from integer or float to string. In this case, nothing is stored from the moment the attribute changed." I understood nothing would be store, no raw or aggregated data... :) What do you think @frbattid ? The point is It could make sense to store the raw data no matter if the values of the attributes are aggregatable or not... On the other hand, it seems reasonable to have the raw and the aggregatable data properly synchronized... :) I mean, not having raw data for which no aggregated data is available... :O Uhm, don't really know... :)
Ups, the PR (https://github.com/telefonicaid/IoT-STH/pull/81) already landed but we can create a new one in case we decide to store the raw data no matter the attribute type... ;)
example of raw response:
The attribute type could change.