CREATE VERTEX MACHINE (PRIMARY_ID ip STRING, ip STRING)
CREATE VERTEX SERVICE (PRIMARY_ID name STRING, name STRING)
CREATE DIRECTED EDGE TRAFFIC (FROM MACHINE, TO MACHINE, traffic_date STRING, app_proto STRING)
CREATE DIRECTED EDGE TRAFFIC_TYPE (FROM MACHINE, TO SERVICE, traffic_date STRING)
CREATE GRAPH traffic (MACHINE,SERVICE,TRAFFIC,TRAFFIC_TYPE)
CREATE QUERY GetAppProto(STRING traffic_date,UINT min_src) FOR GRAPH traffic returns (ListAccum<RESULT_TYPE>){
TYPEDEF tuple<STRING ip,STRING date,STRING app_proto> RESULT_TYPE;
ListAccum<RESULT_TYPE> @@RESULTS;
GroupByAccum<STRING ip,STRING date,STRING app_proto ,SumAccum<INT>num > @@DstAccum;
#STRING d = datetime_format(now(),"%Y-%m-%d%");
machine = {MACHINE.*};
results = SELECT p
FROM machine-(TRAFFIC:l)->:p
WHERE l.traffic_date == traffic_date
ACCUM
@@DstAccum += (p.ip,l.traffic_date,l.app_proto->1);
FOREACH d IN @@DstAccum DO
IF d.num >= min_src THEN
@@RESULTS += RESULT_TYPE(d.ip,d.date,d.app_proto);
END;
END;
PRINT @@RESULTS;
RETURN @@RESULTS;
}
--
Welcome to GSQL-user group.
- our mission is bringing the power of graph databases to everyone www.opengsql.org
- technical resource can be found here https://docs.tigergraph.com/
---
You received this message because you are subscribed to the Google Groups "gsql-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gsql-users+...@opengsql.org.
To view this discussion on the web visit https://groups.google.com/a/opengsql.org/d/msgid/gsql-users/bf2095f8-db4d-4760-a507-7a1f80aa5ed1%40opengsql.org.