@Test public void retrieveABC() throws Exception { Projection p = projection("[{'field':'*','recursive':1},{'field':'b'},{'field':'obj1.c'}]"); QueryExpression q = query("{'field':'_id','op':'=','rvalue':'A01'}"); GMD gmd = new GMD(p, null); CompositeMetadata md = CompositeMetadata.buildCompositeMetadata(getMd("composite/A.json"), gmd); Set<CompositeMetadata> minimalTree = new HashSet<>(); minimalTree.add(md); minimalTree.add(md.getChildMetadata(new Path("b"))); minimalTree.add(md.getChildMetadata(new Path("obj1.c"))); QueryPlan searchQP = new QueryPlanChooser(md, new BruteForceQueryPlanIterator(), new IndexedFieldScorer(), q, minimalTree).choose(); QueryPlan retrievalQP = new QueryPlanChooser(md, new First(), new SimpleScorer(), null, minimalTree).choose(); ExecutionPlan ep = new ExecutionPlan(q,p, null, null, null, md, searchQP, retrievalQP, ctx); ObjectNode j = (ObjectNode) ep.toJson(); System.out.println("retrieveABC"); System.out.println(JsonUtils.prettyPrint(j)); System.out.println("minimal tree:" + minimalTree); JsonNode source = j.get("source"); JsonNode filter1=source.get("filter"); JsonNode source2=source.get("source"); JsonNode assemble1 = source2.get("assemble"); Assert.assertEquals("A", assemble1.get("entity").asText()); JsonNode left1 = assemble1.get("left"); Assert.assertNotNull(left1.get("copy")); JsonNode right1 = assemble1.get("right"); Assert.assertEquals(2, right1.size()); JsonNode assemble2 = right1.get(0).get("source").get("assemble"); JsonNode assemble3 = right1.get(1).get("source").get("assemble"); Assert.assertTrue(assemble2.get("entity").asText().equals("C") || assemble3.get("entity").asText().equals("C")); Assert.assertTrue(assemble2.get("entity").asText().equals("B") || assemble3.get("entity").asText().equals("B")); }
public JsonNode toJson() { return resultStep.toJson(); }
ExecutionPlan { public JsonNode toJson() { return resultStep.toJson(); } }
ExecutionPlan { public JsonNode toJson() { return resultStep.toJson(); } ExecutionPlan(QueryExpression requestQuery,
                         Projection requestProjection,
                         Sort requestSort,
                         Long from,
                         Long to,
                         CompositeMetadata rootMd,
                         QueryPlan searchQueryPlan,
                         QueryPlan retrievalQueryPlan,
                         CRUDOperationContext ctx); }
ExecutionPlan { public JsonNode toJson() { return resultStep.toJson(); } ExecutionPlan(QueryExpression requestQuery,
                         Projection requestProjection,
                         Sort requestSort,
                         Long from,
                         Long to,
                         CompositeMetadata rootMd,
                         QueryPlan searchQueryPlan,
                         QueryPlan retrievalQueryPlan,
                         CRUDOperationContext ctx); StepResult<ResultDocument> getResults(ExecutionContext ctx); static Projection writeProjection(Collection<Path> fields); static Set<Path> getIncludedFieldsOfEntityForSearch(ExecutionBlock block,
                                                               List<QueryFieldInfo> fieldInfo); static Set<Path> getIncludedFieldsOfEntityForProjection(ExecutionBlock block,
                                                                   CompositeMetadata root,
                                                                   Projection requestProjection); static Set<Path> getIncludedFieldsOfRootEntityForSort(CompositeMetadata root,
                                                                 Sort rootSort); static Set<Path> getIncludedFieldsOfEntityForSort(ExecutionBlock block); JsonNode toJson(); @Override String toString(); JsonNode explain(ExecutionContext ctx); }
ExecutionPlan { public JsonNode toJson() { return resultStep.toJson(); } ExecutionPlan(QueryExpression requestQuery,
                         Projection requestProjection,
                         Sort requestSort,
                         Long from,
                         Long to,
                         CompositeMetadata rootMd,
                         QueryPlan searchQueryPlan,
                         QueryPlan retrievalQueryPlan,
                         CRUDOperationContext ctx); StepResult<ResultDocument> getResults(ExecutionContext ctx); static Projection writeProjection(Collection<Path> fields); static Set<Path> getIncludedFieldsOfEntityForSearch(ExecutionBlock block,
                                                               List<QueryFieldInfo> fieldInfo); static Set<Path> getIncludedFieldsOfEntityForProjection(ExecutionBlock block,
                                                                   CompositeMetadata root,
                                                                   Projection requestProjection); static Set<Path> getIncludedFieldsOfRootEntityForSort(CompositeMetadata root,
                                                                 Sort rootSort); static Set<Path> getIncludedFieldsOfEntityForSort(ExecutionBlock block); JsonNode toJson(); @Override String toString(); JsonNode explain(ExecutionContext ctx);  }