edgent-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dale LaBossiere (JIRA)" <j...@apache.org>
Subject [jira] [Created] (EDGENT-407) JsonFunctions: more convenience functions for creation and unpartitioned window
Date Thu, 13 Apr 2017 14:19:42 GMT
Dale LaBossiere created EDGENT-407:
--------------------------------------

             Summary: JsonFunctions: more convenience functions for creation and unpartitioned
window
                 Key: EDGENT-407
                 URL: https://issues.apache.org/jira/browse/EDGENT-407
             Project: Edgent
          Issue Type: Wish
          Components: API
            Reporter: Dale LaBossiere
            Assignee: Dale LaBossiere


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>)):
{code}
TStream<Double> s = ...
TStream<JsonObject> js = s.map(val -> {
  JsonObject jo = new JsonObject();
  jo.addProperty("propName", val);
  return jo.
});
{code}
Unfortunately, addProperty() returns void so the above can't be reduced to something like:

{code}
return new JsonObject().addProperty("propName", val)
{code}

I'd like an ease-of-use function like:
{code}
TStream<JsonObject> js = s.map(JsonFunctions.valueOfNumber("propName"));
{code}
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()}}.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message