2424namespace duckdb {
2525
2626static std::string GetInferaError () {
27- const char *err = infera_last_error ();
27+ const char *err = infera:: infera_last_error ();
2828 return err ? std::string (err) : std::string (" unknown error" );
2929}
3030
@@ -38,19 +38,19 @@ static void SetAutoloadDir(DataChunk &args, ExpressionState &state, Vector &resu
3838 throw InvalidInputException (" Path cannot be NULL" );
3939 }
4040 std::string path_str = path_val.ToString ();
41- char *result_json_c = infera_set_autoload_dir (path_str.c_str ());
41+ char *result_json_c = infera:: infera_set_autoload_dir (path_str.c_str ());
4242 result.SetVectorType (VectorType::CONSTANT_VECTOR);
4343 ConstantVector::GetData<string_t >(result)[0 ] = StringVector::AddString (result, result_json_c);
4444 ConstantVector::SetNull (result, false );
45- infera_free (result_json_c);
45+ infera:: infera_free (result_json_c);
4646}
4747
4848static void GetVersion (DataChunk &args, ExpressionState &state, Vector &result) {
49- char *info_json_c = infera_get_version ();
49+ char *info_json_c = infera:: infera_get_version ();
5050 result.SetVectorType (VectorType::CONSTANT_VECTOR);
5151 ConstantVector::GetData<string_t >(result)[0 ] = StringVector::AddString (result, info_json_c);
5252 ConstantVector::SetNull (result, false );
53- infera_free (info_json_c);
53+ infera:: infera_free (info_json_c);
5454}
5555
5656static void LoadModel (DataChunk &args, ExpressionState &state, Vector &result) {
@@ -68,7 +68,7 @@ static void LoadModel(DataChunk &args, ExpressionState &state, Vector &result) {
6868 if (model_name_str.empty ()) {
6969 throw InvalidInputException (" Model name cannot be empty" );
7070 }
71- int rc = infera_load_model (model_name_str.c_str (), path_str.c_str ());
71+ int rc = infera:: infera_load_model (model_name_str.c_str (), path_str.c_str ());
7272 bool success = rc == 0 ;
7373 if (!success) {
7474 throw InvalidInputException (" Failed to load model '" + model_name_str + " ': " + GetInferaError ());
@@ -88,7 +88,7 @@ static void UnloadModel(DataChunk &args, ExpressionState &state, Vector &result)
8888 throw InvalidInputException (" Model name cannot be NULL" );
8989 }
9090 std::string model_name_str = model_name.ToString ();
91- int rc = infera_unload_model (model_name_str.c_str ());
91+ int rc = infera:: infera_unload_model (model_name_str.c_str ());
9292 bool success = (rc == 0 );
9393 if (!success) {
9494 throw InvalidInputException (" Failed to unload model '" + model_name_str + " ': " + GetInferaError ());
@@ -143,21 +143,21 @@ static void Predict(DataChunk &args, ExpressionState &state, Vector &result) {
143143 std::vector<float > features;
144144 ExtractFeatures (args, features);
145145
146- InferaInferenceResult res = infera_predict (model_name_str.c_str (), features.data (), batch_size, feature_count);
146+ infera:: InferaInferenceResult res = infera:: infera_predict (model_name_str.c_str (), features.data (), batch_size, feature_count);
147147 if (res.status != 0 ) {
148148 throw InvalidInputException (" Inference failed for model '" + model_name_str + " ': " + GetInferaError ());
149149 }
150150 if (res.rows != batch_size || res.cols != 1 ) {
151151 std::string err_msg = StringUtil::Format (" Model output shape mismatch. Expected (%d, 1), but got (%d, %d)." , batch_size, res.rows , res.cols );
152- infera_free_result (res);
152+ infera:: infera_free_result (res);
153153 throw InvalidInputException (err_msg);
154154 }
155155 result.SetVectorType (VectorType::FLAT_VECTOR);
156156 auto result_data = FlatVector::GetData<float >(result);
157157 for (idx_t i = 0 ; i < batch_size; i++) {
158158 result_data[i] = res.data [i];
159159 }
160- infera_free_result (res);
160+ infera:: infera_free_result (res);
161161}
162162
163163static void PredictFromBlob (DataChunk &args, ExpressionState &state, Vector &result) {
@@ -177,9 +177,9 @@ static void PredictFromBlob(DataChunk &args, ExpressionState &state, Vector &res
177177 string_t blob_str_t = blob_val.GetValueUnsafe <string_t >();
178178 auto blob_ptr = reinterpret_cast <const uint8_t *>(blob_str_t .GetDataUnsafe ());
179179 auto blob_len = blob_str_t .GetSize ();
180- InferaInferenceResult res = infera_predict_from_blob (model_name_str.c_str (), blob_ptr, blob_len);
180+ infera:: InferaInferenceResult res = infera:: infera_predict_from_blob (model_name_str.c_str (), blob_ptr, blob_len);
181181 if (res.status != 0 ) {
182- infera_free_result (res);
182+ infera:: infera_free_result (res);
183183 throw InvalidInputException (" Inference failed for model '" + model_name_str + " ': " + GetInferaError ());
184184 }
185185 std::vector<Value> elems;
@@ -188,17 +188,17 @@ static void PredictFromBlob(DataChunk &args, ExpressionState &state, Vector &res
188188 elems.emplace_back (Value::FLOAT (res.data [j]));
189189 }
190190 result.SetValue (i, Value::LIST (std::move (elems)));
191- infera_free_result (res);
191+ infera:: infera_free_result (res);
192192 }
193193 result.Verify (args.size ());
194194}
195195
196196static void GetLoadedModels (DataChunk &args, ExpressionState &state, Vector &result) {
197- char *models_json = infera_get_loaded_models ();
197+ char *models_json = infera:: infera_get_loaded_models ();
198198 result.SetVectorType (VectorType::CONSTANT_VECTOR);
199199 ConstantVector::GetData<string_t >(result)[0 ] = StringVector::AddString (result, models_json);
200200 ConstantVector::SetNull (result, false );
201- infera_free (models_json);
201+ infera:: infera_free (models_json);
202202}
203203
204204static void PredictMulti (DataChunk &args, ExpressionState &state, Vector &result) {
@@ -211,14 +211,14 @@ static void PredictMulti(DataChunk &args, ExpressionState &state, Vector &result
211211 std::vector<float > features;
212212 ExtractFeatures (args, features);
213213
214- InferaInferenceResult res = infera_predict (model_name_str.c_str (), features.data (), batch_size, feature_count);
214+ infera:: InferaInferenceResult res = infera:: infera_predict (model_name_str.c_str (), features.data (), batch_size, feature_count);
215215 if (res.status != 0 ) {
216- infera_free_result (res);
216+ infera:: infera_free_result (res);
217217 throw InvalidInputException (" Inference failed for model '" + model_name_str + " ': " + GetInferaError ());
218218 }
219219 if (res.rows != batch_size) {
220220 std::string err_msg = StringUtil::Format (" Model output row count mismatch. Expected %d, but got %d." , batch_size, res.rows );
221- infera_free_result (res);
221+ infera:: infera_free_result (res);
222222 throw InvalidInputException (err_msg);
223223 }
224224 result.SetVectorType (VectorType::FLAT_VECTOR);
@@ -236,7 +236,7 @@ static void PredictMulti(DataChunk &args, ExpressionState &state, Vector &result
236236 oss << " ]" ;
237237 result_data[row_idx] = StringVector::AddString (result, oss.str ());
238238 }
239- infera_free_result (res);
239+ infera:: infera_free_result (res);
240240}
241241
242242static void GetModelInfo (DataChunk &args, ExpressionState &state, Vector &result) {
@@ -249,12 +249,12 @@ static void GetModelInfo(DataChunk &args, ExpressionState &state, Vector &result
249249 throw InvalidInputException (" Model name cannot be NULL" );
250250 }
251251 std::string model_name_str = model_name.ToString ();
252- char *json_meta = infera_get_model_info (model_name_str.c_str ());
252+ char *json_meta = infera:: infera_get_model_info (model_name_str.c_str ());
253253
254254 result.SetVectorType (VectorType::CONSTANT_VECTOR);
255255 ConstantVector::GetData<string_t >(result)[0 ] = StringVector::AddString (result, json_meta);
256256 ConstantVector::SetNull (result, false );
257- infera_free (json_meta);
257+ infera:: infera_free (json_meta);
258258}
259259
260260static void LoadInternal (ExtensionLoader &loader) {
0 commit comments