Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4, 7.0
    • Component/s: None
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      ResponseWriters are designed to be agnostic of components and they should work with the well know set of types we already support

      1. SOLR_9720_fix_JSONWriterTest.patch
        1 kB
        Shalin Shekhar Mangar
      2. SOLR-9720.patch
        21 kB
        Noble Paul
      3. SOLR-9720.patch
        20 kB
        Noble Paul
      4. SOLR-9720.patch
        17 kB
        Noble Paul

        Activity

        Hide
        noble.paul Noble Paul added a comment -

        not final but gives an idea

        Show
        noble.paul Noble Paul added a comment - not final but gives an idea
        Hide
        joel.bernstein Joel Bernstein added a comment -

        This is quite nice:

        +  public Map toMap(Map<String, Object> map) {
        +    try {
        +      if (!isOpen) {
        +        open();
        +        isOpen = true;
        +      }
        +    } catch (IOException e) {
        +      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
        +    }
        +    return Collections.singletonMap("docs", new Iterator<Tuple>() {
        +      Tuple tuple;
        +      boolean isEOF = false;
        +
        +      @Override
        +      public boolean hasNext() {
        +        if (isEOF) return false;
        +        if (tuple != null) return true;
        +        try {
        +          tuple = read();
        +          if(tuple != null && tuple.EOF) close();
        +          return tuple != null;
        +        } catch (IOException e) {
        +          throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
        +        }
        +      }
        +
        +      @Override
        +      public Tuple next() {
        +        Tuple tmp = tuple;
        +        tuple = null;
        +        isEOF = tmp == null || tmp.EOF;
        +        return tmp;
        +      }
        +    });
           }
        
        Show
        joel.bernstein Joel Bernstein added a comment - This is quite nice: + public Map toMap(Map< String , Object > map) { + try { + if (!isOpen) { + open(); + isOpen = true ; + } + } catch (IOException e) { + throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e); + } + return Collections.singletonMap( "docs" , new Iterator<Tuple>() { + Tuple tuple; + boolean isEOF = false ; + + @Override + public boolean hasNext() { + if (isEOF) return false ; + if (tuple != null ) return true ; + try { + tuple = read(); + if (tuple != null && tuple.EOF) close(); + return tuple != null ; + } catch (IOException e) { + throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e); + } + } + + @Override + public Tuple next() { + Tuple tmp = tuple; + tuple = null ; + isEOF = tmp == null || tmp.EOF; + return tmp; + } + }); }
        Hide
        noble.paul Noble Paul added a comment -

        remove special handling for Explanation as well

        Show
        noble.paul Noble Paul added a comment - remove special handling for Explanation as well
        Hide
        noble.paul Noble Paul added a comment -

        I hope this is not controversial in any way. If all tests pass I plan to commit this

        Show
        noble.paul Noble Paul added a comment - I hope this is not controversial in any way. If all tests pass I plan to commit this
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 53f84f6b9ae7f7a25ad9675b6c9e20353a5b4b19 in lucene-solr's branch refs/heads/branch_6x from Noble Paul
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=53f84f6 ]

        SOLR-9720: Refactor Responsewriters to remove dependencies on TupleStream, Tuple, Explanation

        Show
        jira-bot ASF subversion and git services added a comment - Commit 53f84f6b9ae7f7a25ad9675b6c9e20353a5b4b19 in lucene-solr's branch refs/heads/branch_6x from Noble Paul [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=53f84f6 ] SOLR-9720 : Refactor Responsewriters to remove dependencies on TupleStream, Tuple, Explanation
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1f595a20a2c2a5b06586f637da5f5487f796c2e4 in lucene-solr's branch refs/heads/master from Noble Paul
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=1f595a2 ]

        SOLR-9720: Refactor Responsewriters to remove dependencies on TupleStream, Tuple, Explanation

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1f595a20a2c2a5b06586f637da5f5487f796c2e4 in lucene-solr's branch refs/heads/master from Noble Paul [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=1f595a2 ] SOLR-9720 : Refactor Responsewriters to remove dependencies on TupleStream, Tuple, Explanation
        Hide
        joel.bernstein Joel Bernstein added a comment -

        In general this looks really good.

        The one thing I would look into is the effect of the changes to the Explanation class and whether there is test coverage on this. Dennis Gove any thoughts on this?

        Show
        joel.bernstein Joel Bernstein added a comment - In general this looks really good. The one thing I would look into is the effect of the changes to the Explanation class and whether there is test coverage on this. Dennis Gove any thoughts on this?
        Hide
        shalinmangar Shalin Shekhar Mangar added a comment -

        This change makes the JSONWriterTest.testArrnvpWriterOverridesAllWrites fail because it expects that the ArrayOfNamedValuePairJSONWriter class added in SOLR-9442 overrides all public/protected writeXXX methods from JSONWriter. However, this change introduced two new public/protected methods writeJsonIter(java.util.Iterator) and writeArray(java.lang.String,java.util.List) which aren't overriden by ArrayOfNamedValuePairJSONWriter.

        This patch fixes it by adding a writeArray(java.lang.String,java.util.List) in ArrayOfNamedValuePairJSONWriter which delegates to writeArray(String name, Iterator val) and making writeJsonIter private (which is used internally by both variants of writeArray in the super class. If we ever have a need for overriding writeJsonIter directly, we can make it protected then.

        Show
        shalinmangar Shalin Shekhar Mangar added a comment - This change makes the JSONWriterTest.testArrnvpWriterOverridesAllWrites fail because it expects that the ArrayOfNamedValuePairJSONWriter class added in SOLR-9442 overrides all public/protected writeXXX methods from JSONWriter. However, this change introduced two new public/protected methods writeJsonIter(java.util.Iterator) and writeArray(java.lang.String,java.util.List) which aren't overriden by ArrayOfNamedValuePairJSONWriter. This patch fixes it by adding a writeArray(java.lang.String,java.util.List) in ArrayOfNamedValuePairJSONWriter which delegates to writeArray(String name, Iterator val) and making writeJsonIter private (which is used internally by both variants of writeArray in the super class. If we ever have a need for overriding writeJsonIter directly, we can make it protected then.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 78b768f2a4d62e191a3a8e1e9d19d6c5058b20e5 in lucene-solr's branch refs/heads/master from Shalin Shekhar Mangar
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=78b768f ]

        SOLR-9720: Fix for JSONWriterTest

        Show
        jira-bot ASF subversion and git services added a comment - Commit 78b768f2a4d62e191a3a8e1e9d19d6c5058b20e5 in lucene-solr's branch refs/heads/master from Shalin Shekhar Mangar [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=78b768f ] SOLR-9720 : Fix for JSONWriterTest
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 9f9139ab429708916beab22c05312662dbd9eaa1 in lucene-solr's branch refs/heads/branch_6x from Shalin Shekhar Mangar
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=9f9139a ]

        SOLR-9720: Fix for JSONWriterTest

        (cherry picked from commit 78b768f)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 9f9139ab429708916beab22c05312662dbd9eaa1 in lucene-solr's branch refs/heads/branch_6x from Shalin Shekhar Mangar [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=9f9139a ] SOLR-9720 : Fix for JSONWriterTest (cherry picked from commit 78b768f)
        Hide
        dpgove Dennis Gove added a comment -

        The changes wrt Explanation appear fine. There isn't any test coverage of the toMap(...) function so that could be added on a future date.

        Show
        dpgove Dennis Gove added a comment - The changes wrt Explanation appear fine. There isn't any test coverage of the toMap(...) function so that could be added on a future date.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 358bdd490b1b15f3af6a355f93a98caf83594b18 in lucene-solr's branch refs/heads/master from Christine Poerschke
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=358bdd4 ]

        SOLR-9720: tweak JSONWriter.writeArray

        Show
        jira-bot ASF subversion and git services added a comment - Commit 358bdd490b1b15f3af6a355f93a98caf83594b18 in lucene-solr's branch refs/heads/master from Christine Poerschke [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=358bdd4 ] SOLR-9720 : tweak JSONWriter.writeArray
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 98e4ab52322e163de79a861796f80c2ad518784b in lucene-solr's branch refs/heads/branch_6x from Christine Poerschke
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=98e4ab5 ]

        SOLR-9720: tweak JSONWriter.writeArray

        Show
        jira-bot ASF subversion and git services added a comment - Commit 98e4ab52322e163de79a861796f80c2ad518784b in lucene-solr's branch refs/heads/branch_6x from Christine Poerschke [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=98e4ab5 ] SOLR-9720 : tweak JSONWriter.writeArray
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 358bdd490b1b15f3af6a355f93a98caf83594b18 in lucene-solr's branch refs/heads/apiv2 from Christine Poerschke
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=358bdd4 ]

        SOLR-9720: tweak JSONWriter.writeArray

        Show
        jira-bot ASF subversion and git services added a comment - Commit 358bdd490b1b15f3af6a355f93a98caf83594b18 in lucene-solr's branch refs/heads/apiv2 from Christine Poerschke [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=358bdd4 ] SOLR-9720 : tweak JSONWriter.writeArray
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 4d6be313323cf4389c50b87cd6da5db8d7314627 in lucene-solr's branch refs/heads/master from Noble Paul
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=4d6be31 ]

        SOLR-9720: Use the new MapWriter and IteratorWriter interface

        Show
        jira-bot ASF subversion and git services added a comment - Commit 4d6be313323cf4389c50b87cd6da5db8d7314627 in lucene-solr's branch refs/heads/master from Noble Paul [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=4d6be31 ] SOLR-9720 : Use the new MapWriter and IteratorWriter interface
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1be4bd353eb2916f94d541fb2076e77014c8551e in lucene-solr's branch refs/heads/branch_6x from Noble Paul
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=1be4bd3 ]

        SOLR-9720: Use the new MapWriter and IteratorWriter interface

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1be4bd353eb2916f94d541fb2076e77014c8551e in lucene-solr's branch refs/heads/branch_6x from Noble Paul [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=1be4bd3 ] SOLR-9720 : Use the new MapWriter and IteratorWriter interface

          People

          • Assignee:
            noble.paul Noble Paul
            Reporter:
            noble.paul Noble Paul
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development