Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9546

There is a lot of unnecessary boxing/unboxing going on in {{SolrParams}} class

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.3, 7.0
    • Component/s: None
    • Labels:
      None

      Description

      Here is an excerpt

        public Long getLong(String param, Long def) {
          String val = get(param);
          try {
            return val== null ? def : Long.parseLong(val);
          }
          catch( Exception ex ) {
            throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
          }
        }
      

      Long.parseLong() returns a primitive type but since method expect to return a Long, it needs to be wrapped. There are many more method like that. We might be creating a lot of unnecessary objects here.

      I am not sure if JVM catches upto it and somehow optimizes it if these methods are called enough times (or may be compiler does some modifications at compile time)

      Let me know if I am thinking of some premature optimization

        Attachments

          Activity

            People

            • Assignee:
              noble.paul Noble Paul
              Reporter:
              praste Pushkar Raste

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m

                  Issue deployment