-
Notifications
You must be signed in to change notification settings - Fork 150
add vortex-geo crate and WKB extension type #7722
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
base: develop
Are you sure you want to change the base?
Changes from all commits
9da1d71
260f992
e064113
a4dd175
ba4f867
d5c2e7b
a40f548
b2eff8f
f499553
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ DUCKDB_INCLUDES_BEGIN | |
| #include "duckdb/common/types.hpp" | ||
| DUCKDB_INCLUDES_END | ||
| #include <cassert> | ||
| #include <string> | ||
|
|
||
| duckdb_logical_type duckdb_vx_logical_type_copy(duckdb_logical_type ty) { | ||
| D_ASSERT(ty); | ||
|
|
@@ -23,3 +24,11 @@ char *duckdb_vx_logical_type_stringify(duckdb_logical_type c_type) { | |
| memcpy(result, str.c_str(), str.size() + 1); | ||
| return result; | ||
| } | ||
|
|
||
| duckdb_logical_type duckdb_vx_create_geometry(const char *crs) { | ||
| D_ASSERT(crs); | ||
| auto geom = | ||
| (*crs == '\0') ? duckdb::LogicalType::GEOMETRY() : duckdb::LogicalType::GEOMETRY(std::string(crs)); | ||
| auto copy = duckdb::make_uniq<duckdb::LogicalType>(std::move(geom)); | ||
| return reinterpret_cast<duckdb_logical_type>(copy.release()); | ||
|
Comment on lines
+32
to
+33
Contributor
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. Claude generated this function and the header update, most of the rest of the PR was braincoded
Contributor
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. haha braincoded |
||
| } | ||
|
Comment on lines
+28
to
+34
Contributor
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. These C++ changes are because DuckDB upstream doesn't expose the full geometry type stuff over the C API. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| #include "duckdb_vx/duckdb_diagnostics.h" | ||
|
|
||
| DUCKDB_INCLUDES_BEGIN | ||
| #include "duckdb/common/types/geometry_crs.hpp" | ||
| #include "duckdb/common/types/value.hpp" | ||
| DUCKDB_INCLUDES_END | ||
|
|
||
|
|
@@ -14,3 +15,24 @@ extern "C" duckdb_value duckdb_vx_value_create_null(duckdb_logical_type ty) { | |
| auto value = duckdb::make_uniq<duckdb::Value>(*logical_type); | ||
| return reinterpret_cast<duckdb_value>(value.release()); | ||
| } | ||
|
|
||
| extern "C" duckdb_value duckdb_vx_value_create_geometry(const uint8_t *wkb, idx_t len, const char *crs) { | ||
| const auto bytes = reinterpret_cast<duckdb::const_data_ptr_t>(wkb); | ||
| auto value = | ||
| (crs == nullptr || *crs == '\0') | ||
| ? duckdb::Value::GEOMETRY(bytes, len) | ||
| : duckdb::Value::GEOMETRY(bytes, len, duckdb::CoordinateReferenceSystem(std::string(crs))); | ||
| auto owned = duckdb::make_uniq<duckdb::Value>(std::move(value)); | ||
| return reinterpret_cast<duckdb_value>(owned.release()); | ||
| } | ||
|
|
||
| extern "C" duckdb_blob duckdb_vx_value_get_geometry(duckdb_value value) { | ||
| const auto val = reinterpret_cast<duckdb::Value *>(value); | ||
| const auto &str = duckdb::StringValue::Get(*val); | ||
|
Comment on lines
+30
to
+31
Contributor
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. Is this a panic or memory unsafe is val is not a string type? |
||
| const auto size = str.size(); | ||
| auto buf = reinterpret_cast<void *>(duckdb_malloc(size)); | ||
| if (size > 0) { | ||
| memcpy(buf, str.c_str(), size); | ||
| } | ||
| return {buf, size}; | ||
| } | ||
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.
memory unsafe??