@@ -64,13 +64,15 @@ DataResponse DataRepository::GetVersionedTile(
6464 storage_);
6565 auto response = repository.GetTile (request, version, context);
6666
67+ auto network_statistics = response.GetPayload ();
68+
6769 if (!response.IsSuccessful ()) {
6870 OLP_SDK_LOG_WARNING_F (
6971 kLogTag ,
7072 " GetVersionedDataTile partition request failed, hrn='%s', key='%s'" ,
7173 catalog_.ToCatalogHRNString ().c_str (),
7274 request.CreateKey (layer_id).c_str ());
73- return response.GetError ();
75+ return DataResponse ( response.GetError (), network_statistics );
7476 }
7577
7678 // Get the data using a data handle for requested tile
@@ -79,27 +81,39 @@ DataResponse DataRepository::GetVersionedTile(
7981 .WithDataHandle (partition.GetDataHandle ())
8082 .WithFetchOption (request.GetFetchOption ());
8183
82- return GetBlobData (layer_id, kBlobService , data_request, std::move (context));
84+ auto data_response =
85+ GetBlobData (layer_id, kBlobService , data_request, std::move (context));
86+ network_statistics += data_response.GetPayload ();
87+
88+ if (data_response) {
89+ return DataResponse (data_response.MoveResult (), network_statistics);
90+ } else {
91+ return DataResponse (data_response.GetError (), network_statistics);
92+ }
8393}
8494
8595BlobApi::DataResponse DataRepository::GetVersionedData (
8696 const std::string& layer_id, const DataRequest& request, int64_t version,
8797 client::CancellationContext context, const bool fail_on_cache_error) {
8898 if (request.GetDataHandle () && request.GetPartitionId ()) {
89- return {{ client::ErrorCode ::PreconditionFailed,
90- " Both data handle and partition id specified" }} ;
99+ return client::ApiError ::PreconditionFailed (
100+ " Both data handle and partition id specified" ) ;
91101 }
92102
93103 auto blob_request = request;
104+ client::NetworkStatistics network_statistics;
105+
94106 if (!request.GetDataHandle ()) {
95107 // get data handle for a partition to be queried
96108 PartitionsRepository repository (catalog_, layer_id, settings_,
97109 lookup_client_, storage_);
98110 auto partitions_response =
99111 repository.GetPartitionById (request, version, context);
100112
113+ network_statistics = partitions_response.GetPayload ();
114+
101115 if (!partitions_response.IsSuccessful ()) {
102- return partitions_response.GetError ();
116+ return DataResponse ( partitions_response.GetError (), network_statistics );
103117 }
104118
105119 const auto & partitions = partitions_response.GetResult ().GetPartitions ();
@@ -112,16 +126,25 @@ BlobApi::DataResponse DataRepository::GetVersionedData(
112126 catalog_.ToCatalogHRNString ().c_str (),
113127 request.CreateKey (layer_id, version).c_str ());
114128
115- return {{client::ErrorCode::NotFound, " Partition not found" }};
129+ return DataResponse (client::ApiError::NotFound (" Partition not found" ),
130+ network_statistics);
116131 }
117132
118133 blob_request.WithDataHandle (partitions.front ().GetDataHandle ());
119134 }
120135
121136 // finally get the data using a data handle
122- return repository::DataRepository::GetBlobData (
137+ auto data_response = repository::DataRepository::GetBlobData (
123138 layer_id, kBlobService , blob_request, std::move (context),
124139 fail_on_cache_error);
140+
141+ network_statistics += data_response.GetPayload ();
142+
143+ if (data_response) {
144+ return DataResponse (data_response.MoveResult (), network_statistics);
145+ } else {
146+ return DataResponse (data_response.GetError (), network_statistics);
147+ }
125148}
126149
127150BlobApi::DataResponse DataRepository::GetBlobData (
@@ -132,7 +155,7 @@ BlobApi::DataResponse DataRepository::GetBlobData(
132155 const auto & data_handle = request.GetDataHandle ();
133156
134157 if (!data_handle) {
135- return {{ client::ErrorCode ::PreconditionFailed, " Data handle is missing" }} ;
158+ return client::ApiError ::PreconditionFailed ( " Data handle is missing" ) ;
136159 }
137160
138161 NamedMutex mutex (storage_, catalog_.ToString () + layer + *data_handle);
@@ -157,8 +180,8 @@ BlobApi::DataResponse DataRepository::GetBlobData(
157180 OLP_SDK_LOG_INFO_F (
158181 kLogTag , " GetBlobData not found in cache, hrn='%s', key='%s'" ,
159182 catalog_.ToCatalogHRNString ().c_str (), data_handle->c_str ());
160- return {{ client::ErrorCode ::NotFound,
161- " CacheOnly: resource not found in cache" }} ;
183+ return client::ApiError ::NotFound (
184+ " CacheOnly: resource not found in cache" ) ;
162185 }
163186 }
164187
@@ -231,8 +254,8 @@ BlobApi::DataResponse DataRepository::GetVolatileData(
231254 const std::string& layer_id, const DataRequest& request,
232255 client::CancellationContext context, const bool fail_on_cache_error) {
233256 if (request.GetDataHandle () && request.GetPartitionId ()) {
234- return {{ client::ErrorCode ::PreconditionFailed,
235- " Both data handle and partition id specified" }} ;
257+ return client::ApiError ::PreconditionFailed (
258+ " Both data handle and partition id specified" ) ;
236259 }
237260
238261 auto blob_request = request;
@@ -255,7 +278,7 @@ BlobApi::DataResponse DataRepository::GetVolatileData(
255278 catalog_.ToCatalogHRNString ().c_str (),
256279 request.CreateKey (layer_id, boost::none).c_str ());
257280
258- return {{ client::ErrorCode ::NotFound, " Partition not found" }} ;
281+ return client::ApiError ::NotFound ( " Partition not found" ) ;
259282 }
260283
261284 blob_request.WithDataHandle (partitions.front ().GetDataHandle ());
0 commit comments