遍历索引目录内以Segments开头但是不是Segments_gen的文件,取出最大的N作为genA。 1 String[] files = null; 2 long genA = -1; 3 files = directory.listAll(); 4 if (files != null) { 5 genA = getLastCommitGeneration(files); 6 } 7 8 ... 1 public static long getLastCommitGeneration(String[] files) { 2 if (files == null) { 3 return -1; 4 } 5 long max = -1; 6 for (String file : files) { 7 if (file.startsWith(IndexFileNames.SEGMENTS) && !file.equals(IndexFileNames.SEGMENTS_GEN)) { 8 long gen = generationFromSegmentsFileName(file); 9 if (gen > max) { 10 max = gen; 11 } 12 } 13 } 14 return max; 15 } 打开segments.
Read full article from Solr4.8.0源码分析(9)之Lucene的索引文件(2) - 追风的蓝宝 - 博客园
No comments:
Post a Comment