当前位置: 首页>>代码示例>>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;未经允许,请勿转载。