freevryheid / duckdb

fortran bindings to duckdb c api
MIT License
9 stars 2 forks source link

test_data_chunk #21

Open ludnic opened 1 year ago

ludnic commented 1 year ago

List of functions needed for test_data_chunk.f90

freevryheid commented 1 year ago

The lines following https://github.com/freevryheid/duckdb/blob/main/test/test_data_chunk.f90#L239

don't look right to me.

I'm still trying to figure out this function that returns a c pointer: duckdb_vector_get_data

From: https://github.com/duckdb/duckdb/blob/master/test/api/capi/test_capi_data_chunk.cpp#L135

The lines

    auto col1_ptr = (int64_t *)duckdb_vector_get_data(duckdb_data_chunk_get_vector(data_chunk, 0));
    *col1_ptr = 42;

I don't know c++ but I suspect that the function

duckdb_data_chunk_get_vector(data_chunk, 0)

should return a c_int64_t. Why I don't know as data_chunk in the test appears to be NULL. 42 is then mapped to this memory address.

We may need a helper function for duckdb_vector_get_data that converts the c pointer to a fortran (target) pointer that we can then map/assign to as in "=>"