@Test public void testComplexCartesianProduct() throws Exception { String query = "MATCH (a:Person)-[e1:knows]->(b:Person),(c:Forum)-[e2:hasTag]->(d:Tag)"; QueryHandler queryHandler = new QueryHandler(query); LeafNode aNode = new FilterAndProjectVerticesNode(null, "a", queryHandler.getPredicates().getSubCNF("a"), Sets.newHashSet()); LeafNode bNode = new FilterAndProjectVerticesNode(null, "b", queryHandler.getPredicates().getSubCNF("b"), Sets.newHashSet()); LeafNode cNode = new FilterAndProjectVerticesNode(null, "c", queryHandler.getPredicates().getSubCNF("c"), Sets.newHashSet()); LeafNode dNode = new FilterAndProjectVerticesNode(null, "d", queryHandler.getPredicates().getSubCNF("d"), Sets.newHashSet()); LeafNode e1Node = new FilterAndProjectEdgesNode(null, "a", "e1", "b", queryHandler.getPredicates().getSubCNF("e1"), Sets.newHashSet(), false); LeafNode e2Node = new FilterAndProjectEdgesNode(null, "c", "e2", "d", queryHandler.getPredicates().getSubCNF("e2"), Sets.newHashSet(), false); BinaryNode ae1 = new JoinEmbeddingsNode(aNode, e1Node, Lists.newArrayList("a"), MatchStrategy.HOMOMORPHISM, MatchStrategy.HOMOMORPHISM); BinaryNode ae1b = new JoinEmbeddingsNode(ae1, bNode, Lists.newArrayList("b"), MatchStrategy.HOMOMORPHISM, MatchStrategy.HOMOMORPHISM); BinaryNode ce2 = new JoinEmbeddingsNode(cNode, e2Node, Lists.newArrayList("c"), MatchStrategy.HOMOMORPHISM, MatchStrategy.HOMOMORPHISM); BinaryNode ce2d = new JoinEmbeddingsNode(ce2, dNode, Lists.newArrayList("d"), MatchStrategy.HOMOMORPHISM, MatchStrategy.HOMOMORPHISM); CartesianProductNode crossNode = new CartesianProductNode(ae1b, ce2d, MatchStrategy .HOMOMORPHISM, MatchStrategy.HOMOMORPHISM); QueryPlan ae1bPlan = new QueryPlan(ae1b); QueryPlan ce2dPlan = new QueryPlan(ce2d); QueryPlan crossPlan = new QueryPlan(crossNode); QueryPlanEstimator ae1bEstimator = new QueryPlanEstimator(ae1bPlan, queryHandler, STATS); QueryPlanEstimator ce2dEstimator = new QueryPlanEstimator(ce2dPlan, queryHandler, STATS); QueryPlanEstimator crossEstimator = new QueryPlanEstimator(crossPlan, queryHandler, STATS); assertThat(crossEstimator.getCardinality(), is(ae1bEstimator.getCardinality() * ce2dEstimator.getCardinality())); }
public long getCardinality() { traversePlan(queryPlan.getRoot()); long cardinality = joinEstimator.getCardinality(); if (cardinality == 0) { cardinality = filterEstimator.getCardinality(); } double selectivity = filterEstimator.getSelectivity(); return Math.round(cardinality * selectivity); }
QueryPlanEstimator { public long getCardinality() { traversePlan(queryPlan.getRoot()); long cardinality = joinEstimator.getCardinality(); if (cardinality == 0) { cardinality = filterEstimator.getCardinality(); } double selectivity = filterEstimator.getSelectivity(); return Math.round(cardinality * selectivity); } }
QueryPlanEstimator { public long getCardinality() { traversePlan(queryPlan.getRoot()); long cardinality = joinEstimator.getCardinality(); if (cardinality == 0) { cardinality = filterEstimator.getCardinality(); } double selectivity = filterEstimator.getSelectivity(); return Math.round(cardinality * selectivity); } QueryPlanEstimator(QueryPlan queryPlan, QueryHandler queryHandler,
    GraphStatistics graphStatistics); }
QueryPlanEstimator { public long getCardinality() { traversePlan(queryPlan.getRoot()); long cardinality = joinEstimator.getCardinality(); if (cardinality == 0) { cardinality = filterEstimator.getCardinality(); } double selectivity = filterEstimator.getSelectivity(); return Math.round(cardinality * selectivity); } QueryPlanEstimator(QueryPlan queryPlan, QueryHandler queryHandler,
    GraphStatistics graphStatistics); QueryPlan getQueryPlan(); long getCardinality(); }
QueryPlanEstimator { public long getCardinality() { traversePlan(queryPlan.getRoot()); long cardinality = joinEstimator.getCardinality(); if (cardinality == 0) { cardinality = filterEstimator.getCardinality(); } double selectivity = filterEstimator.getSelectivity(); return Math.round(cardinality * selectivity); } QueryPlanEstimator(QueryPlan queryPlan, QueryHandler queryHandler,
    GraphStatistics graphStatistics); QueryPlan getQueryPlan(); long getCardinality();  }