Skip to content

Commit

Permalink
bump kernel to 0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
samansmink committed Sep 11, 2024
1 parent bc4b6b1 commit 9bf60b0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ExternalProject_Add(
GIT_REPOSITORY "https://github.com/delta-incubator/delta-kernel-rs"
# WARNING: the FFI headers are currently pinned due to the C linkage issue of the c++ headers. Currently, when bumping
# the kernel version, the produced header in ./src/include/delta_kernel_ffi.hpp should be also bumped, applying the fix
GIT_TAG v0.2.0
GIT_TAG v0.3.1
# Prints the env variables passed to the cargo build to the terminal, useful in debugging because passing them
# through CMake is an error-prone mess
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${RUST_UNSET_ENV_VARS} ${RUST_ENV_VARS} env
Expand Down
39 changes: 23 additions & 16 deletions src/include/delta_kernel_ffi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum class KernelError {
InvalidDecimalError,
InvalidStructDataError,
InternalError,
InvalidExpression,
};

struct CStringMap;
Expand Down Expand Up @@ -93,6 +94,13 @@ struct KernelBoolSlice {
uintptr_t len;
};

/// An owned slice of u64 row indexes allocated by the kernel. The engine is responsible for
/// freeing this slice by calling [super::free_row_indexes] once.
struct KernelRowIndexArray {
uint64_t *ptr;
uintptr_t len;
};

/// Represents an object that crosses the FFI boundary and which outlives the scope that created
/// it. It can be passed freely between rust code and external code. The
///
Expand Down Expand Up @@ -382,27 +390,18 @@ using CScanCallback = void(*)(NullableCvoid engine_context,
const DvInfo *dv_info,
const CStringMap *partition_map);

// This trickery is from https://github.com/mozilla/cbindgen/issues/402#issuecomment-578680163
struct im_an_unused_struct_that_tricks_msvc_into_compilation {
ExternResult<KernelBoolSlice> field;
ExternResult<bool> field2;
ExternResult<EngineBuilder*> field3;
ExternResult<Handle<SharedExternEngine>> field4;
ExternResult<Handle<SharedSnapshot>> field5;
ExternResult<uintptr_t> field6;
ExternResult<ArrowFFIData*> field7;
ExternResult<Handle<SharedScanDataIterator>> field8;
ExternResult<Handle<SharedScan>> field9;
ExternResult<Handle<ExclusiveFileReadResultIterator>> field10;
};

extern "C" {

/// # Safety
///
/// Caller is responsible for passing a valid handle.
void free_bool_slice(KernelBoolSlice slice);

/// # Safety
///
/// Caller is responsible for passing a valid handle.
void free_row_indexes(KernelRowIndexArray slice);

/// Drop an `ExclusiveEngineData`.
///
/// # Safety
Expand Down Expand Up @@ -705,6 +704,14 @@ ExternResult<KernelBoolSlice> selection_vector_from_dv(const DvInfo *dv_info,
Handle<SharedExternEngine> engine,
Handle<SharedGlobalScanState> state);

/// Get a vector of row indexes out of a [`DvInfo`] struct
///
/// # Safety
/// Engine is responsible for providing valid pointers for each argument
ExternResult<KernelRowIndexArray> row_indexes_from_dv(const DvInfo *dv_info,
Handle<SharedExternEngine> engine,
Handle<SharedGlobalScanState> state);

/// Shim for ffi to call visit_scan_data. This will generally be called when iterating through scan
/// data which provides the data handle and selection vector as each element in the iterator.
///
Expand All @@ -715,6 +722,6 @@ void visit_scan_data(Handle<ExclusiveEngineData> data,
NullableCvoid engine_context,
CScanCallback callback);

} // extern "C"
} // extern "C"

} // namespace ffi
} // namespace ffi

0 comments on commit 9bf60b0

Please sign in to comment.