-
Notifications
You must be signed in to change notification settings - Fork 155
Add none type #646
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
Add none type #646
Changes from all commits
21023fd
1abf14c
342d466
88ffa19
5eb6282
a81118d
037eb21
95ba288
2089c0d
2f00339
39a7bf8
a2c60ba
a64feaf
83882e5
25d0871
3f4decf
bd63ff2
3daf150
5689bfd
296fa1e
f5315be
cc5cde7
a4f6658
311543c
957c2c9
0be4972
513ca95
a85ed88
5ee6169
31641b5
159bcf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,23 +133,20 @@ void aggregator_set_data( | |
| for (size_t s = 0; s < rows_to_write; ++s, ++ptr_data) { | ||
| if (*ptr_data == none.ptr()) { | ||
| agg.set_no_string_at(col, s, not_a_string()); | ||
| } | ||
| else if(is_py_nan(*ptr_data)){ | ||
| } else if(is_py_nan(*ptr_data)){ | ||
| agg.set_no_string_at(col, s, nan_placeholder()); | ||
| } | ||
| else { | ||
| } else { | ||
| if constexpr (is_utf_type(slice_value_type(dt))) { | ||
| auto wrapper= convert::py_unicode_to_buffer(*ptr_data); | ||
| agg.set_string_at(col, s, wrapper.buffer_, wrapper.length_); | ||
| } | ||
| else { | ||
| } else { | ||
| auto wrapper = convert::pystring_to_buffer(*ptr_data); | ||
| agg.set_string_at(col, s, wrapper.buffer_, wrapper.length_); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| } else if constexpr (is_numeric_type(dt) || is_bool_type(dt)) { | ||
| auto ptr = tensor.template ptr_cast<RawType>(row); | ||
| if (sparsify_floats) { | ||
| if constexpr (is_floating_point_type(dt)) { | ||
|
|
@@ -172,6 +169,8 @@ void aggregator_set_data( | |
| agg.set_array(col, t); | ||
| } | ||
| } | ||
| } else if constexpr (!is_empty_type(dt)) { | ||
| static_assert(!sizeof(dt), "Unknown data type"); | ||
|
Comment on lines
+172
to
+173
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is kind of doing the same thing isn't it? We should do nothing in case of empty type is passed and if ...
else if constexpr (is_empty_type(dt)) {
} else {
static_assert(!sizeof(dt), "Unknown data type");
}and it's better than throwing since if we have type which is not handled we won't even compile. |
||
| } | ||
| }); | ||
| } | ||
|
|
@@ -202,4 +201,4 @@ size_t get_slice_rowcounts( | |
| std::pair<size_t, size_t> offset_and_row_count( | ||
| const std::shared_ptr<pipelines::PipelineContext>& context); | ||
|
|
||
| } //namespace arcticdb | ||
| } //namespace arcticdb | ||
vasil-pashov marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* Copyright 2023 Man Group Operations Limited | ||
| * | ||
| * Use of this software is governed by the Business Source License 1.1 included in the file licenses/BSL.txt. | ||
| * | ||
| * As of the Change Date specified in that file, in accordance with the Business Source License, use of this software will be governed by the Apache License, version 2.0. | ||
| */ | ||
| #include <python/python_handlers.hpp> | ||
vasil-pashov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #include <python/gil_lock.hpp> | ||
|
|
||
| namespace arcticdb { | ||
| void EmptyHandler::handle_type( | ||
vasil-pashov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const uint8_t*&, | ||
| uint8_t* dest, | ||
| const VariantField&, | ||
| const entity::TypeDescriptor&, | ||
| size_t dest_bytes, | ||
| std::shared_ptr<BufferHolder> | ||
| ) { | ||
| ARCTICDB_SAMPLE(HandleEmpty, 0); | ||
| util::check(dest != nullptr, "Got null destination pointer"); | ||
| const size_t num_rows = dest_bytes / get_type_size(DataType::EMPTYVAL); | ||
| static_assert(get_type_size(DataType::EMPTYVAL) == sizeof(PyObject*)); | ||
| const PyObject** ptr_dest = reinterpret_cast<const PyObject**>(dest); | ||
vasil-pashov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| py::none none = {}; | ||
| for(auto row = 0u; row < num_rows; ++row) { | ||
| none.inc_ref(); | ||
| *ptr_dest++ = none.ptr(); | ||
vasil-pashov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note related to this PR: we will need adaptation on the Python layer because
floatis used for empty series when pandas < 2 is used.