Skip to content

Commit 9667267

Browse files
Take into account what is planned to be released (#1477)
Release logic should consider what was requested to be released and make assumption that requested tiles are already released Relates-To: OLPSUP-28891 Signed-off-by: Andrey Kashcheev <ext-andrey.kashcheev@here.com>
1 parent 6f7cd12 commit 9667267

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

olp-cpp-sdk-dataservice-read/src/ReleaseDependencyResolver.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 HERE Europe B.V.
2+
* Copyright (C) 2020-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,7 +49,14 @@ ReleaseDependencyResolver::ReleaseDependencyResolver(
4949
const cache::KeyValueCache::KeyListType&
5050
ReleaseDependencyResolver::GetKeysToRelease(const TileKeys& tiles) {
5151
keys_to_release_.clear();
52-
for (const auto& tile : tiles) {
52+
53+
requested_tiles_ = tiles;
54+
std::sort(requested_tiles_.begin(), requested_tiles_.end());
55+
requested_tiles_.erase(
56+
std::unique(requested_tiles_.begin(), requested_tiles_.end()),
57+
requested_tiles_.end());
58+
59+
for (const auto& tile : requested_tiles_) {
5360
ProcessTileKey(tile);
5461
}
5562
return keys_to_release_;
@@ -134,7 +141,15 @@ void ReleaseDependencyResolver::ProcessQuadTreeCache(
134141
cached_tree)) {
135142
TilesDataKeysType protected_keys =
136143
CheckProtectedTilesInQuad(cached_tree, tile, add_data_handle_key);
137-
if (protected_keys.empty()) {
144+
145+
const bool all_keys_requested = std::all_of(
146+
protected_keys.begin(), protected_keys.end(),
147+
[&](const TilesDataKeysType::value_type& key) {
148+
return std::binary_search(requested_tiles_.begin(),
149+
requested_tiles_.end(), key.first);
150+
});
151+
152+
if (protected_keys.empty() || all_keys_requested) {
138153
// no other tiles are protected, can add quad tree to release list
139154
keys_to_release_.emplace_back(cache::KeyGenerator::CreateQuadTreeKey(
140155
catalog_, layer_id_, root_quad_key, version_, kQuadTreeDepth));

olp-cpp-sdk-dataservice-read/src/ReleaseDependencyResolver.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 HERE Europe B.V.
2+
* Copyright (C) 2020-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121

2222
#include <map>
2323
#include <memory>
24+
#include <vector>
2425
#include <string>
2526

2627
#include <olp/core/cache/KeyValueCache.h>
@@ -53,11 +54,12 @@ class ReleaseDependencyResolver {
5354

5455
void ProcessTileKey(const geo::TileKey& tile_key);
5556

56-
TilesDataKeysType CheckProtectedTilesInQuad(const read::QuadTreeIndex& cached_tree,
57-
const geo::TileKey& tile,
58-
bool& add_data_handle_key);
57+
TilesDataKeysType CheckProtectedTilesInQuad(
58+
const read::QuadTreeIndex& cached_tree, const geo::TileKey& tile,
59+
bool& add_data_handle_key);
5960

60-
void ProcessQuadTreeCache(const geo::TileKey& root_quad_key, const geo::TileKey& tile,
61+
void ProcessQuadTreeCache(const geo::TileKey& root_quad_key,
62+
const geo::TileKey& tile,
6163
bool& add_data_handle_key);
6264

6365
private:
@@ -69,6 +71,7 @@ class ReleaseDependencyResolver {
6971
repository::PartitionsCacheRepository partitions_cache_repository_;
7072
QuadsType quad_trees_with_protected_tiles_;
7173
cache::KeyValueCache::KeyListType keys_to_release_;
74+
std::vector<geo::TileKey> requested_tiles_;
7275
};
7376

7477
} // namespace read

0 commit comments

Comments
 (0)