linksmart / historical-datastore

Lightweight time-series storage on the Edge of IoT
Apache License 2.0
13 stars 2 forks source link

Supporting hierarchy in data streams #74

Closed dschowta closed 4 years ago

dschowta commented 4 years ago

Data streams can be hierarchical. For example, de:Fraunhofer:fit:building1:kitchen can return the data streams which are under it, such as

de:Fraunhofer:fit:building1:kitchen:lamp, de:Fraunhofer:fit:building1:kitchen:refrigerator:power, de:Fraunhofer:fit:building1:kitchen:temperature

These relations can be part of the data stream element by adding fields to the children such as parent

an example:

{
    "name": "de:Fraunhofer:fit:building1:kitchen:lamp",
    "datatype": "boolean",
        "parent": "de:Fraunhofer:fit:building1:kitchen"
}
dschowta commented 4 years ago

Note: in order to avoid the misuse of the parent-child relationships, the "parent" field should be a prefix of the "name" field. Other strings should not be allowed

farshidtz commented 4 years ago

Include meta data inside data api for knowing the dimensions that may come in follow up pages:

{
  "items": [  ], // results
  "series": [ "a/b/c" ]
}
{
  "items": [  ], // results
  "links": [
      {
          "rel": "self",
          "href": "",
      },
      {
          "rel": "next",
          "href": "",
      },
      {
          "rel": "serie1",
          "href": "",
      },
      {
          "rel": "serie2",
          "href": "",
      },
      ...
  ]
}
dschowta commented 4 years ago

This looks good. The heirarchical querying should not be enabled by default in order to avoid load on the server. Instead the client can query the streams the way it is done in registry with operations namely: prefix, suffix, contains, equals. for example, http:localhost:8085/data/de:Fraunhofer:fit:building1:kitchen?prefix or http:localhost:8085/data/de:Fraunhofer:fit:building1:kitchen?suffix etc. The operation equals, is the operation which is performed by default where only exactly matching time series are returned.

farshidtz commented 4 years ago

Since the URL has no size limit by specification, we can assume that the client can query multiple streams by providing their IDs inside the URL without facing issues.

For convenience, we may add a "data" link inside registry with a prepared URL to query listed streams.