kangpinghuang commented on a change in pull request #1341: Add plain page
URL: https://github.com/apache/incubator-doris/pull/1341#discussion_r295877128
##########
File path: be/src/olap/rowset/segment_v2/plain_page.h
##########
@@ -0,0 +1,170 @@
+#pragma once
+
+#include "util/coding.h"
+#include "util/faststring.h"
+#include "olap/olap_common.h"
+#include "olap/types.h"
+#include "olap/rowset/segment_v2/page_builder.h"
+#include "olap/rowset/segment_v2/page_decoder.h"
+#include "olap/rowset/segment_v2/options.h"
+
+namespace doris {
+
+namespace segment_v2 {
+
+static const size_t plainPageHeaderSize = sizeof(uint32_t) * 2;
+
+template<FieldType Type>
+class PlainPageBuilder : public PageBuilder {
+public:
+ PlainPageBuilder(const PageBuilderOptions *options) :
+ _options(options) {
+ // Reserve enough space for the block, plus a bit of slop since
+ // we often overrun the block by a few values.
+ _buffer.reserve(plainPageHeaderSize + _options->data_page_size + 1024);
+ reset();
+ }
+
+ bool is_page_full() override {
+ return _buffer.size() > _options->data_page_size;
+ }
+
+ Status add(const uint8_t *vals, size_t *count) override {
+ size_t old_size = _buffer.size();
+ _buffer.resize(old_size + *count * SIZE_OF_TYPE);
+ memcpy(&_buffer[old_size], vals, *count * SIZE_OF_TYPE);
+ _count += *count;
+ return Status::OK();
Review comment:
you should judge is_page_full here before you add a value.
And the number added to page should be returned the count.
And How to process string or binary values here? It seems that this logic
can not process string or binary type.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]