CrynetLogistics commented on a change in pull request #17913:
URL: https://github.com/apache/flink/pull/17913#discussion_r756961454
##########
File path:
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriter.java
##########
@@ -310,8 +309,32 @@ private void flush() {
inFlightRequestsCount++;
submitRequestEntries(batch, requestResult);
- numRecordsOutCounter.inc(batchSize);
+ }
+
+ /**
+ * Creates the next batch of request entries while respecting the {@code
maxBatchSize} and
+ * {@code flushOnBufferSizeBytes}. Also adds these to the metrics counters.
+ */
+ private List<RequestEntryT> createNextAvailableBatch() {
+ int batchSize = Math.min(maxBatchSize, bufferedRequestEntries.size());
+ List<RequestEntryT> batch = new ArrayList<>(batchSize);
+
+ int batchSizeBytes = 0;
+ for (int i = 0; i < batchSize; i++) {
+ if (batchSizeBytes + bufferedRequestEntries.peek().getSize()
+ >= maxBatchSizeInBytes) {
+ break;
+ }
+ RequestEntryWrapper<RequestEntryT> elem =
bufferedRequestEntries.remove();
+ batch.add(elem.getRequestEntry());
+ bufferedRequestEntriesTotalSizeInBytes -= elem.getSize();
+ batchSizeBytes += elem.getSize();
Review comment:
It's retrieving a primitive long field from a class, so cheap to
call.... but will refactor for readability.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]