xinyiZzz commented on code in PR #19472:
URL: https://github.com/apache/doris/pull/19472#discussion_r1193816753


##########
be/src/olap/page_cache.h:
##########
@@ -28,11 +28,50 @@
 
 #include "olap/lru_cache.h"
 #include "util/slice.h"
+#include "vec/common/allocator.h"
+#include "vec/common/allocator_fwd.h"
 
 namespace doris {
 
 class PageCacheHandle;
 
+template <typename TAllocator>
+class PageBase : private TAllocator {
+public:
+    PageBase() : data(nullptr), size(0), bytes(0) {}
+
+    PageBase(size_t b) : size(b), bytes(b) {
+        data = reinterpret_cast<char*>(TAllocator::alloc(bytes, 
ALLOCATOR_ALIGNMENT_16));
+        ExecEnv::GetInstance()->page_no_cache_mem_tracker()->consume(bytes);
+    }
+
+    ~PageBase() {
+        if (data != nullptr) {
+            DCHECK(bytes != 0 && size != 0);
+            TAllocator::free(data, bytes);
+            
ExecEnv::GetInstance()->page_no_cache_mem_tracker()->release(bytes);
+        }
+    }
+
+    void reset_size(size_t n) {
+        DCHECK(n <= bytes);
+        size = n;
+    }
+
+    void release() {
+        data = nullptr;
+        size = 0;
+        bytes = 0;
+    }
+
+    char* data;

Review Comment:
   A buffer's capacity is the number of elements it contains. The capacity of a 
buffer is never negative and never changes.
   
   A buffer's limit is the index of the first element that should not be read 
or written. A buffer's limit is never negative and is never greater than its 
capacity.
   
   A buffer's position is the index of the next element to be read or written. 
A buffer's position is never negative and is never greater than its limit.
   
   那就像 PodArray 一样,叫 size 和 capacity 好了
   
![image](https://github.com/apache/doris/assets/13197424/8c9feee5-d7de-445c-aec5-fda4e958786f)
   



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to