Skip to content

Commit

Permalink
Merge pull request #22 from TileDB-Inc/dev
Browse files Browse the repository at this point in the history
Metadata bug fix and minor additions to the C API
  • Loading branch information
stavrospapadopoulos authored Jun 10, 2017
2 parents 2d6ce9d + 37f9397 commit 106b72b
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 74 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 15 additions & 2 deletions core/include/c_api/tiledb.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
#define TILEDB_ERRMSG_MAX_LEN 2000




/* ********************************* */
/* MACROS */
/* ********************************* */
Expand All @@ -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
*/
TILEDB_EXPORT void tiledb_version(
int* major,
int* minor,
int* rev);

/* ********************************* */
/* GLOBAL VARIABLES */
Expand Down
5 changes: 4 additions & 1 deletion core/include/c_api/tiledb_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
#include <limits.h>

/** 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 1

/**@{*/
/** Return code. */
Expand Down
4 changes: 2 additions & 2 deletions core/src/array/array_schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
139 changes: 72 additions & 67 deletions core/src/c_api/tiledb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -67,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) {
Expand Down Expand Up @@ -130,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 */
/* ****************************** */
Expand Down Expand Up @@ -226,8 +181,6 @@ int tiledb_workspace_create(
}




/* ****************************** */
/* GROUP */
/* ****************************** */
Expand Down Expand Up @@ -269,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,
Expand Down Expand Up @@ -772,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,
Expand Down Expand Up @@ -898,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,
Expand Down Expand Up @@ -1263,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,
Expand Down
1 change: 1 addition & 0 deletions core/src/fragment/fragment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "fragment.h"
#include "tiledb_constants.h"
#include "utils.h"
#include <cerrno>
#include <cassert>
#include <cstdio>
#include <cstring>
Expand Down
1 change: 1 addition & 0 deletions core/src/misc/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "utils.h"
#include <algorithm>
#include <cassert>
#include <cerrno>
#include <cstring>
#include <dirent.h>
#include <fcntl.h>
Expand Down
1 change: 1 addition & 0 deletions core/src/storage_manager/storage_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "storage_manager.h"
#include "utils.h"
#include <cassert>
#include <cerrno>
#include <cstring>
#include <dirent.h>
#include <fcntl.h>
Expand Down
53 changes: 53 additions & 0 deletions test/include/c_api/c_api_version.h
Original file line number Diff line number Diff line change
@@ -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_VERSION_H__
#define __C_API_VERSION_H__

#include "tiledb.h"
#include <gtest/gtest.h>

class LibraryVersionFixture: public testing::Test {
public:
/* ********************************* */
/* GTEST FUNCTIONS */
/* ********************************* */

/** Test initialization. */
virtual void SetUp();

/** Test finalization. */
virtual void TearDown();

};

#endif
Loading

0 comments on commit 106b72b

Please sign in to comment.