zzzxl1993 commented on code in PR #245: URL: https://github.com/apache/doris-thirdparty/pull/245#discussion_r1827657172
########## src/core/CLucene/store/v2/ByteArrayDataInput.h: ########## @@ -0,0 +1,126 @@ +#pragma once + +#include <zstd.h> + +#include <algorithm> +#include <cstdint> +#include <vector> +#include <iostream> + +#include "CLucene.h" +#include "CLucene/store/IndexInput.h" + +namespace v2 { + +class ByteArrayDataInput : public CL_NS(store)::IndexInput { +public: + ByteArrayDataInput() : owns_(true), bytes_(new std::vector<uint8_t>()) {} + + ByteArrayDataInput(std::vector<uint8_t>* bytes) { reset(bytes); } + + ~ByteArrayDataInput() override { + if (owns_) { + if (bytes_ != nullptr) { + delete bytes_; + bytes_ = nullptr; + } + } + } + + void reset(std::vector<uint8_t>* bytes) { reset(bytes, 0, bytes->size()); } + + void reset(std::vector<uint8_t>* bytes, int32_t offset, int32_t len) { + bytes_ = bytes; + pos_ = offset; + limit_ = offset + len; + } + + uint8_t readByte() override { return (*bytes_)[pos_++]; } Review Comment: 1. Low-level access: This class is designed to provide fast byte reading operations, so it omits additional safety checks to enhance performance. 2. User responsibility: The design assumes that users will ensure data validity before calling these methods, such as verifying that the current pos and limit values are appropriate. 3. Performance priority: In high-performance scenarios, boundary checks can introduce overhead, so these checks may be omitted in low-level operations. Finally, I will add a documentation warning to my implemented class stating, “WARNING: This class omits all low-level checks.” to alert users. -- 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: dev-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org For additional commands, e-mail: dev-h...@doris.apache.org