File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed
main/java/tech/ydb/query/tools
test/java/tech/ydb/query/tools Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -176,8 +176,12 @@ public int getRowCount() {
176
176
177
177
@ Override
178
178
public void setRowIndex (int index ) {
179
+ if (index < 0 || index >= rowsCount ) {
180
+ throw new IndexOutOfBoundsException (String .format ("Index %s out of bounds for length %s" ,
181
+ index , rowsCount ));
182
+ }
179
183
partIndex = 0 ;
180
- int currentIdx = Math . max ( index , 0 ) ;
184
+ int currentIdx = index ;
181
185
while (partIndex < parts .length ) {
182
186
int readerRows = parts [partIndex ].getRowCount ();
183
187
if (currentIdx < readerRows ) {
@@ -189,9 +193,6 @@ public void setRowIndex(int index) {
189
193
partIndex ++;
190
194
}
191
195
192
- if (partIndex >= parts .length ) {
193
- partIndex = parts .length - 1 ;
194
- }
195
196
for (int partStep = partIndex + 1 ; partStep < parts .length ; partStep ++) {
196
197
parts [partStep ].setRowIndex (0 );
197
198
}
Original file line number Diff line number Diff line change @@ -142,11 +142,11 @@ public void compositeResultSetTest() {
142
142
rsr .setRowIndex (5 );
143
143
Assert .assertEquals (1 , readAll (rsr , 5 ));
144
144
145
- rsr .setRowIndex (6 ); // after end
146
- Assert .assertEquals (0 , readAll ( rsr , 0 ));
145
+ IndexOutOfBoundsException ex1 = Assert . assertThrows ( IndexOutOfBoundsException . class , () -> rsr .setRowIndex (6 ));
146
+ Assert .assertEquals ("Index 6 out of bounds for length 6" , ex1 . getMessage ( ));
147
147
148
- rsr .setRowIndex (-1 ); // before start
149
- Assert .assertEquals (6 , readAll ( rsr , 0 ));
148
+ IndexOutOfBoundsException ex2 = Assert . assertThrows ( IndexOutOfBoundsException . class , () -> rsr .setRowIndex (-1 ));
149
+ Assert .assertEquals ("Index -1 out of bounds for length 6" , ex2 . getMessage ( ));
150
150
}
151
151
152
152
private int readAll (ResultSetReader rsr , int startKey ) {
You can’t perform that action at this time.
0 commit comments