MCPcopy Create free account
hub / github.com/asg017/sqlite-vss / vector_value_at

Function vector_value_at

src/sqlite-vector.cpp:211–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209#pragma region Vector general
210
211static void vector_value_at(sqlite3_context *context,
212 int argc,
213 sqlite3_value **argv) {
214
215 vec_ptr pVec = valueAsVector(argv[0]);
216
217 if (pVec == nullptr)
218 return;
219
220 int pos = sqlite3_value_int(argv[1]);
221
222 try {
223
224 float result = pVec->at(pos);
225 sqlite3_result_double(context, result);
226
227 } catch (const out_of_range &oor) {
228
229 char *errmsg = sqlite3_mprintf("%d out of range: %s", pos, oor.what());
230
231 if (errmsg != nullptr) {
232 sqlite3_result_error(context, errmsg, -1);
233 sqlite3_free(errmsg);
234 } else {
235 sqlite3_result_error_nomem(context);
236 }
237 }
238}
239
240static void vector_length(sqlite3_context *context,
241 int argc,

Callers 1

test_vector_value_atMethod · 0.85

Calls 1

valueAsVectorFunction · 0.85

Tested by 1

test_vector_value_atMethod · 0.68