synchronized SegmentInfos toLiveInfos(SegmentInfos sis) { final SegmentInfos newSIS = new SegmentInfos(sis.getIndexCreatedVersionMajor()); final Map<SegmentCommitInfo,SegmentCommitInfo> liveSIS = new HashMap<>(); for(SegmentCommitInfo info : segmentInfos) { liveSIS.put(info, info); } for(SegmentCommitInfo info : sis) { SegmentCommitInfo liveInfo = liveSIS.get(info); if (liveInfo != null) { info = liveInfo; } newSIS.add(info); } return newSIS; }
final SegmentInfos sis = new SegmentInfos(Version.LATEST.major); if (indexExists) { final SegmentInfos previous = SegmentInfos.readLatestCommit(directory);
SegmentInfos infos = new SegmentInfos(indexCreatedVersion); infos.id = id; infos.generation = generation;
assert sources.length > 0; final int luceneIndexCreatedVersionMajor = Lucene.readSegmentInfos(sources[0]).getIndexCreatedVersionMajor(); new SegmentInfos(luceneIndexCreatedVersionMajor).commit(target);
public IndexSplitter(File dir) throws IOException { this.dir = dir; fsDir = FSDirectory.open(dir); infos = new SegmentInfos(); infos.read(fsDir); }
synchronized SegmentInfos toLiveInfos(SegmentInfos sis) { final SegmentInfos newSIS = new SegmentInfos(); final Map<SegmentCommitInfo,SegmentCommitInfo> liveSIS = new HashMap<>(); for(SegmentCommitInfo info : segmentInfos) { liveSIS.put(info, info); } for(SegmentCommitInfo info : sis) { SegmentCommitInfo liveInfo = liveSIS.get(info); if (liveInfo != null) { info = liveInfo; } newSIS.add(info); } return newSIS; }
synchronized SegmentInfos toLiveInfos(SegmentInfos sis) { final SegmentInfos newSIS = new SegmentInfos(); final Map<SegmentCommitInfo,SegmentCommitInfo> liveSIS = new HashMap<>(); for(SegmentCommitInfo info : segmentInfos) { liveSIS.put(info, info); } for(SegmentCommitInfo info : sis) { SegmentCommitInfo liveInfo = liveSIS.get(info); if (liveInfo != null) { info = liveInfo; } newSIS.add(info); } return newSIS; }
synchronized SegmentInfos toLiveInfos(SegmentInfos sis) { final SegmentInfos newSIS = new SegmentInfos(sis.getIndexCreatedVersionMajor()); final Map<SegmentCommitInfo,SegmentCommitInfo> liveSIS = new HashMap<>(); for(SegmentCommitInfo info : segmentInfos) { liveSIS.put(info, info); } for(SegmentCommitInfo info : sis) { SegmentCommitInfo liveInfo = liveSIS.get(info); if (liveInfo != null) { info = liveInfo; } newSIS.add(info); } return newSIS; }
public static int getNumSegments(Directory idx) throws IOException { SegmentInfos infos = new SegmentInfos(); infos.read(idx); return infos.size(); }
public static String getSegmentsInfo(Directory idx) { SegmentInfos infos = new SegmentInfos(); try { infos.read(idx); StringBuilder buf = new StringBuilder(); for (int i = 0; i < infos.size(); i++) { SegmentInfoPerCommit segInfo = infos.info(i); buf.append("[").append(segInfo.info.name).append(",numDoc:").append(segInfo.info.getDocCount()) .append(",numDel:").append(segInfo.getDelCount()).append("]"); } return buf.toString(); } catch (Exception e) { return e.toString(); } } }
/** * Returns a new SegmentInfos containg the SegmentInfo * instances in the specified range first (inclusive) to * last (exclusive), so total number of segments returned * is last-first. */ public SegmentInfos range(int first, int last) { SegmentInfos infos = new SegmentInfos(); infos.addAll(super.subList(first, last)); return infos; }
public static int getNumSegments(Directory idx) throws IOException { SegmentInfos infos = new SegmentInfos(); infos.read(idx); return infos.size(); }
/** * Returns a new SegmentInfos containg the SegmentInfo * instances in the specified range first (inclusive) to * last (exclusive), so total number of segments returned * is last-first. */ public SegmentInfos range(int first, int last) { SegmentInfos infos = new SegmentInfos(); infos.addAll(super.subList(first, last)); return infos; }
public static int getNumSegments(Directory idx) throws IOException { SegmentInfos infos=new SegmentInfos(); infos.read(idx); return infos.size(); } public static String getSegmentsInfo(Directory idx)
protected Object doBody(String segmentFileName) throws CorruptIndexException, IOException { SegmentInfos infos = new SegmentInfos(); infos.read(directory, segmentFileName); DirectoryIndexReader newReader = doReopen(infos); if (DirectoryIndexReader.this != newReader) { newReader.init(directory, infos, closeDirectory, readOnly); newReader.deletionPolicy = deletionPolicy; } return newReader; } };
public static int getNumDocs(Directory dir) throws IOException { int count = 0; SegmentInfos sis = new SegmentInfos(); sis.read(dir); for (SegmentCommitInfo sci : sis) { count += sci.info.getDocCount() - sci.getDelCount(); } return count; }
protected Object doBody(String segmentFileName) throws CorruptIndexException, IOException { SegmentInfos infos = new SegmentInfos(); infos.read(directory, segmentFileName); DirectoryIndexReader newReader = doReopen(infos); if (DirectoryIndexReader.this != newReader) { newReader.init(directory, infos, closeDirectory, readOnly); newReader.deletionPolicy = deletionPolicy; } return newReader; } };
public static int getNumDocs(Directory dir) throws IOException { int count = 0; SegmentInfos sis = new SegmentInfos(); sis.read(dir); for (SegmentCommitInfo sci : sis) { count += sci.info.getDocCount() - sci.getDelCount(); } return count; }
@Test public void testMergeWithNoSegments() throws Exception { CommitMitigatingTieredMergePolicy mergePolicy = new CommitMitigatingTieredMergePolicy(); SegmentInfos infos = new SegmentInfos(); MergePolicy.MergeSpecification merges = mergePolicy.findMerges(MergeTrigger.SEGMENT_FLUSH, infos); assertNull(merges); }
public Object doBody() throws IOException { SegmentInfos infos = new SegmentInfos(); infos.read(directory); if (infos.size() == 1) { // index is optimized return new SegmentReader(infos, infos.info(0), closeDirectory); } else { IndexReader[] readers = new IndexReader[infos.size()]; for (int i = 0; i < infos.size(); i++) readers[i] = new SegmentReader(infos.info(i)); return new MultiReader(directory, infos, closeDirectory, readers); } } }.run();