Skip to content
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

Deprecate all KV APIs. #1322

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
* Removed 256-character length limit from URIs.
* Dense reads and writes now always require a subarray to be set, to avoid confusion.

## Deprecations

* The TileDB KV API has been deprecated and will be [removed entirely](https://github.com/TileDB-Inc/TileDB/issues/1258) in a future release. The KV mechanism will be removed when full support for string-valued dimensions has been added.

## Bug fixes

* Bug fix with amplification factor in consolidation.
Expand Down
5 changes: 3 additions & 2 deletions doc/source/tutorials/kv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ to TileDB arrays.

.. warning::

This TileDB feature is experimental. Everything covered here works
great, but the APIs might undergo changes in future versions.
The TileDB key-value API has been deprecated and will be
`removed entirely <https://github.com/TileDB-Inc/TileDB/issues/1258>`_
in a future release.

.. table:: Full programs
:widths: auto
Expand Down
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ if (WIN32)
else()
# Don't treat printf format warnings as errors.
add_compile_options(-Wno-error=format)
# TODO: Remove when KV API has been removed.
add_compile_options(-Wno-deprecated-declarations)
endif()

# The examples pretend as if they use an installed TileDB, e.g.
Expand Down
5 changes: 5 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ add_executable(
${TILEDB_TEST_SOURCES}
)

# TODO: Remove when KV API has been removed.
if (NOT WIN32)
target_compile_options(tiledb_unit PRIVATE -Wno-deprecated-declarations)
endif()

target_include_directories(
tiledb_unit BEFORE PRIVATE
${TILEDB_CORE_INCLUDE_DIR}
Expand Down
89 changes: 82 additions & 7 deletions tiledb/sm/c_api/tiledb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3501,8 +3501,39 @@ int32_t tiledb_kv_schema_check(

int32_t tiledb_kv_schema_load(
tiledb_ctx_t* ctx, const char* kv_uri, tiledb_kv_schema_t** kv_schema) {
return tiledb_kv_schema_load_with_key(
ctx, kv_uri, TILEDB_NO_ENCRYPTION, nullptr, 0, kv_schema);
if (sanity_check(ctx) == TILEDB_ERR)
return TILEDB_ERR;
// Create array schema
*kv_schema = new (std::nothrow) tiledb_kv_schema_t;
if (*kv_schema == nullptr) {
tiledb::sm::Status st = tiledb::sm::Status::Error(
"Failed to allocate TileDB key-value schema object");
LOG_STATUS(st);
save_error(ctx, st);
return TILEDB_OOM;
}

// Create key
tiledb::sm::EncryptionKey key;
if (SAVE_ERROR_CATCH(
ctx,
key.set_key(tiledb::sm::EncryptionType::NO_ENCRYPTION, nullptr, 0)))
return TILEDB_ERR;

// Load array schema
auto storage_manager = ctx->ctx_->storage_manager();
if (SAVE_ERROR_CATCH(
ctx,
storage_manager->load_array_schema(
tiledb::sm::URI(kv_uri),
tiledb::sm::ObjectType::KEY_VALUE,
key,
&((*kv_schema)->array_schema_)))) {
delete *kv_schema;
return TILEDB_ERR;
}

return TILEDB_OK;
}

int32_t tiledb_kv_schema_load_with_key(
Expand Down Expand Up @@ -3958,8 +3989,36 @@ int32_t tiledb_kv_create(
tiledb_ctx_t* ctx,
const char* kv_uri,
const tiledb_kv_schema_t* kv_schema) {
return tiledb_kv_create_with_key(
ctx, kv_uri, kv_schema, TILEDB_NO_ENCRYPTION, nullptr, 0);
// Sanity checks
if (sanity_check(ctx) == TILEDB_ERR ||
sanity_check(ctx, kv_schema) == TILEDB_ERR)
return TILEDB_ERR;

// Check key-value name
tiledb::sm::URI uri(kv_uri);
if (uri.is_invalid()) {
tiledb::sm::Status st = tiledb::sm::Status::Error(
"Failed to create key-value store; Invalid array URI");
LOG_STATUS(st);
save_error(ctx, st);
return TILEDB_ERR;
}

// Create key
tiledb::sm::EncryptionKey key;
if (SAVE_ERROR_CATCH(
ctx,
key.set_key(tiledb::sm::EncryptionType::NO_ENCRYPTION, nullptr, 0)))
return TILEDB_ERR;

// Create the key-value store
if (SAVE_ERROR_CATCH(
ctx,
ctx->ctx_->storage_manager()->array_create(
uri, kv_schema->array_schema_, key)))
return TILEDB_ERR;

return TILEDB_OK;
}

int32_t tiledb_kv_create_with_key(
Expand Down Expand Up @@ -4006,8 +4065,20 @@ int32_t tiledb_kv_create_with_key(

int32_t tiledb_kv_consolidate(
tiledb_ctx_t* ctx, const char* kv_uri, tiledb_config_t* config) {
return tiledb_kv_consolidate_with_key(
ctx, kv_uri, TILEDB_NO_ENCRYPTION, nullptr, 0, config);
if (sanity_check(ctx) == TILEDB_ERR)
return TILEDB_ERR;

if (SAVE_ERROR_CATCH(
ctx,
ctx->ctx_->storage_manager()->array_consolidate(
kv_uri,
tiledb::sm::EncryptionType::NO_ENCRYPTION,
nullptr,
0,
(config == nullptr) ? nullptr : config->config_)))
return TILEDB_ERR;

return TILEDB_OK;
}

int32_t tiledb_kv_consolidate_with_key(
Expand Down Expand Up @@ -4364,7 +4435,11 @@ int32_t tiledb_kv_iter_here(
}

if (SAVE_ERROR_CATCH(ctx, kv_iter->kv_iter_->here(&((*kv_item)->kv_item_)))) {
tiledb_kv_item_free(kv_item);
if (kv_item != nullptr && *kv_item != nullptr) {
delete (*kv_item)->kv_item_;
delete *kv_item;
*kv_item = nullptr;
}
return TILEDB_ERR;
}

Expand Down
Loading