Python: add api for getting values back from key-value store.

This commit is contained in:
Kristian Bendiksen authored and Magne Sjaastad committed 2025-08-08 08:58:31 +02:00
1 parent 377d300767
commit 90d1555de3
7 files changed
+167 -20

No files matched your search

@@ -23,3 +23,22 @@ std::vector<float> RiaKeyValueStoreUtil::convertToFloatVector( const std::option
return floatVector;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<char> RiaKeyValueStoreUtil::convertToByteVector( const std::vector<float>& floatVec )
{
if ( floatVec.empty() ) return {};
// Calculate the total size needed for the byte array
size_t sizeInBytes = floatVec.size() * sizeof( float );
// Create a vector of bytes with the appropriate size
std::vector<char> byteVec( sizeInBytes );
// Copy the binary data from the float vector to the byte vector
std::memcpy( byteVec.data(), floatVec.data(), sizeInBytes );
return byteVec;
}
@@ -28,4 +28,5 @@ class RiaKeyValueStoreUtil
{
public:
static std::vector<float> convertToFloatVector( const std::optional<std::vector<char>>& input );
static std::vector<char> convertToByteVector( const std::vector<float>& floatVec );
};