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 KV_DB_WINDOWED_RESULT_SET_H 17 #define KV_DB_WINDOWED_RESULT_SET_H 18 19 #include "ikvdb_result_set.h" 20 #include "result_entries_window.h" 21 22 namespace DistributedDB { 23 class KvDBWindowedResultSet : public IKvDBResultSet { 24 public: 25 KvDBWindowedResultSet(); 26 ~KvDBWindowedResultSet() override; 27 DISABLE_COPY_ASSIGN_MOVE(KvDBWindowedResultSet); 28 29 // Initialize logic 30 int Open(bool isMemDb) override; 31 32 // Get total entries count. 33 // >= 0: count, < 0: errCode. 34 int GetCount() const override; 35 36 // Get current read position. 37 // >= 0: position, < 0: errCode 38 int GetPosition() const override; 39 40 int Move(int offset) const override; 41 42 // Move the read position to an absolute position value. 43 int MoveTo(int position) const override; 44 45 int MoveToFirst() override; 46 47 int MoveToLast() override; 48 49 bool IsFirst() const override; 50 51 bool IsLast() const override; 52 53 bool IsBeforeFirst() const override; 54 55 bool IsAfterLast() const override; 56 57 // Get the entry of current position. 58 int GetEntry(Entry &entry) const override; 59 60 // Finalize logic 61 int Close() override; 62 63 private: 64 ResultEntriesWindow *window_; 65 }; 66 } // namespace DistributedDB 67 68 #endif // KV_DB_WINDOWED_RESULT_SET_H 69