Re: Union with Count returning unexpected results
hadoopmarc@...
Hi Vinayak,
I guess this has to do with differences in lazy vs eager evaluation between the two queries. The TinkerPop ref docs reference the aggregated values with cap('ACount','E1Count','BCount','E2Count','CCount'), rather than with select(), to force eager evaluation, see: https://tinkerpop.apache.org/docs/current/reference/#store-step
Best wishes, Marc
For other readers, please find the queries from the original post in a better readable format:
g2.inject(1).union(
V().has('title', 'A').aggregate('v1').union(
outE().has('title', 'E1').aggregate('e').inV().has('title', 'B'),
outE().has('title', 'E2').aggregate('e').inV().has('title','C')
).aggregate('v2')
).
select('v1').dedup().as('sourceCount').
select('e').dedup().as('edgeCount').
select('v2').dedup().as('destinationCount').
select('sourceCount','edgeCount','destinationCount').by(unfold().count())
g2.inject(1).union(
V().has('title', 'A').aggregate('A').union(
outE().has('title', 'E1').aggregate('E1').inV().has('title', 'B').aggregate('B'),
outE().has('title', 'E2').aggregate('E2').inV().has('title','C').aggregate('C')
)
).
select('A').dedup().as('ACount').
select('E1').dedup().as('E1Count').
select('B').dedup().as('BCount').
select('E2').dedup().as('E2Count').
select('C').dedup().as('CCount').
select('ACount','E1Count','BCount','E2Count','CCount').by(unfold().count())
I guess this has to do with differences in lazy vs eager evaluation between the two queries. The TinkerPop ref docs reference the aggregated values with cap('ACount','E1Count','BCount','E2Count','CCount'), rather than with select(), to force eager evaluation, see: https://tinkerpop.apache.org/docs/current/reference/#store-step
Best wishes, Marc
For other readers, please find the queries from the original post in a better readable format:
g2.inject(1).union(
V().has('title', 'A').aggregate('v1').union(
outE().has('title', 'E1').aggregate('e').inV().has('title', 'B'),
outE().has('title', 'E2').aggregate('e').inV().has('title','C')
).aggregate('v2')
).
select('v1').dedup().as('sourceCount').
select('e').dedup().as('edgeCount').
select('v2').dedup().as('destinationCount').
select('sourceCount','edgeCount','destinationCount').by(unfold().count())
g2.inject(1).union(
V().has('title', 'A').aggregate('A').union(
outE().has('title', 'E1').aggregate('E1').inV().has('title', 'B').aggregate('B'),
outE().has('title', 'E2').aggregate('E2').inV().has('title','C').aggregate('C')
)
).
select('A').dedup().as('ACount').
select('E1').dedup().as('E1Count').
select('B').dedup().as('BCount').
select('E2').dedup().as('E2Count').
select('C').dedup().as('CCount').
select('ACount','E1Count','BCount','E2Count','CCount').by(unfold().count())