Skip to content

Commit 6dbc3b9

Browse files
authored
VolatileLayerClient PrefetchTiles API. (#759)
The method loads data for specified tile and levels range. This is third and the last part of prefetch update of VolatileLayerClient. Change only connects public API with impl and add integration tests for it. Resolves: OLPEDGE-794 Signed-off-by: Kostiantyn Zvieriev <[email protected]>
1 parent 828c334 commit 6dbc3b9

File tree

4 files changed

+522
-0
lines changed

4 files changed

+522
-0
lines changed

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/VolatileLayerClient.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <olp/core/geo/tiling/TileKey.h>
3030
#include <olp/dataservice/read/DataRequest.h>
3131
#include <olp/dataservice/read/PartitionsRequest.h>
32+
#include <olp/dataservice/read/PrefetchTilesRequest.h>
3233
#include <olp/dataservice/read/Types.h>
3334

3435
namespace olp {
@@ -194,6 +195,53 @@ class DATASERVICE_READ_API VolatileLayerClient final {
194195
*/
195196
bool RemoveFromCache(const geo::TileKey& tile);
196197

198+
/**
199+
* @brief Prefetches a set of tiles asynchronously.
200+
*
201+
* This method recursively downloads all tile keys from the `min_level`
202+
* parameter to the `max_level` parameter of the \c PrefetchTilesRequest
203+
* object for the given root tiles. If min_level/max_level are the same or
204+
* default, only tiles listed in \c PrefetchTilesRequest will be downloaded.
205+
* Only tiles will be downloaded which are not already present in the cache,
206+
* this helps reduce the network load.
207+
*
208+
* @note This method does not guarantee that all tiles are available offline
209+
* as the cache might overflow, and data might be evicted at any point.
210+
*
211+
* @param request The `PrefetchTilesRequest` instance that contains
212+
* a complete set of request parameters.
213+
* @param callback The `PrefetchTilesResponseCallback` object that is invoked
214+
* if the `PrefetchTilesResult` instance is available or an error is
215+
* encountered.
216+
*
217+
* @return A token that can be used to cancel this request.
218+
*/
219+
client::CancellationToken PrefetchTiles(
220+
PrefetchTilesRequest request, PrefetchTilesResponseCallback callback);
221+
222+
/**
223+
* @brief Prefetches a set of tiles asynchronously.
224+
*
225+
* This method recursively downloads all tile keys from the `min_level`
226+
* parameter to the `max_level` parameter of the \c PrefetchTilesRequest
227+
* object for the given root tiles. If min_level/max_level are the same or
228+
* default, only tiles listed in \c PrefetchTilesRequest will be downloaded.
229+
* Only tiles will be downloaded which are not already present in the cache,
230+
* this helps reduce the network load.
231+
*
232+
* @note This method does not guarantee that all tiles are available offline
233+
* as the cache might overflow, and data might be evicted at any point.
234+
*
235+
* @param request The `PrefetchTilesRequest` instance that contains
236+
* a complete set of request parameters.
237+
*
238+
* @return `CancellableFuture` that contains the `PrefetchTilesResponse`
239+
* instance with data or an error. You can also use `CancellableFuture` to
240+
* cancel this request.
241+
*/
242+
client::CancellableFuture<PrefetchTilesResponse> PrefetchTiles(
243+
PrefetchTilesRequest request);
244+
197245
private:
198246
std::unique_ptr<VolatileLayerClientImpl> impl_;
199247
};

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ bool VolatileLayerClient::RemoveFromCache(const geo::TileKey& tile) {
7272
return impl_->RemoveFromCache(tile);
7373
}
7474

75+
client::CancellationToken VolatileLayerClient::PrefetchTiles(
76+
PrefetchTilesRequest request, PrefetchTilesResponseCallback callback) {
77+
return impl_->PrefetchTiles(std::move(request), std::move(callback));
78+
}
79+
80+
client::CancellableFuture<PrefetchTilesResponse>
81+
VolatileLayerClient::PrefetchTiles(PrefetchTilesRequest request) {
82+
return impl_->PrefetchTiles(std::move(request));
83+
}
7584
} // namespace read
7685
} // namespace dataservice
7786
} // namespace olp

tests/integration/olp-cpp-sdk-dataservice-read/HttpResponses.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@
223223
#define URL_QUADKEYS_92259 \
224224
R"(https://query.data.api.platform.here.com/query/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/versions/4/quadkeys/92259/depths/4)"
225225

226+
#define URL_QUADKEYS_VOLATILE_23618364 \
227+
R"(https://query.data.api.platform.here.com/query/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/quadkeys/23618364/depths/0)"
228+
229+
#define URL_QUADKEYS_VOLATILE_1476147 \
230+
R"(https://query.data.api.platform.here.com/query/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/quadkeys/1476147/depths/2)"
231+
232+
#define URL_QUADKEYS_VOLATILE_5904591 \
233+
R"(https://query.data.api.platform.here.com/query/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/quadkeys/5904591/depths/1)"
234+
235+
#define URL_QUADKEYS_VOLATILE_369036 \
236+
R"(https://query.data.api.platform.here.com/query/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/quadkeys/369036/depths/0)"
237+
238+
#define URL_QUADKEYS_VOLATILE_92259 \
239+
R"(https://query.data.api.platform.here.com/query/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/quadkeys/92259/depths/4)"
240+
226241
#define URL_QUERY_PARTITION_23618365 \
227242
R"(https://query.data.api.platform.here.com/query/v1/catalogs/)"+GetTestCatalog()+R"(/layers/hype-test-prefetch/partitions?partition=23618365&version=4)"
228243

@@ -253,6 +268,27 @@
253268
#define URL_BLOB_DATA_PREFETCH_7 \
254269
R"(https://blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/data/95c5c703-e00e-4c38-841e-e419367474f1)"
255270

271+
#define URL_BLOB_DATA_VOLATILE_PREFETCH_1 \
272+
R"(https://volatile-blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/data/a7a1afdf-db7e-4833-9627-d38bee6e2f81)"
273+
274+
#define URL_BLOB_DATA_VOLATILE_PREFETCH_2 \
275+
R"(https://volatile-blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/data/e119d20e-c7c6-4563-ae88-8aa5c6ca75c3)"
276+
277+
#define URL_BLOB_DATA_VOLATILE_PREFETCH_3 \
278+
R"(https://volatile-blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/data/f9a9fd8e-eb1b-48e5-bfdb-4392b3826443)"
279+
280+
#define URL_BLOB_DATA_VOLATILE_PREFETCH_4 \
281+
R"(https://volatile-blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/data/9d515348-afce-44e8-bc6f-3693cfbed104)"
282+
283+
#define URL_BLOB_DATA_VOLATILE_PREFETCH_5 \
284+
R"(https://volatile-blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/data/f9a9fd8e-eb1b-48e5-bfdb-4392b3826443)"
285+
286+
#define URL_BLOB_DATA_VOLATILE_PREFETCH_6 \
287+
R"(https://volatile-blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/data/e83b397a-2be5-45a8-b7fb-ad4cb3ea13b1)"
288+
289+
#define URL_BLOB_DATA_VOLATILE_PREFETCH_7 \
290+
R"(https://volatile-blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/hype-test-prefetch/data/95c5c703-e00e-4c38-841e-e419367474f1)"
291+
256292
#define URL_VOLATILE_BLOB_DATA \
257293
R"(https://volatile-blob-ireland.data.api.platform.here.com/blobstore/v1/catalogs/hereos-internal-test-v2/layers/testlayer_volatile/data/4eed6ed1-0d32-43b9-ae79-043cb4256410)"
258294

0 commit comments

Comments
 (0)