2024-05-14 15:37:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/logger_useful.h>
|
|
|
|
#include <IO/WriteBufferFromPocoSocket.h>
|
2024-06-26 20:43:13 +00:00
|
|
|
#include <algorithm>
|
2024-05-14 15:37:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class WriteBufferFromPocoSocketChunked: public WriteBufferFromPocoSocket
|
|
|
|
{
|
|
|
|
public:
|
2024-06-26 20:43:13 +00:00
|
|
|
explicit WriteBufferFromPocoSocketChunked(Poco::Net::Socket & socket_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE);
|
|
|
|
explicit WriteBufferFromPocoSocketChunked(Poco::Net::Socket & socket_, const ProfileEvents::Event & write_event_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE);
|
2024-05-14 15:37:20 +00:00
|
|
|
|
2024-06-15 00:22:51 +00:00
|
|
|
void enableChunked();
|
|
|
|
void finishChunk();
|
|
|
|
~WriteBufferFromPocoSocketChunked() override;
|
2024-06-11 16:47:05 +00:00
|
|
|
|
2024-05-14 15:37:20 +00:00
|
|
|
protected:
|
2024-06-15 00:22:51 +00:00
|
|
|
void nextImpl() override;
|
|
|
|
void finalizeImpl() override;
|
|
|
|
Poco::Net::SocketAddress peerAddress() const { return peer_address; }
|
|
|
|
Poco::Net::SocketAddress ourAddress() const { return our_address; }
|
2024-05-20 14:15:47 +00:00
|
|
|
|
2024-05-14 15:37:20 +00:00
|
|
|
private:
|
|
|
|
LoggerPtr log;
|
|
|
|
bool chunked = false;
|
2024-06-15 00:22:51 +00:00
|
|
|
UInt32 * last_finish_chunk = nullptr; // pointer to the last chunk header created by finishChunk
|
|
|
|
bool chunk_started = false; // chunk started flag
|
|
|
|
UInt32 * chunk_size_ptr = nullptr; // pointer to the chunk size holder in the buffer
|
2024-06-07 01:45:56 +00:00
|
|
|
size_t finishing = sizeof(*chunk_size_ptr); // indicates not enough buffer for end-of-chunk marker
|
2024-05-14 15:37:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|