Skip to content

Commit

Permalink
Fixes constructing empty arrow buffers (#1613)
Browse files Browse the repository at this point in the history
Signed-off-by: Tao He <[email protected]>
  • Loading branch information
sighingnow authored Nov 13, 2023
1 parent c01c493 commit d2b5ab4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
21 changes: 11 additions & 10 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.18.0"
version = "0.18.1"
homepage = "https://v6d.io"
repository = "https://github.com/v6d-io/v6d.git"
authors = ["Vineyard <[email protected]>"]
Expand All @@ -22,11 +22,11 @@ edition = "2021"
readme = "README.md"

[workspace.dependencies]
arrow-array = ">=40, <47"
arrow-buffer = ">=40, <47"
arrow-ipc = ">=40, <47"
arrow-schema = ">=40, <47"
arrow2 = { version = ">=0.17, <0.19", features = ["arrow"] }
arrow-array = ">=40, <45"
arrow-buffer = ">=40, <45"
arrow-ipc = ">=40, <45"
arrow-schema = ">=40, <45"
arrow2 = { version = ">=0.17, <0.18", features = ["arrow"] }
ctor = "0.2"
datafusion = ">= 28"
downcast-rs = "1.2"
Expand All @@ -41,6 +41,7 @@ memmap2 = "0.7"
num-traits = ">= 0.2"
num-derive = ">= 0.4"
parking_lot = "0.12"
polars-arrow = ">=0.32, <34"
polars-core = ">=0.32, <34"
rand = "0.8"
sendfd = "0.4"
Expand All @@ -50,7 +51,7 @@ serde_json = "1.0"
spectral = "0.6"
static_str_ops = "0.1.2"

vineyard = { version = "0.18.0", path = "./vineyard" }
vineyard-datafusion = { version = "0.18.0", path = "./vineyard-datafusion" }
vineyard-polars = { version = "0.18.0", path = "./vineyard-polars" }
vineyard-integration-testing = { version = "0.18.0", path = "./vineyard-integration-testing" }
vineyard = { version = "0.18.1", path = "./vineyard" }
vineyard-datafusion = { version = "0.18.1", path = "./vineyard-datafusion" }
vineyard-polars = { version = "0.18.1", path = "./vineyard-polars" }
vineyard-integration-testing = { version = "0.18.1", path = "./vineyard-integration-testing" }
1 change: 1 addition & 0 deletions rust/vineyard-polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ arrow-array = { workspace = true }
arrow-schema = { workspace = true }
arrow2 = { workspace = true }
itertools = { workspace = true }
polars-arrow = { workspace = true }
polars-core = { workspace = true }
serde_json = { workspace = true }
vineyard = { workspace = true }
Expand Down
20 changes: 12 additions & 8 deletions rust/vineyard/src/common/util/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use std::ptr::NonNull;
use std::sync::Arc;

use arrow_buffer::{alloc, Buffer};
use arrow_buffer::{alloc, Buffer, MutableBuffer};

/// An `arrow::alloc::Allocation` implementation to prevent the pointer
/// been freed by `arrow::Buffer`.
Expand Down Expand Up @@ -46,13 +46,17 @@ pub fn arrow_buffer_mut(pointer: *mut u8, len: usize) -> Buffer {
}

pub fn arrow_buffer_with_offset_mut(pointer: *mut u8, offset: isize, len: usize) -> Buffer {
return unsafe {
Buffer::from_custom_allocation(
NonNull::new_unchecked(pointer.offset(offset) as *mut u8),
len,
MMAP_ALLOCATION.clone(),
)
};
if pointer.is_null() {
return MutableBuffer::new(0).into();
} else {
return unsafe {
Buffer::from_custom_allocation(
NonNull::new_unchecked(pointer.offset(offset)),
len,
MMAP_ALLOCATION.clone(),
)
};
}
}

pub fn arrow_buffer_null() -> Buffer {
Expand Down

0 comments on commit d2b5ab4

Please sign in to comment.