Class SliceAccessorImpl<A>
java.lang.Object
org.apache.jena.sparql.service.enhancer.impl.util.AutoCloseableBase
org.apache.jena.sparql.service.enhancer.impl.util.AutoCloseableWithLeakDetectionBase
org.apache.jena.sparql.service.enhancer.slice.impl.SliceAccessorImpl<A>
- Type Parameters:
A
- The array type for transferring data in blocks
- All Implemented Interfaces:
AutoCloseable
,SliceAccessor<A>
public class SliceAccessorImpl<A>
extends AutoCloseableWithLeakDetectionBase
implements SliceAccessor<A>
A sequence of claimed ranges within a certain range, whereas the range
can be modified resulting in an incremental change of the claims.
An individual page range should only be operated by a single thread though
multiple threads may each have their own page range.
- claimByOffsetRange() only triggers loading of the pages but does not wait for them to become ready
- lock() waits for all claimed pages to become ready and afterwards locks them
- unlock() must be called after lock(); unlocks all pages
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEvictionGuard
(com.google.common.collect.RangeSet<Long> ranges) Adds an eviction guard (if the slice supports it) and binds its life cycle to this accessor.int
blockingRead
(A tgt, int tgtOffset, long srcOffset, int length) Method is subject to removal - use sequentialReaderForSlice.read The range [srcOffset, srcOffset + length) must be within the claimed range!void
claimByOffsetRange
(long startOffset, long endOffset) Set or update the claimed range - this will immediately request references to any pages providing the data for that range.getCache()
com.google.common.collect.Range<Long>
getSlice()
void
lock()
Lock the range for writingvoid
Releases all currently held pages.void
void
unlock()
Unlock the rangeint
unsafeRead
(A tgt, int tgtOffset, long srcOffset, int length) Read a range of data - does not await any new datavoid
Put a sequence of items into the claimed range Attempts to put items outside of the claimed range raises anIndexOutOfBoundsException
The page range should be locked when calling this method.Methods inherited from class org.apache.jena.sparql.service.enhancer.impl.util.AutoCloseableWithLeakDetectionBase
getInstantiationStackTrace
Methods inherited from class org.apache.jena.sparql.service.enhancer.impl.util.AutoCloseableBase
close
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.jena.sparql.service.enhancer.slice.api.SliceAccessor
addEvictionGuard, close
-
Constructor Details
-
SliceAccessorImpl
-
-
Method Details
-
getSlice
- Specified by:
getSlice
in interfaceSliceAccessor<A>
-
getOffsetRange
-
getCache
-
getClaimedPages
-
claimByOffsetRange
public void claimByOffsetRange(long startOffset, long endOffset) Description copied from interface:SliceAccessor
Set or update the claimed range - this will immediately request references to any pages providing the data for that range. Pages outside of that range are considered as no longer needed pages will immediately be released. This method prepares the pages which can be subsequently locked. Calling this method while the page range is locked (SliceAccessor.lock()
) raises anIllegalStateException
.- Specified by:
claimByOffsetRange
in interfaceSliceAccessor<A>
-
lock
public void lock()Description copied from interface:SliceAccessor
Lock the range for writing- Specified by:
lock
in interfaceSliceAccessor<A>
-
unlock
public void unlock()Description copied from interface:SliceAccessor
Unlock the range- Specified by:
unlock
in interfaceSliceAccessor<A>
-
releaseEvictionGuards
public void releaseEvictionGuards() -
releaseAll
public void releaseAll()Description copied from interface:SliceAccessor
Releases all currently held pages. Future requests viaSliceAccessor.claimByOffsetRange(long, long)
are allowed.- Specified by:
releaseAll
in interfaceSliceAccessor<A>
-
write
Description copied from interface:SliceAccessor
Put a sequence of items into the claimed range Attempts to put items outside of the claimed range raises anIndexOutOfBoundsException
The page range should be locked when calling this method.- Specified by:
write
in interfaceSliceAccessor<A>
-
unsafeRead
Read a range of data - does not await any new data- Specified by:
unsafeRead
in interfaceSliceAccessor<A>
- Throws:
IOException
-
blockingRead
Method is subject to removal - use sequentialReaderForSlice.read The range [srcOffset, srcOffset + length) must be within the claimed range!- Throws:
IOException
-
addEvictionGuard
Description copied from interface:SliceAccessor
Adds an eviction guard (if the slice supports it) and binds its life cycle to this accessor. Closing an accessor thus also removes all eviction guards created by it. This method must be called after acquiring a read lock on the slice's metadata.- Specified by:
addEvictionGuard
in interfaceSliceAccessor<A>
- Parameters:
ranges
- The set of ranges which to protected from eviction
-