Lucene - Core
  1. Lucene - Core
  2. LUCENE-435

[PATCH] BufferedIndexOutput - optimized writeBytes() method

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/store
    • Labels:
      None

      Description

      I have created a patch that optimize writeBytes metod:

      public void writeBytes(byte[] b, int length) throws IOException {
      if (bufferPosition > 0) // flush buffer
      flush();

      if (length < BUFFER_SIZE)

      { flushBuffer(b, length); bufferStart += length; }

      else {
      int pos = 0;
      int size;
      while (pos < length) {
      if (length - pos < BUFFER_SIZE)

      { size = length - pos; }

      else

      { size = BUFFER_SIZE; }

      System.arraycopy(b, pos, buffer, 0, size);
      pos += size;
      flushBuffer(buffer, size);
      bufferStart += size;
      }
      }
      }

      Its a much more faster now. I know that for indexing this not help much, but for copying files in the IndexStore this is so big improvement. Its about 400% faster that old implementation.

      The patch was tested with 300MB data, "ant test" sucessfuly finished with no errors.

      1. BufferedIndexOutputWriteBytes.patch
        1 kB
        Lukas Zapletal
      2. fastWrite.patch
        6 kB
        Lukas Zapletal
      3. writeBytes.patch
        4 kB
        Lukas Zapletal

        Activity

        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12562183 ] jira [ 12583195 ]
        Mark Thomas made changes -
        Workflow jira [ 12330311 ] Default workflow, editable Closed status [ 12562183 ]
        Doug Cutting made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Doug Cutting made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Lukas Zapletal made changes -
        Attachment fastWrite.patch [ 12321272 ]
        Lukas Zapletal made changes -
        Attachment writeBytes.patch [ 12314792 ]
        Lukas Zapletal made changes -
        Field Original Value New Value
        Attachment BufferedIndexOutputWriteBytes.patch [ 12314466 ]
        Lukas Zapletal created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Lukas Zapletal
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development