Accessing vertex attributes from within a UDF

Accessing vertex attributes from within a UDF

Hello Tigergraph community,

I have been learning gsql before I attempt to implement a complicated graph traversal in which I will need to access vertex & edge attributes. While it is probable I would be able to impelment it in pure gsql, I am very intrigued by using UDFs. I have been trying to access vertex & edge attributes from within a UDF. I have encountered several difficulties with this.

The vertices in this graph have an attribute named ‘value’ which I would like to access from the UDF and the following query.

CREATE QUERY vertexValueQuery(){
SetAccum @@vertexValues;
source = {node*}
nodes = SELECT v FROM source ACCUM @@vertexValues += vertex_value_udf(v);
PRINT @@vertexValues;
}

I was able to get the the udf to compile with the following function signature, though passing the VERTEX by reference to the function did not compile.

inline int vertex_value_udf(const VERTEX v){

}

How would I access the vertex’s ‘value’ attribute? I would like to be able to do somethign like this.

inline int vertex_value_udf(const VERTEX v){
v.attributes.value // does not compile
v.value // does not compile
}

Can somebody please point me towards some documentation that shows how to work with vertex, edge & accumulators from within udfs? Is it possible to view the gle/engine/cpplib/headers.hpp headers?

Thanks