@API(value=MAINTAINED) public class RecordStoreState extends Object
RecordStoreState
interface handles information that might differ between otherwise identical
record stores. In particular, it handles the data that might be different between two different record stores
that have the same meta-data.
At the moment, this class tracks two pieces of store-specific meta-data:
Modifier and Type | Field and Description |
---|---|
static RecordStoreState |
EMPTY
Deprecated.
as this object usually has the wrong store header
|
protected AtomicReference<Map<String,IndexState>> |
indexStateMap |
protected AtomicReference<RecordMetaDataProto.DataStoreInfo> |
storeHeader |
Constructor and Description |
---|
RecordStoreState()
Deprecated.
as the default store header is incorrect for most record stores
|
RecordStoreState(Map<String,IndexState> indexStateMap)
Deprecated.
as the default store header is incorrect for most record stores
|
RecordStoreState(RecordMetaDataProto.DataStoreInfo storeHeader,
Map<String,IndexState> indexStateMap)
Creates a
RecordStoreState with the given index states. |
Modifier and Type | Method and Description |
---|---|
boolean |
allIndexesReadable()
Determines whether all of the indexes in the store are currently readable.
|
void |
beginRead()
Begin using this record store state.
|
boolean |
compatibleWith(RecordStoreState other)
Determines if it is safe to use queries and other operations planned
with the passed
RecordStoreState with a record store
that has the current state. |
void |
endRead()
End using this record store state.
|
boolean |
equals(Object o)
Checks if this
RecordStoreState specifies identical state
as the given object. |
Set<String> |
getDisabledIndexNames()
Get the names of any disabled indexes.
|
Map<String,IndexState> |
getIndexStates()
Retrieve the mapping from index names to
IndexState that is
underlying this RecordStoreState . |
IndexState |
getState(Index index)
Determine the state of an index.
|
IndexState |
getState(String indexName)
Determine the state of the index with the given name.
|
RecordMetaDataProto.DataStoreInfo |
getStoreHeader()
Get the store header associated with this record store state.
|
Set<String> |
getWriteOnlyIndexNames()
Get the names of any write-only indexes.
|
int |
hashCode()
Creates a valid hash code of this state based on the hashes of its members.
|
boolean |
isDisabled(Index index)
Determines whether the index is disabled.
|
boolean |
isDisabled(String indexName)
Determines whether the index of the given is disabled.
|
boolean |
isReadable(Index index)
Determines whether the index is readable.
|
boolean |
isReadable(String indexName)
Determines whether the index of the given name is readable.
|
boolean |
isWriteOnly(Index index)
Determines whether the index provided is a write-only index.
|
boolean |
isWriteOnly(String indexName)
Determines whether the index of the given name is a write-only
index.
|
RecordStoreState |
toImmutable()
Create an immutable version of this
RecordStoreState . |
MutableRecordStoreState |
toMutable()
Create a mutable copy of this
RecordStoreState . |
String |
toString()
A human-readable representation of the state.
|
RecordStoreState |
withIndexesInState(List<String> indexNames,
IndexState state)
Create a new version of this RecordStoreState, but with the specified indexes in the specified state,
ignoring their present state.
|
RecordStoreState |
withWriteOnlyIndexes(List<String> writeOnlyIndexNames)
Create a new version of this
RecordStoreState , but with additional IndexState.WRITE_ONLY indexes. |
protected Map<String,IndexState> |
writeOnlyMap(List<String> writeOnlyIndexNames) |
@Deprecated @Nonnull public static final RecordStoreState EMPTY
RecordStoreState
. This is the state of an empty record store that has not yet been
used. Calling the argument-less constructor of this class will produce a logically-equivalent object,
but having this code around avoids having to instantiate this class unnecessarily.
When this object was initially introduced, the only information included in the record store state was index readability information. This was the common case, and therefore sharing the same object for most record stores was desirable. However, the store header information is not likely to be the same for multiple record stores, so using this record store state is usually not recommended.
@Nonnull protected final AtomicReference<RecordMetaDataProto.DataStoreInfo> storeHeader
@Nonnull protected final AtomicReference<Map<String,IndexState>> indexStateMap
@API(value=INTERNAL) public RecordStoreState(@Nullable RecordMetaDataProto.DataStoreInfo storeHeader, @Nullable Map<String,IndexState> indexStateMap)
RecordStoreState
with the given index states.
Only indexes that are not in the default state (IndexState.READABLE
)
need to be included in the map.storeHeader
- header information for the given storeindexStateMap
- mapping from index name to index state@Deprecated public RecordStoreState(@Nullable Map<String,IndexState> indexStateMap)
RecordStoreState
with the given index states.
Only indexes that are not in the default state (IndexState.READABLE
)
need to be included in the map. This initializes the record store state with a default store header, which
is not the expected state for most record stores. As a result, this constructor has been deprecated in favor
of the constructor where a store header must be provided.indexStateMap
- mapping from index name to index state@Deprecated public RecordStoreState()
RecordStoreState
instance. This is the state that an empty FDBRecordStoreBase
would be expected to be in. All indexes are assumed to be readable with this constructor. This also
initializes the record store state with the default store header, which is not the expected state for
most record stores. As a result, this constructor has been deprecated in favor of the constructor where
a store header must be provided.public void beginRead()
endRead()
is called, the state will not change.public void endRead()
beginRead()
@Nonnull public Map<String,IndexState> getIndexStates()
IndexState
that is
underlying this RecordStoreState
. This operation is
constant time as it does not return a copy, but the map that is
returned is immutable.public boolean isWriteOnly(@Nonnull Index index)
index
- the index to checktrue
if the given index is write-only and false
otherwisepublic boolean isWriteOnly(@Nonnull String indexName)
indexName
- the name of the index to checktrue
if the given name is the name of a write-only index and false
otherwisepublic boolean isDisabled(@Nonnull Index index)
index
- the index to checktrue
if the given index is disabled and false
otherwisepublic boolean isDisabled(@Nonnull String indexName)
indexName
- the name of the index to checktrue
if the given index is disabled and false
otherwisepublic boolean isReadable(@Nonnull Index index)
index
- the index to checktrue
if the given index is readable and false
otherwisepublic boolean isReadable(@Nonnull String indexName)
indexName
- the name of the index to checktrue
if the given index is readable and false
otherwise@Nonnull public IndexState getState(@Nonnull Index index)
IndexState.READABLE
if it is given an index that is not explicitly in its write-only or disabled lists.index
- the index to check@Nonnull public IndexState getState(@Nonnull String indexName)
IndexState.READABLE
if it is given an index name that is not explicitly in its write-only or disabled lists.indexName
- the name of the index to checkpublic boolean allIndexesReadable()
true
if all of the indexes are readable and false
otherwisepublic boolean compatibleWith(@Nonnull RecordStoreState other)
RecordStoreState
with a record store
that has the current state. It is possible that these operations will
be less efficient with the older state information, but they should
not cause correctness problems.other
- the RecordStoreState
to check compatibility withother
will be correct
if the state is actually described by this RecordStoreState
public Set<String> getWriteOnlyIndexNames()
public Set<String> getDisabledIndexNames()
@Nonnull public RecordStoreState withIndexesInState(@Nonnull List<String> indexNames, @Nonnull IndexState state)
indexNames
- the names of the indexes to modifystate
- the new state for the given indexes@Nonnull public RecordStoreState withWriteOnlyIndexes(@Nonnull List<String> writeOnlyIndexNames)
RecordStoreState
, but with additional IndexState.WRITE_ONLY
indexes.writeOnlyIndexNames
- the indexes to be marked as WRITE_ONLY. If the index is already DISABLED, it will
stay disabled, but will otherwise be set to WRITE_ONLY.@Nonnull protected Map<String,IndexState> writeOnlyMap(@Nonnull List<String> writeOnlyIndexNames)
@Nonnull public RecordMetaDataProto.DataStoreInfo getStoreHeader()
public boolean equals(Object o)
RecordStoreState
specifies identical state
as the given object.public int hashCode()
public String toString()
@Nonnull public RecordStoreState toImmutable()
RecordStoreState
. If the state object is already immutable,
this will return this
. This version of the record store state is safe to cache as none of
its members can be mutated.RecordStoreState
@Nonnull public MutableRecordStoreState toMutable()
RecordStoreState
. The returned object will contain the same information
as this record store state, but it will be mutable and will not share any mutable objects with this
object.RecordStoreState