Publish data to a volatile layer

If you need to store only the current version of data, use a volatile layer. As new data is published to the volatile layer, old data is overwritten.

To publish data to the volatile layer:

  1. Create the OlpClientSettings object.

    For instructions, see Create platform client settings.

  2. Create the VolatileLayerClient object with the HERE Resource Name (HRN) of the catalog that contains the layer and the platform client settings from step 1.

    auto client = olp::dataservice::write::VolatileLayerClient(
    olp::client::HRN{kCatalogHRN}, client_settings);
    
  3. Create the PublishPartitionDataRequest object with the data that you want to publish, layer ID, and partition ID.

    auto request = PublishPartitionDataRequest().WithData(buffer).WithLayerId(kLayer).WithPartitionId(kPartition);
    
  4. Call the PublishPartitionData method with the DataRequest parameter.

    auto futureResponse = client.PublishPartitionData(request);
    
  5. Wait for the PublishPartitionDataResponse future.

    auto response = futureResponse.GetFuture().get();
    

The PublishDataResponse object holds details of the completed operation and is used to determine operation success and access resultant data:

  • IsSuccessful() – if the operation is successful, returns true. Otherwise, returns false.
  • GetResult()– if the operation is successful, returns the following resultant data: olp::dataservice::write::PublishDataResult
  • GetError() – contains error information as a result of an error in the olp::client::ApiError object.
if (response.IsSuccessful()) {
    auto response_result = response.GetResult();
    // Handle success
} else {
    auto api_error = response.GetError();
    // Handle fail
}

results matching ""

    No results matching ""