@Test public void writeChildQueriesTest_parentArray() throws Exception { CompositeMetadata umd = getCmd("U", projection("[{'field':'legalEntities.*.legalEntity'}]")); CompositeMetadata lmd = umd.getChildMetadata(new Path("legalEntities.*.legalEntity")); QueryPlanChooser chooser = new QueryPlanChooser(umd, new First(), new SimpleScorer(), query("{'field':'_id','op':'=','rvalue':1}"), null); QueryPlan qp = chooser.choose(); ExecutionBlock ublock = new ExecutionBlock(umd, qp.getNode(umd)); ExecutionBlock lblock = new ExecutionBlock(umd, qp.getNode(lmd)); QueryPlanData data = qp.getEdgeData(qp.getNode(umd), qp.getNode(lmd)); AssociationQuery a1 = new AssociationQuery(umd, lmd, data.getReference(), data.getConjuncts()); lblock.setAssociationQuery(ublock, a1); lblock.addSourceBlock(ublock); ublock.linkBlocks(); lblock.linkBlocks(); Map<ChildSlot, QueryExpression> map = Searches. writeChildQueriesFromParentDoc(a1, resultDoc(ublock, "{'_id':1,'legalEntities':[{'legalEntityId':1,'title':'a'},{'legalEntityId':2,'title':'b'}]}")); System.out.println(map); Assert.assertEquals(2, map.size()); ChildSlot slot = findSlot(map, "legalEntities.0"); Assert.assertNotNull(slot); JSONAssert.assertEquals("{field:_id,op:$eq,rvalue:1}", map.get(slot).toString(), false); slot = findSlot(map, "legalEntities.1"); Assert.assertNotNull(slot); JSONAssert.assertEquals("{field:_id,op:$eq,rvalue:2}", map.get(slot).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);  }