zzzxl1993 commented on code in PR #245: URL: https://github.com/apache/doris-thirdparty/pull/245#discussion_r1827641782
########## 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_++]; } + + void readBytes(uint8_t* b, const int32_t len) override { readBytes(b, 0, len); } + + void readBytes(uint8_t* b, const int32_t len, int32_t offset) override { Review Comment: I need to maintain consistency with the clucene IndexOutput interface. -- 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