-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Void pointers / Operator casting #1
Comments
Is this function just a fancy malloc, or is it doing anything else besides allocating? You can always pretend that the function signature looks different for the current context, see: coat/include/coat/datastructs/pod_vector.h Lines 186 to 188 in 7f27e8d
Here, both void* in realloc()'s signature are casted to T*, T being the element type of the vector in this case. So, in COAT, we use T*, but it calls the function which uses void*. You can probably use something very similar. |
That wouldn't work if you want to write multiple datatypes to the same Buffer. Suppose you have a table of form (uiint64_t, uint32_t, uint8_t). Then if you want to materialize tuples of this table (to sort for example), I would expect something like the following: // Buffer store returns a uint8_t*
coat::Ptr<CC, coat::Value<CC, uint8_t>> store_address = coat::FunctionCall(fn, buffer.store_tuple, "tuple_store",16);
// Registers with values to be stored
register0 = coat::Value<CC, uint64_t>(fn, val0);
register1 = coat::Value<CC, uint32_t>(fn, val1);
register2 = coat::Value<CC, uint8_t>(fn, val2);
auto ptr0 = store_address.cast<CC, coat::Value<CC, uint64_t>>();
*ptr0 = register0;
store_address +=8
auto ptr1 = store_address.cast<CC, coat::Value<CC, uint32_t>>();
*ptr1 = register1;
store_address +=4
auto ptr2 = store_address.cast<CC, coat::Value<CC, uint8_t>>();
*ptr2 = register2; |
Well, then we need a cast function. It was on my todo list anyway. I pushed a change, see the example: Lines 36 to 42 in 94cc783
|
I just tested it and seems to work. Thanks a lot! |
Hi, first of all congrats on the framework. It's quite interesting
My issue is the following: I have a Buffer which allows to store tuples (for operators that need materialization). It works by calling a method
void* store_tuple(size_t tuple_size)
which allocates memory of size "tuple_size" and returns a pointer to the beginning of this region.In normal, non-generated code, I would cast this void pointer to the type I need. However, I don't know how to do it in coat. One could template the function to store tuples, like the following
However, this would still be problematic when trying to store tuples with different datatypes
The text was updated successfully, but these errors were encountered: