@@ -107,31 +107,16 @@ private MetricDataSplitOperationResult prepareExportBatches(
107107 // Remaining capacity can't hold all points, partition existing metric data object
108108 List <PointData > originalPointsList = new ArrayList <>(metricData .getData ().getPoints ());
109109 Collection <Collection <MetricData >> preparedBatches = new ArrayList <>();
110-
111- // Fill current batch buffer completely
112- int pointsToTake = remainingCapacityInCurrentBatch ;
113110 int currentIndex = 0 ;
114111
115- if (pointsToTake > 0 ) {
116- currentBatch .add (
117- copyMetricData (metricData , originalPointsList , currentIndex , pointsToTake ));
118- currentIndex = pointsToTake ;
119- preparedBatches .add (currentBatch );
120- }
121-
122- // Buffer spillover onto fresh partitions
123- int remainingPoints = totalPointsInMetricData - currentIndex ;
124- currentBatch = new ArrayList <>(maxExportBatchSize );
125- remainingCapacityInCurrentBatch = maxExportBatchSize ;
126-
127- // Iterate extra chunks sized to exact transport constraints
128- while (currentIndex < totalPointsInMetricData && remainingPoints > 0 ) {
129- pointsToTake = Math .min (remainingPoints , remainingCapacityInCurrentBatch );
112+ while (currentIndex < totalPointsInMetricData ) {
113+ int pointsToTake =
114+ Math .min (totalPointsInMetricData - currentIndex , remainingCapacityInCurrentBatch );
130115 currentBatch .add (
131116 copyMetricData (metricData , originalPointsList , currentIndex , pointsToTake ));
132117 currentIndex += pointsToTake ;
133- remainingPoints -= pointsToTake ;
134118 remainingCapacityInCurrentBatch -= pointsToTake ;
119+
135120 if (remainingCapacityInCurrentBatch == 0 ) {
136121 preparedBatches .add (currentBatch );
137122 currentBatch = new ArrayList <>(maxExportBatchSize );
0 commit comments