Skip to content

Commit

Permalink
Performance Improvement for Datetime formats (update version checks t…
Browse files Browse the repository at this point in the history
…o 2.12.0) (#10754)

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed Oct 19, 2023
1 parent 69f6f4e commit da24ca7
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public DateTime(DateFormatter formatter, ZoneId timeZone, DateFieldMapper.Resolu
}

public DateTime(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
if (in.getVersion().onOrAfter(Version.V_2_12_0)) {
this.formatter = DateFormatter.forPattern(in.readString(), in.readOptionalString());
} else {
this.formatter = DateFormatter.forPattern(in.readString());
Expand All @@ -265,12 +265,12 @@ public String getWriteableName() {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().before(Version.V_3_0_0) && formatter.equals(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER)) {
if (out.getVersion().before(Version.V_2_12_0) && formatter.equals(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER)) {
out.writeString(DateFieldMapper.LEGACY_DEFAULT_DATE_TIME_FORMATTER.pattern()); // required for backwards compatibility
} else {
out.writeString(formatter.pattern());
}
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_12_0)) {
out.writeOptionalString(formatter.printPattern());
}
out.writeString(timeZone.getId());
Expand Down

0 comments on commit da24ca7

Please sign in to comment.