@Test public void testFixedPattern() throws Exception { String query = "MATCH (n)-[e]->(m)-[f]->(o)"; QueryHandler queryHandler = new QueryHandler(query); LeafNode nNode = new FilterAndProjectVerticesNode(null, "n", queryHandler.getPredicates().getSubCNF("n"), Sets.newHashSet()); LeafNode mNode = new FilterAndProjectVerticesNode(null, "m", queryHandler.getPredicates().getSubCNF("m"), Sets.newHashSet()); LeafNode oNode = new FilterAndProjectVerticesNode(null, "o", queryHandler.getPredicates().getSubCNF("o"), Sets.newHashSet()); LeafNode eNode = new FilterAndProjectEdgesNode(null, "n", "e", "m", queryHandler.getPredicates().getSubCNF("e"), Sets.newHashSet(), false); LeafNode fNode = new FilterAndProjectEdgesNode(null, "m", "f", "o", queryHandler.getPredicates().getSubCNF("f"), Sets.newHashSet(), false); JoinEmbeddingsNode neJoin = new JoinEmbeddingsNode(nNode, eNode, Lists.newArrayList("n"), MatchStrategy.ISOMORPHISM, MatchStrategy.ISOMORPHISM); QueryPlan plan = new QueryPlan(neJoin); QueryPlanEstimator estimator = new QueryPlanEstimator(plan, queryHandler, STATS); assertThat(estimator.getCardinality(), is(24L)); JoinEmbeddingsNode nemJoin = new JoinEmbeddingsNode(neJoin, mNode, Lists.newArrayList("m"), MatchStrategy.ISOMORPHISM, MatchStrategy.ISOMORPHISM); plan = new QueryPlan(nemJoin); estimator = new QueryPlanEstimator(plan, queryHandler, STATS); assertThat(estimator.getCardinality(), is(24L)); JoinEmbeddingsNode nemfJoin = new JoinEmbeddingsNode(nemJoin, fNode, Lists.newArrayList("m"), MatchStrategy.ISOMORPHISM, MatchStrategy.ISOMORPHISM); plan = new QueryPlan(nemfJoin); estimator = new QueryPlanEstimator(plan, queryHandler, STATS); assertThat(estimator.getCardinality(), is(72L)); JoinEmbeddingsNode nemfoJoin = new JoinEmbeddingsNode(nemfJoin, oNode, Lists.newArrayList("o"), MatchStrategy.ISOMORPHISM, MatchStrategy.ISOMORPHISM); plan = new QueryPlan(nemfoJoin); estimator = new QueryPlanEstimator(plan, queryHandler, STATS); assertThat(estimator.getCardinality(), is(72L)); }
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();  }