Limitations on templated arrays

Hi, Blues team

Using the latest FW v9.3.1, I was wondering what I can expect from the templated arrays.
I’m familiar with the fact that they are designed to store only known data types.
So, given how I have an Array of complex data Structures, I was thinking of flattening such AoS to an SoA type of a configuration, with known types composing the template arrays.

Are template arrays meant to be fixed length?
If so, is it possible to define an upper bound for it? Because I was thinking of having an upper bound on its storage, would still make its size deterministic, but preserve some bandwidth, since only a portion of an array is sent - or does Notecard send the full array? What if the "full”: true is define etc.

Thank you for your time!

1 Like

Hi @Jakov,

You can definitely move to a Structure-of-Arrays configuration such that each array is variable length, but with the datatype specified, like so:

  "body": {
    "voltages":[12.1],
    "currents":[12.1],
    "movements":[12]
  }

There is not a way to define an upper bound, but the Notecard will omit fields entirely if no data is sent in a given field.

Thanks,
Rob

2 Likes

Hi @RobLauer,

Excuse my rambling here:

I got the sense, from template API, that their specification was meant to provide a fixed(bounded) Note size, so that they could be stored on Flash more effectively. Or I’d suppose that only known types are allowed because Notecard implements some kind of key-value type flash storage?

In any case, I just have an engineering spidey sense tingling, that using template arrays might incurr some hidden limitation Im not seeing right away.

At some point in device lifetime, we could have a variance of upto 200 integers let’s say in a given Note, but most likely ~30.

Just for the sake of argument, that would mean a templated Notefile (be it Outbound or DB), where I could send a note with an array of 5 integers and some other note of about 60, all residing in flash?

@RobLauer Just letting you know that I appreciate the engagment on Forum so far.

Any bit of info is welcome!

Hi @Jakov,

These are all good questions, and I assure you there are no hidden limitations when using templates. Arguably the only “downside” in terms of data usage is the first time you sync a Notefile that uses a template, you’re going to incur a very small data penalty to sync the template with Notehub (check out this doc on estimating data usage in a variety of scenarios).

After that, the difference between syncing [1,2,3] and syncing an array with 200+ integers is simply the raw bytes required for those values. Without a template, you’d be paying a much larger recurring cost because every sync would have to serialize and transmit all the surrounding JSON structure.

Rob

1 Like