@@ -115,29 +115,31 @@ static void readFromCompressed(ByteArrayDataInput input, Extent extent) {
115
115
posRight = Integer .MIN_VALUE ;
116
116
break ;
117
117
case POSITIVE_SET :
118
- posRight = input .readVInt ();
119
- posLeft = Math .toIntExact (posRight - input .readVLong ());
118
+ posLeft = input .readVInt ();
119
+ posRight = Math .toIntExact (input .readVLong () + posLeft );
120
120
negLeft = Integer .MAX_VALUE ;
121
121
negRight = Integer .MIN_VALUE ;
122
122
break ;
123
123
case NEGATIVE_SET :
124
- negRight = input .readInt ();
124
+ negRight = - input .readVInt ();
125
125
negLeft = Math .toIntExact (negRight - input .readVLong ());
126
126
posLeft = Integer .MAX_VALUE ;
127
127
posRight = Integer .MIN_VALUE ;
128
128
break ;
129
129
case CROSSES_LAT_AXIS :
130
- posRight = input .readInt ();
131
- negLeft = Math . toIntExact ( posRight - input .readVLong () );
130
+ posRight = input .readVInt ();
131
+ negLeft = - input .readVInt ( );
132
132
posLeft = 0 ;
133
133
negRight = 0 ;
134
134
break ;
135
- default :
136
- posRight = input .readVInt ();
137
- posLeft = Math .toIntExact (posRight - input .readVLong ());
138
- negRight = input .readInt ();
135
+ case ALL_SET :
136
+ posLeft = input .readVInt ();
137
+ posRight = Math .toIntExact (input .readVLong () + posLeft );
138
+ negRight = - input .readVInt ();
139
139
negLeft = Math .toIntExact (negRight - input .readVLong ());
140
140
break ;
141
+ default :
142
+ throw new IllegalArgumentException ("invalid extent values-set byte read [" + type + "]" );
141
143
}
142
144
extent .reset (top , bottom , negLeft , negRight , posLeft , posRight );
143
145
}
@@ -165,23 +167,25 @@ void writeCompressed(ByteBuffersDataOutput output) throws IOException {
165
167
switch (type ) {
166
168
case NONE_SET : break ;
167
169
case POSITIVE_SET :
168
- output .writeVInt (this .posRight );
170
+ output .writeVInt (this .posLeft );
169
171
output .writeVLong ((long ) this .posRight - this .posLeft );
170
172
break ;
171
173
case NEGATIVE_SET :
172
- output .writeInt ( this .negRight );
174
+ output .writeVInt (- this .negRight );
173
175
output .writeVLong ((long ) this .negRight - this .negLeft );
174
176
break ;
175
177
case CROSSES_LAT_AXIS :
176
- output .writeInt (this .posRight );
177
- output .writeVLong ((long ) this .posRight - this .negLeft );
178
- break ;
179
- default :
180
178
output .writeVInt (this .posRight );
179
+ output .writeVInt (-this .negLeft );
180
+ break ;
181
+ case ALL_SET :
182
+ output .writeVInt (this .posLeft );
181
183
output .writeVLong ((long ) this .posRight - this .posLeft );
182
- output .writeInt ( this .negRight );
184
+ output .writeVInt (- this .negRight );
183
185
output .writeVLong ((long ) this .negRight - this .negLeft );
184
186
break ;
187
+ default :
188
+ throw new IllegalArgumentException ("invalid extent values-set byte read [" + type + "]" );
185
189
}
186
190
}
187
191
0 commit comments