MCPcopy Create free account
hub / github.com/apache/paimon-rust / paimon_catalog_create

Function paimon_catalog_create

bindings/c/src/catalog.rs:35–82  ·  view source on GitHub ↗
(
    options: *const paimon_option,
    options_len: usize,
)

Source from the content-addressed store, hash-verified

33/// Each key and value in the options must be valid null-terminated C strings.
34#[no_mangle]
35pub unsafe extern "C" fn paimon_catalog_create(
36 options: *const paimon_option,
37 options_len: usize,
38) -> paimon_result_catalog_new {
39 // Build Options from the array
40 let mut opts = Options::new();
41 if !options.is_null() && options_len > 0 {
42 let options_slice = std::slice::from_raw_parts(options, options_len);
43 for opt in options_slice {
44 let key = match validate_cstr(opt.key, "option key") {
45 Ok(s) => s,
46 Err(e) => {
47 return paimon_result_catalog_new {
48 catalog: std::ptr::null_mut(),
49 error: e,
50 }
51 }
52 };
53 let value = match validate_cstr(opt.value, "option value") {
54 Ok(s) => s,
55 Err(e) => {
56 return paimon_result_catalog_new {
57 catalog: std::ptr::null_mut(),
58 error: e,
59 }
60 }
61 };
62 opts.set(key, value);
63 }
64 }
65
66 // Create catalog using CatalogFactory
67 match runtime().block_on(CatalogFactory::create(opts)) {
68 Ok(catalog) => {
69 let wrapper = Box::new(paimon_catalog {
70 inner: Box::into_raw(Box::new(catalog)) as *mut c_void,
71 });
72 paimon_result_catalog_new {
73 catalog: Box::into_raw(wrapper),
74 error: std::ptr::null_mut(),
75 }
76 }
77 Err(e) => paimon_result_catalog_new {
78 catalog: std::ptr::null_mut(),
79 error: paimon_error::from_paimon(e),
80 },
81 }
82}
83
84/// Free a paimon_catalog.
85///

Callers

nothing calls this directly

Calls 4

validate_cstrFunction · 0.85
is_nullMethod · 0.80
setMethod · 0.80
runtimeFunction · 0.70

Tested by

no test coverage detected