lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmiley <...@git.apache.org>
Subject [GitHub] lucene-solr pull request #370: SOLR-12312: Change buf to not always use up 1...
Date Fri, 04 May 2018 19:44:11 GMT
Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/370#discussion_r186196579
  
    --- Diff: solr/core/src/java/org/apache/solr/handler/IndexFetcher.java ---
    @@ -1549,6 +1549,8 @@ public ReplicationHandlerException(String message) {
           this.file = file;
           this.fileName = (String) fileDetails.get(NAME);
           this.size = (Long) fileDetails.get(SIZE);
    +      //Max buf of 1 MB, but we should save memory if the file size is smaller
    +      buf = this.size < 1048576 ? new byte[(int) this.size] : new byte[1024 * 1024];
    --- End diff --
    
    I observe 1048576 is 1024*1024.
    Lets define a constant DEFAULT_BUF_SIZE = 1024 * 1024  (or perhaps call MAX_BUF_SIZE?)
and then use this constant twice here.  And you can simply use `Math.min(this.size(), DEFAULT_BUF_SIZE)`.
 No need for any comment; it's plain enough (IMO).


---

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


Mime
View raw message