當前位置: 首頁>>代碼示例>>Java>>正文


Java Version.parse方法代碼示例

本文整理匯總了Java中org.apache.lucene.util.Version.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java Version.parse方法的具體用法?Java Version.parse怎麽用?Java Version.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.util.Version的用法示例。


在下文中一共展示了Version.parse方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readUpgradedSegmentInfo

import org.apache.lucene.util.Version; //導入方法依賴的package包/類
private SegmentInfo readUpgradedSegmentInfo(String name, Directory dir, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene3xSegmentInfoFormat.UPGRADED_SI_CODEC_NAME,
                               Lucene3xSegmentInfoFormat.UPGRADED_SI_VERSION_START,
                               Lucene3xSegmentInfoFormat.UPGRADED_SI_VERSION_CURRENT);
  final Version version;
  try {
    version = Version.parse(input.readString());
  } catch (ParseException pe) {
    throw new CorruptIndexException("unable to parse version string (input: " + input + "): " + pe.getMessage(), pe);
  }

  final int docCount = input.readInt();
  
  final Map<String,String> attributes = input.readStringStringMap();

  final boolean isCompoundFile = input.readByte() == SegmentInfo.YES;

  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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:Lucene3xSegmentInfoReader.java

示例2: parseVersion

import org.apache.lucene.util.Version; //導入方法依賴的package包/類
public static Version parseVersion(@Nullable String version, Version defaultVersion, Logger logger) {
    if (version == null) {
        return defaultVersion;
    }
    try {
        return Version.parse(version);
    } catch (ParseException e) {
        logger.warn((Supplier<?>) () -> new ParameterizedMessage("no version match {}, default to {}", version, defaultVersion), e);
        return defaultVersion;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,代碼來源:Lucene.java

示例3: parseVersion

import org.apache.lucene.util.Version; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static Version parseVersion(@Nullable String version, Version defaultVersion, ESLogger logger) {
    if (version == null) {
        return defaultVersion;
    }
    try {
        return Version.parse(version);
    } catch (ParseException e) {
        logger.warn("no version match {}, default to {}", e, version, defaultVersion);
        return defaultVersion;
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:13,代碼來源:Lucene.java

示例4: read

import org.apache.lucene.util.Version; //導入方法依賴的package包/類
@Override
public SegmentInfo read(Directory dir, String segment, IOContext context) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(segment, "", Lucene40SegmentInfoFormat.SI_EXTENSION);
  final IndexInput input = dir.openInput(fileName, context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40SegmentInfoFormat.CODEC_NAME,
                                 Lucene40SegmentInfoFormat.VERSION_START,
                                 Lucene40SegmentInfoFormat.VERSION_CURRENT);
    final Version version;
    try {
      version = Version.parse(input.readString());
    } catch (ParseException pe) {
      throw new CorruptIndexException("unable to parse version string (resource=" + input + "): " + pe.getMessage(), pe);
    }

    final int docCount = input.readInt();
    if (docCount < 0) {
      throw new CorruptIndexException("invalid docCount: " + docCount + " (resource=" + input + ")");
    }
    final boolean isCompoundFile = input.readByte() == SegmentInfo.YES;
    final Map<String,String> diagnostics = input.readStringStringMap();
    input.readStringStringMap(); // read deprecated attributes
    final Set<String> files = input.readStringSet();
    
    CodecUtil.checkEOF(input);

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

    success = true;

    return si;

  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(input);
    } else {
      input.close();
    }
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:43,代碼來源:Lucene40SegmentInfoReader.java

示例5: read

import org.apache.lucene.util.Version; //導入方法依賴的package包/類
@Override
public SegmentInfo read(Directory dir, String segment, IOContext context) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(segment, "", Lucene46SegmentInfoFormat.SI_EXTENSION);
  final ChecksumIndexInput input = dir.openChecksumInput(fileName, context);
  boolean success = false;
  try {
    int codecVersion = CodecUtil.checkHeader(input, Lucene46SegmentInfoFormat.CODEC_NAME,
                                                    Lucene46SegmentInfoFormat.VERSION_START,
                                                    Lucene46SegmentInfoFormat.VERSION_CURRENT);
    final Version version;
    try {
      version = Version.parse(input.readString());
    } catch (ParseException pe) {
      throw new CorruptIndexException("unable to parse version string (resource=" + input + "): " + pe.getMessage(), pe);
    }

    final int docCount = input.readInt();
    if (docCount < 0) {
      throw new CorruptIndexException("invalid docCount: " + docCount + " (resource=" + input + ")");
    }
    final boolean isCompoundFile = input.readByte() == SegmentInfo.YES;
    final Map<String,String> diagnostics = input.readStringStringMap();
    final Set<String> files = input.readStringSet();
    
    if (codecVersion >= Lucene46SegmentInfoFormat.VERSION_CHECKSUM) {
      CodecUtil.checkFooter(input);
    } else {
      CodecUtil.checkEOF(input);
    }

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

    success = true;

    return si;

  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(input);
    } else {
      input.close();
    }
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:46,代碼來源:Lucene46SegmentInfoReader.java


注:本文中的org.apache.lucene.util.Version.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。