You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@edgent.apache.org by "Dale LaBossiere (JIRA)" <ji...@apache.org> on 2018/01/02 18:59:00 UTC

[jira] [Closed] (EDGENT-407) JsonFunctions: more convenience functions for creation and unpartitioned window

     [ https://issues.apache.org/jira/browse/EDGENT-407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dale LaBossiere closed EDGENT-407.
----------------------------------

> 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
>             Fix For: Apache Edgent 1.2.0
>
>
> 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.4.14#64029)