From c79332454fb9418a810f5cb6348324598a354e01 Mon Sep 17 00:00:00 2001 From: Jake Bolewski Date: Thu, 18 May 2017 18:37:07 -0400 Subject: [PATCH 1/9] Add c-api to access library version include a simple test --- core/include/c_api/tiledb.h | 17 ++++++- core/include/c_api/tiledb_constants.h | 5 +- core/src/c_api/tiledb.cc | 8 ++++ test/include/c_api/c_api_version.h | 53 +++++++++++++++++++++ test/src/c_api/c_api_version.cc | 67 +++++++++++++++++++++++++++ 5 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 test/include/c_api/c_api_version.h create mode 100644 test/src/c_api/c_api_version.cc diff --git a/core/include/c_api/tiledb.h b/core/include/c_api/tiledb.h index 8526aa2b949..aa6233c0199 100755 --- a/core/include/c_api/tiledb.h +++ b/core/include/c_api/tiledb.h @@ -54,8 +54,6 @@ #define TILEDB_ERRMSG_MAX_LEN 2000 - - /* ********************************* */ /* MACROS */ /* ********************************* */ @@ -74,7 +72,22 @@ extern "C" { /**@}*/ +/* ****************************** */ +/* TILEDB */ +/* ****************************** */ +/** + * Return the version of the tiledb library + * being currently used. + * + * @param major Store the major version number + * @param minor Store the minor version number + * @param rev Store the revision (patch) number + */ +void tiledb_version( + int* major, + int* minor, + int* rev); /* ********************************* */ /* GLOBAL VARIABLES */ diff --git a/core/include/c_api/tiledb_constants.h b/core/include/c_api/tiledb_constants.h index 43a153687ea..31bac8cccc3 100644 --- a/core/include/c_api/tiledb_constants.h +++ b/core/include/c_api/tiledb_constants.h @@ -37,7 +37,10 @@ #include /** Version. */ -#define TILEDB_VERSION "0.6.0" +#define TILEDB_VERSION "0.6.0" +#define TILEDB_VERSION_MAJOR 0 +#define TILEDB_VERSION_MINOR 6 +#define TILEDB_VERSION_REVISION 0 /**@{*/ /** Return code. */ diff --git a/core/src/c_api/tiledb.cc b/core/src/c_api/tiledb.cc index 0ca47cdc45e..10069f9c9dc 100644 --- a/core/src/c_api/tiledb.cc +++ b/core/src/c_api/tiledb.cc @@ -57,7 +57,15 @@ char tiledb_errmsg[TILEDB_ERRMSG_MAX_LEN]; +/* ****************************** */ +/* TILEDB */ +/* ****************************** */ +void tiledb_version(int* major, int* minor, int* rev) { + *major = TILEDB_VERSION_MAJOR; + *minor = TILEDB_VERSION_MINOR; + *rev = TILEDB_VERSION_REVISION; +} /* ****************************** */ /* CONTEXT */ diff --git a/test/include/c_api/c_api_version.h b/test/include/c_api/c_api_version.h new file mode 100644 index 00000000000..9fb7e5152b5 --- /dev/null +++ b/test/include/c_api/c_api_version.h @@ -0,0 +1,53 @@ +/** + * @file c_api_version.h + * + * @section LICENSE + * + * The MIT License + * + * @copyright Copyright (c) 2016 MIT and Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @section DESCRIPTION + * + * Declarations for testing the C API sparse array spec. + */ + +#ifndef __C_API_SPARSE_ARRAY_SPEC_H__ +#define __C_API_SPARSE_ARRAY_SPEC_H__ + +#include "tiledb.h" +#include + +class LibraryVersionFixture: public testing::Test { + public: + /* ********************************* */ + /* GTEST FUNCTIONS */ + /* ********************************* */ + + /** Test initialization. */ + virtual void SetUp(); + + /** Test finalization. */ + virtual void TearDown(); + +}; + +#endif diff --git a/test/src/c_api/c_api_version.cc b/test/src/c_api/c_api_version.cc new file mode 100644 index 00000000000..01b81b0fe55 --- /dev/null +++ b/test/src/c_api/c_api_version.cc @@ -0,0 +1,67 @@ +/** + * @file c_api_version.cc + * + * @section LICENSE + * + * The MIT License + * + * @copyright Copyright (c) 2016 MIT and Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @section DESCRIPTION + * + * Tests for the C API library version + */ + +#include "c_api_version.h" +#include "utils.h" +#include + + +/* ****************************** */ +/* GTEST FUNCTIONS */ +/* ****************************** */ + +void LibraryVersionFixture::SetUp() { +} + +void LibraryVersionFixture::TearDown() { +} + + +/* ****************************** */ +/* TESTS */ +/* ****************************** */ + +/** + * Tests the library version + */ +TEST_F(LibraryVersionFixture, test_library_version) { + + int major = -1; + int minor = -1; + int rev = -1; + + tiledb_version(&major, &minor, &rev); + + ASSERT_EQ(major, 0); + ASSERT_EQ(minor, 6); + ASSERT_EQ(rev, 0); +} From 40475a26960de560e7cb9379909fb1605e7508ff Mon Sep 17 00:00:00 2001 From: Jake Bolewski Date: Thu, 18 May 2017 22:40:09 -0400 Subject: [PATCH 2/9] Update c_api_version.h --- test/include/c_api/c_api_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/include/c_api/c_api_version.h b/test/include/c_api/c_api_version.h index 9fb7e5152b5..a2b75347d53 100644 --- a/test/include/c_api/c_api_version.h +++ b/test/include/c_api/c_api_version.h @@ -30,8 +30,8 @@ * Declarations for testing the C API sparse array spec. */ -#ifndef __C_API_SPARSE_ARRAY_SPEC_H__ -#define __C_API_SPARSE_ARRAY_SPEC_H__ +#ifndef __C_API_VERSION_H__ +#define __C_API_VERSION_H__ #include "tiledb.h" #include From dc8eb5611362809bb60a65a747f4f93a7c4ab429 Mon Sep 17 00:00:00 2001 From: Jake Bolewski Date: Fri, 19 May 2017 15:13:07 -0400 Subject: [PATCH 3/9] Update .travis.yml make sure that all examples build during CI --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e332ddc499..ace70899e12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,8 +42,9 @@ install: - mkdir -p $TILEDB_BUILD_DIR - cd $TILEDB_BUILD_DIR - cmake .. -DCMAKE_BUILD_TYPE=Coverage - - make -j 4 - + - make -j4 + - make examples -j4 + before_script: - lcov --directory $TILEDB_BUILD_DIR --zerocounters From e9300a84cadfbb6bb43bc724989d8976844aca1e Mon Sep 17 00:00:00 2001 From: Jake Bolewski Date: Fri, 19 May 2017 17:03:11 -0400 Subject: [PATCH 4/9] Better sanity checking in the c-api Throw an error instead of segfaulting if an opaque struct is not initialized correctly --- core/src/c_api/tiledb.cc | 131 +++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 67 deletions(-) diff --git a/core/src/c_api/tiledb.cc b/core/src/c_api/tiledb.cc index 10069f9c9dc..5067b229020 100644 --- a/core/src/c_api/tiledb.cc +++ b/core/src/c_api/tiledb.cc @@ -75,6 +75,18 @@ typedef struct TileDB_CTX { StorageManager* storage_manager_; } TileDB_CTX; +bool sanity_check(const TileDB_CTX* tiledb_ctx) { + if(tiledb_ctx == nullptr || + tiledb_ctx->storage_manager_ == nullptr) { + std::string errmsg = "Invalid TileDB context"; + PRINT_ERROR(errmsg); + strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); + return false; + } else { + return true; + } +} + int tiledb_ctx_init( TileDB_CTX** tiledb_ctx, const TileDB_Config* tiledb_config) { @@ -138,71 +150,6 @@ int tiledb_ctx_finalize(TileDB_CTX* tiledb_ctx) { return TILEDB_OK; } - - - -/* ****************************** */ -/* SANITY CHECKS */ -/* ****************************** */ - -bool sanity_check(const TileDB_CTX* tiledb_ctx) { - if(tiledb_ctx == NULL || tiledb_ctx->storage_manager_ == NULL) { - std::string errmsg = "Invalid TileDB context"; - PRINT_ERROR(errmsg); - strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); - return false; - } else { - return true; - } -} - -bool sanity_check(const TileDB_Array* tiledb_array) { - if(tiledb_array == NULL) { - std::string errmsg = "Invalid TileDB array"; - PRINT_ERROR(errmsg); - strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); - return false; - } else { - return true; - } -} - -bool sanity_check(const TileDB_ArrayIterator* tiledb_array_it) { - if(tiledb_array_it == NULL) { - std::string errmsg = "Invalid TileDB array iterator"; - PRINT_ERROR(errmsg); - strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); - return false; - } else { - return true; - } -} - -bool sanity_check(const TileDB_Metadata* tiledb_metadata) { - if(tiledb_metadata == NULL) { - std::string errmsg = "Invalid TileDB metadata"; - PRINT_ERROR(errmsg); - strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); - return false; - } else { - return true; - } -} - -bool sanity_check(const TileDB_MetadataIterator* tiledb_metadata_it) { - if(tiledb_metadata_it == NULL) { - std::string errmsg = "Invalid TileDB metadata iterator"; - PRINT_ERROR(errmsg); - strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); - return false; - } else { - return true; - } -} - - - - /* ****************************** */ /* WORKSPACE */ /* ****************************** */ @@ -234,8 +181,6 @@ int tiledb_workspace_create( } - - /* ****************************** */ /* GROUP */ /* ****************************** */ @@ -277,6 +222,19 @@ typedef struct TileDB_Array { const TileDB_CTX* tiledb_ctx_; } TileDB_Array; +bool sanity_check(const TileDB_Array* tiledb_array) { + if(tiledb_array == nullptr || + tiledb_array->array_ == nullptr || + tiledb_array->tiledb_ctx_ == nullptr) { + std::string errmsg = "Invalid TileDB array"; + PRINT_ERROR(errmsg); + strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); + return false; + } else { + return true; + } +} + int tiledb_array_set_schema( TileDB_ArraySchema* tiledb_array_schema, const char* array_name, @@ -780,6 +738,19 @@ typedef struct TileDB_ArrayIterator { const TileDB_CTX* tiledb_ctx_; } TileDB_ArrayIterator; +bool sanity_check(const TileDB_ArrayIterator* tiledb_array_it) { + if(tiledb_array_it == nullptr || + tiledb_array_it->array_it_ == nullptr || + tiledb_array_it->tiledb_ctx_ == nullptr) { + std::string errmsg = "Invalid TileDB array iterator"; + PRINT_ERROR(errmsg); + strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); + return false; + } else { + return true; + } +} + int tiledb_array_iterator_init( const TileDB_CTX* tiledb_ctx, TileDB_ArrayIterator** tiledb_array_it, @@ -906,6 +877,19 @@ typedef struct TileDB_Metadata { const TileDB_CTX* tiledb_ctx_; } TileDB_Metadata; +bool sanity_check(const TileDB_Metadata* tiledb_metadata) { + if(tiledb_metadata == nullptr || + tiledb_metadata->metadata_ == nullptr || + tiledb_metadata->tiledb_ctx_ == nullptr) { + std::string errmsg = "Invalid TileDB metadata"; + PRINT_ERROR(errmsg); + strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); + return false; + } else { + return true; + } +} + int tiledb_metadata_set_schema( TileDB_MetadataSchema* tiledb_metadata_schema, const char* metadata_name, @@ -1271,6 +1255,19 @@ typedef struct TileDB_MetadataIterator { const TileDB_CTX* tiledb_ctx_; } TileDB_MetadataIterator; +bool sanity_check(const TileDB_MetadataIterator* tiledb_metadata_it) { + if(tiledb_metadata_it == nullptr || + tiledb_metadata_it->metadata_it_ == nullptr || + tiledb_metadata_it->tiledb_ctx_ == nullptr) { + std::string errmsg = "Invalid TileDB metadata iterator"; + PRINT_ERROR(errmsg); + strcpy(tiledb_errmsg, (TILEDB_ERRMSG + errmsg).c_str()); + return false; + } else { + return true; + } +} + int tiledb_metadata_iterator_init( const TileDB_CTX* tiledb_ctx, TileDB_MetadataIterator** tiledb_metadata_it, From c0a42b81c9b89285b32db5eb568735e873c1e5c3 Mon Sep 17 00:00:00 2001 From: Jake Bolewski Date: Fri, 26 May 2017 15:38:59 -0400 Subject: [PATCH 5/9] add missing errno header --- core/src/fragment/fragment.cc | 1 + core/src/misc/utils.cc | 1 + core/src/storage_manager/storage_manager.cc | 1 + 3 files changed, 3 insertions(+) diff --git a/core/src/fragment/fragment.cc b/core/src/fragment/fragment.cc index 30eea20045a..aa3ee6d1bd0 100644 --- a/core/src/fragment/fragment.cc +++ b/core/src/fragment/fragment.cc @@ -33,6 +33,7 @@ #include "fragment.h" #include "tiledb_constants.h" #include "utils.h" +#include #include #include #include diff --git a/core/src/misc/utils.cc b/core/src/misc/utils.cc index 6986bb5113d..95d25a00f4f 100644 --- a/core/src/misc/utils.cc +++ b/core/src/misc/utils.cc @@ -34,6 +34,7 @@ #include "utils.h" #include #include +#include #include #include #include diff --git a/core/src/storage_manager/storage_manager.cc b/core/src/storage_manager/storage_manager.cc index 5fb38bff13c..bd6fb779c26 100755 --- a/core/src/storage_manager/storage_manager.cc +++ b/core/src/storage_manager/storage_manager.cc @@ -33,6 +33,7 @@ #include "storage_manager.h" #include "utils.h" #include +#include #include #include #include From b6abae6880f90e42c2e1dc582a09cd3d84cd67de Mon Sep 17 00:00:00 2001 From: Jake Bolewski Date: Tue, 30 May 2017 17:23:21 -0400 Subject: [PATCH 6/9] make `tiledb_version` an exported symbol in the shared library --- core/include/c_api/tiledb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/include/c_api/tiledb.h b/core/include/c_api/tiledb.h index aa6233c0199..b39af9a9845 100755 --- a/core/include/c_api/tiledb.h +++ b/core/include/c_api/tiledb.h @@ -84,7 +84,7 @@ extern "C" { * @param minor Store the minor version number * @param rev Store the revision (patch) number */ -void tiledb_version( +TILEDB_EXPORT void tiledb_version( int* major, int* minor, int* rev); From 6ce97da7626c46ea2e8d4c57a23e646cdf8e78d5 Mon Sep 17 00:00:00 2001 From: Stavros Papadopoulos Date: Fri, 9 Jun 2017 19:47:57 -0400 Subject: [PATCH 7/9] Fixes #20 (error with the metadata schema domain) --- core/src/array/array_schema.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/array/array_schema.cc b/core/src/array/array_schema.cc index 0457e7336f7..b64ff3c61ff 100644 --- a/core/src/array/array_schema.cc +++ b/core/src/array/array_schema.cc @@ -1309,8 +1309,8 @@ int ArraySchema::init(const MetadataSchemaC* metadata_schema_c) { // Set domain int* domain = (int*) malloc(8*sizeof(int)); for(int i=0; i<4; ++i) { - domain[2*i] = INT_MIN; - domain[2*i+1] = INT_MAX; + domain[2*i] = 0; + domain[2*i+1] = UINT_MAX; } array_schema_c.domain_ = domain; From b477574bc8a34fbbc5bca5d5ab33ceab01d4298f Mon Sep 17 00:00:00 2001 From: Stavros Papadopoulos Date: Fri, 9 Jun 2017 19:59:35 -0400 Subject: [PATCH 8/9] Changing the version --- core/include/c_api/tiledb_constants.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/include/c_api/tiledb_constants.h b/core/include/c_api/tiledb_constants.h index 31bac8cccc3..61dcf2c44ac 100644 --- a/core/include/c_api/tiledb_constants.h +++ b/core/include/c_api/tiledb_constants.h @@ -37,10 +37,10 @@ #include /** Version. */ -#define TILEDB_VERSION "0.6.0" +#define TILEDB_VERSION "0.6.1" #define TILEDB_VERSION_MAJOR 0 #define TILEDB_VERSION_MINOR 6 -#define TILEDB_VERSION_REVISION 0 +#define TILEDB_VERSION_REVISION 1 /**@{*/ /** Return code. */ From 9f57febeeb4e308a772db0c6b6543a4fa522b315 Mon Sep 17 00:00:00 2001 From: Stavros Papadopoulos Date: Fri, 9 Jun 2017 20:05:24 -0400 Subject: [PATCH 9/9] Changing the version on tests --- test/src/c_api/c_api_version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/c_api/c_api_version.cc b/test/src/c_api/c_api_version.cc index 01b81b0fe55..8889a2f1085 100644 --- a/test/src/c_api/c_api_version.cc +++ b/test/src/c_api/c_api_version.cc @@ -63,5 +63,5 @@ TEST_F(LibraryVersionFixture, test_library_version) { ASSERT_EQ(major, 0); ASSERT_EQ(minor, 6); - ASSERT_EQ(rev, 0); + ASSERT_EQ(rev, 1); }