trace-server-protocol icon indicating copy to clipboard operation
trace-server-protocol copied to clipboard

Type of yValues in an XY model series is listed as int64 but encoded as double

Open awendelin-work opened this issue 1 year ago • 1 comments

The trace-server (built from incubator 4b14d71637df2cedecd48d4287851315418a2d31) returns XY model data which is inconsistent with the openapi specification.

The XY endpoint to fetch the model (https://localhost:8080/tsp/api/experiments/{expUUID}/outputs/XY/{outputId}/xy) lists in its response schema that yValues is an array of int64, but the actual values returned by the trace-server are encoded as doubles.

In org.eclipse.tracecompass.incubator, the series is serialized by SeriesModelSerializer.java which takes in an ISeriesModel and writes its data to JSON. The relevant part is:

public void serialize(ISeriesModel value, ...)
    ...
    gen.writeObjectField("yValues", value.getData())
    ...

getData is defined by the interface ISeriesModel as:

/**
 * Get the y values
 *
 * @return An array of y values
 */
double[] getData();

A consumer following the specification will attempt to parse the yValues as an int64 and either fail or truncate the values.

Example of a series:

{
  "seriesId": 2,
  "seriesName": "2",
  "xValues": [
    28170745093,
    28180756897,
    28190770283,
    28200779146,
    28201221406,
    28211228374
  ],
  "yValues": [
    10913.0,
    12613.0,
    12177.0,
    12455.0,
    14821.0,
    17925.0
  ],
  "style": {
    "parentKey": null,
    "values": {
      "series-type": "scatter"
    }
  }
},

To me it makes sense that the yValues should listed as doubles in the openapi specification, and that that's where the issue lies.

diff --git a/API.yaml b/API.yaml
index af1ee4c..5c36fa4 100644
--- a/API.yaml
+++ b/API.yaml
@@ -2246,8 +2246,8 @@ components:
           type: array
           description: Series' Y values
           items:
-            type: integer
-            format: int64
+            type: number
+            format: double
       description: This model includes the series output style values.
     XYModel:
       required:

awendelin-work avatar Jul 19 '24 15:07 awendelin-work