congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SegmentInfos.readLatestCommit
Code IndexAdd Tabnine to your IDE (free)

How to use
readLatestCommit
method
in
org.apache.lucene.index.SegmentInfos

Best Java code snippets using org.apache.lucene.index.SegmentInfos.readLatestCommit (Showing top 20 results out of 315)

origin: neo4j/neo4j

  private static boolean hasCommits( Directory directory ) throws IOException
  {
    return DirectoryReader.indexExists( directory ) && SegmentInfos.readLatestCommit( directory ) != null;
  }
}
origin: oracle/opengrok

  /**
   * Check index version in given directory. It assumes that that all commits
   * in the Lucene segment file were done with the same version.
   *
   * @param dir directory with index
   * @thows IOException if the directory cannot be opened
   */
  private static void checkDir(File dir) throws Exception {
    LockFactory lockfact = NativeFSLockFactory.INSTANCE;
    int segVersion;

    try (Directory indexDirectory = FSDirectory.open(dir.toPath(), lockfact)) {
      SegmentInfos segInfos = null;

      try {
        segInfos = SegmentInfos.readLatestCommit(indexDirectory);
        segVersion = segInfos.getIndexCreatedVersionMajor();
      } catch (IndexNotFoundException e) {
        return;
      }
    }

    if (segVersion != Version.LATEST.major) {
      throw new IndexVersionException(
        String.format("Directory %s has index of version %d and Lucene has %d",
        dir.toString(), segVersion, Version.LATEST.major));
    }
  }
}
origin: org.apache.lucene/lucene-core

SegmentInfos latest = SegmentInfos.readLatestCommit(dir);
final long currentGen = latest.getGeneration();
origin: org.apache.lucene/lucene-core

@Override
public boolean isCurrent() throws IOException {
 ensureOpen();
 if (writer == null || writer.isClosed()) {
  // Fully read the segments file: this ensures that it's
  // completely written so that if
  // IndexWriter.prepareCommit has been called (but not
  // yet commit), then the reader will still see itself as
  // current:
  SegmentInfos sis = SegmentInfos.readLatestCommit(directory);
  // we loaded SegmentInfos from the directory
  return sis.getVersion() == segmentInfos.getVersion();
 } else {
  return writer.nrtIsCurrent(segmentInfos);
 }
}
origin: org.elasticsearch/elasticsearch

/**
 * Reads the segments infos, failing if it fails to load
 */
public static SegmentInfos readSegmentInfos(Directory directory) throws IOException {
  return SegmentInfos.readLatestCommit(directory);
}
origin: org.apache.lucene/lucene-core

 infoStream.message("IW", "addIndexes: process directory " + dir);
SegmentInfos sis = SegmentInfos.readLatestCommit(dir); // read infos from dir
if (segmentInfos.getIndexCreatedVersionMajor() != sis.getIndexCreatedVersionMajor()) {
 throw new IllegalArgumentException("Cannot use addIndexes(Directory) with indexes that have been created "
origin: org.elasticsearch/elasticsearch

private boolean assertSequenceNumbersInCommit() throws IOException {
  final Map<String, String> userData = SegmentInfos.readLatestCommit(store.directory()).getUserData();
  assert userData.containsKey(SequenceNumbers.LOCAL_CHECKPOINT_KEY) : "commit point doesn't contains a local checkpoint";
  assert userData.containsKey(SequenceNumbers.MAX_SEQ_NO) : "commit point doesn't contains a maximum sequence number";
  assert userData.containsKey(Engine.HISTORY_UUID_KEY) : "commit point doesn't contains a history uuid";
  assert userData.get(Engine.HISTORY_UUID_KEY).equals(getHistoryUUID()) : "commit point history uuid ["
    + userData.get(Engine.HISTORY_UUID_KEY) + "] is different than engine [" + getHistoryUUID() + "]";
  return true;
}
origin: org.apache.lucene/lucene-core

final SegmentInfos previous = SegmentInfos.readLatestCommit(directory);
sis.updateGenerationVersionAndCounter(previous);
origin: org.elasticsearch/elasticsearch

private boolean assertMaxUnsafeAutoIdInCommit() throws IOException {
  final Map<String, String> userData = SegmentInfos.readLatestCommit(store.directory()).getUserData();
  if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_5_5_0)) {
    // as of 5.5.0, the engine stores the maxUnsafeAutoIdTimestamp in the commit point.
    // This should have baked into the commit by the primary we recover from, regardless of the index age.
    assert userData.containsKey(Engine.MAX_UNSAFE_AUTO_ID_TIMESTAMP_COMMIT_ID) :
      "opening index which was created post 5.5.0 but " + Engine.MAX_UNSAFE_AUTO_ID_TIMESTAMP_COMMIT_ID
        + " is not found in commit";
  }
  return true;
}
origin: com.strapdata.elasticsearch/elasticsearch

/**
 * Reads the segments infos, failing if it fails to load
 */
