Loading...
Searching...
No Matches
kv_executor.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include <map>
23#include <optional>
24#include <unordered_map>
25
28#include "proto/kv/kv.pb.h"
29
30namespace resdb {
31
33 public:
34 KVExecutor(std::unique_ptr<Storage> storage);
35 virtual ~KVExecutor() = default;
36
37 std::unique_ptr<std::string> ExecuteData(const std::string& request) override;
38
39 protected:
40 virtual void Set(const std::string& key, const std::string& value);
41 std::string Get(const std::string& key);
42 std::string GetAllValues();
43 std::string GetRange(const std::string& min_key, const std::string& max_key);
44
45 void SetWithVersion(const std::string& key, const std::string& value,
46 int version);
47 void GetWithVersion(const std::string& key, int version, ValueInfo* info);
48 void GetAllItems(Items* items);
49 void GetKeyRange(const std::string& min_key, const std::string& max_key,
50 Items* items);
51 void GetHistory(const std::string& key, int min_key, int max_key,
52 Items* items);
53 void GetTopHistory(const std::string& key, int top_number, Items* items);
54
55 private:
56 std::unique_ptr<Storage> storage_;
57};
58
59} // namespace resdb
virtual void Set(const std::string &key, const std::string &value)
std::unique_ptr< std::string > ExecuteData(const std::string &request) override
virtual ~KVExecutor()=default
void GetTopHistory(const std::string &key, int top_number, Items *items)
void GetAllItems(Items *items)
void GetKeyRange(const std::string &min_key, const std::string &max_key, Items *items)
std::string Get(const std::string &key)
void GetHistory(const std::string &key, int min_key, int max_key, Items *items)
void GetWithVersion(const std::string &key, int version, ValueInfo *info)
std::string GetAllValues()
std::string GetRange(const std::string &min_key, const std::string &max_key)
void SetWithVersion(const std::string &key, const std::string &value, int version)
std::unique_ptr< Storage > storage