[jboss-jira] [JBoss JIRA] (JBRULES-2640) Implement support for group-by (if an explicit construct is necessary) and distinct
Matteo Mortari (JIRA)
issues at jboss.org
Fri Feb 13 04:15:51 EST 2015
[ https://issues.jboss.org/browse/JBRULES-2640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13040076#comment-13040076 ]
Matteo Mortari commented on JBRULES-2640:
-----------------------------------------
Is this a {{group-by}} intended to be in conjunction with {{accumulate}} ?
IFF so, normally I try to normalize it as per the below example; possibly doesn't cover all possibly use-case, but I thought maybe could be helpful in the time being.
{{
declare GroupByString
groupId : String
groups : String[]
end
rule "init Metro hash of my interest"
no-loop
when
then
GroupByString grp = new GroupByString();
grp.setGroupId("metroHash");
grp.setGroups(new String[]{"#M1", "#M2"});
insert(grp);
end
// Remember see JSON 'in_reply_to_user_id' if null actually will be -1 by convention of method getLong(String str) of Maven-Central / org.twitter4j / twitter4j-core / 3.0.5 / twitter4j.internal.json.z_T4JInternalParseUtil
rule "Multiple tweets about a metro line hash"
no-loop
when
$group : GroupByString( groupId == "metroHash")
$metroHash : String() from $group.groups
accumulate ( $tweet : Status( text contains $metroHash, inReplyToUserId == -1 ) over window:time( 5m ) ;
$list : collectList( $tweet ),
$count : count( $tweet );
$count >= 2
)
not Alert( condition == "Multiple tweets about a metro line hash "+$metroHash ) over window:time( 5m )
then
Status[] theTweets = new Status[$list.size()];
$list.toArray(theTweets); // TODO check: I've tried more concise one-liner syntax but fail KB compilation.
Alert<Status[]> alert = new Alert<Status[]>(sessionCurrentTime(kcontext),
"Multiple tweets about a metro line hash "+$metroHash,
AlertType.INFO,
theTweets);
insert(alert);
LOG.info("Multiple tweets for " + $metroHash + " count " + $count + " list: " + $list);
end
}}
> Implement support for group-by (if an explicit construct is necessary) and distinct
> -----------------------------------------------------------------------------------
>
> Key: JBRULES-2640
> URL: https://issues.jboss.org/browse/JBRULES-2640
> Project: JBRULES
> Issue Type: Feature Request
> Components: All
> Affects Versions: 5.1.0.FINAL
> Reporter: Edson Tirelli
> Assignee: Edson Tirelli
> Labels: fusion_roadmap
> Fix For: FUTURE
>
>
> Implement support for group-by (if an explicit construct is necessary) and distinct
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
More information about the jboss-jira
mailing list