Record Class Store.MetadataSnapshot
- Record Components:
numDocs- the number of documents in this store snapshot
- All Implemented Interfaces:
Iterable<StoreFileMetadata>,Writeable
- Enclosing class:
Store
Note: This class will ignore the segments.gen file since it's optional and might
change concurrently for safety reasons.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMetadataSnapshot(Map<String, StoreFileMetadata> fileMetadataMap, Map<String, String> commitUserData, long numDocs) Creates an instance of aMetadataSnapshotrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecommitUserDatarecord component.booleanReturns true iff this metadata contains the given file.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefileMetadataMaprecord component.returns the history uuid the store points at, or null if nonexistent.Returns the segments file that this metadata snapshot represents or null if the snapshot is empty.final inthashCode()Returns a hash code value for this object.static booleanisReadAsHash(String file) iterator()longnumDocs()Returns the value of thenumDocsrecord component.static Store.MetadataSnapshotreadFrom(StreamInput in) recoveryDiff(Store.MetadataSnapshot targetSnapshot) Returns a diff between the two snapshots that can be used for recovery.intsize()Returns the number of files in this snapshotfinal StringtoString()Returns a string representation of this record class.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY
-
-
Constructor Details
-
MetadataSnapshot
public MetadataSnapshot(Map<String, StoreFileMetadata> fileMetadataMap, Map<String, String> commitUserData, long numDocs) Creates an instance of aMetadataSnapshotrecord class.- Parameters:
fileMetadataMap- the value for thefileMetadataMaprecord componentcommitUserData- the value for thecommitUserDatarecord componentnumDocs- the value for thenumDocsrecord component
-
-
Method Details
-
readFrom
- Throws:
IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
getCommitVersion
-
isReadAsHash
-
iterator
- Specified by:
iteratorin interfaceIterable<StoreFileMetadata>
-
get
-
recoveryDiff
Returns a diff between the two snapshots that can be used for recovery. The given snapshot is treated as the recovery target and this snapshot as the source. The returned diff will hold a list of files that are:- identical: they exist in both snapshots and they can be considered the same ie. they don't need to be recovered
- different: they exist in both snapshots but their they are not identical
- missing: files that exist in the source but not in the target
Individual files are compared by name, length, checksum and (if present) a UUID that was assigned when the file was originally written. The segment info (
*.si) files and the segments file (segments_N) are also checked to be a byte-for-byte match.Files are collected together into a group for each segment plus one group of "per-commit" (
segments_N) files. Each per-segment group is subdivided into a nongenerational group (most of them) and a generational group (e.g.*.liv,*.fnm,*.dvm,*.dvdthat have been updated by subsequent commits).For each segment, if any nongenerational files are different then the whole segment is considered to be different and will be recovered in full. If all the nongenerational files are the same but any generational files are different then all the generational files are considered to be different and will be recovered in full, but the nongenerational files are left alone. Finally, if any file is different then all the per-commit files are recovered too.
-
size
public int size()Returns the number of files in this snapshot -
getHistoryUUID
returns the history uuid the store points at, or null if nonexistent. -
contains
Returns true iff this metadata contains the given file. -
getSegmentsFile
Returns the segments file that this metadata snapshot represents or null if the snapshot is empty. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
fileMetadataMap
Returns the value of thefileMetadataMaprecord component.- Returns:
- the value of the
fileMetadataMaprecord component
-
commitUserData
Returns the value of thecommitUserDatarecord component.- Returns:
- the value of the
commitUserDatarecord component
-
numDocs
public long numDocs()Returns the value of thenumDocsrecord component.- Returns:
- the value of the
numDocsrecord component
-