|
| 1 | +from enum import Enum |
| 2 | +from typing import List, Optional |
| 3 | + |
| 4 | +from nisystemlink.clients.core._uplink._json_model import JsonModel |
| 5 | + |
| 6 | +from ._query_table_data_base import QueryTableDataBase |
| 7 | + |
| 8 | + |
| 9 | +class DecimationMethod(str, Enum): |
| 10 | + """Represents the different methods that can be used to decimate data.""" |
| 11 | + |
| 12 | + Lossy = "LOSSY" |
| 13 | + """Creates an ``x_column`` ordered set and returns an uniformly distributed |
| 14 | + sample of rows with as many rows as the number specified as ``intervals.``""" |
| 15 | + |
| 16 | + MaxMin = "MAX_MIN" |
| 17 | + """Creates an ``x_column`` ordered set which will be divided in the number of |
| 18 | + ``intervals`` specified. For each of the intervals, the maximum and minimum |
| 19 | + values for all the columns specified in ``y_columns`` will be returned.""" |
| 20 | + |
| 21 | + EntryExit = "ENTRY_EXIT" |
| 22 | + """Creates an ``x_column`` ordered set which will be divided in the number of |
| 23 | + ``intervals`` specified. For each of the intervals, the first and last row |
| 24 | + within the interval will be returned in addition to the maximum and minimum |
| 25 | + values for all the columns specified in ``y_columns``.""" |
| 26 | + |
| 27 | + |
| 28 | +class DecimationOptions(JsonModel): |
| 29 | + """Contains the parameters to use for data decimation.""" |
| 30 | + |
| 31 | + x_column: Optional[str] = None |
| 32 | + """The name of the column that will be used as the x-axis for decimating the |
| 33 | + data. The column in the table that was specified as Index will be used if |
| 34 | + this field is excluded. Only numeric columns are supported. i.e. ``INT32``, |
| 35 | + ``INT64``, ``FLOAT32``, ``FLOAT64`` and ``TIMESTAMP``.""" |
| 36 | + |
| 37 | + y_columns: Optional[List[str]] = None |
| 38 | + """A list of columns to decimate by. This property is only needed when the |
| 39 | + specified method is ``MAX_MIN`` or ``ENTRY_EXIT``. Only numeric columns are |
| 40 | + supported. i.e. ``INT32``, ``INT64``, ``FLOAT32``, ``FLOAT64`` and |
| 41 | + ``TIMESTAMP``.""" |
| 42 | + |
| 43 | + intervals: Optional[int] = None |
| 44 | + """Number of intervals to use for decimation. Defaults to 1000.""" |
| 45 | + |
| 46 | + method: Optional[DecimationMethod] = None |
| 47 | + """Specifies the method used to decimate the data. Defaults to |
| 48 | + :class:`DecimationMethod.Lossy`""" |
| 49 | + |
| 50 | + |
| 51 | +class QueryDecimatedDataRequest(QueryTableDataBase): |
| 52 | + """Specifies the columns, filters and decimation parameters for a query.""" |
| 53 | + |
| 54 | + decimation: Optional[DecimationOptions] = None |
| 55 | + """The decimation options to use when querying data. If not specified, the |
| 56 | + default is to use :class:`DecimationMethod.Lossy` with 1000 intervals over |
| 57 | + the table's index column.""" |
0 commit comments