/** * Parse the given version number as a constant or dot based version. * <p>This method allows to use {@code "LUCENE_X_Y"} constant names, * or version numbers in the format {@code "x.y.z"}. * * @lucene.internal */ public static Version parseLeniently(String version) throws ParseException { String versionOrig = version; version = version.toUpperCase(Locale.ROOT); switch (version) { case "LATEST": case "LUCENE_CURRENT": return LATEST; default: version = version .replaceFirst("^LUCENE_(\\d+)_(\\d+)_(\\d+)$", "$1.$2.$3") .replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2.0") .replaceFirst("^LUCENE_(\\d)(\\d)$", "$1.$2.0"); try { return parse(version); } catch (ParseException pe) { ParseException pe2 = new ParseException("failed to parse lenient version string \"" + versionOrig + "\": " + pe.getMessage(), 0); pe2.initCause(pe); throw pe2; } } }
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(() -> new ParameterizedMessage("no version match {}, default to {}", version, defaultVersion), e); return defaultVersion; } }
@Override public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); primary = in.readBoolean(); upgradeVersion = Version.readVersion(in); try { oldestLuceneSegment = org.apache.lucene.util.Version.parse(in.readString()); } catch (ParseException ex) { throw new IOException("failed to parse lucene version [" + oldestLuceneSegment + "]", ex); } }
/** * Read from a stream. */ public StoreFileMetaData(StreamInput in) throws IOException { name = in.readString(); length = in.readVLong(); checksum = in.readString(); try { writtenBy = Version.parse(in.readString()); } catch (ParseException e) { throw new AssertionError(e); } hash = in.readBytesRef(); }
/** * Parse the given version number as a constant or dot based version. * <p>This method allows to use {@code "LUCENE_X_Y"} constant names, * or version numbers in the format {@code "x.y.z"}. * * @lucene.internal */ public static Version parseLeniently(String version) throws ParseException { String versionOrig = version; version = version.toUpperCase(Locale.ROOT); switch (version) { case "LATEST": case "LUCENE_CURRENT": return LATEST; default: version = version .replaceFirst("^LUCENE_(\\d+)_(\\d+)_(\\d+)$", "$1.$2.$3") .replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2.0") .replaceFirst("^LUCENE_(\\d)(\\d)$", "$1.$2.0"); try { return parse(version); } catch (ParseException pe) { ParseException pe2 = new ParseException("failed to parse lenient version string \"" + versionOrig + "\": " + pe.getMessage(), 0); pe2.initCause(pe); throw pe2; } } }
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; } }
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(() -> new ParameterizedMessage("no version match {}, default to {}", version, defaultVersion), e); return defaultVersion; } }
.replaceFirst("^LUCENE_(\\d)(\\d)$", "$1.$2.0"); try { return parse(version); } catch (ParseException pe) { ParseException pe2 = new ParseException("failed to parse lenient version string \"" + versionOrig + "\": " + pe.getMessage(), 0);
.replaceFirst("^LUCENE_(\\d)(\\d)$", "$1.$2.0"); try { return parse(version); } catch (ParseException pe) { ParseException pe2 = new ParseException("failed to parse lenient version string \"" + versionOrig + "\": " + pe.getMessage(), 0);
@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; } }
@Override public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); primary = in.readBoolean(); upgradeVersion = Version.readVersion(in); try { oldestLuceneSegment = org.apache.lucene.util.Version.parse(in.readString()); } catch (ParseException ex) { throw new IOException("failed to parse lucene version [" + oldestLuceneSegment + "]", ex); } }
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; } }
@Override public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); primary = in.readBoolean(); upgradeVersion = Version.readVersion(in); try { oldestLuceneSegment = org.apache.lucene.util.Version.parse(in.readString()); } catch (ParseException ex) { throw new IOException("failed to parse lucene version [" + oldestLuceneSegment + "]", ex); } }
@Override public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); primary = in.readBoolean(); upgradeVersion = Version.readVersion(in); try { oldestLuceneSegment = org.apache.lucene.util.Version.parse(in.readString()); } catch (ParseException ex) { throw new IOException("failed to parse lucene version [" + oldestLuceneSegment + "]", ex); } }
@Override public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); primary = in.readBoolean(); upgradeVersion = Version.readVersion(in); try { oldestLuceneSegment = org.apache.lucene.util.Version.parse(in.readString()); } catch (ParseException ex) { throw new IOException("failed to parse lucene version [" + oldestLuceneSegment + "]", ex); } }
/** * Read from a stream. */ public StoreFileMetaData(StreamInput in) throws IOException { name = in.readString(); length = in.readVLong(); checksum = in.readString(); try { writtenBy = Version.parse(in.readString()); } catch (ParseException e) { throw new AssertionError(e); } hash = in.readBytesRef(); }
/** * Read from a stream. */ public StoreFileMetaData(StreamInput in) throws IOException { name = in.readString(); length = in.readVLong(); checksum = in.readString(); try { writtenBy = Version.parse(in.readString()); } catch (ParseException e) { throw new AssertionError(e); } hash = in.readBytesRef(); }
oldSegment = Version.parse("3.0"); } catch (ParseException pe) { throw new IOException(pe);
@Override public SegmentInfo read(Directory dir, String segment, byte segmentID[], IOContext context) throws IOException { final String fileName = IndexFileNames.segmentFileName(segment, "", Lucene46SegmentInfoFormat.SI_EXTENSION); try (ChecksumIndexInput input = dir.openChecksumInput(fileName, context)) { 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: " + pe.getMessage(), input, pe); } final int docCount = input.readInt(); if (docCount < 0) { throw new CorruptIndexException("invalid docCount: " + docCount, input); } final boolean isCompoundFile = input.readByte() == SegmentInfo.YES; final Map<String,String> diagnostics = Collections.unmodifiableMap(input.readStringStringMap()); final Set<String> files = Collections.unmodifiableSet(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, null, Collections.<String,String>emptyMap()); si.setFiles(files); return si; } }
final Version version; try { version = Version.parse(input.readString()); } catch (ParseException pe) { throw new CorruptIndexException("unable to parse version string: " + pe.getMessage(), input, pe);