nqminds / nqm-iot-database-py

nqm-iot-database-py
https://nqminds.github.io/nqm-iot-database-py/
0 stars 0 forks source link

API architecture #20

Open mereacre opened 5 years ago

mereacre commented 5 years ago

We need to standardise the APIs for nqm-iot-database-py and nqm-iot-database-utils as there's no numpy array definition in nodejs. Plus we do need to implement the stream functionality for both Python and nodejs versions.

The getData functions in Python and nodejs versions have different input types. I propose to remove the numpy functionality and use a custom object for buffer type fields as defined in the latest version of the nodejs code. Here is the buffer type definition:

  /**
   * @global
   * @typedef  {object} NdarrayData
   * @property  {Buffer|{object: any}} data - The ndarray data Buffer or Stream.
   * @property  {string} dtype - The ndarray data type is of type `NDARRAY_DTYPES`.
   * @property  {number[]} shape - The ndarray shape.
   * @property  {boolean} major - The ndarray major (`true` - row-major, `false` - column-major).
   * @property  {string} ftype - The ndarray file type is of type `NDARRAY_FTYPES`.
   */

The below function should be also standardised for both Python and nodejs:

  /**
   * Returns the Javascript typed array from a buffer of a given type.
   * @function
   * @alias module:sqlite-ndarray.getTypedArrayFromBuffer
   * @sync
   * @param {Buffer} buffer - The data buffer.
   * @param {string} dtype - The data type is of type `NDARRAY_DTYPES`.
   * @returns {object} - The typed array.
   */

The below function transforms from custom object to the sqlite entry:

  /**
   * Returns the ndarray metadata.
   * @function
   * @alias module:sqlite-ndarray.getNdarrayMeta
   * @sync
   * @param {Buffer|{object: any}} data - The input data buffer or data stream.
   * @param {string} [dtype] - The data type is of type `NDARRAY_DTYPES`.
   * @param {array} [shape] - The shape of the data.
   * @param {boolean} [major] - The data major (true - row-major, false - column-major).
   * @param {string} [ftype] - The ndarray file type is of type `NDARRAY_FTYPES`.
   * @returns {object} - The ndarray metadata.
   */