Iterate all vertices without returning anything

is there a way to iterate all vertices without returning any vertex or edge? I need to reach to each of my 10 million vertices and get some data into UDF C++ side. If I return all vertices, it hits the 2 GB limit of select.

list = {ANY};

all = select p from list:p;

      ACCUM

      call_udf(p);

I did not want to return any p to all, yet do call_udf§ for all so that I do not run out of memory.

Thanks

Kumar

all = select p from list:p;
ACCUM
call_udf§
having false;

//ACCUM will be executed, but nothing will be stored in “all”.

Hi Kumar,

Could you please be more specific on the purpose of this query, what is the input and what is the expected output?

If the vertex set all is not printed, I don’t think we would hit any 2GB limit.

Thanks.

Hello Xinyu,

The query needs to reach to each vertex and look for certain edges and collect a list of numbers in a global accumulator. Then for each vertex I need to pass that list to the UDF C++ side for further processing. I want to keep memory usage low and hence do not want to use accumulators (I may have 50 million vertices and my machine does not have enough of RAM), rather as I am traversing, I want to just call UDF C++ code for each vertex and then clear the list and reuse it for next vertex.

I am new to GSQL and may be doing something quite inefficient. Would love to hear your suggestions.

I am doing following for now:

SetAccum<VERTEX> @@teachersSet;

ListAccum @@propertyList;

population = {teachers.*};

all = select p from population:p having false;

    ACCUM

     @@teachersSet +=p;

foreach p in @@teachersSet DO

currentTeacher = {p};

@@propertyList.clear();

a_set = select a FROM currentTeacher -(studied_in:e)-universities:a

           ACCUM @@propertyList += a.CODE1,  @@propertyList += a.CODE2, @@propertyList += a.CODE3 

          having false;

More iterations like above on other edge types

Pass elements of @@propertyList.to UDF

foreach elem in @@propertyList DO

 call_my_udf(elem);

end;

end;

is there a way to write nested select statement so that I can avoid following code just to get the @@teachersSet populated for usage by the foreach iteration?

all = select p from population:p having false;

    ACCUM

     @@teachersSet +=p;

Thanks for your help!

Kumar