@@ -118,7 +118,7 @@ client::CancellationToken VersionedLayerClientImpl::StreamLayerPartitions(
118
118
auto async_stream = std::make_shared<repository::AsyncJsonStream>();
119
119
120
120
auto request_task =
121
- [=](client::CancellationContext context) -> client::ApiNoResponse {
121
+ [=](const client::CancellationContext& context) -> client::ApiNoResponse {
122
122
auto version_response =
123
123
GetVersion (boost::none, FetchOptions::OnlineIfNotFound, context);
124
124
if (!version_response.IsSuccessful ()) {
@@ -145,8 +145,8 @@ client::CancellationToken VersionedLayerClientImpl::StreamLayerPartitions(
145
145
repository::PartitionsRepository repository (catalog_, layer_id_, settings_,
146
146
lookup_client_, mutex_storage_);
147
147
148
- return repository.ParsePartitionsStream (async_stream,
149
- partition_stream_callback, context);
148
+ return repository.ParsePartitionsStream (
149
+ async_stream, partition_stream_callback, std::move ( context) );
150
150
};
151
151
152
152
auto parse_task_token =
@@ -166,14 +166,13 @@ VersionedLayerClientImpl::GetPartitions(PartitionsRequest partitions_request) {
166
166
[promise](PartitionsResponse response) {
167
167
promise->set_value (std::move (response));
168
168
});
169
- return client::CancellableFuture<PartitionsResponse>(std::move (cancel_token),
170
- std::move (promise));
169
+ return {cancel_token, std::move (promise)};
171
170
}
172
171
173
172
client::CancellationToken VersionedLayerClientImpl::GetData (
174
173
DataRequest request, DataResponseCallback callback) {
175
174
auto data_task =
176
- [=](client::CancellationContext context) mutable -> DataResponse {
175
+ [=](const client::CancellationContext& context) mutable -> DataResponse {
177
176
if (request.GetFetchOption () == CacheWithUpdate) {
178
177
return client::ApiError::InvalidArgument (
179
178
" CacheWithUpdate option can not be used for versioned layer" );
@@ -201,8 +200,8 @@ client::CancellationToken VersionedLayerClientImpl::GetData(
201
200
202
201
client::CancellationToken VersionedLayerClientImpl::QuadTreeIndex (
203
202
TileRequest tile_request, PartitionsResponseCallback callback) {
204
- auto data_task =
205
- [=](client::CancellationContext context) mutable -> PartitionsResponse {
203
+ auto data_task = [=]( const client::CancellationContext& context) mutable
204
+ -> PartitionsResponse {
206
205
if (!tile_request.GetTileKey ().IsValid ()) {
207
206
return client::ApiError::InvalidArgument (" Tile key is invalid" );
208
207
}
@@ -224,20 +223,19 @@ client::CancellationToken VersionedLayerClientImpl::QuadTreeIndex(
224
223
repository::PartitionsRepository repository (catalog_, layer_id_, settings_,
225
224
lookup_client_, mutex_storage_);
226
225
227
- std::vector<std::string> additional_fields = {PartitionsRequest::kChecksum ,
228
- PartitionsRequest::kCrc ,
229
- PartitionsRequest::kDataSize };
230
- auto partition_response = repository.GetTile (tile_request, version, context,
231
- std::move (additional_fields));
226
+ static const std::vector<std::string> additional_fields = {
227
+ PartitionsRequest::kChecksum , PartitionsRequest::kCrc ,
228
+ PartitionsRequest::kDataSize };
229
+
230
+ auto partition_response =
231
+ repository.GetTile (tile_request, version, context, additional_fields);
232
232
if (!partition_response) {
233
- return PartitionsResponse (partition_response.GetError (),
234
- partition_response.GetPayload ());
233
+ return {partition_response.GetError (), partition_response.GetPayload ()};
235
234
}
236
235
237
236
model::Partitions result;
238
237
result.GetMutablePartitions ().emplace_back (partition_response.MoveResult ());
239
- return PartitionsResponse (std::move (result),
240
- partition_response.GetPayload ());
238
+ return {std::move (result), partition_response.GetPayload ()};
241
239
};
242
240
243
241
return task_sink_.AddTask (std::move (data_task), std::move (callback),
@@ -251,8 +249,7 @@ client::CancellableFuture<DataResponse> VersionedLayerClientImpl::GetData(
251
249
GetData (std::move (data_request), [promise](DataResponse response) {
252
250
promise->set_value (std::move (response));
253
251
});
254
- return client::CancellableFuture<DataResponse>(std::move (cancel_token),
255
- std::move (promise));
252
+ return {cancel_token, std::move (promise)};
256
253
}
257
254
258
255
client::CancellationToken VersionedLayerClientImpl::PrefetchPartitions (
@@ -291,7 +288,7 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchPartitions(
291
288
return ;
292
289
}
293
290
294
- auto billing_tag = request.GetBillingTag ();
291
+ const auto & billing_tag = request.GetBillingTag ();
295
292
296
293
auto response = GetVersion (billing_tag, OnlineIfNotFound, context);
297
294
@@ -366,7 +363,8 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchPartitions(
366
363
version, std::move (inner_context), true );
367
364
};
368
365
369
- auto append_result = [](ExtendedDataResponse response, std::string item,
366
+ auto append_result = [](const ExtendedDataResponse& response,
367
+ std::string item,
370
368
PrefetchPartitionsResult& prefetch_result) {
371
369
if (response.IsSuccessful ()) {
372
370
prefetch_result.AddPartition (std::move (item));
@@ -406,8 +404,7 @@ VersionedLayerClientImpl::PrefetchPartitions(
406
404
promise->set_value (std::move (response));
407
405
},
408
406
std::move (status_callback));
409
- return client::CancellableFuture<PrefetchPartitionsResponse>(cancel_token,
410
- promise);
407
+ return {cancel_token, promise};
411
408
}
412
409
413
410
client::CancellationToken VersionedLayerClientImpl::PrefetchTiles (
@@ -420,7 +417,7 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchTiles(
420
417
421
418
execution_context.ExecuteOrCancelled ([&]() -> client::CancellationToken {
422
419
return task_sink_.AddTask (
423
- [=](client::CancellationContext context) mutable -> void {
420
+ [=](const client::CancellationContext& context) mutable {
424
421
if (context.IsCancelled ()) {
425
422
callback (ApiError::Cancelled ());
426
423
return ;
@@ -507,27 +504,28 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchTiles(
507
504
}
508
505
};
509
506
510
- auto query = [=](geo::TileKey root,
511
- client::CancellationContext inner_context) mutable {
512
- auto response = repository.GetVersionedSubQuads (
513
- root, kQuadTreeDepth , version, inner_context);
514
-
515
- if (response.IsSuccessful () && aggregation_enabled) {
516
- const auto & tiles = response.GetResult ();
517
- auto network_stats = repository.LoadAggregatedSubQuads (
518
- root,
519
- request_only_input_tiles
520
- ? repository.FilterTileKeysByList (request, tiles)
521
- : repository.FilterTileKeysByLevel (request, tiles),
522
- version, inner_context);
523
-
524
- // append network statistics
525
- network_stats += GetNetworkStatistics (response);
526
- response = {response.MoveResult (), network_stats};
527
- }
507
+ auto query =
508
+ [=](geo::TileKey root,
509
+ const client::CancellationContext& inner_context) mutable {
510
+ auto response = repository.GetVersionedSubQuads (
511
+ root, kQuadTreeDepth , version, inner_context);
512
+
513
+ if (response.IsSuccessful () && aggregation_enabled) {
514
+ const auto & tiles = response.GetResult ();
515
+ auto network_stats = repository.LoadAggregatedSubQuads (
516
+ root,
517
+ request_only_input_tiles
518
+ ? repository.FilterTileKeysByList (request, tiles)
519
+ : repository.FilterTileKeysByLevel (request, tiles),
520
+ version, inner_context);
521
+
522
+ // append network statistics
523
+ network_stats += GetNetworkStatistics (response);
524
+ response = {response.MoveResult (), network_stats};
525
+ }
528
526
529
- return response;
530
- };
527
+ return response;
528
+ };
531
529
532
530
auto & billing_tag = request.GetBillingTag ();
533
531
@@ -569,10 +567,10 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchTiles(
569
567
return root.first ;
570
568
});
571
569
572
- auto append_result = [](ExtendedDataResponse response,
570
+ auto append_result = [](const ExtendedDataResponse& response,
573
571
geo::TileKey item,
574
572
PrefetchTilesResult& prefetch_result) {
575
- if (response. IsSuccessful () ) {
573
+ if (response) {
576
574
prefetch_result.emplace_back (std::make_shared<PrefetchTileResult>(
577
575
item, PrefetchTileNoError ()));
578
576
} else {
@@ -587,7 +585,7 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchTiles(
587
585
std::move (callback), std::move (status_callback));
588
586
589
587
return PrefetchTilesHelper::Prefetch (
590
- std::move (download_job), std::move ( roots) , std::move (query),
588
+ std::move (download_job), roots, std::move (query),
591
589
std::move (filter), task_sink_, request.GetPriority (),
592
590
execution_context);
593
591
},
@@ -607,8 +605,7 @@ VersionedLayerClientImpl::PrefetchTiles(
607
605
promise->set_value (std::move (response));
608
606
},
609
607
std::move (status_callback));
610
- return client::CancellableFuture<PrefetchTilesResponse>(cancel_token,
611
- promise);
608
+ return {cancel_token, promise};
612
609
}
613
610
614
611
CatalogVersionResponse VersionedLayerClientImpl::GetVersion (
@@ -678,8 +675,7 @@ client::CancellableFuture<DataResponse> VersionedLayerClientImpl::GetData(
678
675
GetData (std::move (request), [promise](DataResponse response) {
679
676
promise->set_value (std::move (response));
680
677
});
681
- return client::CancellableFuture<DataResponse>(std::move (cancel_token),
682
- std::move (promise));
678
+ return {cancel_token, std::move (promise)};
683
679
}
684
680
685
681
bool VersionedLayerClientImpl::RemoveFromCache (
@@ -812,10 +808,10 @@ bool VersionedLayerClientImpl::IsCached(const geo::TileKey& tile,
812
808
813
809
client::CancellationToken VersionedLayerClientImpl::GetAggregatedData (
814
810
TileRequest request, AggregatedDataResponseCallback callback) {
815
- auto data_task =
816
- [=](client::CancellationContext context) -> AggregatedDataResponse {
811
+ auto data_task = [=]( const client::CancellationContext& context)
812
+ -> AggregatedDataResponse {
817
813
const auto fetch_option = request.GetFetchOption ();
818
- const auto billing_tag = request.GetBillingTag ();
814
+ const auto & billing_tag = request.GetBillingTag ();
819
815
820
816
if (fetch_option == CacheWithUpdate) {
821
817
return client::ApiError::InvalidArgument (
@@ -832,28 +828,20 @@ client::CancellationToken VersionedLayerClientImpl::GetAggregatedData(
832
828
}
833
829
834
830
auto version = version_response.GetResult ().GetVersion ();
835
- repository::PartitionsRepository repository (catalog_, layer_id_, settings_,
836
- lookup_client_, mutex_storage_);
837
- auto partition_response =
838
- repository .GetAggregatedTile (request, version, context);
831
+ repository::PartitionsRepository partition_repository (
832
+ catalog_, layer_id_, settings_, lookup_client_, mutex_storage_);
833
+ const auto & partition_response =
834
+ partition_repository .GetAggregatedTile (request, version, context);
839
835
if (!partition_response.IsSuccessful ()) {
840
- return AggregatedDataResponse (partition_response.GetError (),
841
- partition_response.GetPayload ());
836
+ return {partition_response.GetError (), partition_response.GetPayload ()};
842
837
}
843
838
844
- const auto & fetch_partition = partition_response.GetResult ();
845
- const auto fetch_tile_key =
846
- geo::TileKey::FromHereTile (fetch_partition.GetPartition ());
847
-
848
- auto data_request = DataRequest ()
849
- .WithDataHandle (fetch_partition.GetDataHandle ())
850
- .WithFetchOption (fetch_option)
851
- .WithBillingTag (billing_tag);
839
+ const auto & partition = partition_response.GetResult ();
852
840
853
841
repository::DataRepository data_repository (catalog_, settings_,
854
842
lookup_client_, mutex_storage_);
855
- auto data_response = data_repository.GetVersionedData (
856
- layer_id_, data_request, version , context,
843
+ auto data_response = data_repository.GetBlobData (
844
+ layer_id_, " blob " , partition, fetch_option, billing_tag , context,
857
845
settings_.propagate_all_cache_errors );
858
846
859
847
const auto aggregated_network_statistics =
@@ -863,18 +851,15 @@ client::CancellationToken VersionedLayerClientImpl::GetAggregatedData(
863
851
OLP_SDK_LOG_WARNING_F (
864
852
kLogTag ,
865
853
" GetAggregatedData: failed to load data, key=%s, data_handle=%s" ,
866
- fetch_tile_key.ToHereTile ().c_str (),
867
- fetch_partition.GetDataHandle ().c_str ());
868
- return AggregatedDataResponse (data_response.GetError (),
869
- aggregated_network_statistics);
854
+ partition.GetPartition ().c_str (), partition.GetDataHandle ().c_str ());
855
+ return {data_response.GetError (), aggregated_network_statistics};
870
856
}
871
857
872
858
AggregatedDataResult result;
873
- result.SetTile (fetch_tile_key );
859
+ result.SetTile (geo::TileKey::FromHereTile (partition. GetPartition ()) );
874
860
result.SetData (data_response.MoveResult ());
875
861
876
- return AggregatedDataResponse (std::move (result),
877
- aggregated_network_statistics);
862
+ return {result, aggregated_network_statistics};
878
863
};
879
864
880
865
return task_sink_.AddTask (std::move (data_task), std::move (callback),
@@ -888,8 +873,7 @@ VersionedLayerClientImpl::GetAggregatedData(TileRequest request) {
888
873
std::move (request), [promise](AggregatedDataResponse response) {
889
874
promise->set_value (std::move (response));
890
875
});
891
- return client::CancellableFuture<AggregatedDataResponse>(
892
- std::move (cancel_token), std::move (promise));
876
+ return {cancel_token, std::move (promise)};
893
877
}
894
878
895
879
bool VersionedLayerClientImpl::Protect (const TileKeys& tiles) {
0 commit comments