From 7a913522ac398bc4e477a4102b465ae678dd63d7 Mon Sep 17 00:00:00 2001 From: Ashot Vardanian Date: Sun, 16 Oct 2022 21:41:02 +0400 Subject: [PATCH] Add: Placeholder for bulk import/export tools --- include/ukv/db.h | 3 ++ tools/dataset.cpp | 1 + tools/dataset.h | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 tools/dataset.cpp create mode 100644 tools/dataset.h diff --git a/include/ukv/db.h b/include/ukv/db.h index 3f81d58b8..0a5088b74 100644 --- a/include/ukv/db.h +++ b/include/ukv/db.h @@ -106,6 +106,9 @@ typedef void* ukv_arena_t; typedef uint8_t* ukv_bytes_ptr_t; typedef uint8_t const* ukv_bytes_cptr_t; +typedef void* ukv_callback_payload_t; +typedef void (*ukv_callback_t)(ukv_callback_payload_t); + typedef enum { ukv_options_default_k = 0, diff --git a/tools/dataset.cpp b/tools/dataset.cpp new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tools/dataset.cpp @@ -0,0 +1 @@ + diff --git a/tools/dataset.h b/tools/dataset.h new file mode 100644 index 000000000..7223fe270 --- /dev/null +++ b/tools/dataset.h @@ -0,0 +1,99 @@ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct ukv_graph_import_t { + + ukv_database_t db; + ukv_error_t* error; + ukv_arena_t* arena = NULL; + ukv_options_t options = ukv_options_default_k; + + ukv_collection_t collection = ukv_collection_main_k; + ukv_str_view_t paths_pattern = ".*\.(csv|ndjson|parquet)"; + ukv_size_t max_batch_size = 1024ul * 1024ul * 1024ul; + ukv_callback_t callback = NULL; + ukv_callback_payload_t callback_payload = NULL; + + ukv_str_view_t source_id_field = "source"; + ukv_str_view_t target_id_field = "target"; + ukv_str_view_t edge_id_field = "edge"; + +} ukv_graph_import_t; + +void ukv_graph_import(ukv_graph_import_t*); + +typedef struct ukv_graph_export_t { + + ukv_database_t db; + ukv_error_t* error; + ukv_arena_t* arena = NULL; + ukv_options_t options = ukv_options_default_k; + + ukv_collection_t collection = ukv_collection_main_k; + ukv_str_view_t paths_extension = ".parquet"; + ukv_size_t max_batch_size = 1024ul * 1024ul * 1024ul; + ukv_callback_t callback = NULL; + ukv_callback_payload_t callback_payload = NULL; + + ukv_str_view_t source_id_field = "source"; + ukv_str_view_t target_id_field = "target"; + ukv_str_view_t edge_id_field = "edge"; + +} ukv_graph_export_t; + +void ukv_graph_export(ukv_graph_export_t*); + +typedef struct ukv_docs_import_t { + + ukv_database_t db; + ukv_error_t* error; + ukv_arena_t* arena = NULL; + ukv_options_t options = ukv_options_default_k; + + ukv_collection_t collection = ukv_collection_main_k; + ukv_str_view_t paths_pattern = ".*\.(csv|ndjson|parquet)"; + ukv_size_t max_batch_size = 1024ul * 1024ul * 1024ul; + ukv_callback_t callback = NULL; + ukv_callback_payload_t callback_payload = NULL; + + ukv_size_t fields_count = 0; + ukv_str_view_t const* fields = NULL; + ukv_size_t fields_stride = 0; + + ukv_str_view_t id_field = "_id"; + +} ukv_docs_import_t; + +void ukv_docs_import(ukv_docs_import_t*); + +typedef struct ukv_docs_export_t { + + ukv_database_t db; + ukv_error_t* error; + ukv_arena_t* arena = NULL; + ukv_options_t options = ukv_options_default_k; + + ukv_collection_t collection = ukv_collection_main_k; + ukv_str_view_t paths_extension = ".parquet"; + ukv_size_t max_batch_size = 1024ul * 1024ul * 1024ul; + ukv_callback_t callback = NULL; + ukv_callback_payload_t callback_payload = NULL; + + ukv_size_t fields_count = 0; + ukv_str_view_t const* fields = NULL; + ukv_size_t fields_stride = 0; + +} ukv_docs_export_t; + +void ukv_docs_export(ukv_docs_export_t*); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif +