lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elbek kamoliddinov <elbek....@gmail.com>
Subject ByteBlockPool class.
Date Mon, 03 Aug 2015 15:35:46 GMT
Hi Lucene hackers.
I was looking into lucene internals and came across ByteBlockPool class. In
that class I see following static final array:
 public final static int[] LEVEL_SIZE_ARRAY = {5, 14, 20, 30, 40, 40, 80,
80, 120, 200};

why and how these numbers are selected?

In addition In the #allocSlice() method I see the following snippet:

final int level = slice[upto] & 15;
final int newLevel = NEXT_LEVEL_ARRAY[level];
final int newSize = LEVEL_SIZE_ARRAY[newLevel];

but NEXT_LEVEL_ARRAY size is upto 10. How can we guarantee that level
variable value (slice[upto] & 15) will not exceed the array size and won't
throw array out of index exception? Value of this (slice[upto] & 15) can go
upto 15.

Thanks.

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