1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef INTERCEPTED_DATA_IMPL_H 17 #define INTERCEPTED_DATA_IMPL_H 18 19 #include <cstddef> 20 #include <functional> 21 #include <vector> 22 23 #include "intercepted_data.h" 24 #include "macro_utils.h" 25 #include "single_ver_kv_entry.h" 26 #include "store_types.h" 27 #include "types_export.h" 28 29 namespace DistributedDB { 30 class InterceptedDataImpl : public InterceptedData { 31 public: 32 InterceptedDataImpl(std::vector<SingleVerKvEntry *> dataItems, const std::function<int(const Value&)> &checkSchema); 33 virtual ~InterceptedDataImpl(); 34 DISABLE_COPY_ASSIGN_MOVE(InterceptedDataImpl); 35 36 std::vector<KVEntry> GetEntries() override; 37 DBStatus ModifyKey(size_t index, const Key &newKey) override; 38 DBStatus ModifyValue(size_t index, const Value &newValue) override; 39 40 bool IsError() const; 41 42 private: 43 bool CheckIndex(size_t index); 44 void GetKvEntries(); 45 46 bool kvEntriesReady_; 47 bool isError_; 48 size_t totalLength_; 49 size_t maxPacketSize_; 50 std::function<int(const Value &)> checkSchema_; 51 std::vector<SingleVerKvEntry *> dataItems_; 52 std::vector<KVEntry> kvEntries_; 53 std::vector<size_t> indexes_; 54 }; 55 } // namespace DistributedDB 56 #endif // INTERCEPTED_DATA_IMPL_H