本文整理汇总了Java中org.apache.lucene.index.IndexCommit.getGeneration方法的典型用法代码示例。如果您正苦于以下问题:Java IndexCommit.getGeneration方法的具体用法?Java IndexCommit.getGeneration怎么用?Java IndexCommit.getGeneration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.index.IndexCommit
的用法示例。
在下文中一共展示了IndexCommit.getGeneration方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndexVersion
import org.apache.lucene.index.IndexCommit; //导入方法依赖的package包/类
private long[] getIndexVersion() {
long version[] = new long[2];
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
try {
final IndexCommit commit = searcher.get().getIndexReader().getIndexCommit();
final Map<String,String> commitData = commit.getUserData();
String commitTime = commitData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
if (commitTime != null) {
version[0] = Long.parseLong(commitTime);
}
version[1] = commit.getGeneration();
} catch (IOException e) {
LOG.warn("Unable to get index version : ", e);
} finally {
searcher.decref();
}
return version;
}
示例2: onCommit
import org.apache.lucene.index.IndexCommit; //导入方法依赖的package包/类
@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();
}
}
示例3: createSnapshot
import org.apache.lucene.index.IndexCommit; //导入方法依赖的package包/类
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();
}
}
示例4: findIndexCommit
import org.apache.lucene.index.IndexCommit; //导入方法依赖的package包/类
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.");
}
示例5: findIndexCommit
import org.apache.lucene.index.IndexCommit; //导入方法依赖的package包/类
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 + "]");
}
示例6: findIndexCommit
import org.apache.lucene.index.IndexCommit; //导入方法依赖的package包/类
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 + "]");
}
示例7: isStillInUse
import org.apache.lucene.index.IndexCommit; //导入方法依赖的package包/类
private boolean isStillInUse(IndexCommit commit) {
long generation = commit.getGeneration();
return _gens.contains(generation);
}