@@ -123,6 +123,8 @@ void VWErrorMessageClearValue(VWErrorMessage* error_message) noexcept
123
123
error_message->clear ();
124
124
}
125
125
126
+ DLL_PUBLIC void VWWorkspaceDeleteBuffer (const unsigned char * buffer) noexcept { delete[] buffer; }
127
+
126
128
// VWWorkspace
127
129
128
130
DLL_PUBLIC int VWWorkspaceInitialize (
138
140
}
139
141
CATCH_RETURN_EXCEPTION
140
142
141
- DLL_PUBLIC int VWWorkspaceInitializeFromModel (
142
- const char * const * extra_tokens, size_t count, const unsigned char * bytes, size_t num_bytes, VWWorkspace** output_handle, VWErrorMessage* error_message) noexcept
143
+ DLL_PUBLIC int VWWorkspaceInitializeFromModel (const char * const * extra_tokens, size_t count, const unsigned char * bytes,
144
+ size_t num_bytes, VWWorkspace** output_handle, VWErrorMessage* error_message) noexcept
143
145
try
144
146
{
145
147
std::vector<std::string> args (extra_tokens, extra_tokens + count);
@@ -157,7 +159,9 @@ DLL_PUBLIC void VWWorkspaceDelete(VWWorkspace* workspace_handle) noexcept
157
159
delete workspace;
158
160
}
159
161
160
- DLL_PUBLIC int VWWorkspaceSerializeModel (const VWWorkspace* workspace_handle, const unsigned char ** bytes, size_t * num_bytes, VWErrorMessage* error_message) noexcept try
162
+ DLL_PUBLIC int VWWorkspaceSerializeModel (const VWWorkspace* workspace_handle, const unsigned char ** bytes,
163
+ size_t * num_bytes, VWErrorMessage* error_message) noexcept
164
+ try
161
165
{
162
166
assert (workspace_handle != nullptr );
163
167
auto * workspace = reinterpret_cast <const VW::workspace*>(workspace_handle);
@@ -173,7 +177,9 @@ DLL_PUBLIC int VWWorkspaceSerializeModel(const VWWorkspace* workspace_handle, co
173
177
}
174
178
CATCH_RETURN_EXCEPTION
175
179
176
- DLL_PUBLIC int VWWorkspaceSerializeReadableModel (const VWWorkspace* workspace_handle, const unsigned char ** bytes, size_t * num_bytes, VWErrorMessage* error_message) noexcept try
180
+ DLL_PUBLIC int VWWorkspaceSerializeReadableModel (const VWWorkspace* workspace_handle, const unsigned char ** bytes,
181
+ size_t * num_bytes, VWErrorMessage* error_message) noexcept
182
+ try
177
183
{
178
184
assert (workspace_handle != nullptr );
179
185
auto * workspace = reinterpret_cast <const VW::workspace*>(workspace_handle);
@@ -189,10 +195,18 @@ DLL_PUBLIC int VWWorkspaceSerializeReadableModel(const VWWorkspace* workspace_ha
189
195
}
190
196
CATCH_RETURN_EXCEPTION
191
197
192
- DLL_PUBLIC void VWWorkspaceDeleteBuffer (const unsigned char * buffer) noexcept
198
+ DLL_PUBLIC int VWWorkspaceEndPass (VWWorkspace* workspace_handle, VWErrorMessage* error_message) noexcept
199
+ try
193
200
{
194
- delete[] buffer;
201
+ assert (workspace_handle != nullptr );
202
+ assert (example_handle != nullptr );
203
+
204
+ auto * workspace = reinterpret_cast <VW::workspace*>(workspace_handle);
205
+ workspace->current_pass ++;
206
+ workspace->l ->end_pass ();
207
+ return VW_STATUS_SUCCESS;
195
208
}
209
+ CATCH_RETURN_EXCEPTION
196
210
197
211
DLL_PUBLIC int VWWorkspaceSetupExample (
198
212
const VWWorkspace* workspace_handle, VWExample* example_handle, VWErrorMessage* error_message) noexcept
282
296
}
283
297
CATCH_RETURN_EXCEPTION
284
298
285
- DLL_PUBLIC int VWWorkspaceParseDSJson (const VWWorkspace* workspace_handle, const char * json_string, size_t length, VWExampleFactoryFunc example_factory, void * example_factory_context,
286
- VWMultiEx* output_handle, VWErrorMessage* error_message) noexcept
299
+ DLL_PUBLIC int VWWorkspaceRecordExample (
300
+ VWWorkspace* workspace_handle, VWExample* example_handle, VWErrorMessage* error_message) noexcept
301
+ try
302
+ {
303
+ assert (workspace_handle != nullptr );
304
+ assert (example_handle != nullptr );
305
+ auto * workspace = reinterpret_cast <VW::workspace*>(workspace_handle);
306
+ auto * ex = reinterpret_cast <VW::example*>(example_handle);
307
+ workspace->finish_example (*ex);
308
+ return VW_STATUS_SUCCESS;
309
+ }
310
+ CATCH_RETURN_EXCEPTION
311
+
312
+ DLL_PUBLIC int VWWorkspaceRecordMultiEx (
313
+ VWWorkspace* workspace_handle, VWMultiEx* example_handle, VWErrorMessage* error_message) noexcept
314
+ try
315
+ {
316
+ assert (workspace_handle != nullptr );
317
+ assert (example_handle != nullptr );
318
+ auto * workspace = reinterpret_cast <VW::workspace*>(workspace_handle);
319
+ auto * ex = reinterpret_cast <VW::multi_ex*>(example_handle);
320
+ workspace->finish_example (*ex);
321
+ return VW_STATUS_SUCCESS;
322
+ }
323
+ CATCH_RETURN_EXCEPTION
324
+
325
+ DLL_PUBLIC int VWWorkspaceParseDSJson (const VWWorkspace* workspace_handle, const char * json_string, size_t length,
326
+ VWExampleFactoryFunc example_factory, void * example_factory_context, VWMultiEx* output_handle,
327
+ VWErrorMessage* error_message) noexcept
287
328
try
288
329
{
289
330
assert (workspace_handle != nullptr );
@@ -302,11 +343,12 @@ try
302
343
303
344
using example_factory_t = example& (*)(void *);
304
345
305
- example_factory_t factory = [](void * context) -> VW::example& {
346
+ example_factory_t factory = [](void * context) -> VW::example&
347
+ {
306
348
auto * conv = reinterpret_cast <Converter*>(context);
307
349
auto * ex = reinterpret_cast <VW::example*>(conv->_func (conv->_ctx ));
308
350
return *ex;
309
- };
351
+ };
310
352
auto * workspace = const_cast <VW::workspace*>(reinterpret_cast <const VW::workspace*>(workspace_handle));
311
353
auto * multi_ex = reinterpret_cast <VW::multi_ex*>(output_handle);
312
354
assert (multi_ex->empty ());
@@ -463,7 +505,8 @@ DLL_PUBLIC void VWActionScoresGetLength(const VWActionScores* action_scores_hand
463
505
}
464
506
465
507
DLL_PUBLIC int VWActionScoresGetValue (const VWActionScores* action_scores_handle, uint32_t * action, float * value,
466
- size_t index, VWErrorMessage* error_message) noexcept try
508
+ size_t index, VWErrorMessage* error_message) noexcept
509
+ try
467
510
{
468
511
assert (action_scores_handle != nullptr );
469
512
auto & a_s = *reinterpret_cast <const ACTION_SCORE::action_scores*>(action_scores_handle);
0 commit comments