public static final class Store.MetadataSnapshot extends Object implements Iterable<StoreFileMetaData>, Writeable<Store.MetadataSnapshot>
Note: This class will ignore the segments.gen file since it's optional and might change concurrently for safety reasons.
StoreFileMetaData
Modifier and Type | Field and Description |
---|---|
static Store.MetadataSnapshot |
EMPTY |
Constructor and Description |
---|
MetadataSnapshot(Map<String,StoreFileMetaData> metadata,
Map<String,String> commitUserData,
long numDocs) |
MetadataSnapshot(StreamInput in) |
Modifier and Type | Method and Description |
---|---|
Map<String,StoreFileMetaData> |
asMap() |
boolean |
contains(String existingFile)
Returns true iff this metadata contains the given file.
|
StoreFileMetaData |
get(String name) |
Map<String,String> |
getCommitUserData() |
long |
getNumDocs()
Returns the number of documents in this store snapshot
|
StoreFileMetaData |
getSegmentsFile()
Returns the segments file that this metadata snapshot represents or null if the snapshot is empty.
|
String |
getSyncId()
Returns the sync id of the commit point that this MetadataSnapshot represents.
|
static void |
hashFile(org.apache.lucene.util.BytesRefBuilder fileHash,
InputStream in,
long size)
Computes a strong hash value for small files.
|
static org.apache.lucene.util.BytesRef |
hashFile(org.apache.lucene.store.Directory directory,
String file)
Computes a strong hash value for small files.
|
Iterator<StoreFileMetaData> |
iterator() |
Store.MetadataSnapshot |
readFrom(StreamInput in)
Reads a copy of an object with the same type form the stream input
The caller object remains unchanged.
|
Store.RecoveryDiff |
recoveryDiff(Store.MetadataSnapshot recoveryTargetSnapshot)
Returns a diff between the two snapshots that can be used for recovery.
|
int |
size()
Returns the number of files in this snapshot
|
void |
writeTo(StreamOutput out)
Writes the current object into the output stream out
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final Store.MetadataSnapshot EMPTY
public MetadataSnapshot(Map<String,StoreFileMetaData> metadata, Map<String,String> commitUserData, long numDocs)
public MetadataSnapshot(StreamInput in) throws IOException
IOException
public long getNumDocs()
public static org.apache.lucene.util.BytesRef hashFile(org.apache.lucene.store.Directory directory, String file) throws IOException
IOException
public static void hashFile(org.apache.lucene.util.BytesRefBuilder fileHash, InputStream in, long size) throws IOException
IOException
public Iterator<StoreFileMetaData> iterator()
iterator
in interface Iterable<StoreFileMetaData>
public StoreFileMetaData get(String name)
public Map<String,StoreFileMetaData> asMap()
public Store.RecoveryDiff recoveryDiff(Store.MetadataSnapshot recoveryTargetSnapshot)
The .si file contains a lot of diagnostics including a timestamp etc. in the future there might be unique segment identifiers in there hardening this method further.
The per-commit files handles very similar. A commit is composed of the segments_N files as well as generational files like deletes (_x_y.del) or field-info (_x_y.fnm) files. On a per-commit level files for a commit are treated as identical iff:
NOTE: this diff will not contain the segments.gen file. This file is omitted on recovery.
public int size()
public void writeTo(StreamOutput out) throws IOException
Writeable
writeTo
in interface Writeable<Store.MetadataSnapshot>
IOException
public boolean contains(String existingFile)
public StoreFileMetaData getSegmentsFile()
public String getSyncId()
public Store.MetadataSnapshot readFrom(StreamInput in) throws IOException
StreamableReader
readFrom
in interface StreamableReader<Store.MetadataSnapshot>
IOException
Copyright © 2009–2016. All rights reserved.