lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Van Den Berghe, Vincent" <Vincent.VanDenBer...@bvdinfo.com>
Subject Performance improvement for Lucene.net with memory mapped files (bis)
Date Tue, 28 Feb 2017 07:21:16 GMT
Further testing has indicated that mapped memory accessors will throw an exception if the position
argument is already at the end, even if zero bytes are read.
The methods mentioned previously therefore become:

              public override ByteBuffer Get(byte[] dst, int offset, int length)
              {
                     CheckBounds(offset, length, dst.Length);
                     if (length > Remaining)
                           throw new BufferUnderflowException();
                     // we need to check for 0-length reads, since ReadArray will throw an
ArgumentOutOfRange exception if position is at the end
                     // even when nothing is read
                     if (length > 0)
                           _accessor.ReadArray(Ix(NextGetIndex(length)), dst, offset, length);
                     return this;
              }


And

              public override ByteBuffer Put(byte[] src, int offset, int length)
              {
                     CheckBounds(offset, length, src.Length);
                     if (length > Remaining)
                           throw new BufferOverflowException();
                     // we need to check for 0-length writes, since ReadArray will throw an
ArgumentOutOfRange exception if position is at the end
                     // even when nothing is read
                     if (length > 0)
                           _accessor.WriteArray(Ix(NextPutIndex(length)), src, offset, length);
                     return this;
              }


Vincent

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message