@@ -223,6 +223,77 @@ class Client : public SRObject
223
223
const SRTensorType type,
224
224
const SRMemoryLayout mem_layout);
225
225
226
+ /* !
227
+ * \brief Puts a byte string into the database
228
+ * \details The provided byte string is placed into the database
229
+ * without any type associated with the bytes.
230
+ * The final key under which the bytes are stored
231
+ * may be formed by applying a prefix to the supplied
232
+ * name. See use_bytes_ensemble_prefix() for
233
+ * more details.
234
+ * \param name The name for referencing the bytes in the database
235
+ * \param data The data
236
+ * \param n_bytes The number of bytes in the provided data
237
+ * \throw SmartRedis::Exception if put bytes command fails
238
+ */
239
+ void put_bytes (const std::string& name,
240
+ const void * bytes,
241
+ const size_t n_bytes);
242
+
243
+ /* !
244
+ * \brief Retrieve bytes from the database and place into a new
245
+ * memory buffer
246
+ * \details The key used to locate the stored bytes
247
+ * may be formed by applying a prefix to the supplied
248
+ * name. See set_data_source()
249
+ * and use_bytes_ensemble_prefix() for more details.
250
+ * Unlike other "get" operations in the client, the
251
+ * the byte data memeory is allocated but not managed
252
+ * by the client. The caller is responsible for invoking
253
+ * free() on the returned memory.
254
+ * \param name The name for referencing the bytes in the database
255
+ * \param data A user-provided pointer that will be modified to
256
+ * point to a new block of memory containing the bytes
257
+ * \param n_bytes A user-provided size_t variable that will be modified
258
+ * to indicate the total number of bytes.
259
+ * \throw SmartRedis::Exception if get bytes command fails
260
+ */
261
+ void get_bytes (const std::string& name,
262
+ void *& data,
263
+ size_t & n_bytes);
264
+
265
+ /* !
266
+ * \brief Retrieve bytes from the database and place into memory
267
+ * provided by the caller
268
+ * \details The key used to locate the stored bytes
269
+ * may be formed by applying a prefix to the supplied
270
+ * name. See set_data_source()
271
+ * and use_bytes_ensemble_prefix() for more details.
272
+ * \param name The name for referencing the bytes in the database
273
+ * \param data A buffer into which to place byte data
274
+ * \param n_bytes The number of bytes in the provided memory block
275
+ * \param n_used_bytes The number of bytes in the provided
276
+ * buffer that were used
277
+ * \throw SmartRedis::Exception if unpack bytes command fails or
278
+ * the number of provided bytes is less than the retrieved
279
+ * number of bytes
280
+ */
281
+ void unpack_bytes (const std::string& name,
282
+ void * data,
283
+ const size_t n_bytes,
284
+ size_t & n_used_bytes);
285
+
286
+ /* !
287
+ * \brief Delete bytes from the database
288
+ * \details The key used to locate the bytes to be
289
+ * deleted may be formed by applying a prefix to the
290
+ * supplied name. See set_data_source()
291
+ * and use_bytes_ensemble_prefix() for more details.
292
+ * \param name The name of the bytes to delete
293
+ * \throw SmartRedis::Exception if delete bytes command fails
294
+ */
295
+ void delete_bytes (const std::string& name);
296
+
226
297
/* !
227
298
* \brief Retrieve the tensor data, dimensions, and type for the
228
299
* provided tensor key. This function will allocate and retain
@@ -795,18 +866,6 @@ class Client : public SRObject
795
866
*/
796
867
bool key_exists (const std::string& key);
797
868
798
- /* !
799
- * \brief Check if a model (or script) key exists in the database
800
- * \details The model or script key used to check for existence
801
- * may be formed by applying a prefix to the supplied
802
- * name. See set_data_source()
803
- * and use_model_ensemble_prefix() for more details.
804
- * \param name The model/script name to be checked in the database
805
- * \returns Returns true if the model exists in the database
806
- * \throw SmartRedis::Exception if model exists command fails
807
- */
808
- bool model_exists (const std::string& name);
809
-
810
869
/* !
811
870
* \brief Check if a tensor key exists in the database
812
871
* \details The tensor key used to check for existence
@@ -831,6 +890,30 @@ class Client : public SRObject
831
890
*/
832
891
bool dataset_exists (const std::string& name);
833
892
893
+ /* !
894
+ * \brief Check if a model (or script) key exists in the database
895
+ * \details The model or script key used to check for existence
896
+ * may be formed by applying a prefix to the supplied
897
+ * name. See set_data_source()
898
+ * and use_model_ensemble_prefix() for more details.
899
+ * \param name The model/script name to be checked in the database
900
+ * \returns Returns true if the model exists in the database
901
+ * \throw SmartRedis::Exception if model exists command fails
902
+ */
903
+ bool model_exists (const std::string& name);
904
+
905
+ /* !
906
+ * \brief Check if bytes exists in the database
907
+ * \details The key used to check for existence
908
+ * may be formed by applying a prefix to the supplied
909
+ * name. See set_data_source()
910
+ * and use_bytes_ensemble_prefix() for more details.
911
+ * \param name The bytes name to be checked in the database
912
+ * \returns Returns true if the bytes exists in the database
913
+ * \throw SmartRedis::Exception if bytes exists command fails
914
+ */
915
+ bool bytes_exists (const std::string& name);
916
+
834
917
/* !
835
918
* \brief Check if a key exists in the database, repeating the check
836
919
* at a specified polling interval
@@ -903,6 +986,25 @@ class Client : public SRObject
903
986
int poll_frequency_ms,
904
987
int num_tries);
905
988
989
+ /* !
990
+ * \brief Check if bytes exists in the database, repeating
991
+ * the check at a specified polling interval
992
+ * \details The key used to check for existence
993
+ * may be formed by applying a prefix to the supplied
994
+ * name. See set_data_source()
995
+ * and use_bytes_ensemble_prefix() for more details.
996
+ * \param name The bytes name to be checked in the database
997
+ * \param poll_frequency_ms The time delay between checks,
998
+ * in milliseconds
999
+ * \param num_tries The total number of times to check for the name
1000
+ * \returns Returns true if the bytes is found within the
1001
+ * specified number of tries, otherwise false.
1002
+ * \throw SmartRedis::Exception if poll bytes command fails
1003
+ */
1004
+ bool poll_bytes (const std::string& name,
1005
+ int poll_frequency_ms,
1006
+ int num_tries);
1007
+
906
1008
/* !
907
1009
* \brief Set the data source, a key prefix for future operations.
908
1010
* \details When running multiple applications, such as an ensemble
@@ -1011,6 +1113,25 @@ class Client : public SRObject
1011
1113
*/
1012
1114
void use_list_ensemble_prefix (bool use_prefix);
1013
1115
1116
+ /* !
1117
+ * \brief Control whether bytes are prefixed
1118
+ * \details This function can be used to avoid key collisions in an
1119
+ * ensemble by prepending the string value from the
1120
+ * environment variable SSKEYIN and/or SSKEYOUT to
1121
+ * raw byte names. Prefixes will only be used if
1122
+ * they were previously set through the environment variables
1123
+ * SSKEYOUT and SSKEYIN. Keys for raw bytes created
1124
+ * before this function is called will not be retroactively
1125
+ * prefixed. By default, the client prefixes raw bytes
1126
+ * keys with the first prefix specified with the SSKEYIN
1127
+ * and SSKEYOUT environment variables.
1128
+ * \param use_prefix If set to true, all future operations
1129
+ * on raw bytes will use a prefix, if available.
1130
+ * \throw SmartRedis::Exception for failed activation of
1131
+ * raw byte prefixing
1132
+ */
1133
+ void use_bytes_ensemble_prefix (bool use_prefix);
1134
+
1014
1135
/* !
1015
1136
* \brief Returns information about the given database node
1016
1137
* \param address The address of the database node (host:port)
@@ -1569,6 +1690,12 @@ class Client : public SRObject
1569
1690
*/
1570
1691
bool _use_list_prefix;
1571
1692
1693
+ /* !
1694
+ * \brief Flag determining whether prefixes should be used
1695
+ * for raw byte keys.
1696
+ */
1697
+ bool _use_bytes_prefix;
1698
+
1572
1699
/* !
1573
1700
* \brief Our configuration options, used to access runtime settings
1574
1701
*/
@@ -1664,6 +1791,15 @@ class Client : public SRObject
1664
1791
*/
1665
1792
inline std::string _build_list_key (const std::string& list_name,
1666
1793
bool on_db);
1794
+ /* !
1795
+ * \brief Build full formatted key for bytes, based on
1796
+ * current prefix settings.
1797
+ * \param name Unprefixed bytes name
1798
+ * \param on_db Indicates whether the key refers to an entity
1799
+ * which is already in the database.
1800
+ */
1801
+ inline std::string _build_bytes_key (const std::string& name,
1802
+ bool on_db);
1667
1803
1668
1804
/* !
1669
1805
* \brief Append the Command associated with
0 commit comments