Package org.apache.uima.cas.impl
Class CASImpl.SharedViewData
- java.lang.Object
-
- org.apache.uima.cas.impl.CASImpl.SharedViewData
-
- Enclosing class:
- CASImpl
static class CASImpl.SharedViewData extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private CASImplbaseCASprivate FsGenerator3[]baseGeneratorsWhen generating a new instance of a FS in a PEAR where there's an alternate JCas class impl, generate the base version, and make the alternate a trampoline to it.private BinaryCasSerDesbcsdCreated at startup time, lives as long as the CAS lives Serves to reference code for binary cas ser/des that used to live in this class, but was moved outprivate java.lang.StringcasIdprivate java.util.concurrent.atomic.AtomicIntegercasResetsprivate java.util.EnumSet<CasState>casStateC A S S T A T E management * Cas state is implemented in a way to allow the Java to efficiently * access the state test without synchronization or "voliatile" memory accessing, * while at the same time, allowing for an occasional cross-thread memory invalidation * when the state is changed.private java.util.Map<java.lang.ClassLoader,JCasHashMap>cl2id2trampprivate ComponentInfocomponentInfoprivate CommonSerDesSequentialcsdsCreated when doing binary or form4 non-delta (de)serialization, used in subsequent delta ser/deserialization Created when doing binary or form4 non-delta ser/deserialization, used in subsequent delta (de)serialization Reset with CasReset or deltaMergesComplete API callprivate java.lang.Threadcurrent_one_thread_access(package private) booleandisableAutoCorruptionChecktemporarily set to true by deserialization routines doing their own management of this checkprivate BooleanArrayemptyBooleanArrayprivate ByteArrayemptyByteArrayprivate DoubleArrayemptyDoubleArrayprivate FloatArrayemptyFloatArrayprivate EmptyFloatListemptyFloatListprivate java.util.Map<Type,FSArray>emptyFSArrayMapprivate EmptyFSListemptyFSListprivate IntegerArrayemptyIntegerArrayprivate EmptyIntegerListemptyIntegerListprivate LongArrayemptyLongArrayprivate ShortArrayemptyShortArrayprivate StringArrayemptyStringArrayprivate EmptyStringListemptyStringListprivate java.util.BitSetfeatureCodesInIndexKeysThese fields are here, not in TypeSystemImpl, because different CASes may have different indexes but share the same type system They hold the same data (constant per CAS) but are accessed with different indexesprivate booleanflushEnabledprivate intfsIdGeneratorThe fsId of the last created FS used to generate FSIDs, increments by 1 for each use.(package private) java.util.concurrent.atomic.AtomicIntegerfsIdLastValueused to "capture" the fsIdGenerator value for a read-only CAS to be visible in other threadsprivate java.util.ArrayList<FSsTobeAddedback>fssTobeAddedbackThis stack corresponds to nested protectIndexes contexts.private FSsTobeAddedback.FSsTobeAddedbackSinglefsTobeAddedbackSingleThis version is for single fs use, by binary deserializers and by automatic mode Only one user at a time is allowed.(package private) booleanfsTobeAddedbackSingleInUseSet to true while this is in use.private FsGenerator3[]generatorsThe current (active, switches at Pear boundaries) FsGenerators (excluding array-generators) key = type code read-only, unsynchronized for this CAS Cache for setting this kept in TypeSystemImpl, by classloader - shared among all CASs that use that Type System and class loader -- in turn, initialized from FSClassRegistry, once per classloader / typesystem combo Pear generators are mostly null except for instances where the PEAR has redefined the JCas cover classprivate IntVectorid2addrprivate JCasHashMapid2basea map from IDs of FSs that have a Pear version, to the base (non-Pear) version used to locate the base version for adding to indexesprivate Id2FSid2fsmap from FS ids to FSs.private JCasHashMapid2trampA map from IDs to already created trampoline FSs for the base FS with that id.private intinitialHeapSizeprivate booleaninitialSofaCreatedprivate java.lang.invoke.MethodHandleis_readableprivate java.lang.invoke.MutableCallSiteis_readable_callsiteprivate java.lang.invoke.MutableCallSite[]is_readable_callsitesprivate java.lang.invoke.MethodHandleis_updatableprivate java.lang.invoke.MutableCallSiteis_updatable_callsiteprivate java.lang.invoke.MutableCallSite[]is_updatable_callsitesprivate booleanisId2Fsif true, modify fs creation to save in id2fs map modify deserializers to create fss with ids the same as the serialized form ( or the V2 "address" imputed from that) modify serializers to include reachables only found via id2fs table not static because is updated (see ll_enableV2IdRefs)private java.lang.ClassLoaderjcasClassLoaderprivate intlastFsV2SizeThe version 2 size on the main heap of the last created FSprivate LongSetlllongSetA LongSet used only to support v2 ll_get/setInt api get adds long to this and returns the int handle set retrieves the long, given the handle lazy initializedprivate StringSetllstringSetA StringSet used only to support ll_get/setInt api get adds string to this and returns the int handle set retrieves the string, given the handle lazy initializedprivate static java.lang.invoke.MethodHandlemh_return_falseprivate static java.lang.invoke.MethodHandlemh_return_trueprivate java.util.Map<TOP,CASImpl.FsChange>modifiedPreexistingFSsTrack modified preexistingFSs Note this is a map, keyed by the FS, so all changes are merged when addedprivate intnextId2Addrprivate static java.lang.invoke.MethodTypenoArgBooleanprivate java.lang.ClassLoaderpreviousJCasClassLoaderOnly support one level of PEAR nesting; for more general approach, make this a dequeprivate intreuseIdset to > 0 to reuse an id, 0 otherwise(package private) java.util.ArrayList<FSIndexRepositoryImpl>sofa2indexMapprivate java.util.Set<java.lang.String>sofaNameSeta set of instantiated sofaNames(package private) java.util.ArrayList<CASImpl>sofaNbr2ViewMapA map from Sofa numbers to CAS views.private java.lang.ClassLoadersuspendPreviousJCasClassLoaderSave area for suspending this while we create a base instanceprivate java.util.Deque<CASImpl.SwitchControl>switchControla stack used to remember and restore previous state of cas lock and class loaders when switching classloaders and locking the cas https://issues.apache.org/jira/browse/UIMA-6057private java.lang.StringBuildertraceCowSbprivate java.lang.StringBuildertraceFScreationSbprivate inttraceFSidprivate booleantraceFSisCreateprivate MarkerImpltrackingMarkThis tracks the changes for delta cas May also in the future support Journaling by component, allowing determination of which component in a flow created/updated a FeatureStructure (not implmented) TrackingMarkers are held on to by things outside of the Cas, to support switching from one tracking marker to another (currently not used, but designed to support Component Journaling).private java.util.List<MarkerImpl>trackingMarkListThis list currently only contains at most 1 element.private TypeSystemImpltsi(package private) intviewCount
-
Constructor Summary
Constructors Modifier Constructor Description privateSharedViewData(CASImpl baseCAS, int initialHeapSize, TypeSystemImpl tsi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclear()Called from CasComplete deserialization (reinit).(package private) voidclearCasReset()private booleanclearCasState(CasState state)private voidclearNonSharedInstanceData()(package private) voidclearSofaInfo()called by resetNoQuestions and cas complete reinitprivate voidclearTrackingMarks()private voidflushIndexRepositoriesAllViews()(package private) CASImplgetInitialView()private intgetNextFsId(TOP fs)The logic for this is: - normal - add 1 to the value of the previous which is kept in fsIdGenerator Update fsIdGenerator to be this id.private CASImplgetViewFromSofaNbr(int nbr)(package private) intlastFsV2IdIncr()(package private) intpeekNextFsId()private voidresetNoQuestions(boolean flushIndexRepos)(package private) voidrestoreClassLoader(boolean empty_switchControl, CASImpl.SwitchControl switchControlInstance)private booleansetCasState(CasState state, java.lang.Thread thread)(package private) voidsetViewForSofaNbr(int nbr, CASImpl view)(package private) voidswitchClassLoader(java.lang.ClassLoader newClassLoader, boolean wasLocked)private voidupdateCallSite(boolean desired_state, java.lang.invoke.MethodHandle tester, java.lang.invoke.MutableCallSite c, java.lang.invoke.MethodHandle mh, java.lang.invoke.MutableCallSite[] cs)
-
-
-
Field Detail
-
id2fs
private final Id2FS id2fs
map from FS ids to FSs.
-
reuseId
private int reuseId
set to > 0 to reuse an id, 0 otherwise
-
baseCAS
private final CASImpl baseCAS
-
featureCodesInIndexKeys
private final java.util.BitSet featureCodesInIndexKeys
These fields are here, not in TypeSystemImpl, because different CASes may have different indexes but share the same type system They hold the same data (constant per CAS) but are accessed with different indexes
-
sofa2indexMap
java.util.ArrayList<FSIndexRepositoryImpl> sofa2indexMap
-
sofaNbr2ViewMap
java.util.ArrayList<CASImpl> sofaNbr2ViewMap
A map from Sofa numbers to CAS views. number 0 - not used number 1 - used for view named "_InitialView" number 2-n used for other views Note: this is not reset with "Cas Reset" because views (really, their associated index repos) take a lot of setup for the indexes. However, the maximum view count is reset; so creation of new views "reuses" these pre-setup indexRepos associated with these views.
-
sofaNameSet
private java.util.Set<java.lang.String> sofaNameSet
a set of instantiated sofaNames
-
initialSofaCreated
private boolean initialSofaCreated
-
viewCount
int viewCount
-
jcasClassLoader
private java.lang.ClassLoader jcasClassLoader
-
previousJCasClassLoader
private java.lang.ClassLoader previousJCasClassLoader
Only support one level of PEAR nesting; for more general approach, make this a deque
-
suspendPreviousJCasClassLoader
private java.lang.ClassLoader suspendPreviousJCasClassLoader
Save area for suspending this while we create a base instance
-
id2tramp
private JCasHashMap id2tramp
A map from IDs to already created trampoline FSs for the base FS with that id. These are used when in a Pear and retrieving a FS (via index or deref) and you want the Pear version for that ID. There are potentially multiple maps - one per PEAR Classpath
-
id2base
private JCasHashMap id2base
a map from IDs of FSs that have a Pear version, to the base (non-Pear) version used to locate the base version for adding to indexes
-
cl2id2tramp
private final java.util.Map<java.lang.ClassLoader,JCasHashMap> cl2id2tramp
-
generators
private FsGenerator3[] generators
The current (active, switches at Pear boundaries) FsGenerators (excluding array-generators) key = type code read-only, unsynchronized for this CAS Cache for setting this kept in TypeSystemImpl, by classloader - shared among all CASs that use that Type System and class loader -- in turn, initialized from FSClassRegistry, once per classloader / typesystem combo Pear generators are mostly null except for instances where the PEAR has redefined the JCas cover class
-
baseGenerators
private FsGenerator3[] baseGenerators
When generating a new instance of a FS in a PEAR where there's an alternate JCas class impl, generate the base version, and make the alternate a trampoline to it. Note: in future, if it is known that this FS is never used outside of this PEAR, then can skip generating the double version
-
flushEnabled
private boolean flushEnabled
-
tsi
private TypeSystemImpl tsi
-
componentInfo
private ComponentInfo componentInfo
-
trackingMark
private MarkerImpl trackingMark
This tracks the changes for delta cas May also in the future support Journaling by component, allowing determination of which component in a flow created/updated a FeatureStructure (not implmented) TrackingMarkers are held on to by things outside of the Cas, to support switching from one tracking marker to another (currently not used, but designed to support Component Journaling). We track changes on a granularity of features and for features which are arrays, which element of the array (This last to enable efficient delta serializations of giant arrays of things, where you've only updated a few items) The FsChange doesn't store the changed data, only stores the ref info needed to get to what was changed.
-
modifiedPreexistingFSs
private java.util.Map<TOP,CASImpl.FsChange> modifiedPreexistingFSs
Track modified preexistingFSs Note this is a map, keyed by the FS, so all changes are merged when added
-
trackingMarkList
private java.util.List<MarkerImpl> trackingMarkList
This list currently only contains at most 1 element. If Journaling is implemented, it may contain an element per component being journaled.
-
fssTobeAddedback
private final java.util.ArrayList<FSsTobeAddedback> fssTobeAddedback
This stack corresponds to nested protectIndexes contexts. Normally should be very shallow.
-
fsTobeAddedbackSingle
private final FSsTobeAddedback.FSsTobeAddedbackSingle fsTobeAddedbackSingle
This version is for single fs use, by binary deserializers and by automatic mode Only one user at a time is allowed.
-
fsTobeAddedbackSingleInUse
boolean fsTobeAddedbackSingleInUse
Set to true while this is in use.
-
disableAutoCorruptionCheck
boolean disableAutoCorruptionCheck
temporarily set to true by deserialization routines doing their own management of this check
-
fsIdGenerator
private int fsIdGenerator
The fsId of the last created FS used to generate FSIDs, increments by 1 for each use. First id == 1
-
lastFsV2Size
private int lastFsV2Size
The version 2 size on the main heap of the last created FS
-
fsIdLastValue
java.util.concurrent.atomic.AtomicInteger fsIdLastValue
used to "capture" the fsIdGenerator value for a read-only CAS to be visible in other threads
-
casResets
private final java.util.concurrent.atomic.AtomicInteger casResets
-
casId
private final java.lang.String casId
-
emptyFSList
private EmptyFSList emptyFSList
-
emptyFloatList
private EmptyFloatList emptyFloatList
-
emptyIntegerList
private EmptyIntegerList emptyIntegerList
-
emptyStringList
private EmptyStringList emptyStringList
-
emptyFloatArray
private FloatArray emptyFloatArray
-
emptyIntegerArray
private IntegerArray emptyIntegerArray
-
emptyStringArray
private StringArray emptyStringArray
-
emptyDoubleArray
private DoubleArray emptyDoubleArray
-
emptyLongArray
private LongArray emptyLongArray
-
emptyShortArray
private ShortArray emptyShortArray
-
emptyByteArray
private ByteArray emptyByteArray
-
emptyBooleanArray
private BooleanArray emptyBooleanArray
-
bcsd
private final BinaryCasSerDes bcsd
Created at startup time, lives as long as the CAS lives Serves to reference code for binary cas ser/des that used to live in this class, but was moved out
-
csds
private CommonSerDesSequential csds
Created when doing binary or form4 non-delta (de)serialization, used in subsequent delta ser/deserialization Created when doing binary or form4 non-delta ser/deserialization, used in subsequent delta (de)serialization Reset with CasReset or deltaMergesComplete API call
-
llstringSet
private StringSet llstringSet
A StringSet used only to support ll_get/setInt api get adds string to this and returns the int handle set retrieves the string, given the handle lazy initialized
-
lllongSet
private LongSet lllongSet
A LongSet used only to support v2 ll_get/setInt api get adds long to this and returns the int handle set retrieves the long, given the handle lazy initialized
-
traceFScreationSb
private final java.lang.StringBuilder traceFScreationSb
-
traceCowSb
private final java.lang.StringBuilder traceCowSb
-
traceFSid
private int traceFSid
-
traceFSisCreate
private boolean traceFSisCreate
-
id2addr
private final IntVector id2addr
-
nextId2Addr
private int nextId2Addr
-
initialHeapSize
private final int initialHeapSize
-
isId2Fs
private boolean isId2Fs
if true, modify fs creation to save in id2fs map modify deserializers to create fss with ids the same as the serialized form ( or the V2 "address" imputed from that) modify serializers to include reachables only found via id2fs table not static because is updated (see ll_enableV2IdRefs)
-
switchControl
private final java.util.Deque<CASImpl.SwitchControl> switchControl
a stack used to remember and restore previous state of cas lock and class loaders when switching classloaders and locking the cas https://issues.apache.org/jira/browse/UIMA-6057
-
casState
private final java.util.EnumSet<CasState> casState
C A S S T A T E management * Cas state is implemented in a way to allow the Java to efficiently * access the state test without synchronization or "voliatile" memory accessing, * while at the same time, allowing for an occasional cross-thread memory invalidation * when the state is changed. This is done using a MutableCallSite plus that * objects "syncAll" method. *
-
noArgBoolean
private static final java.lang.invoke.MethodType noArgBoolean
-
mh_return_false
private static final java.lang.invoke.MethodHandle mh_return_false
-
mh_return_true
private static final java.lang.invoke.MethodHandle mh_return_true
-
is_updatable_callsite
private final java.lang.invoke.MutableCallSite is_updatable_callsite
-
is_readable_callsite
private final java.lang.invoke.MutableCallSite is_readable_callsite
-
is_updatable
private final java.lang.invoke.MethodHandle is_updatable
-
is_readable
private final java.lang.invoke.MethodHandle is_readable
-
is_updatable_callsites
private final java.lang.invoke.MutableCallSite[] is_updatable_callsites
-
is_readable_callsites
private final java.lang.invoke.MutableCallSite[] is_readable_callsites
-
current_one_thread_access
private volatile java.lang.Thread current_one_thread_access
-
-
Constructor Detail
-
SharedViewData
private SharedViewData(CASImpl baseCAS, int initialHeapSize, TypeSystemImpl tsi)
-
-
Method Detail
-
updateCallSite
private void updateCallSite(boolean desired_state, java.lang.invoke.MethodHandle tester, java.lang.invoke.MutableCallSite c, java.lang.invoke.MethodHandle mh, java.lang.invoke.MutableCallSite[] cs)
-
setCasState
private boolean setCasState(CasState state, java.lang.Thread thread)
-
clearCasState
private boolean clearCasState(CasState state)
-
clearCasReset
void clearCasReset()
-
clearSofaInfo
void clearSofaInfo()
called by resetNoQuestions and cas complete reinit
-
clear
void clear()
Called from CasComplete deserialization (reinit). Skips the resetNoQuestions operation of flushing the indexes, since these will be reinitialized with potentially new definitions. Clears additional data related to having the - type system potentially change - the features belonging to indexes change
-
resetNoQuestions
private void resetNoQuestions(boolean flushIndexRepos)
-
flushIndexRepositoriesAllViews
private void flushIndexRepositoriesAllViews()
-
clearNonSharedInstanceData
private void clearNonSharedInstanceData()
-
clearTrackingMarks
private void clearTrackingMarks()
-
switchClassLoader
void switchClassLoader(java.lang.ClassLoader newClassLoader, boolean wasLocked)
-
restoreClassLoader
void restoreClassLoader(boolean empty_switchControl, CASImpl.SwitchControl switchControlInstance)
-
getNextFsId
private int getNextFsId(TOP fs)
The logic for this is: - normal - add 1 to the value of the previous which is kept in fsIdGenerator Update fsIdGenerator to be this id. (maybe) set lastFsV2Size to the size of this FS in v2 - pear trampolines: use the exact same id as the main fs. This value is in reuseId. In this case, no computation of "next" is done - isId2Fs This is set if in special mode to emulate v2 addresses. - used for backwards compatibility when LowLevelCas getFSForRef calls in use - used for debugging v2 vs v3 runs - causes fsId to be set to a value which should match the v2 address Side effect: when doing v2 emulation, updates the lastFsV2Size- Parameters:
fs- - the fs, used to compute its "size" on the v2 heap when emulating v2 addresses- Returns:
- the id to use
-
peekNextFsId
int peekNextFsId()
- Returns:
- the lastUsedFsId + the size of that or 1
-
lastFsV2IdIncr
int lastFsV2IdIncr()
-
getViewFromSofaNbr
private CASImpl getViewFromSofaNbr(int nbr)
-
getInitialView
CASImpl getInitialView()
-
setViewForSofaNbr
void setViewForSofaNbr(int nbr, CASImpl view)
-
-