Add to a "count" attribute inside the loading job

Hello everyone,

we are currently trying to find a way to have an attribute in an edge that count how many times the edge “would be created” between two vertex types.

Meaning on its first creation the attribute is initialized with 1 and on every following “creation” the attribute would be counted +1. So that we have a metric on how many times this connection was witnessed in our events.

Is it possible to read from an existing value in the loading job and add to this value? (if it exists)

I read the documentation page on reducer functions but it isn’t clear to me if they could be used in this szenario.


@Felix-P - This section might help you out if i’m reading your problem correctly.

The GSQL Loader language supports most of the standard arithmetic, relational, and boolean operators found in C++. Standard operator precedence applies, and parentheses provide the usual override of precedence.

Yes I believe so.

The REDUCE(ADD(1)) on the attribute you are loading should work as I recall.

1 Like

Thanks for the response. I will try it out like that and come back to you.



I tried your suggestion and it does not work as I need it to.
If it was not clear, I want to count an edge attribute +1 every time the edge would be created from a message

message1 -> edge is created with count 1
message2 -> edge is updated to have count 2

but there is no indication in the message itself if the connection had previously been established.

Hello again,

I tried it again with the REDUCE( ADD (1) ) solution and it worked as you mentioned. I do not know what went wrong the first time, but thanks for the help.

1 Like

@Felix-P Thanks for letting us know it worked! Thanks @rik for the tip!