public static SegmentInfos readSegmentInfos(Directory directory) throws IOException {
  return SegmentInfos.readLatestCommit(directory);
}
origin: harbby/presto-connectors

/**
 * Reads the segments infos, failing if it fails to load
 */
public static SegmentInfos readSegmentInfos(Directory directory) throws IOException {
  return SegmentInfos.readLatestCommit(directory);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Reads the segments infos, failing if it fails to load
 */
public static SegmentInfos readSegmentInfos(Directory directory) throws IOException {
  return SegmentInfos.readLatestCommit(directory);
}
origin: org.codelibs/elasticsearch-querybuilders

/**
 * Reads the segments infos, failing if it fails to load
 */
public static SegmentInfos readSegmentInfos(Directory directory) throws IOException {
  return SegmentInfos.readLatestCommit(directory);
}
origin: org.apache.lucene/lucene-misc

public IndexSplitter(Path dir) throws IOException {
 this.dir = dir;
 fsDir = FSDirectory.open(dir);
 infos = SegmentInfos.readLatestCommit(fsDir);
}
origin: org.infinispan/infinispan-embedded-query

public IndexSplitter(Path dir) throws IOException {
 this.dir = dir;
 fsDir = FSDirectory.open(dir);
 infos = SegmentInfos.readLatestCommit(fsDir);
}
origin: harbby/presto-connectors

public IndexSplitter(Path dir) throws IOException {
 this.dir = dir;
 fsDir = FSDirectory.open(dir);
 infos = SegmentInfos.readLatestCommit(fsDir);
}
origin: org.infinispan/infinispan-embedded-query

/** Reads the commit data from a Directory. */
private static Map<String, String> readCommitData(Directory dir) throws IOException {
 SegmentInfos infos = SegmentInfos.readLatestCommit(dir);
 return infos.getUserData();
}

origin: org.apache.lucene/lucene-facet

/** Reads the commit data from a Directory. */
private static Map<String, String> readCommitData(Directory dir) throws IOException {
 SegmentInfos infos = SegmentInfos.readLatestCommit(dir);
 return infos.getUserData();
}

origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

private boolean assertSequenceNumbersInCommit() throws IOException {
  final Map<String, String> userData = SegmentInfos.readLatestCommit(store.directory()).getUserData();
  assert userData.containsKey(SequenceNumbers.LOCAL_CHECKPOINT_KEY) : "commit point doesn't contains a local checkpoint";
  assert userData.containsKey(SequenceNumbers.MAX_SEQ_NO) : "commit point doesn't contains a maximum sequence number";
  assert userData.containsKey(Engine.HISTORY_UUID_KEY) : "commit point doesn't contains a history uuid";
  assert userData.get(Engine.HISTORY_UUID_KEY).equals(getHistoryUUID()) : "commit point history uuid ["
    + userData.get(Engine.HISTORY_UUID_KEY) + "] is different than engine [" + getHistoryUUID() + "]";
  return true;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

private boolean assertMaxUnsafeAutoIdInCommit() throws IOException {
  final Map<String, String> userData = SegmentInfos.readLatestCommit(store.directory()).getUserData();
  if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_5_5_0)) {
    // as of 5.5.0, the engine stores the maxUnsafeAutoIdTimestamp in the commit point.
    // This should have baked into the commit by the primary we recover from, regardless of the index age.
    assert userData.containsKey(Engine.MAX_UNSAFE_AUTO_ID_TIMESTAMP_COMMIT_ID) :
      "opening index which was created post 5.5.0 but " + Engine.MAX_UNSAFE_AUTO_ID_TIMESTAMP_COMMIT_ID
        + " is not found in commit";
  }
  return true;
}
org.apache.lucene.indexSegmentInfosreadLatestCommit

Javadoc

Find the latest commit ( segments_N file) and load all SegmentCommitInfos.

Popular methods of SegmentInfos

  • <init>
    Sole constructor.
  • size
    Returns number of SegmentCommitInfos.
  • info
  • commit
    Writes and syncs to the Directory dir, taking care to remove the segments file on exception Note: #c
  • getVersion
    version number when this SegmentInfos was generated.
  • getGeneration
    Returns current generation.
  • files
    Returns all file names referenced by SegmentInfo. The returned collection is recomputed on each invo
  • getLastCommitSegmentsFileName
    Get the filename of the segments_N file for the most recent commit in the list of index files.
  • getUserData
    Return userData saved with this commit.
  • read
    Read a particular segmentFileName. Note that this may throw an IOException if a commit is in process
  • readCommit
    Read the commit from the provided ChecksumIndexInput.
  • add
  • readCommit,
  • add,
  • addAll,
  • asList,
  • getSegmentsFileName,
  • getId,
  • getIndexCreatedVersionMajor,
  • getLastGeneration,
  • write

Popular in Java

  • Reactive rest calls using spring rest template
  • addToBackStack (FragmentTransaction)
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Path (java.nio.file)
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now