lukecwik commented on code in PR #25354:
URL: https://github.com/apache/beam/pull/25354#discussion_r1114675284
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/debug/OutputSampler.java:
##########
@@ -104,19 +104,22 @@ public List<BeamFnApi.SampledElement> samples() throws
IOException {
// Serializing can take a lot of CPU time for larger or complex elements.
Copy the array here
// so as to not slow down the main processing hot path.
- List<T> copiedBuffer;
+ List<T> bufferToSend;
+ int sampleIndex = 0;
synchronized (this) {
- copiedBuffer = new ArrayList<>(buffer);
- buffer.clear();
+ bufferToSend = buffer;
+ sampleIndex = resampleIndex;
+ buffer = new ArrayList<>(maxElements);
resampleIndex = 0;
}
ByteStringOutputStream stream = new ByteStringOutputStream();
- for (T el : copiedBuffer) {
+ for (int i = 0; i < bufferToSend.size(); i++) {
+ int index = (sampleIndex + i) % bufferToSend.size();
Review Comment:
The specification doesn't say anything about having these ordered in the
response based upon oldest to newest.
--
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]