Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/dataservice-cache-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ You can get data from a [versioned layer](https://www.here.com/docs/bundle/data-
olp::dataservice::read::VersionedLayerClient layer_client (
client::HRN catalog,
std::string layer_id,
boost::optional<int64_t> catalog_version,
porting::optional<int64_t> catalog_version,
client::OlpClientSettings settings);
```

Expand All @@ -102,7 +102,7 @@ You can get data from a [versioned layer](https://www.here.com/docs/bundle/data-
```cpp
auto request = olp::dataservice::read::DataRequest()
.WithPartitionId(first_partition_id)
.WithBillingTag(boost::none)
.WithBillingTag(olp::porting::none)
.WithFetchOption(olp::dataservice::read::FetchOptions::OnlineIfNotFound);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/dataservice-read-catalog-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ You can request any data version from a [versioned layer](https://www.here.com/d
olp::dataservice::read::VersionedLayerClient layer_client (
client::HRN catalog,
std::string layer_id,
boost::optional<int64_t> catalog_version,
porting::optional<int64_t> catalog_version,
client::OlpClientSettings settings);
```

Expand Down
31 changes: 16 additions & 15 deletions examples/ProtectedCacheExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ bool HandleDataResponse(
} // namespace

int RunExampleReadWithCache(const AccessKey& access_key,
const olp::cache::CacheSettings& cache_settings, const std::string& catalog) {
const olp::cache::CacheSettings& cache_settings,
const std::string& catalog) {
OLP_SDK_LOG_INFO_F(
kLogTag, "Mutable cache path is \"%s\"",
cache_settings.disk_path_mutable.get_value_or("none").c_str());
olp::porting::value_or(cache_settings.disk_path_mutable, "none").c_str());
OLP_SDK_LOG_INFO_F(
kLogTag, "Protected cache path is \"%s\"",
cache_settings.disk_path_protected.get_value_or("none").c_str());
olp::porting::value_or(cache_settings.disk_path_protected, "none")
.c_str());
// Create a task scheduler instance
std::shared_ptr<olp::thread::TaskScheduler> task_scheduler =
olp::client::OlpClientSettingsFactory::CreateDefaultTaskScheduler(1u);
Expand All @@ -84,8 +86,8 @@ int RunExampleReadWithCache(const AccessKey& access_key,
olp::authentication::AuthenticationCredentials::ReadFromFile();

// Initialize authentication settings.
olp::authentication::Settings settings{
read_credentials_result.get_value_or({access_key.id, access_key.secret})};
olp::authentication::Settings settings{olp::porting::value_or(
read_credentials_result, {access_key.id, access_key.secret})};
settings.task_scheduler = task_scheduler;
settings.network_request_handler = http_client;

Expand All @@ -108,23 +110,22 @@ int RunExampleReadWithCache(const AccessKey& access_key,

// Create appropriate layer client with HRN, layer name and settings.
olp::dataservice::read::VersionedLayerClient layer_client(
olp::client::HRN(catalog), first_layer_id, boost::none, client_settings);
olp::client::HRN(catalog), first_layer_id, olp::porting::none,
client_settings);

// Retrieve the partition data
// Create a DataRequest with appropriate LayerId and PartitionId
auto request = olp::dataservice::read::DataRequest()
.WithPartitionId(first_partition_id)
.WithBillingTag(boost::none);
if (cache_settings.disk_path_protected.is_initialized()) {
auto request =
olp::dataservice::read::DataRequest().WithPartitionId(first_partition_id);
if (cache_settings.disk_path_protected.has_value()) {
request.WithFetchOption(olp::dataservice::read::FetchOptions::CacheOnly);
}

// Run the DataRequest
auto future = layer_client.GetData(request);

// Wait for DataResponse
olp::dataservice::read::DataResponse data_response =
future.GetFuture().get();
olp::dataservice::read::DataResponse data_response = future.GetFuture().get();

// Compact mutable cache, so it can be used as protected cache
cache->Compact();
Expand All @@ -133,8 +134,8 @@ int RunExampleReadWithCache(const AccessKey& access_key,
return (HandleDataResponse(data_response) ? 0 : -1);
}

int RunExampleProtectedCache(const AccessKey& access_key, const std::string& catalog)
{
int RunExampleProtectedCache(const AccessKey& access_key,
const std::string& catalog) {
// Read data with mutable cache.
olp::cache::CacheSettings cache_settings;
cache_settings.disk_path_mutable =
Expand All @@ -145,6 +146,6 @@ int RunExampleProtectedCache(const AccessKey& access_key, const std::string& cat
}
// Read data with protected cache. Set mutable cache to none.
cache_settings.disk_path_protected = cache_settings.disk_path_mutable;
cache_settings.disk_path_mutable = boost::none;
cache_settings.disk_path_mutable = olp::porting::none;
return RunExampleReadWithCache(access_key, cache_settings, catalog);
}
19 changes: 9 additions & 10 deletions examples/ReadExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bool HandleDataResponse(
} // namespace

int RunExampleRead(const AccessKey& access_key, const std::string& catalog,
const boost::optional<int64_t>& catalog_version) {
const olp::porting::optional<int64_t>& catalog_version) {
// Create a task scheduler instance
std::shared_ptr<olp::thread::TaskScheduler> task_scheduler =
olp::client::OlpClientSettingsFactory::CreateDefaultTaskScheduler(1u);
Expand All @@ -135,8 +135,8 @@ int RunExampleRead(const AccessKey& access_key, const std::string& catalog,
olp::authentication::AuthenticationCredentials::ReadFromFile();

// Initialize authentication settings.
olp::authentication::Settings settings{
read_credentials_result.get_value_or({access_key.id, access_key.secret})};
olp::authentication::Settings settings{olp::porting::value_or(
read_credentials_result, {access_key.id, access_key.secret})};
settings.task_scheduler = task_scheduler;
settings.network_request_handler = http_client;

Expand All @@ -161,8 +161,8 @@ int RunExampleRead(const AccessKey& access_key, const std::string& catalog,
olp::client::HRN(catalog), client_settings);

// Create CatalogRequest
auto request =
olp::dataservice::read::CatalogRequest().WithBillingTag(boost::none);
auto request = olp::dataservice::read::CatalogRequest().WithBillingTag(
olp::porting::none);

// Run the CatalogRequest
auto future = catalog_client.GetCatalog(request);
Expand All @@ -184,8 +184,8 @@ int RunExampleRead(const AccessKey& access_key, const std::string& catalog,
if (!first_layer_id.empty()) {
// Retrieve the partitions metadata
// Create a PartitionsRequest with appropriate LayerId
auto request =
olp::dataservice::read::PartitionsRequest().WithBillingTag(boost::none);
auto request = olp::dataservice::read::PartitionsRequest().WithBillingTag(
olp::porting::none);

// Run the PartitionsRequest
auto future = layer_client.GetPartitions(request);
Expand All @@ -204,9 +204,8 @@ int RunExampleRead(const AccessKey& access_key, const std::string& catalog,
if (!first_partition_id.empty()) {
// Retrieve the partition data
// Create a DataRequest with appropriate LayerId and PartitionId
auto request = olp::dataservice::read::DataRequest()
.WithPartitionId(first_partition_id)
.WithBillingTag(boost::none);
auto request = olp::dataservice::read::DataRequest().WithPartitionId(
first_partition_id);

// Run the DataRequest
auto future = layer_client.GetData(request);
Expand Down
8 changes: 4 additions & 4 deletions examples/ReadExample.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "Examples.h"

#include <boost/optional.hpp>
#include <olp/core/porting/optional.h>

/**
* @brief Dataservice read example. Authenticate client using access key id and
Expand All @@ -33,6 +33,6 @@
* @param catalog_version The desired version of the catalog.
* @return result of publish data(0 - if succeed)
*/
int RunExampleRead(
const AccessKey& access_key, const std::string& catalog,
const boost::optional<int64_t>& catalog_version = boost::none);
int RunExampleRead(const AccessKey& access_key, const std::string& catalog,
const olp::porting::optional<int64_t>& catalog_version =
olp::porting::none);
7 changes: 3 additions & 4 deletions examples/StreamLayerReadExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ int GetDataFromMessages(dataread::StreamLayerClient& client,
auto handle = message.GetMetaData().GetDataHandle();
if (handle) {
OLP_SDK_LOG_INFO_F(kLogTag, "Message data: handle - %s, size - %lu",
handle.get().c_str(),
message.GetMetaData().GetDataSize().get());
handle->c_str(), *message.GetMetaData().GetDataSize());
// use GetData(const model::Message& message) with message instance to
// request actual data with data handle.
auto message_future = client.GetData(message);
Expand All @@ -73,14 +72,14 @@ int GetDataFromMessages(dataread::StreamLayerClient& client,
OLP_SDK_LOG_WARNING_F(kLogTag,
"Failed to get data for data handle %s - HTTP "
"Status: %d Message: %s",
handle.get().c_str(),
handle->c_str(),
message_result.GetError().GetHttpStatusCode(),
message_result.GetError().GetMessage().c_str());
continue;
}
auto message_data = message_result.MoveResult();
OLP_SDK_LOG_INFO_F(kLogTag, "GetData for %s successful: size - %lu",
handle.get().c_str(), message_data->size());
handle->c_str(), message_data->size());
} else {
// If data is less than 1 MB, the data content published directly in the
// metadata and encoded in Base64.
Expand Down
16 changes: 8 additions & 8 deletions examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "Options.h"
#include "ProtectedCacheExample.h"
#include "ReadExample.h"
#include "WriteExample.h"
#include "StreamLayerReadExample.h"
#include "WriteExample.h"

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -68,7 +68,7 @@ int RequiredArgumentError(const tools::Option& arg) {
}
int ParseArguments(const int argc, char** argv, AccessKey& access_key,
std::string& catalog,
boost::optional<int64_t>& catalog_version,
olp::porting::optional<int64_t>& catalog_version,
std::string& layer_id,
olp::dataservice::read::SubscribeRequest::SubscriptionMode&
subscription_mode) {
Expand Down Expand Up @@ -128,7 +128,7 @@ int ParseArguments(const int argc, char** argv, AccessKey& access_key,
if (ss.fail() || !ss.eof()) {
std::cout << "invalid catalog version value -- '" << *it
<< "', but int64 is expected." << std::endl;
catalog_version = boost::none;
catalog_version = olp::porting::none;
}
} else if (IsMatch(*it, tools::kLayerIdOption)) {
if (++it == arguments.end()) {
Expand Down Expand Up @@ -168,7 +168,7 @@ int ParseArguments(const int argc, char** argv, AccessKey& access_key,

int RunExamples(const AccessKey& access_key, int examples_to_run,
const std::string& catalog,
const boost::optional<int64_t>& catalog_version,
const olp::porting::optional<int64_t>& catalog_version,
const std::string& layer_id,
olp::dataservice::read::SubscribeRequest::SubscriptionMode
subscription_mode) {
Expand Down Expand Up @@ -210,10 +210,10 @@ int RunExamples(const AccessKey& access_key, int examples_to_run,
int main(int argc, char** argv) {
AccessKey access_key{}; // You can specify your here.access.key.id
// and here.access.key.secret
std::string catalog; // the HRN of the catalog to which you to publish data
std::string layer_id; // the of the layer inside the catalog to which you
// want to publish data
boost::optional<int64_t> catalog_version; // version of the catalog.
std::string catalog; // the HRN of the catalog to which you to publish data
std::string layer_id; // the of the layer inside the catalog to which you
// want to publish data
olp::porting::optional<int64_t> catalog_version; // version of the catalog.
auto subscription_mode =
olp::dataservice::read::SubscribeRequest::SubscriptionMode::
kSerial; // subscription mode for read stream layer example
Expand Down
3 changes: 1 addition & 2 deletions tests/common/PlatformUrlsGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
#include "PlatformUrlsGenerator.h"

#include <algorithm>
#include <cassert>
#include <utility>

#include <olp/core/utils/Url.h>
#include <olp/dataservice/read/model/Partitions.h>
#include <olp/dataservice/read/model/VersionResponse.h>
#include "ApiDefaultResponses.h"

namespace {
Expand Down
22 changes: 11 additions & 11 deletions tests/common/ReadDefaultResponses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ void FillSubQuads(std::int32_t depth, std::vector<std::uint16_t>& sub_quads_) {
sub_quads_.insert(sub_quads_.end(), layer_ids.begin(), layer_ids.end());
}

mockserver::TileMetadata MakePartition(std::string data_handle,
boost::optional<int32_t> version) {
mockserver::TileMetadata MakePartition(
std::string data_handle, olp::porting::optional<int32_t> version) {
mockserver::TileMetadata partition;
partition.data_handle = std::move(data_handle);
partition.version = version;
Expand Down Expand Up @@ -173,17 +173,17 @@ std::string ReadDefaultResponses::GenerateQuadTreeResponse(
}

QuadTreeBuilder::QuadTreeBuilder(olp::geo::TileKey root_tile,
boost::optional<int32_t> version)
olp::porting::optional<int32_t> version)
: root_tile_(root_tile), base_version_(version) {}

QuadTreeBuilder& QuadTreeBuilder::WithParent(olp::geo::TileKey parent,
std::string data_handle,
boost::optional<int32_t> version) {
QuadTreeBuilder& QuadTreeBuilder::WithParent(
olp::geo::TileKey parent, std::string data_handle,
olp::porting::optional<int32_t> version) {
assert(root_tile_.IsChildOf(parent));

// Make sure to set version when the base_version is set
if (version != boost::none) {
assert(base_version_ != boost::none);
if (version != olp::porting::none) {
assert(base_version_ != olp::porting::none);
} else if (base_version_) {
version = base_version_;
}
Expand All @@ -208,11 +208,11 @@ QuadTreeBuilder& QuadTreeBuilder::FillParents() {

QuadTreeBuilder& QuadTreeBuilder::WithSubQuad(
olp::geo::TileKey tile, std::string datahandle,
boost::optional<int32_t> version) {
olp::porting::optional<int32_t> version) {
assert(tile.IsChildOf(root_tile_) || tile == root_tile_);
assert((tile.Level() - root_tile_.Level()) <= 4);
if (version != boost::none) {
assert(base_version_ != boost::none);
if (version != olp::porting::none) {
assert(base_version_ != olp::porting::none);
}

auto origin = root_tile_.ChangedLevelTo(tile.Level());
Expand Down
16 changes: 9 additions & 7 deletions tests/common/ReadDefaultResponses.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace mockserver {

struct TileMetadata {
std::string data_handle;
boost::optional<int32_t> version;
olp::porting::optional<int32_t> version;
std::string crc;
std::string checksum;
int32_t data_size{0};
Expand Down Expand Up @@ -87,23 +87,25 @@ class QuadTreeBuilder {
public:
// if version is set, the quad tree is considered to be a versioned type.
explicit QuadTreeBuilder(olp::geo::TileKey root_tile,
boost::optional<int32_t> base_version);
olp::porting::optional<int32_t> base_version);

QuadTreeBuilder& WithParent(olp::geo::TileKey parent, std::string data_handle,
boost::optional<int32_t> version = boost::none);
QuadTreeBuilder& WithParent(
olp::geo::TileKey parent, std::string data_handle,
olp::porting::optional<int32_t> version = olp::porting::none);
QuadTreeBuilder& FillParents();

// tile is represented as a normal tilekey
QuadTreeBuilder& WithSubQuad(olp::geo::TileKey tile, std::string datahandle,
boost::optional<int32_t> version = boost::none);
QuadTreeBuilder& WithSubQuad(
olp::geo::TileKey tile, std::string datahandle,
olp::porting::optional<int32_t> version = olp::porting::none);

std::string BuildJson() const;

olp::geo::TileKey Root() const;

protected:
olp::geo::TileKey root_tile_;
boost::optional<int32_t> base_version_;
olp::porting::optional<int32_t> base_version_;

std::map<std::uint64_t, TileMetadata> sub_quads_;
std::map<std::uint64_t, TileMetadata> parent_quads_;
Expand Down
3 changes: 2 additions & 1 deletion tests/functional/network/ConcurrencyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ constexpr auto kTimeout = std::chrono::seconds(3);

class ConcurrencyTest : public NetworkTestBase {
public:
void AddExpectation(int i, boost::optional<int32_t> delay_ms = boost::none) {
void AddExpectation(
int i, olp::porting::optional<int32_t> delay_ms = olp::porting::none) {
const auto url = kApiBase + std::to_string(i);
mock_server_client_->MockResponse(
"GET", url, mockserver::ReadDefaultResponses::GenerateData(), 200, true,
Expand Down
Loading
Loading