@Test public void writeChildQueriesTest() throws Exception { CompositeMetadata amd = getCmd("A", projection("[{'field':'obj1.c'},{'field':'obj1.c.*.b'}]")); CompositeMetadata cmd = amd.getChildMetadata(new Path("obj1.c")); CompositeMetadata bmd = cmd.getChildMetadata(new Path("obj1.c.*.b")); QueryPlanChooser chooser = new QueryPlanChooser(amd, new First(), new SimpleScorer(), query("{'field':'_id','op':'=','rvalue':1}"), null); QueryPlan qp = chooser.choose(); ExecutionBlock ablock = new ExecutionBlock(amd, qp.getNode(amd)); ExecutionBlock bblock = new ExecutionBlock(amd, qp.getNode(bmd)); ExecutionBlock cblock = new ExecutionBlock(amd, qp.getNode(cmd)); QueryPlanData data = qp.getEdgeData(qp.getNode(amd), qp.getNode(cmd)); AssociationQuery a1 = new AssociationQuery(amd, cmd, data.getReference(), data.getConjuncts()); data = qp.getEdgeData(qp.getNode(cmd), qp.getNode(bmd)); AssociationQuery a2 = new AssociationQuery(amd, cmd, data.getReference(), data.getConjuncts()); cblock.setAssociationQuery(ablock, a1); cblock.setAssociationQuery(bblock, a2); qp.flip(qp.getNode(bmd), qp.getNode(cmd)); cblock.addSourceBlock(ablock); cblock.addSourceBlock(bblock); ablock.linkBlocks(); bblock.linkBlocks(); cblock.linkBlocks(); Map<ChildSlot, QueryExpression> map = Searches. writeChildQueriesFromParentDoc(a1, resultDoc(ablock, "{'id':'a','obj1':{'c_ref':'ref'}}")); System.out.println(map); Assert.assertEquals(1, map.size()); ChildSlot slot = map.keySet().iterator().next(); Assert.assertEquals("obj1", slot.getLocalContainerName().toString()); Assert.assertEquals("c", slot.getReferenceFieldName()); JSONAssert.assertEquals("{field:_id,op:$eq,rvalue:ref}", map.values().iterator().next().toString(), false); }
public static Map<ChildSlot, QueryExpression> writeChildQueriesFromParentDoc(AssociationQuery aq, ResultDocument parentDocument) { Map<ChildSlot, BindQuery> binders = parentDocument.getBindersForChild(aq); LOGGER.debug("writeChildQueriesForParentDoc: aq={} binders={}", aq, binders); Map<ChildSlot, QueryExpression> queries = new HashMap<>(); for (Map.Entry<ChildSlot, BindQuery> entry : binders.entrySet()) { if (aq.getQuery() != null) { queries.put(entry.getKey(), entry.getValue().iterate(aq.getQuery())); } else { queries.put(entry.getKey(), null); } } LOGGER.debug("Queries:{}", queries); return queries; }
Searches { public static Map<ChildSlot, QueryExpression> writeChildQueriesFromParentDoc(AssociationQuery aq, ResultDocument parentDocument) { Map<ChildSlot, BindQuery> binders = parentDocument.getBindersForChild(aq); LOGGER.debug("writeChildQueriesForParentDoc: aq={} binders={}", aq, binders); Map<ChildSlot, QueryExpression> queries = new HashMap<>(); for (Map.Entry<ChildSlot, BindQuery> entry : binders.entrySet()) { if (aq.getQuery() != null) { queries.put(entry.getKey(), entry.getValue().iterate(aq.getQuery())); } else { queries.put(entry.getKey(), null); } } LOGGER.debug("Queries:{}", queries); return queries; } }
Searches { public static Map<ChildSlot, QueryExpression> writeChildQueriesFromParentDoc(AssociationQuery aq, ResultDocument parentDocument) { Map<ChildSlot, BindQuery> binders = parentDocument.getBindersForChild(aq); LOGGER.debug("writeChildQueriesForParentDoc: aq={} binders={}", aq, binders); Map<ChildSlot, QueryExpression> queries = new HashMap<>(); for (Map.Entry<ChildSlot, BindQuery> entry : binders.entrySet()) { if (aq.getQuery() != null) { queries.put(entry.getKey(), entry.getValue().iterate(aq.getQuery())); } else { queries.put(entry.getKey(), null); } } LOGGER.debug("Queries:{}", queries); return queries; } private  Searches(); }
Searches { public static Map<ChildSlot, QueryExpression> writeChildQueriesFromParentDoc(AssociationQuery aq, ResultDocument parentDocument) { Map<ChildSlot, BindQuery> binders = parentDocument.getBindersForChild(aq); LOGGER.debug("writeChildQueriesForParentDoc: aq={} binders={}", aq, binders); Map<ChildSlot, QueryExpression> queries = new HashMap<>(); for (Map.Entry<ChildSlot, BindQuery> entry : binders.entrySet()) { if (aq.getQuery() != null) { queries.put(entry.getKey(), entry.getValue().iterate(aq.getQuery())); } else { queries.put(entry.getKey(), null); } } LOGGER.debug("Queries:{}", queries); return queries; } private  Searches(); static Map<ChildSlot, QueryExpression> writeChildQueriesFromParentDoc(AssociationQuery aq,
                                                                                 ResultDocument parentDocument); static List<QueryExpression> writeQueriesForJoinTuple(JoinTuple tuple, ExecutionBlock childBlock); static QueryExpression and(QueryExpression... q); static QueryExpression and(List<QueryExpression> list); static QueryExpression combine(NaryLogicalOperator op, List<QueryExpression> list); }
Searches { public static Map<ChildSlot, QueryExpression> writeChildQueriesFromParentDoc(AssociationQuery aq, ResultDocument parentDocument) { Map<ChildSlot, BindQuery> binders = parentDocument.getBindersForChild(aq); LOGGER.debug("writeChildQueriesForParentDoc: aq={} binders={}", aq, binders); Map<ChildSlot, QueryExpression> queries = new HashMap<>(); for (Map.Entry<ChildSlot, BindQuery> entry : binders.entrySet()) { if (aq.getQuery() != null) { queries.put(entry.getKey(), entry.getValue().iterate(aq.getQuery())); } else { queries.put(entry.getKey(), null); } } LOGGER.debug("Queries:{}", queries); return queries; } private  Searches(); static Map<ChildSlot, QueryExpression> writeChildQueriesFromParentDoc(AssociationQuery aq,
                                                                                 ResultDocument parentDocument); static List<QueryExpression> writeQueriesForJoinTuple(JoinTuple tuple, ExecutionBlock childBlock); static QueryExpression and(QueryExpression... q); static QueryExpression and(List<QueryExpression> list); static QueryExpression combine(NaryLogicalOperator op, List<QueryExpression> list);  }