kangkaisen commented on a change in pull request #2308: Add BinaryPrefixPage
URL: https://github.com/apache/incubator-doris/pull/2308#discussion_r351648279
 
 

 ##########
 File path: be/src/olap/rowset/segment_v2/binary_plain_page.h
 ##########
 @@ -107,19 +109,41 @@ class BinaryPlainPageBuilder : public PageBuilder {
         return _size_estimate;
     }
 
+    Status get_first_value(void* value) const override {
+        DCHECK(_finished);
+        return _get_value_at(value, 0);
+    }
+    Status get_last_value(void* value) const override {
+        DCHECK(_finished);
+        return _get_value_at(value, _offsets.size() - 1);
+    }
+
     void update_prepared_size(size_t added_size) {
         _prepared_size += added_size;
         _prepared_size += sizeof(uint32_t);
     }
 
 private:
+    Status _get_value_at(void* value, size_t idx) const {
+        if (_offsets.size() == 0) {
+            return Status::NotFound("page is empty");
+        }
+        size_t value_size = (idx < _offsets.size() - 1) ?
+                            _offsets[idx + 1] - _offsets[idx] : 
_last_value_size;
+        auto res = reinterpret_cast<Slice*>(value);
+        *res = Slice(&_buffer[_offsets[idx]], value_size);
+        return Status::OK();
+    }
+
     faststring _buffer;
     size_t _size_estimate;
     size_t _prepared_size;
     // Offsets of each entry, relative to the start of the page
     std::vector<uint32_t> _offsets;
     bool _finished;
     PageBuilderOptions _options;
+    // size of last added value
+    uint32_t _last_value_size;
 
 Review comment:
   done

----------------------------------------------------------------
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]

Reply via email to