olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
PrefetchPartitionsRequest.h
1/*
2 * Copyright (C) 2020 HERE Europe B.V.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * License-Filename: LICENSE
18 */
19
20#pragma once
21
22#include <sstream>
23#include <string>
24#include <utility>
25#include <vector>
26
27#include <olp/core/porting/optional.h>
28#include <olp/core/thread/TaskScheduler.h>
29#include <olp/dataservice/read/DataServiceReadApi.h>
30#include <olp/dataservice/read/FetchOptions.h>
31
32namespace olp {
33namespace dataservice {
34namespace read {
35
40class DATASERVICE_READ_API PrefetchPartitionsRequest final {
41 public:
43 using PartitionIds = std::vector<std::string>;
44
58 partition_ids_ = std::move(partition_ids);
59 return *this;
60 }
61
67 inline const PartitionIds& GetPartitionIds() const { return partition_ids_; }
68
79 const porting::optional<std::string>& GetBillingTag() const {
80 return billing_tag_;
81 }
82
92 template <class T = porting::optional<std::string>>
94 billing_tag_ = std::forward<T>(billing_tag);
95 return *this;
96 }
97
105 uint32_t GetPriority() const { return priority_; }
106
115 priority_ = priority;
116 return *this;
117 }
118
127 std::string CreateKey(
128 const std::string& layer_id,
129 porting::optional<int64_t> version = porting::none) const {
130 std::stringstream out;
131 out << layer_id;
132 if (version) {
133 out << "@" << *version;
134 }
135 out << "^" << partition_ids_.size();
136 if (!partition_ids_.empty()) {
137 out << "[" << partition_ids_.front() << ", ...]";
138 }
139 if (GetBillingTag()) {
140 out << "$" << *GetBillingTag();
141 }
142 out << "*" << priority_;
143 return out.str();
144 }
145
146 private:
147 PartitionIds partition_ids_;
148 porting::optional<std::string> billing_tag_;
149 uint32_t priority_{thread::LOW};
150};
151
152} // namespace read
153} // namespace dataservice
154} // namespace olp
Encapsulates the fields required to prefetch a list of partitions for the given catalog and layer.
Definition PrefetchPartitionsRequest.h:40
uint32_t GetPriority() const
Gets the request priority.
Definition PrefetchPartitionsRequest.h:105
PrefetchPartitionsRequest & WithPriority(uint32_t priority)
Sets the priority of the prefetch request.
Definition PrefetchPartitionsRequest.h:114
PrefetchPartitionsRequest & WithPartitionIds(PartitionIds partition_ids)
Sets the list of partitions.
Definition PrefetchPartitionsRequest.h:57
const porting::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition PrefetchPartitionsRequest.h:79
std::vector< std::string > PartitionIds
An alias for the vector of partitions IDs.
Definition PrefetchPartitionsRequest.h:43
std::string CreateKey(const std::string &layer_id, porting::optional< int64_t > version=porting::none) const
Creates a readable format for the request.
Definition PrefetchPartitionsRequest.h:127
PrefetchPartitionsRequest & WithBillingTag(T &&billing_tag)
Sets the billing tag for the request.
Definition PrefetchPartitionsRequest.h:93
const PartitionIds & GetPartitionIds() const
Gets the list of the partitions.
Definition PrefetchPartitionsRequest.h:67
Rules all the other namespaces.
Definition AppleSignInProperties.h:24