From 6f119d53f5b6329509a1ea1d3f9858939e9f0085 Mon Sep 17 00:00:00 2001 From: Nikita Mikhaylov Date: Tue, 26 Nov 2019 19:33:43 +0300 Subject: [PATCH] adding comments to strange functions used in parallel parsing --- dbms/src/IO/ReadHelpers.cpp | 1 - dbms/src/IO/ReadHelpers.h | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dbms/src/IO/ReadHelpers.cpp b/dbms/src/IO/ReadHelpers.cpp index 860ce734c4..ea54d37b1b 100644 --- a/dbms/src/IO/ReadHelpers.cpp +++ b/dbms/src/IO/ReadHelpers.cpp @@ -1053,7 +1053,6 @@ void skipToUnescapedNextLineOrEOF(ReadBuffer & buf) } } -/// TODO (akuzm) - write comments for this and next function. void saveUpToPosition(ReadBuffer & in, DB::Memory<> & memory, char * current) { assert(current >= in.position()); diff --git a/dbms/src/IO/ReadHelpers.h b/dbms/src/IO/ReadHelpers.h index 4b162588d7..d829839e1a 100644 --- a/dbms/src/IO/ReadHelpers.h +++ b/dbms/src/IO/ReadHelpers.h @@ -924,8 +924,24 @@ if (method == DB::CompressionMethod::Gzip) return std::make_unique(args...); } -/// TODO (akuzm) - write comments for this and next function. +/** This function just copies the data from buffer's internal position (in.position()) + * to current position (from arguments) into memory. + * @param buf - original buffer to read from. + * memory - where to put data from buf + * current - defines the upper bound of copyble data. + */ void saveUpToPosition(ReadBuffer & in, DB::Memory<> & memory, char * current); + +/** This function is negative to eof(). + * In fact it returns whether the data was loaded to internal ReadBuffers's buffer or not. + * And saves data from buffer's position to current if there is no pending data in buffer. + * Why we have to use this strange function? Consider we have buffer's internal position in the middle + * of our buffer and the current cursor in the end of the buffer. When we call eof() it calls next(). + * And this function can fill the buffer with new data, so we will lose the data from previous buffer state. + * @param buf - original buffer to read from. + * memory - where to put data from buf + * current - defines the upper bound of copyble data. + */ bool loadAtPosition(ReadBuffer & in, DB::Memory<> & memory, char * & current); } -- GitLab