Java Code Examples for org.apache.lucene.index.IndexCommit#getGeneration()
The following examples show how to use
org.apache.lucene.index.IndexCommit#getGeneration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnapshotIndexDeletionPolicy.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
@Override public void onCommit(List<? extends IndexCommit> commits) throws IOException { _writeLock.lock(); try { int size = commits.size(); for (int i = 0; i < size - 1; i++) { IndexCommit indexCommit = commits.get(i); long generation = indexCommit.getGeneration(); if (!_generationsToNames.containsKey(generation)) { indexCommit.delete(); } } } finally { _writeLock.unlock(); } }
Example 2
Source File: SnapshotIndexDeletionPolicy.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
public void createSnapshot(String name, DirectoryReader reader, String context) throws IOException { _writeLock.lock(); try { if (_namesToGenerations.containsKey(name)) { throw new IOException("Snapshot [" + name + "] already exists."); } LOG.info("Creating snapshot [{0}] in [{1}].", name, context); IndexCommit indexCommit = reader.getIndexCommit(); long generation = indexCommit.getGeneration(); _namesToGenerations.put(name, generation); Set<String> names = _generationsToNames.get(generation); if (names == null) { names = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); _generationsToNames.put(generation, names); } names.add(name); storeGenerations(); } finally { _writeLock.unlock(); } }
Example 3
Source File: Commit.java From lucene-solr with Apache License 2.0 | 5 votes |
static Commit of(IndexCommit ic) { Commit commit = new Commit(); commit.generation = ic.getGeneration(); commit.isDeleted = ic.isDeleted(); commit.segCount = ic.getSegmentCount(); try { commit.userData = IndexUtils.getCommitUserData(ic); } catch (IOException e) { } return commit; }
Example 4
Source File: MergeSortRowIdMatcher.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
private IndexCommit findIndexCommit(List<IndexCommit> listCommits, long generation) throws IOException { for (IndexCommit commit : listCommits) { if (commit.getGeneration() == generation) { return commit; } } throw new IOException("Generation [" + generation + "] not found."); }
Example 5
Source File: ExistingDataIndexLookupMapper.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
public static IndexCommit findIndexCommit(List<IndexCommit> listCommits, long generation, Path shardDir) throws IOException { for (IndexCommit commit : listCommits) { if (commit.getGeneration() == generation) { return commit; } } throw new IOException("Generation [" + generation + "] not found in shard [" + shardDir + "]"); }
Example 6
Source File: BlurInputFormat.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
private static IndexCommit findIndexCommit(List<IndexCommit> listCommits, long generation, Path shardDir) throws IOException { for (IndexCommit commit : listCommits) { if (commit.getGeneration() == generation) { return commit; } } throw new IOException("Generation [" + generation + "] not found in shard [" + shardDir + "]"); }
Example 7
Source File: IndexDeletionPolicyReader.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
private boolean isStillInUse(IndexCommit commit) { long generation = commit.getGeneration(); return _gens.contains(generation); }