java.lang.Object
org.apache.lucene.store.ByteBufferGuard
A guard that is created for every
ByteBufferIndexInput that tries on best effort to
reject any access to the ByteBuffer behind, once it is unmapped. A single instance of
this is used for the original and all clones, so once the original is closed and unmapped all
clones also throw AlreadyClosedException, triggered by a NullPointerException.
This code tries to hopefully flush any CPU caches using a store-store barrier. It also yields the current thread to give other threads a chance to finish in-flight requests...
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfacePass in an implementation of this interface to cleanup ByteBuffers. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBufferGuard.BufferCleanerprivate booleanNot volatile; see comments on visibility below!private final String -
Constructor Summary
ConstructorsConstructorDescriptionByteBufferGuard(String resourceDescription, ByteBufferGuard.BufferCleaner cleaner) Creates an instance to be used for a singleByteBufferIndexInputwhich must be shared by all of its clones. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidbytegetByte(ByteBuffer receiver) bytegetByte(ByteBuffer receiver, int pos) voidgetBytes(ByteBuffer receiver, byte[] dst, int offset, int length) voidgetFloats(FloatBuffer receiver, float[] dst, int offset, int length) intgetInt(ByteBuffer receiver) intgetInt(ByteBuffer receiver, int pos) voidlonggetLong(ByteBuffer receiver) longgetLong(ByteBuffer receiver, int pos) voidgetLongs(LongBuffer receiver, long[] dst, int offset, int length) shortgetShort(ByteBuffer receiver) shortgetShort(ByteBuffer receiver, int pos) voidinvalidateAndUnmap(ByteBuffer... bufs) Invalidates this guard and unmaps (if supported).boolean
-
Field Details
-
resourceDescription
-
cleaner
-
invalidated
private boolean invalidatedNot volatile; see comments on visibility below!
-
-
Constructor Details
-
ByteBufferGuard
Creates an instance to be used for a singleByteBufferIndexInputwhich must be shared by all of its clones.
-
-
Method Details
-
invalidateAndUnmap
Invalidates this guard and unmaps (if supported).- Throws:
IOException
-
isInvalidated
public boolean isInvalidated() -
ensureValid
private void ensureValid() -
getBytes
-
getByte
-
getShort
-
getInt
-
getLong
-
getByte
-
getShort
-
getInt
-
getLong
-
getLongs
-
getInts
-
getFloats
-