Package org.aksw.commons.io.slice
Class SliceWithPagesSyncToDisk<A>
java.lang.Object
org.aksw.commons.io.slice.SliceBase<A>
org.aksw.commons.io.slice.SliceWithPagesSyncToDisk<A>
- Type Parameters:
A- The collection type of what to store in the pages. Usually an an array such as Binding[] or byte[].
- All Implemented Interfaces:
Slice<A>,SliceMetaDataBasic,SliceWithPages<A>,org.aksw.commons.io.util.Sync,PageHelper
A file-based slice implementation.
The is one metadata file and one 'content' file for each page.
The metadata file holds the information about which ranges of data have been loaded in the content files.
Whenever a set of pages is updated, the metadata needs to be updated as well.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SliceMetaDataWithPagesprotected org.aksw.commons.txn.impl.PathDiffStateprotected RangeSetDelegateMutable<Long>protected RangeBufferDelegateMutable<A>protected intAttribute for advertising detection of external changes to the base data.protected SliceMetaDataWithPagesprotected com.google.common.collect.RangeSet<Long>Cached view of the most recent loaded ranges Changing the value of 'this.liveMetaData' also changes this view's delegateprotected org.slf4j.Loggerprotected org.aksw.commons.txn.impl.PathStateprotected ObjectStoreprotected AsyncClaimingCache<Long,BufferView<A>> protected LongFunction<String>protected intprotected RangeBufferDelegateMutable<A>protected SliceMetaDataWithPagesprotected ScheduleOnceFields inherited from class org.aksw.commons.io.slice.SliceBase
arrayOps, hasDataCondition, readWriteLock -
Constructor Summary
ConstructorsConstructorDescriptionSliceWithPagesSyncToDisk(ArrayOps<A> arrayOps, ObjectStore objectStore, Path<String> objectStoreBasePath, int pageSize, Duration syncDelay) -
Method Summary
Modifier and TypeMethodDescriptionaddEvictionGuard(com.google.common.collect.RangeSet<Long> range) Protect a set of ranges from eviction.static SliceMetaDataWithPagescopyWithNewRanges(SliceMetaDataWithPages base, com.google.common.collect.RangeSet<Long> rangeSet) Create an immutable snapshot of the current state of the slice suitable for syncing to disk.static <A> SliceWithPagesSyncToDisk<A>create(ArrayOps<A> arrayOps, Path repoPath, Path<String> objectStoreBasePath, int pageSize, Duration syncDelay) static <A> SliceWithPagesSyncToDisk<A>create(ArrayOps<A> arrayOps, ObjectStore objectStore, Path<String> objectStoreBasePath, int pageSize, Duration syncDelay) com.google.common.collect.RangeSet<Long>com.google.common.collect.RangeSet<Long>longprotected SliceMetaDataBasiclonggetPageForPageId(long pageId) longbooleanvoidloadMetaData(int pageSize) loadPage(long pageId) Loading a page requires locking the metadata file - by loading pages in batch we can reduce redundant locking and reduce the risk of in-between external changesintlockAndSyncMetaData(ObjectStoreConnection conn, int fallbackPageSize) Returns the metadata generationprotected RangeBuffer<A>voidsetMaximumKnownSize(long maximumKnownSize) voidsetMinimumKnownSize(long minimumKnownSize) voidsync()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aksw.commons.util.range.PageHelper
getIndexInPageForOffset, getPageIdForOffset, getPageOffsetForPageIdMethods inherited from interface org.aksw.commons.io.slice.Slice
computeFromMetaData, isComplete, mutateMetaData, readMetaDataMethods inherited from interface org.aksw.commons.io.slice.SliceMetaDataBasic
getKnownSize, setKnownSize, updateMaximumKnownSize, updateMinimumKnownSizeMethods inherited from interface org.aksw.commons.io.slice.SliceWithPages
newSliceAccessor
-
Field Details
-
logger
protected org.slf4j.Logger logger -
objectStore
-
objectStoreBasePath
-
pageCache
-
pageSize
protected int pageSize -
baseRanges
-
baseMetaData
-
baseMetaDataStatus
protected org.aksw.commons.txn.impl.PathDiffState baseMetaDataStatus -
liveMetaData
-
liveMetaDataLoadedRangesView
Cached view of the most recent loaded ranges Changing the value of 'this.liveMetaData' also changes this view's delegate -
syncMetaData
-
metaDataIdentity
protected org.aksw.commons.txn.impl.PathState metaDataIdentity -
syncScheduler
-
liveGeneration
protected int liveGenerationAttribute for advertising detection of external changes to the base data. Modification demands the global write lock. Whenever a change to the base data is detected (during sync) then the generation is incremented. All clients should then re-schedule their read/writes. -
liveChanges
-
syncChanges
-
pageIdToFileName
-
-
Constructor Details
-
SliceWithPagesSyncToDisk
-
-
Method Details
-
getReadWriteLock
- Specified by:
getReadWriteLockin interfaceSlice<A>- Overrides:
getReadWriteLockin classSliceBase<A>
-
setMinimumKnownSize
public void setMinimumKnownSize(long minimumKnownSize) - Specified by:
setMinimumKnownSizein interfaceSliceMetaDataBasic- Overrides:
setMinimumKnownSizein classSliceBase<A>
-
setMaximumKnownSize
public void setMaximumKnownSize(long maximumKnownSize) - Specified by:
setMaximumKnownSizein interfaceSliceMetaDataBasic- Overrides:
setMaximumKnownSizein classSliceBase<A>
-
getMetaData
- Specified by:
getMetaDatain classSliceBase<A>
-
loadMetaData
public void loadMetaData(int pageSize) -
create
public static <A> SliceWithPagesSyncToDisk<A> create(ArrayOps<A> arrayOps, ObjectStore objectStore, Path<String> objectStoreBasePath, int pageSize, Duration syncDelay) -
create
-
newChangeBuffer
-
getPageForPageId
- Specified by:
getPageForPageIdin interfaceSliceWithPages<A>
-
getGaps
public com.google.common.collect.RangeSet<Long> getGaps(com.google.common.collect.Range<Long> requestRange) - Specified by:
getGapsin interfaceSliceMetaDataBasic
-
hasMetaDataChanged
public boolean hasMetaDataChanged() -
lockAndSyncMetaData
Returns the metadata generation -
loadPage
-
loadPages
Loading a page requires locking the metadata file - by loading pages in batch we can reduce redundant locking and reduce the risk of in-between external changes -
getArrayOps
- Specified by:
getArrayOpsin interfaceSlice<A>- Overrides:
getArrayOpsin classSliceBase<A>
-
copyWithNewRanges
public static SliceMetaDataWithPages copyWithNewRanges(SliceMetaDataWithPages base, com.google.common.collect.RangeSet<Long> rangeSet) Create an immutable snapshot of the current state of the slice suitable for syncing to disk. This method only requires brief locking in order to set up a new layer of change tracking on top of the existing one.- Throws:
IOException
-
sync
- Specified by:
syncin interfaceorg.aksw.commons.io.util.Sync- Throws:
IOException
-
getLoadedRanges
- Specified by:
getLoadedRangesin interfaceSliceMetaDataBasic- Overrides:
getLoadedRangesin classSliceBase<A>
-
getMinimumKnownSize
public long getMinimumKnownSize()- Specified by:
getMinimumKnownSizein interfaceSliceMetaDataBasic- Overrides:
getMinimumKnownSizein classSliceBase<A>
-
getMaximumKnownSize
public long getMaximumKnownSize()- Specified by:
getMaximumKnownSizein interfaceSliceMetaDataBasic- Overrides:
getMaximumKnownSizein classSliceBase<A>
-
getHasDataCondition
- Specified by:
getHasDataConditionin interfaceSlice<A>- Overrides:
getHasDataConditionin classSliceBase<A>
-
getPageSize
public long getPageSize()- Specified by:
getPageSizein interfacePageHelper- Specified by:
getPageSizein interfaceSliceWithPages<A>
-
getFailedRanges
- Specified by:
getFailedRangesin interfaceSliceMetaDataBasic- Overrides:
getFailedRangesin classSliceBase<A>
-
addEvictionGuard
Description copied from interface:SliceProtect a set of ranges from eviction. If the slice does make use of eviction then this method can return null. Otherwise, a disposable must be returned. As long as it is not disposed no data in the range may get lost due to eviction. This method should not be used directly but via {@link SliceAccessor#addEvictionGuard(RangeSet))}.- Specified by:
addEvictionGuardin interfaceSlice<A>
-