Skip to content
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

free() pointer to arrow binary in Python #1273

Merged
merged 1 commit into from
Jan 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion python/perspective/perspective/src/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ std::shared_ptr<Table> make_table_py(t_val table, t_data_accessor accessor,
std::shared_ptr<Table> tbl;
std::shared_ptr<t_gnode> gnode;
std::uint32_t offset;
void* ptr = nullptr;

// If the Table has already been created, use it
if (table_initialized) {
Expand All @@ -59,7 +60,7 @@ std::shared_ptr<Table> make_table_py(t_val table, t_data_accessor accessor,
if (is_arrow && !is_delete) {
py::bytes bytes = accessor.cast<py::bytes>();
std::int32_t size = bytes.attr("__len__")().cast<std::int32_t>();
void * ptr = malloc(size);
ptr = malloc(size);
std::memcpy(ptr, bytes.cast<std::string>().c_str(), size);
{
PerspectiveScopedGILRelease acquire(pool->get_event_loop_thread_id());
Expand Down Expand Up @@ -193,6 +194,10 @@ std::shared_ptr<Table> make_table_py(t_val table, t_data_accessor accessor,
_fill_data(data_table, accessor, input_schema, index, offset, limit, is_update);
}

if (is_arrow) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any case where is_arrow && is_delete?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. should this match above if (is_arrow && !is_delete) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be any - remove only takes a list of pkeys, but this whole conditional block is kind of messy. I'll take a look and fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is incorrect, but so is the fix suggestion - there should be (or will need to be) one case, for remove() ... when we get around to fixing this API method generally ...

free(ptr);
}

// calculate offset, limit, and set the gnode
tbl->init(data_table, row_count, op, port_id);

Expand Down