You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by dsmiley <gi...@git.apache.org> on 2018/05/24 03:45:43 UTC

[GitHub] lucene-solr pull request #382: WIP: SOLR-12361

Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/382#discussion_r190457184
  
    --- Diff: solr/solrj/src/java/org/apache/solr/common/SolrDocument.java ---
    @@ -388,20 +386,47 @@ public void addChildDocuments(Collection<SolrDocument> children) {
          }
        }
     
    +   @Override
    +   public Map<String, Object> getChildDocumentsMap() {
    +     Map<String, Object> childDocs = new HashMap<>();
    +     for (Entry<String, Object> entry: _fields.entrySet()) {
    +       Object value = entry.getValue();
    +       if(objIsDocument(value)) {
    +         childDocs.put(entry.getKey(), value);
    +       }
    +     }
    +     return childDocs;
    +   }
    +
        /** Returns the list of child documents, or null if none. */
        @Override
        public List<SolrDocument> getChildDocuments() {
    -     return _childDocuments;
    +     List<SolrDocument> childDocs = new ArrayList<>();
    +     Stream<AbstractMap.SimpleEntry<String, SolrDocument>> fields = _fields.entrySet().stream()
    +         .filter(value -> value.getValue() instanceof SolrInputDocument)
    +         .map(value -> new AbstractMap.SimpleEntry<>(value.getKey(), (SolrDocument) value.getValue()));
    +     fields.forEach(e -> childDocs.add(e.getValue()));
    +     return childDocs.size() > 0 ? childDocs: null;
        }
        
        @Override
        public boolean hasChildDocuments() {
    --- End diff --
    
    We'd probably deprecate these if we go with this overall approach.  It's too much internal cost to call this method.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org