Lines 533-540
public abstract class IndexWriter
Link Here
|
533 |
{ |
533 |
{ |
534 |
static class IndexedThreadLocalCache<T> |
534 |
static class IndexedThreadLocalCache<T> |
535 |
{ |
535 |
{ |
|
|
536 |
// because it is ThreadLocal, it is always only this thread, no sync required |
536 |
final ThreadLocal<Integer> pageNumber = ThreadLocal.withInitial(() -> -1); |
537 |
final ThreadLocal<Integer> pageNumber = ThreadLocal.withInitial(() -> -1); |
537 |
final ThreadLocal<SoftReference<T>> page = ThreadLocal.withInitial(() -> null); |
538 |
final ThreadLocal<SoftReference<T>> page = ThreadLocal.withInitial(() -> new SoftReference(null)); |
538 |
|
539 |
|
539 |
void set(int pageNumber, T page) |
540 |
void set(int pageNumber, T page) |
540 |
{ |
541 |
{ |
Lines 619-626
public abstract class IndexWriter
Link Here
|
619 |
|
620 |
|
620 |
public void set(int index, int value) |
621 |
public void set(int index, int value) |
621 |
{ |
622 |
{ |
622 |
ArrayIntCompressed array = getPage(index / pageSize); |
|
|
623 |
// TODO unlock this by having ArrayIntCompressed use atomics |
623 |
// TODO unlock this by having ArrayIntCompressed use atomics |
|
|
624 |
ArrayIntCompressed array = getPage(index / pageSize); |
624 |
// uses bit operations internally, so we should sync against the page |
625 |
// uses bit operations internally, so we should sync against the page |
625 |
synchronized(array) |
626 |
synchronized(array) |
626 |
{ |
627 |
{ |