Robert Peach Robert Peach - 1 year ago 147
Java Question

Google-app-engine datastore multi-dimensional arrays

I have a class that runs as a cron job (every 5 minutes or so) and it produces a multidimensional array. I then want to access this array from another class.

Is it possible to just put() a whole md-array as a single object into the datastore? And then to get() that md-array in another class?

If so, is it similar to just putting other simple variables into the datastore?

Cheers for any help

Answer Source

No, you cannot directly store a multi-dimensional array as a property of a datastore entity. The closest type would be a ListProperty, but this will only store one dimension. (Python only, not for Java)

Depending on what the data in your md-array represents, you could:

  • Serialize the values into a byte array, which you store as a Blob (1 MB size limit)

  • Flatten the array and store each dimension as an individual property

  • Create an entity for the rows, and properties for the columns (if 2-dimensional)

For all supported datastore property types, see this section of the GAE documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download