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) (opensearch-project#10754)

Signed-off-by: Andriy Redko <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
reta authored and shiv0408 committed Apr 25, 2024
1 parent 11679ee commit 82e5b1c
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 82e5b1c

Please sign in to comment.