![JAR search and dependency download from the Maven repository](/logo.png)
com.clickhouse.data.stream.ByteArrayQueueInputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickhouse-data Show documentation
Show all versions of clickhouse-data Show documentation
Data processing utilities for ClickHouse
package com.clickhouse.data.stream;
import com.clickhouse.data.ClickHouseByteBuffer;
import com.clickhouse.data.ClickHouseChecker;
import java.io.IOException;
import java.util.Queue;
public class ByteArrayQueueInputStream extends AbstractByteArrayInputStream {
private final Queue queue;
public ByteArrayQueueInputStream(Queue queue, Runnable postCloseAction) {
super(null, null, postCloseAction);
this.queue = ClickHouseChecker.nonNull(queue, "queue");;
}
@Override
protected int updateBuffer() throws IOException {
position = 0;
while (!queue.isEmpty()) {
byte[] bytes = queue.poll();
int len = bytes != null ? bytes.length : 0;
if (len > 0) {
buffer = bytes;
if (copyTo != null) {
copyTo.write(bytes);
}
return limit = len;
}
}
buffer = ClickHouseByteBuffer.EMPTY_BYTES;
return limit = 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy