Uploaded image for project: 'Edgent'
  1. Edgent
  2. EDGENT-407

JsonFunctions: more convenience functions for creation and unpartitioned window

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • Apache Edgent 1.2.0
    • API
    • None

    Description

      Recently I've found myself repetitively doing the following when transforming a stream of simple numerics into a JsonObject (e.g., for publishing via IotDevice(TStream<JsonObject>)):

      TStream<Double> s = ...
      TStream<JsonObject> js = s.map(val -> {
        JsonObject jo = new JsonObject();
        jo.addProperty("propName", val);
        return jo.
      });
      

      Unfortunately, addProperty() returns void so the above can't be reduced to something like:

      return new JsonObject().addProperty("propName", val)
      

      I'd like an ease-of-use function like:

      TStream<JsonObject> js = s.map(JsonFunctions.valueOfNumber("propName"));
      

      For completeness, there should also be valueOfString(), valueOfCharacter(), valueOfBoolean().

      Also, JsonAnalytics works with JsonElement partitioned windows: TWindow<JsonObject,JsonElement>. It should be trivial to be able to specify an unpartitioned window. Functions.unpartitioned() provides that for Integer keyed windows. There should be a corresponding JsonFunctions.unpartitioned().

      Attachments

        Activity

          People

            dlaboss Dale LaBossiere
            dlaboss Dale LaBossiere
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: