Package org.apache.lucene.index

Examples of org.apache.lucene.index.SegmentInfo


      // be optimized (other segments may have been flushed
      // since optimize started):
      int last = infos.size();
      while(last > 0)
      {
        final SegmentInfo info = infos.info(--last);
        if (segmentsToOptimize.contains(info))
        {
          last++;
          break;
        }
View Full Code Here


      }
      else
      {
        if(partialExpunge)
        {
          SegmentInfo info = infos.info(mergeStart);
          int delCount = info.getDelCount();
          if(delCount > maxDelCount)
          {
            expungeCandidate = mergeStart;
            maxDelCount = delCount;
          }
View Full Code Here

    }

    if(spec == null) spec = new MergeSpecification();
    for(int i = 0; i < numLargeSegs; i++)
    {
      SegmentInfo info = infos.info(i);
      if(info.hasDeletions())
      {
        spec.add(new OneMerge(infos.range(i, i + 1), getUseCompoundFile()));       
      }
    }
    return spec;
View Full Code Here

    if(numSegs <= numLargeSegs) return null;

    long totalLargeSegSize = 0;
    long totalSmallSegSize = 0;
    SegmentInfo info;

    // compute the total size of large segments
    for(int i = 0; i < numLargeSegs; i++)
    {
      info = infos.info(i);
View Full Code Here

    int expungeCandidate = -1;
    int maxDelCount = 0;

    for(int i = maxNumSegments - 1; i >= 0; i--)
    {
      SegmentInfo info = infos.info(i);
      int delCount = info.getDelCount();
      if(delCount > maxDelCount)
      {
        expungeCandidate = i;
        maxDelCount = delCount;
      }
View Full Code Here

      if (input.getFilePointer() != input.length()) {
        throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read "
            + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
      }

      final SegmentInfo si = new SegmentInfo(dir, version, segment, docCount, isCompoundFile, null, diagnostics,
          Collections.unmodifiableMap(attributes));
      si.setFiles(files);

      success = true;

      return si;
View Full Code Here

    infos.version = input.readLong(); // read version
    infos.counter = input.readInt(); // read counter
    Lucene3xSegmentInfoReader reader = new Lucene3xSegmentInfoReader();
    for (int i = input.readInt(); i > 0; i--) { // read segmentInfos
      SegmentCommitInfo siPerCommit = reader.readLegacySegmentInfo(directory, format, input);
      SegmentInfo si = siPerCommit.info;

      if (si.getVersion() == null) {
        // Could be a 3.0 - try to open the doc stores - if it fails, it's a
        // 2.x segment, and an IndexFormatTooOldException will be thrown,
        // which is what we want.
        Directory dir = directory;
        if (Lucene3xSegmentInfoFormat.getDocStoreOffset(si) != -1) {
          if (Lucene3xSegmentInfoFormat.getDocStoreIsCompoundFile(si)) {
            dir = new CompoundFileDirectory(dir, IndexFileNames.segmentFileName(
                Lucene3xSegmentInfoFormat.getDocStoreSegment(si), "",
                Lucene3xCodec.COMPOUND_FILE_STORE_EXTENSION), IOContext.READONCE, false);
          }
        } else if (si.getUseCompoundFile()) {
          dir = new CompoundFileDirectory(dir, IndexFileNames.segmentFileName(
              si.name, "", IndexFileNames.COMPOUND_FILE_EXTENSION), IOContext.READONCE, false);
        }

        try {
          Lucene3xStoredFieldsReader.checkCodeVersion(dir, Lucene3xSegmentInfoFormat.getDocStoreSegment(si));
        } finally {
          // If we opened the directory, close it
          if (dir != directory) dir.close();
        }
         
        // Above call succeeded, so it's a 3.0 segment. Upgrade it so the next
        // time the segment is read, its version won't be null and we won't
        // need to open FieldsReader every time for each such segment.
        si.setVersion("3.0");
      } else if (si.getVersion().equals("2.x")) {
        // If it's a 3x index touched by 3.1+ code, then segments record their
        // version, whether they are 2.x ones or not. We detect that and throw
        // appropriate exception.
        throw new IndexFormatTooOldException("segment " + si.name + " in resource " + input, si.getVersion());
      }
      infos.add(siPerCommit);
    }
     
    infos.userData = input.readStringStringMap();
View Full Code Here

    boolean success = false;

    IndexInput input = directory.openInput(fileName, context);

    try {
      SegmentInfo si = readUpgradedSegmentInfo(segmentName, directory, input);
      success = true;
      return si;
    } finally {
      if (!success) {
        IOUtils.closeWhileHandlingException(input);
View Full Code Here

          assert false;
        }
      }
    }

    SegmentInfo info = new SegmentInfo(dir, version, name, docCount, isCompoundFile,
                                       null, diagnostics, Collections.unmodifiableMap(attributes));
    info.setFiles(files);

    SegmentCommitInfo infoPerCommit = new SegmentCommitInfo(info, delCount, delGen, -1, -1);
    return infoPerCommit;
  }
View Full Code Here

    final Map<String,String> diagnostics = input.readStringStringMap();

    final Set<String> files = input.readStringSet();

    SegmentInfo info = new SegmentInfo(dir, version, name, docCount, isCompoundFile,
                                       null, diagnostics, Collections.unmodifiableMap(attributes));
    info.setFiles(files);
    return info;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.SegmentInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.