@@ -321,35 +321,32 @@ private Object[] calculateRowKey(ObTableSingleOp operation) {
321321 return rowKey ;
322322 }
323323
324- private List <ObTableSingleOp > extractOperations (Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>> tabletOperationsMap ) {
325- List <ObTableSingleOp > operations = new ArrayList <>();
324+ private List <ObPair < Integer , ObTableSingleOp > > extractOperations (Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>> tabletOperationsMap ) {
325+ List <ObPair < Integer , ObTableSingleOp >> operationsWithIndex = new ArrayList <>();
326326 for (ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>> pair : tabletOperationsMap .values ()) {
327- for (ObPair <Integer , ObTableSingleOp > operationWithIndex : pair .getRight ()) {
328- operations .add (operationWithIndex .getRight ());
329- }
327+ operationsWithIndex .addAll (pair .getRight ());
330328 }
331- return operations ;
329+ return operationsWithIndex ;
332330 }
333331
334- public Map <Long , Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>>> prepareOperations (List <ObTableSingleOp > operations ) throws Exception {
335- Map <Long , Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>>> lsOperationsMap = new HashMap <>();
332+ public Map <Long , Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>>> prepareOperations (List <ObPair < Integer , ObTableSingleOp >> operationsWithIndex ) throws Exception {
333+ Map <Long , Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>>> lsOperationsMap = new HashMap <>();
336334
337335 if (obTableClient .isOdpMode ()) {
338336 Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>> tabletOperationsMap = new HashMap <>();
339337 ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>> obTableOperations =
340338 new ObPair <>(new ObTableParam (obTableClient .getOdpTable ()),
341339 new ArrayList <ObPair <Integer , ObTableSingleOp >>());
342- for (int i = 0 ; i < operations .size (); i ++) {
343- ObTableSingleOp operation = operations .get (i );
344- obTableOperations .getRight ().add (new ObPair <Integer , ObTableSingleOp >(i , operation ));
340+ for (int i = 0 ; i < operationsWithIndex .size (); i ++) {
341+ obTableOperations .getRight ().add (operationsWithIndex .get (i ));
345342 }
346343 tabletOperationsMap .put (INVALID_TABLET_ID , obTableOperations );
347344 lsOperationsMap .put (INVALID_LS_ID , tabletOperationsMap );
348345 return lsOperationsMap ;
349346 }
350347
351- for (int i = 0 ; i < operations .size (); i ++) {
352- ObTableSingleOp operation = operations .get (i );
348+ for (int i = 0 ; i < operationsWithIndex .size (); i ++) {
349+ ObTableSingleOp operation = operationsWithIndex .get (i ). getRight ( );
353350 Object [] rowKey = calculateRowKey (operation );
354351
355352 String real_tableName = tableName ;
@@ -361,22 +358,26 @@ public Map<Long, Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableSing
361358 long lsId = tableObPair .getRight ().getLsId ();
362359
363360 Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>> tabletOperations
364- = lsOperationsMap .computeIfAbsent (lsId , k -> new HashMap <>());
361+ = lsOperationsMap .computeIfAbsent (lsId , k -> new HashMap <>());
365362 // if ls id not exists
366363
367364 ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>> singleOperations =
368- tabletOperations .computeIfAbsent (tableObPair .getLeft (), k -> new ObPair <>(tableObPair .getRight (), new ArrayList <>()));
365+ tabletOperations .computeIfAbsent (tableObPair .getLeft (), k -> new ObPair <>(tableObPair .getRight (), new ArrayList <>()));
369366 // if tablet id not exists
370- singleOperations .getRight ().add (new ObPair <>( i , operation ));
367+ singleOperations .getRight ().add (operationsWithIndex . get ( i ));
371368 }
372369
373370 return lsOperationsMap ;
374371 }
375372
376373 public Map <Long , Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableSingleOp >>>>> partitionPrepare ()
377- throws Exception {
374+ throws Exception {
378375 List <ObTableSingleOp > operations = getSingleOperations ();
379- return prepareOperations (operations );
376+ List <ObPair <Integer , ObTableSingleOp >> operationsWithIndex = new LinkedList <>();
377+ for (int i = 0 ; i < operations .size (); i ++) {
378+ operationsWithIndex .add (new ObPair <>(i , operations .get (i )));
379+ }
380+ return prepareOperations (operationsWithIndex );
380381 }
381382
382383 /*
@@ -640,7 +641,7 @@ private void executeWithRetries(
640641 retryCount ++;
641642 errCode = ((ObTableNeedFetchAllException )e ).getErrorCode ();
642643 errMsg = e .getMessage ();
643- List <ObTableSingleOp > failedOperations = extractOperations (currentEntry .getValue ());
644+ List <ObPair < Integer , ObTableSingleOp > > failedOperations = extractOperations (currentEntry .getValue ());
644645 currentPartitions = prepareOperations (failedOperations );
645646 allPartitionsSuccess = false ;
646647 break ;
0 commit comments