Overlap between two sets out of one map

Hello,

I am trying to get the overlap between two sets out of the same map:

MapAccum<vertex, SetAccum> @@map;

overlap = (@@map.get(key1) INTERSECT @@map.get(key2)).size();

But as a syntax error I get the following:

" Left set “@@map.get(key1)” returns vertex type [], but the richt set " @@map.get(key2)" returns vertex type [] "

In my understanding both “.get(key)” calls should return a set of strings.

Is there an other way one could calculate this easily?

And please tell me if I am using the INTERSECT clause wrongly.

Thanks

Felix

So the problem here may be that GSQL type inference is sometimes a little shallow. I’ll raise a ticket anyway in case it is a bug.

This code works by expanding your expression, otherwise you are exactly correct:

        MapAccum<vertex, SetAccum<String>> @@map;

	VERTEX  key1, key2;
	SetAccum<String> @@left, @@right, @@result;
	int overlap;
	
	@@left = @@map.get(key1);
	@@right = @@map.get(key2);
	@@result = @@left INTERSECT @@right;
        overlap = @@result.size();
	
	print overlap;