@@ -682,16 +682,8 @@ private static class IndexMetaDataDiff implements Diff<IndexMetaData> {
682682 index = in .readString ();
683683 routingNumShards = in .readInt ();
684684 version = in .readLong ();
685- if (in .getVersion ().onOrAfter (Version .V_6_5_0 )) {
686- mappingVersion = in .readVLong ();
687- } else {
688- mappingVersion = 1 ;
689- }
690- if (in .getVersion ().onOrAfter (Version .V_6_5_0 )) {
691- settingsVersion = in .readVLong ();
692- } else {
693- settingsVersion = 1 ;
694- }
685+ mappingVersion = in .readVLong ();
686+ settingsVersion = in .readVLong ();
695687 state = State .fromId (in .readByte ());
696688 settings = Settings .readSettingsFromStream (in );
697689 primaryTerms = in .readVLongArray ();
@@ -703,36 +695,25 @@ private static class IndexMetaDataDiff implements Diff<IndexMetaData> {
703695 DiffableStringMap ::readDiffFrom );
704696 inSyncAllocationIds = DiffableUtils .readImmutableOpenIntMapDiff (in , DiffableUtils .getVIntKeySerializer (),
705697 DiffableUtils .StringSetValueSerializer .getInstance ());
706- if (in .getVersion ().onOrAfter (Version .V_6_4_0 )) {
707- rolloverInfos = DiffableUtils .readImmutableOpenMapDiff (in , DiffableUtils .getStringKeySerializer (), RolloverInfo ::new ,
708- RolloverInfo ::readDiffFrom );
709- } else {
710- ImmutableOpenMap <String , RolloverInfo > emptyMap = ImmutableOpenMap .of ();
711- rolloverInfos = DiffableUtils .diff (emptyMap , emptyMap , DiffableUtils .getStringKeySerializer ());
712- }
698+ rolloverInfos = DiffableUtils .readImmutableOpenMapDiff (in , DiffableUtils .getStringKeySerializer (), RolloverInfo ::new ,
699+ RolloverInfo ::readDiffFrom );
713700 }
714701
715702 @ Override
716703 public void writeTo (StreamOutput out ) throws IOException {
717704 out .writeString (index );
718705 out .writeInt (routingNumShards );
719706 out .writeLong (version );
720- if (out .getVersion ().onOrAfter (Version .V_6_5_0 )) {
721- out .writeVLong (mappingVersion );
722- }
723- if (out .getVersion ().onOrAfter (Version .V_6_5_0 )) {
724- out .writeVLong (settingsVersion );
725- }
707+ out .writeVLong (mappingVersion );
708+ out .writeVLong (settingsVersion );
726709 out .writeByte (state .id );
727710 Settings .writeSettingsToStream (settings , out );
728711 out .writeVLongArray (primaryTerms );
729712 mappings .writeTo (out );
730713 aliases .writeTo (out );
731714 customData .writeTo (out );
732715 inSyncAllocationIds .writeTo (out );
733- if (out .getVersion ().onOrAfter (Version .V_6_4_0 )) {
734- rolloverInfos .writeTo (out );
735- }
716+ rolloverInfos .writeTo (out );
736717 }
737718
738719 @ Override
@@ -757,16 +738,8 @@ public IndexMetaData apply(IndexMetaData part) {
757738 public static IndexMetaData readFrom (StreamInput in ) throws IOException {
758739 Builder builder = new Builder (in .readString ());
759740 builder .version (in .readLong ());
760- if (in .getVersion ().onOrAfter (Version .V_6_5_0 )) {
761- builder .mappingVersion (in .readVLong ());
762- } else {
763- builder .mappingVersion (1 );
764- }
765- if (in .getVersion ().onOrAfter (Version .V_6_5_0 )) {
766- builder .settingsVersion (in .readVLong ());
767- } else {
768- builder .settingsVersion (1 );
769- }
741+ builder .mappingVersion (in .readVLong ());
742+ builder .settingsVersion (in .readVLong ());
770743 builder .setRoutingNumShards (in .readInt ());
771744 builder .state (State .fromId (in .readByte ()));
772745 builder .settings (readSettingsFromStream (in ));
@@ -782,29 +755,20 @@ public static IndexMetaData readFrom(StreamInput in) throws IOException {
782755 builder .putAlias (aliasMd );
783756 }
784757 int customSize = in .readVInt ();
785- if (in .getVersion ().onOrAfter (Version .V_6_5_0 )) {
786- for (int i = 0 ; i < customSize ; i ++) {
787- String key = in .readString ();
788- DiffableStringMap custom = new DiffableStringMap (in );
789- builder .putCustom (key , custom );
790- }
791- } else {
792- assert customSize == 0 : "expected no custom index metadata" ;
793- if (customSize > 0 ) {
794- throw new IllegalStateException ("unexpected custom metadata when none is supported" );
795- }
758+ for (int i = 0 ; i < customSize ; i ++) {
759+ String key = in .readString ();
760+ DiffableStringMap custom = new DiffableStringMap (in );
761+ builder .putCustom (key , custom );
796762 }
797763 int inSyncAllocationIdsSize = in .readVInt ();
798764 for (int i = 0 ; i < inSyncAllocationIdsSize ; i ++) {
799765 int key = in .readVInt ();
800766 Set <String > allocationIds = DiffableUtils .StringSetValueSerializer .getInstance ().read (in , key );
801767 builder .putInSyncAllocationIds (key , allocationIds );
802768 }
803- if (in .getVersion ().onOrAfter (Version .V_6_4_0 )) {
804- int rolloverAliasesSize = in .readVInt ();
805- for (int i = 0 ; i < rolloverAliasesSize ; i ++) {
806- builder .putRolloverInfo (new RolloverInfo (in ));
807- }
769+ int rolloverAliasesSize = in .readVInt ();
770+ for (int i = 0 ; i < rolloverAliasesSize ; i ++) {
771+ builder .putRolloverInfo (new RolloverInfo (in ));
808772 }
809773 return builder .build ();
810774 }
@@ -813,12 +777,8 @@ public static IndexMetaData readFrom(StreamInput in) throws IOException {
813777 public void writeTo (StreamOutput out ) throws IOException {
814778 out .writeString (index .getName ()); // uuid will come as part of settings
815779 out .writeLong (version );
816- if (out .getVersion ().onOrAfter (Version .V_6_5_0 )) {
817- out .writeVLong (mappingVersion );
818- }
819- if (out .getVersion ().onOrAfter (Version .V_6_5_0 )) {
820- out .writeVLong (settingsVersion );
821- }
780+ out .writeVLong (mappingVersion );
781+ out .writeVLong (settingsVersion );
822782 out .writeInt (routingNumShards );
823783 out .writeByte (state .id ());
824784 writeSettingsToStream (settings , out );
@@ -831,25 +791,19 @@ public void writeTo(StreamOutput out) throws IOException {
831791 for (ObjectCursor <AliasMetaData > cursor : aliases .values ()) {
832792 cursor .value .writeTo (out );
833793 }
834- if (out .getVersion ().onOrAfter (Version .V_6_5_0 )) {
835- out .writeVInt (customData .size ());
836- for (final ObjectObjectCursor <String , DiffableStringMap > cursor : customData ) {
837- out .writeString (cursor .key );
838- cursor .value .writeTo (out );
839- }
840- } else {
841- out .writeVInt (0 );
794+ out .writeVInt (customData .size ());
795+ for (final ObjectObjectCursor <String , DiffableStringMap > cursor : customData ) {
796+ out .writeString (cursor .key );
797+ cursor .value .writeTo (out );
842798 }
843799 out .writeVInt (inSyncAllocationIds .size ());
844800 for (IntObjectCursor <Set <String >> cursor : inSyncAllocationIds ) {
845801 out .writeVInt (cursor .key );
846802 DiffableUtils .StringSetValueSerializer .getInstance ().write (cursor .value , out );
847803 }
848- if (out .getVersion ().onOrAfter (Version .V_6_4_0 )) {
849- out .writeVInt (rolloverInfos .size ());
850- for (ObjectCursor <RolloverInfo > cursor : rolloverInfos .values ()) {
851- cursor .value .writeTo (out );
852- }
804+ out .writeVInt (rolloverInfos .size ());
805+ for (ObjectCursor <RolloverInfo > cursor : rolloverInfos .values ()) {
806+ cursor .value .writeTo (out );
853807 }
854808 }
855809
0 commit comments