in flink-doris-connector/src/main/java/org/apache/doris/flink/sink/batch/BatchBufferStream.java [45:72]
public int read(byte[] buf, int off, int len) throws IOException {
if (!iterator.hasNext() && currentRow == null) {
return -1;
}
byte[] item = currentRow;
int pos = currentPos;
int readBytes = 0;
while (readBytes < len && (item != null || iterator.hasNext())) {
if (item == null) {
item = iterator.next();
pos = 0;
}
int size = Math.min(len - readBytes, item.length - pos);
System.arraycopy(item, pos, buf, off + readBytes, size);
readBytes += size;
pos += size;
if (pos == item.length) {
item = null;
pos = 0;
}
}
currentRow = item;
currentPos = pos;
return readBytes;
}