coderex2522 commented on code in PR #1271: URL: https://github.com/apache/orc/pull/1271#discussion_r990583071
########## c++/src/BlockBuffer.hh: ########## @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ORC_MEMORYPOOL_IMPL_HH +#define ORC_MEMORYPOOL_IMPL_HH + +#include "orc/MemoryPool.hh" + +#include <vector> + +namespace orc { + + struct Block { + char* data; + uint64_t size; + + Block() : data(nullptr), size(0) {} + Block(char* _data, uint64_t _size) : data(_data), size(_size) {} + Block(const Block& block) = default; + ~Block() {} + }; + + class BlockBuffer { + private: + MemoryPool& memoryPool; + // current buffer size + uint64_t currentSize; + // maximal capacity (actual allocated memory) + uint64_t currentCapacity; + // unit for buffer expansion + const uint64_t blockSize; + // pointers to the start of each block + std::vector<char*> blocks; + + // non-copy-constructible + BlockBuffer(BlockBuffer& buffer) = delete; + BlockBuffer& operator=(BlockBuffer& buffer) = delete; + BlockBuffer(BlockBuffer&& buffer) = delete; + BlockBuffer& operator=(BlockBuffer&& buffer) = delete; + + public: + BlockBuffer(MemoryPool& pool, uint64_t blockSize); + + ~BlockBuffer(); + + /** + * Get the Block object + */ + Block getBlock(uint64_t blockIndex); Review Comment: Added some description for block, blockbuffer, block index and block number. -- 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]
