├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake └── Modules │ ├── FindBLOSC.cmake │ ├── FindLZ4.cmake │ ├── FindZSTD.cmake │ └── SetCXX2011Flag.cmake ├── core ├── CMakeLists.txt ├── include │ ├── array │ │ ├── aio_request.h │ │ ├── array.h │ │ ├── array_iterator.h │ │ ├── array_read_state.h │ │ ├── array_schema.h │ │ ├── array_schema_c.h │ │ ├── array_sorted_read_state.h │ │ └── array_sorted_write_state.h │ ├── c_api │ │ ├── tiledb.h │ │ └── tiledb_constants.h │ ├── fragment │ │ ├── book_keeping.h │ │ ├── fragment.h │ │ ├── read_state.h │ │ └── write_state.h │ ├── metadata │ │ ├── metadata.h │ │ ├── metadata_iterator.h │ │ └── metadata_schema_c.h │ ├── misc │ │ ├── comparators.h │ │ ├── hilbert_curve.h │ │ ├── progress_bar.h │ │ └── utils.h │ └── storage_manager │ │ ├── storage_manager.h │ │ └── storage_manager_config.h └── src │ ├── array │ ├── array.cc │ ├── array_iterator.cc │ ├── array_read_state.cc │ ├── array_schema.cc │ ├── array_sorted_read_state.cc │ └── array_sorted_write_state.cc │ ├── c_api │ └── tiledb.cc │ ├── fragment │ ├── book_keeping.cc │ ├── fragment.cc │ ├── read_state.cc │ └── write_state.cc │ ├── metadata │ ├── metadata.cc │ └── metadata_iterator.cc │ ├── misc │ ├── hilbert_curve.cc │ ├── progress_bar.cc │ └── utils.cc │ └── storage_manager │ ├── storage_manager.cc │ └── storage_manager_config.cc ├── doc ├── Doxyfile.mk └── mainpage.dox ├── examples ├── CMakeLists.txt └── src │ ├── tiledb_array_aio_read_dense.cc │ ├── tiledb_array_aio_write_dense.cc │ ├── tiledb_array_consolidate.cc │ ├── tiledb_array_create_dense.cc │ ├── tiledb_array_create_sparse.cc │ ├── tiledb_array_iterator_dense.cc │ ├── tiledb_array_iterator_sparse.cc │ ├── tiledb_array_parallel_consolidate_dense.cc │ ├── tiledb_array_parallel_consolidate_sparse.cc │ ├── tiledb_array_parallel_read_dense_1.cc │ ├── tiledb_array_parallel_read_dense_2.cc │ ├── tiledb_array_parallel_read_mpi_io_dense.cc │ ├── tiledb_array_parallel_read_sparse_1.cc │ ├── tiledb_array_parallel_read_sparse_2.cc │ ├── tiledb_array_parallel_write_dense_1.cc │ ├── tiledb_array_parallel_write_dense_2.cc │ ├── tiledb_array_parallel_write_sparse_1.cc │ ├── tiledb_array_parallel_write_sparse_2.cc │ ├── tiledb_array_primitive.cc │ ├── tiledb_array_read_dense_1.cc │ ├── tiledb_array_read_dense_2.cc │ ├── tiledb_array_read_dense_3.cc │ ├── tiledb_array_read_dense_sorted.cc │ ├── tiledb_array_read_sparse_1.cc │ ├── tiledb_array_read_sparse_2.cc │ ├── tiledb_array_read_sparse_sorted.cc │ ├── tiledb_array_update_dense_1.cc │ ├── tiledb_array_update_dense_2.cc │ ├── tiledb_array_update_sparse_1.cc │ ├── tiledb_array_update_sparse_2.cc │ ├── tiledb_array_write_dense_1.cc │ ├── tiledb_array_write_dense_2.cc │ ├── tiledb_array_write_dense_sorted.cc │ ├── tiledb_array_write_sparse_1.cc │ ├── tiledb_array_write_sparse_2.cc │ ├── tiledb_array_write_sparse_3.cc │ ├── tiledb_array_write_sparse_4.cc │ ├── tiledb_catching_errors.cc │ ├── tiledb_clear_delete_move.cc │ ├── tiledb_config.cc │ ├── tiledb_ls.cc │ ├── tiledb_ls_workspaces.cc │ ├── tiledb_metadata_consolidate.cc │ ├── tiledb_metadata_create.cc │ ├── tiledb_metadata_iterator.cc │ ├── tiledb_metadata_primitive.cc │ ├── tiledb_metadata_read.cc │ ├── tiledb_metadata_update.cc │ ├── tiledb_metadata_write.cc │ └── tiledb_workspace_group_create.cc └── test ├── CMakeLists.txt ├── include ├── c_api │ ├── c_api_array_schema_spec.h │ ├── c_api_dense_array_spec.h │ └── c_api_sparse_array_spec.h └── misc │ └── utils_spec.h └── src ├── c_api ├── c_api_array_schema_spec.cc ├── c_api_dense_array_spec.cc └── c_api_sparse_array_spec.cc └── misc └── utils_spec.cc /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | core/bin/* 3 | core/obj/* 4 | core/lib/* 5 | core/include/temp 6 | core/src/temp 7 | coverage.info 8 | test/obj/* 9 | test/bin/* 10 | Doxyfile.log 11 | doxyfile.inc 12 | doxygen/html/ 13 | doxygen/latex/ 14 | examples/bin/* 15 | examples/obj/* 16 | *temp* 17 | *.DS_Store 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Adapted from 2 | # http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/ 3 | 4 | sudo: required 5 | dist: trusty 6 | 7 | env: 8 | - TILEDB_BUILD_DIR=$TRAVIS_BUILD_DIR/build 9 | 10 | install: 11 | # Install cmake, lcov, MPICH 12 | - sudo apt-get -y install cmake lcov mpich 13 | # Install zlib, OpenSSL, Gtest and LZ4 14 | - sudo apt-get -y install zlib1g-dev libssl-dev libgtest-dev liblz4-dev 15 | # Install Zstandard 16 | - wget https://github.com/facebook/zstd/archive/v1.0.0.tar.gz 17 | - tar xf v1.0.0.tar.gz 18 | - cd zstd-1.0.0 19 | - sudo make install PREFIX='/usr' 20 | - cd $TRAVIS_BUILD_DIR 21 | # Install Blosc 22 | - git clone https://github.com/Blosc/c-blosc 23 | - cd c-blosc 24 | - mkdir build 25 | - cd build 26 | - cmake -DCMAKE_INSTALL_PREFIX='/usr' .. 27 | - cmake --build . 28 | - sudo cmake --build . --target install 29 | - cd $TRAVIS_BUILD_DIR 30 | # Install Google Test 31 | - cd /usr/src/gtest 32 | - sudo cmake . 33 | - sudo make 34 | - sudo mv libgtest* /usr/lib/ 35 | - cd $TRAVIS_BUILD_DIR 36 | # Install lcov to coveralls conversion + upload tool 37 | - gem install coveralls-lcov 38 | # Build TileDB 39 | - rm -rf $TILEDB_BUILD_DIR 40 | - mkdir -p $TILEDB_BUILD_DIR 41 | - cd $TILEDB_BUILD_DIR 42 | - cmake .. -DCMAKE_BUILD_TYPE=Coverage 43 | - make -j 4 44 | 45 | before_script: 46 | - lcov --directory $TILEDB_BUILD_DIR --zerocounters 47 | 48 | script: 49 | - make check -j 4 50 | 51 | after_success: 52 | - cd $TILEDB_BUILD_DIR 53 | - lcov --directory . --capture --output-file coverage.info 54 | - lcov --list coverage.info # debug before upload 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 MIT and Intel Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DISCONTINUATION OF PROJECT # 2 | This project will no longer be maintained by Intel. 3 | Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project. 4 | Intel no longer accepts patches to this project. 5 | If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. 6 | 7 | # TileDB 8 | 9 | [![Travis](https://img.shields.io/travis/Intel-HLS/TileDB.svg?maxAge=2592000)] 10 | (https://travis-ci.org/Intel-HLS/TileDB) 11 | 12 | The installation guide for TileDB can be found at this [Github 13 | Wiki](https://github.com/Intel-HLS/TileDB/wiki). 14 | 15 | The TileDB C API documentation and tutorials can be 16 | found at the [TileDB official website](http://istc-bigdata.org/tiledb). 17 | -------------------------------------------------------------------------------- /cmake/Modules/FindBLOSC.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # FindBLOSC.cmake 3 | # 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (c) 2016 MIT and Intel Corporation 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | # THE SOFTWARE. 26 | # 27 | # Finds the Blosc library. This module defines: 28 | # - BLOSC_INCLUDE_DIR, directory containing headers 29 | # - BLOSC_LIBRARIES, the Blosc library path 30 | # - BLOSC_FOUND, whether Blosc has been found 31 | 32 | # Find header files 33 | if(BLOSC_SEARCH_HEADER_PATHS) 34 | find_path( 35 | BLOSC_INCLUDE_DIR blosc.h 36 | PATHS ${BLOSC_SEARCH_HEADER_PATHS} 37 | NO_DEFAULT_PATH 38 | ) 39 | else() 40 | find_path(BLOSC_INCLUDE_DIR blosc.h) 41 | endif() 42 | 43 | # Find library 44 | if(BLOSC_SEARCH_LIB_PATH) 45 | find_library( 46 | BLOSC_LIBRARIES NAMES blosc 47 | PATHS ${BLOSC_SEARCH_LIB_PATH}$ 48 | NO_DEFAULT_PATH 49 | ) 50 | else() 51 | find_library(BLOSC_LIBRARIES NAMES blosc) 52 | endif() 53 | 54 | if(BLOSC_INCLUDE_DIR AND BLOSC_LIBRARIES) 55 | message(STATUS "Found Blosc: ${BLOSC_LIBRARIES}") 56 | set(BLOSC_FOUND TRUE) 57 | else() 58 | set(BLOSC_FOUND FALSE) 59 | endif() 60 | 61 | if(BLOSC_FIND_REQUIRED AND NOT BLOSC_FOUND) 62 | message(FATAL_ERROR "Could not find the Blosc library.") 63 | endif() 64 | 65 | -------------------------------------------------------------------------------- /cmake/Modules/FindLZ4.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # FindLZ4.cmake 3 | # 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (c) 2016 MIT and Intel Corporation 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | # THE SOFTWARE. 26 | # 27 | # Finds the LZ4 library. This module defines: 28 | # - LZ4_INCLUDE_DIR, directory containing headers 29 | # - LZ4_LIBRARIES, the LZ4 library path 30 | # - LZ4_FOUND, whether LZ4 has been found 31 | 32 | # Find header files 33 | if(LZ4_SEARCH_HEADER_PATHS) 34 | find_path( 35 | LZ4_INCLUDE_DIR lz4.h 36 | PATHS ${LZ4_SEARCH_HEADER_PATHS} 37 | NO_DEFAULT_PATH 38 | ) 39 | else() 40 | find_path(LZ4_INCLUDE_DIR lz4.h) 41 | endif() 42 | 43 | # Find library 44 | if(LZ4_SEARCH_LIB_PATH) 45 | find_library( 46 | LZ4_LIBRARIES NAMES lz4 47 | PATHS ${LZ4_SEARCH_LIB_PATH}$ 48 | NO_DEFAULT_PATH 49 | ) 50 | else() 51 | find_library(LZ4_LIBRARIES NAMES lz4) 52 | endif() 53 | 54 | if(LZ4_INCLUDE_DIR AND LZ4_LIBRARIES) 55 | message(STATUS "Found LZ4: ${LZ4_LIBRARIES}") 56 | set(LZ4_FOUND TRUE) 57 | else() 58 | set(LZ4_FOUND FALSE) 59 | endif() 60 | 61 | if(LZ4_FIND_REQUIRED AND NOT LZ4_FOUND) 62 | message(FATAL_ERROR "Could not find the LZ4 library.") 63 | endif() 64 | 65 | -------------------------------------------------------------------------------- /cmake/Modules/FindZSTD.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # FindZSTD.cmake 3 | # 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (c) 2016 MIT and Intel Corporation 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | # THE SOFTWARE. 26 | # 27 | # Finds the Zstandard library. This module defines: 28 | # - ZSTD_INCLUDE_DIR, directory containing headers 29 | # - ZSTD_LIBRARIES, the Zstandard library path 30 | # - ZSTD_FOUND, whether Zstandard has been found 31 | 32 | # Find header files 33 | if(ZSTD_SEARCH_HEADER_PATHS) 34 | find_path( 35 | ZSTD_INCLUDE_DIR zstd.h 36 | PATHS ${ZSTD_SEARCH_HEADER_PATHS} 37 | NO_DEFAULT_PATH 38 | ) 39 | else() 40 | find_path(ZSTD_INCLUDE_DIR zstd.h) 41 | endif() 42 | 43 | # Find library 44 | if(ZSTD_SEARCH_LIB_PATH) 45 | find_library( 46 | ZSTD_LIBRARIES NAMES zstd 47 | PATHS ${ZSTD_SEARCH_LIB_PATH}$ 48 | NO_DEFAULT_PATH 49 | ) 50 | else() 51 | find_library(ZSTD_LIBRARIES NAMES zstd) 52 | endif() 53 | 54 | if(ZSTD_INCLUDE_DIR AND ZSTD_LIBRARIES) 55 | message(STATUS "Found Zstandard: ${ZSTD_LIBRARIES}") 56 | set(ZSTD_FOUND TRUE) 57 | else() 58 | set(ZSTD_FOUND FALSE) 59 | endif() 60 | 61 | if(ZSTD_FIND_REQUIRED AND NOT ZSTD_FOUND) 62 | message(FATAL_ERROR "Could not find the Zstandard library.") 63 | endif() 64 | 65 | -------------------------------------------------------------------------------- /cmake/Modules/SetCXX2011Flag.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # SetCXX2011Flag.cmake 3 | # 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (c) 2017 MIT and Intel Corporation 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | # THE SOFTWARE. 26 | # 27 | # Sets compiler support for C++ 2011. 28 | # 29 | 30 | include(CheckCXXCompilerFlag) 31 | 32 | # Set support for C++ 2011 33 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") 34 | CHECK_CXX_COMPILER_FLAG(-std=gnu++11 CXX_2011_FOUND) 35 | if(NOT CXX_2011_FOUND) 36 | message(FATAL_ERROR "Your compiler does not support C++ 2011.") 37 | else() 38 | message(STATUS "Compiler supports C++ 2011.") 39 | endif() 40 | 41 | -------------------------------------------------------------------------------- /core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # core/CMakeLists.txt 3 | # 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (c) 2016 MIT and Intel Corporation 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | # THE SOFTWARE. 26 | # 27 | 28 | # Include core header directories 29 | file(GLOB TILEDB_CORE_INCLUDE_DIRS "include/*") 30 | include_directories(${TILEDB_CORE_INCLUDE_DIRS}) 31 | 32 | # Gather the core source files 33 | file(GLOB_RECURSE TILEDB_CORE_SOURCES "src/*.cc") 34 | 35 | # Compile sources with PIC 36 | add_library(TILEDB_CORE_OBJECTS OBJECT ${TILEDB_CORE_SOURCES}) 37 | set_property(TARGET TILEDB_CORE_OBJECTS PROPERTY POSITION_INDEPENDENT_CODE ON) 38 | 39 | # Create static library 40 | add_library(tiledb_static STATIC $) 41 | set_target_properties(tiledb_static PROPERTIES OUTPUT_NAME "tiledb") 42 | 43 | # Create dynamic library 44 | add_library(tiledb_shared SHARED $) 45 | set_target_properties(tiledb_shared PROPERTIES OUTPUT_NAME "tiledb") 46 | target_link_libraries(tiledb_shared ${TILEDB_LIB_DEPENDENCIES}) 47 | 48 | # Install libraries 49 | install( 50 | TARGETS tiledb_static tiledb_shared 51 | LIBRARY DESTINATION lib 52 | ARCHIVE DESTINATION lib 53 | ) 54 | file(GLOB TILEDB_HEADERS "include/c_api/*.h") 55 | install(FILES ${TILEDB_HEADERS} DESTINATION include) 56 | 57 | -------------------------------------------------------------------------------- /core/include/array/aio_request.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file aio_request.h 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * This file declares the AIO_Request struct. 31 | */ 32 | 33 | #ifndef __AIO_REQUEST_H__ 34 | #define __AIO_REQUEST_H__ 35 | 36 | #include 37 | 38 | /** Describes an AIO (read or write) request. */ 39 | struct AIO_Request { 40 | /** 41 | * An array of buffers, one for each attribute. These must be 42 | * provided in the same order as the attributes specified in 43 | * array initialization or when resetting the attributes. The case of 44 | * variable-sized attributes is special. Instead of providing a single 45 | * buffer for such an attribute, **two** must be provided: the second 46 | * will hold the variable-sized cell values, whereas the first holds the 47 | * start offsets of each cell in the second buffer. 48 | */ 49 | void** buffers_; 50 | /** 51 | * The sizes (in bytes) allocated by the user for the input 52 | * buffers (there is a one-to-one correspondence). The function will attempt 53 | * to write as many results as can fit in the buffers, and potentially 54 | * alter the buffer size to indicate the size of the *useful* data written 55 | * in the buffer. 56 | */ 57 | size_t* buffer_sizes_; 58 | /** Function to be called upon completion of the request. */ 59 | void *(*completion_handle_) (void*); 60 | /** Data to be passed to the completion handle. */ 61 | void* completion_data_; 62 | /** A unique request id. */ 63 | size_t id_; 64 | /** 65 | * It can be one of the following: 66 | * - TILEDB_ARRAY_READ 67 | * - TILEDB_ARRAY_READ_SORTED_COL 68 | * - TILEDB_ARRAY_READ_SORTED_ROW 69 | * - TILEDB_ARRAY_WRITE 70 | * - TILEDB_ARRAY_WRITE_UNSORTED 71 | */ 72 | int mode_; 73 | /** 74 | * Applicable only to read requests. 75 | * Indicates whether a buffer has overflowed during a read request. 76 | * If it is NULL, it will be ignored. Otherwise, it must be an array 77 | * with as many elements as the number of buffers above. 78 | */ 79 | bool* overflow_; 80 | /** 81 | * The status of the AIO request. It can be one of the following: 82 | * - TILEDB_AIO_COMPLETED 83 | * The request is completed. 84 | * - TILEDB_AIO_INPROGRESS 85 | * The request is still in progress. 86 | * - TILEDB_AIO_OVERFLOW 87 | * At least one of the input buffers overflowed (applicable only to AIO 88 | * read requests) 89 | * - TILEDB_AIO_ERR 90 | * The request caused an error (and thus was canceled). 91 | */ 92 | int* status_; 93 | /** 94 | * The subarray in which the array read/write will be 95 | * constrained on. It should be a sequence of [low, high] pairs (one 96 | * pair per dimension), whose type should be the same as that of the 97 | * coordinates. If it is NULL, then the subarray is set to the entire 98 | * array domain. For the case of writes, this is meaningful only for 99 | * dense arrays, and specifically dense writes. 100 | */ 101 | const void* subarray_; 102 | }; 103 | 104 | #endif 105 | 106 | -------------------------------------------------------------------------------- /core/include/array/array_schema_c.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file array_schema_c.h 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * A C-style struct that specifies the array schema. 31 | */ 32 | 33 | #ifndef __ARRAY_SCHEMA_C_H__ 34 | #define __ARRAY_SCHEMA_C_H__ 35 | 36 | #include 37 | 38 | /** Specifies the array schema. */ 39 | typedef struct ArraySchemaC { 40 | /** 41 | * The array name. It is a directory, whose parent must be a TileDB workspace, 42 | * or group. 43 | */ 44 | char* array_name_; 45 | /** The attribute names. */ 46 | char** attributes_; 47 | /** The number of attributes. */ 48 | int attribute_num_; 49 | /** 50 | * The tile capacity for the case of sparse fragments. If it is <=0, 51 | * TileDB will use its default. 52 | */ 53 | int64_t capacity_; 54 | /** 55 | * The cell order. It can be one of the following: 56 | * - TILEDB_ROW_MAJOR 57 | * - TILEDB_COL_MAJOR 58 | * - TILEDB_HILBERT. 59 | */ 60 | int cell_order_; 61 | /** 62 | * Specifies the number of values per attribute for a cell. If it is NULL, 63 | * then each attribute has a single value per cell. If for some attribute 64 | * the number of values is variable (e.g., in the case off strings), then 65 | * TILEDB_VAR_NUM must be used. 66 | */ 67 | int* cell_val_num_; 68 | /** 69 | * The compression type for each attribute (plus one extra at the end for the 70 | * coordinates. It can be one of the following: 71 | * - TILEDB_NO_COMPRESSION 72 | * - TILEDB_GZIP 73 | * - TILEDB_ZSTD 74 | * - TILEDB_LZ4 75 | * - TILEDB_BLOSC 76 | * - TILEDB_BLOSC_LZ4 77 | * - TILEDB_BLOSC_LZ4HC 78 | * - TILEDB_BLOSC_SNAPPY 79 | * - TILEDB_BLOSC_ZLIB 80 | * - TILEDB_BLOSC_ZSTD 81 | * - TILEDB_RLE 82 | */ 83 | int* compression_; 84 | /** 85 | * Specifies if the array is dense (1) or sparse (0). If the array is dense, 86 | * then the user must specify tile extents (see below). 87 | */ 88 | int dense_; 89 | /** The dimension names. */ 90 | char** dimensions_; 91 | /** The number of dimensions. */ 92 | int dim_num_; 93 | /** 94 | * The array domain. It should contain one [lower, upper] pair per dimension. 95 | * The type of the values stored in this buffer should match the coordinates 96 | * type. 97 | */ 98 | void* domain_; 99 | /** 100 | * The tile extents. There should be one value for each dimension. The type of 101 | * the values stored in this buffer should match the coordinates type. If it 102 | * is NULL (applicable only to sparse arrays), then it means that the 103 | * array has irregular tiles. 104 | */ 105 | void* tile_extents_; 106 | /** 107 | * The tile order. It can be one of the following: 108 | * - TILEDB_ROW_MAJOR 109 | * - TILEDB_COL_MAJOR. 110 | */ 111 | int tile_order_; 112 | /** 113 | * The attribute types, plus an extra one in the end for the coordinates. 114 | * The attribute type can be one of the following: 115 | * - TILEDB_INT32 116 | * - TILEDB_INT64 117 | * - TILEDB_FLOAT32 118 | * - TILEDB_FLOAT64 119 | * - TILEDB_CHAR 120 | * 121 | * The coordinate type can be one of the following: 122 | * - TILEDB_INT32 123 | * - TILEDB_INT64 124 | * - TILEDB_FLOAT32 125 | * - TILEDB_FLOAT64 126 | */ 127 | int* types_; 128 | } ArraySchemaC; 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /core/include/metadata/metadata_schema_c.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file metadata_schema_c.h 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * A C-style struct that specifies the metadata schema. 31 | */ 32 | 33 | #ifndef __METADATA_SCHEMA_C_H__ 34 | #define __METADATA_SCHEMA_C_H__ 35 | 36 | #include 37 | 38 | /** Specifies the metadata schema. */ 39 | typedef struct MetadataSchemaC { 40 | /** 41 | * The metadata name. It is a directory, whose parent must be a TileDB 42 | * workspace, group, or array. 43 | */ 44 | char* metadata_name_; 45 | /** The attribute names. */ 46 | char** attributes_; 47 | /** The number of attributes. */ 48 | int attribute_num_; 49 | /** 50 | * The tile capacity. If it is <=0, TileDB will use its default. 51 | */ 52 | int64_t capacity_; 53 | /** 54 | * Specifies the number of values per attribute for a cell. If it is NULL, 55 | * then each attribute has a single value per cell. If for some attribute 56 | * the number of values is variable (e.g., in the case off strings), then 57 | * TILEDB_VAR_NUM must be used. 58 | */ 59 | int* cell_val_num_; 60 | /** 61 | * The compression type for each attribute (plus one extra at the end for the 62 | * key. It can be one of the following: 63 | * - TILEDB_NO_COMPRESSION 64 | * - TILEDB_GZIP 65 | * - TILEDB_ZSTD 66 | * - TILEDB_LZ4 67 | * - TILEDB_BLOSC 68 | * - TILEDB_BLOSC_LZ4 69 | * - TILEDB_BLOSC_LZ4HC 70 | * - TILEDB_BLOSC_SNAPPY 71 | * - TILEDB_BLOSC_ZLIB 72 | * - TILEDB_BLOSC_ZSTD 73 | * - TILEDB_RLE 74 | */ 75 | int* compression_; 76 | /** 77 | * The attribute types. 78 | * The attribute type can be one of the following: 79 | * - TILEDB_INT32 80 | * - TILEDB_INT64 81 | * - TILEDB_FLOAT32 82 | * - TILEDB_FLOAT64 83 | * - TILEDB_CHAR. 84 | */ 85 | int* types_; 86 | } MetadataSchemaC; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /core/include/misc/progress_bar.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file progress_bar.h 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * This file defines class ProgressBar. 31 | */ 32 | 33 | #ifndef __PROGRESS_BAR_H__ 34 | #define __PROGRESS_BAR_H__ 35 | 36 | #include 37 | 38 | /** The default complete amount of the bar. */ 39 | #define PB_COMPLETE 1.0 40 | /** The default filler character of the bar. */ 41 | #define PB_FILLER '=' 42 | /** The default maximum length of the bar. */ 43 | #define PB_MAX_LENGTH 30 44 | /** The increase in the incomplete/complete ratio before the next print. */ 45 | #define PB_RATIO_STEP 0.01 46 | 47 | 48 | 49 | /** Implements a simple progress bar printed in standard output. */ 50 | class ProgressBar { 51 | public: 52 | /* ********************************* */ 53 | /* CONSTRUCTORS & DESTRUCTORS */ 54 | /* ********************************* */ 55 | 56 | /** 57 | * Constructor. 58 | * 59 | * @param complete The amount at which the bar must reach its maximum length. 60 | * @param max_length The visual length of the bar. 61 | * @param filler The character that fills the bar. 62 | */ 63 | ProgressBar( 64 | double complete = PB_COMPLETE, 65 | int max_length = PB_MAX_LENGTH, 66 | char filler = PB_FILLER); 67 | 68 | /** Destructor. */ 69 | ~ProgressBar(); 70 | 71 | 72 | 73 | 74 | /* ********************************* */ 75 | /* METHODS */ 76 | /* ********************************* */ 77 | 78 | /** 79 | * "Loads" the progress bar with the input amount, which may trigger drawing 80 | * the current progress on the standard output. 81 | */ 82 | void load(double amount); 83 | 84 | 85 | private: 86 | /* ********************************* */ 87 | /* PRIVATE ATTRIBUTES */ 88 | /* ********************************* */ 89 | 90 | /** The amount at which the bar reaches its maximum length. */ 91 | double complete_; 92 | /** The character that fills the bar. */ 93 | char filler_; 94 | /** The current amount accummulated towards completion. */ 95 | double incomplete_; 96 | /** The incomplete/complete ratio upon the last print. */ 97 | double last_ratio_; 98 | /** The bar current length. */ 99 | int length_; 100 | /** The bar maximum length. */ 101 | int max_length_; 102 | /** The current ratio incomplete/complete. */ 103 | double ratio_; 104 | 105 | 106 | 107 | /* ********************************* */ 108 | /* PRIVATE METHODS */ 109 | /* ********************************* */ 110 | 111 | /** Prints the bar with its current status. */ 112 | void print(); 113 | }; 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /core/include/storage_manager/storage_manager_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file storage_manager_config.h 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * This file defines class StorageManagerConfig. 31 | */ 32 | 33 | #ifndef __CONFIG_H__ 34 | #define __CONFIG_H__ 35 | 36 | #ifdef HAVE_MPI 37 | #include 38 | #endif 39 | #include 40 | 41 | 42 | 43 | 44 | /** 45 | * This class is responsible for the TileDB storage manager configuration 46 | * parameters. 47 | */ 48 | class StorageManagerConfig { 49 | public: 50 | /* ********************************* */ 51 | /* CONSTRUCTORS & DESTRUCTORS */ 52 | /* ********************************* */ 53 | 54 | /** Constructor. */ 55 | StorageManagerConfig(); 56 | 57 | /** Destructor. */ 58 | ~StorageManagerConfig(); 59 | 60 | 61 | 62 | 63 | /* ********************************* */ 64 | /* MUTATORS */ 65 | /* ********************************* */ 66 | 67 | #ifdef HAVE_MPI 68 | /** 69 | * Initializes the configuration parameters. 70 | * 71 | * @param home The TileDB home directory. 72 | * @param mpi_comm The MPI communicator. 73 | * @param read_method The method for reading data from a file. 74 | * It can be one of the following: 75 | * - TILEDB_IO_READ 76 | * TileDB will use POSIX read. 77 | * - TILEDB_IO_MMAP 78 | * TileDB will use mmap. 79 | * - TILEDB_IO_MPI 80 | * TileDB will use MPI-IO read. 81 | * @param write_method The method for writing data to a file. 82 | * It can be one of the following: 83 | * - TILEDB_IO_WRITE 84 | * TileDB will use POSIX write. 85 | * - TILEDB_IO_MPI 86 | * TileDB will use MPI-IO write. 87 | * @return void. 88 | */ 89 | void init( 90 | const char* home, 91 | MPI_Comm* mpi_comm, 92 | int read_method, 93 | int write_methods); 94 | #else 95 | /** 96 | * Initializes the configuration parameters. 97 | * 98 | * @param home The TileDB home directory. 99 | * @param read_method The method for reading data from a file. 100 | * It can be one of the following: 101 | * - TILEDB_IO_READ 102 | * TileDB will use POSIX read. 103 | * - TILEDB_IO_MMAP 104 | * TileDB will use mmap. 105 | * - TILEDB_IO_MPI 106 | * TileDB will use MPI-IO read. 107 | * @param write_method The method for writing data to a file. 108 | * It can be one of the following: 109 | * - TILEDB_IO_WRITE 110 | * TileDB will use POSIX write. 111 | * - TILEDB_IO_MPI 112 | * TileDB will use MPI-IO write. 113 | * @return void. 114 | */ 115 | void init( 116 | const char* home, 117 | int read_method, 118 | int write_method); 119 | #endif 120 | 121 | /* ********************************* */ 122 | /* ACCESSORS */ 123 | /* ********************************* */ 124 | 125 | /** Returns the TileDB home directory. */ 126 | const std::string& home() const; 127 | 128 | #ifdef HAVE_MPI 129 | /** Returns the MPI communicator. */ 130 | MPI_Comm* mpi_comm() const; 131 | #endif 132 | 133 | /** Returns the read method. */ 134 | int read_method() const; 135 | 136 | /** Returns the write method. */ 137 | int write_method() const; 138 | 139 | private: 140 | /* ********************************* */ 141 | /* PRIVATE ATTRIBUTES */ 142 | /* ********************************* */ 143 | 144 | /** TileDB home directory. */ 145 | std::string home_; 146 | #ifdef HAVE_MPI 147 | /** The MPI communicator. */ 148 | MPI_Comm* mpi_comm_; 149 | #endif 150 | /** 151 | * The method for reading data from a file. 152 | * It can be one of the following: 153 | * - TILEDB_IO_READ 154 | * TileDB will use POSIX read. 155 | * - TILEDB_IO_MMAP 156 | * TileDB will use mmap. 157 | * - TILEDB_IO_MPI 158 | * TileDB will use MPI-IO read. 159 | */ 160 | int read_method_; 161 | /** 162 | * The method for writing data to a file. 163 | * It can be one of the following: 164 | * - TILEDB_IO_WRITE 165 | * TileDB will use POSIX write. 166 | * - TILEDB_IO_MPI 167 | * TileDB will use MPI-IO write. 168 | */ 169 | int write_method_; 170 | }; 171 | 172 | #endif 173 | -------------------------------------------------------------------------------- /core/src/metadata/metadata_iterator.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file metadata_iterator.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * This file implements the MetadataIterator class. 31 | */ 32 | 33 | #include "metadata_iterator.h" 34 | 35 | 36 | 37 | 38 | /* ****************************** */ 39 | /* MACROS */ 40 | /* ****************************** */ 41 | 42 | #ifdef TILEDB_VERBOSE 43 | # define PRINT_ERROR(x) std::cerr << TILEDB_MIT_ERRMSG << x << ".\n" 44 | #else 45 | # define PRINT_ERROR(x) do { } while(0) 46 | #endif 47 | 48 | 49 | 50 | 51 | /* ****************************** */ 52 | /* GLOBAL VARIABLES */ 53 | /* ****************************** */ 54 | 55 | std::string tiledb_mit_errmsg = ""; 56 | 57 | 58 | 59 | 60 | /* ****************************** */ 61 | /* CONSTRUCTORS & DESTRUCTORS */ 62 | /* ****************************** */ 63 | 64 | MetadataIterator::MetadataIterator() { 65 | array_it_ = NULL; 66 | } 67 | 68 | MetadataIterator::~MetadataIterator() { 69 | } 70 | 71 | 72 | 73 | 74 | /* ****************************** */ 75 | /* ACCESSORS */ 76 | /* ****************************** */ 77 | 78 | const std::string& MetadataIterator::metadata_name() const { 79 | return array_it_->array_name(); 80 | } 81 | 82 | bool MetadataIterator::end() const { 83 | return array_it_->end(); 84 | } 85 | 86 | int MetadataIterator::get_value( 87 | int attribute_id, 88 | const void** value, 89 | size_t* value_size) const { 90 | if(array_it_->get_value(attribute_id, value, value_size) != TILEDB_AIT_OK) { 91 | tiledb_mit_errmsg = tiledb_ait_errmsg; 92 | return TILEDB_MIT_ERR; 93 | } 94 | 95 | // Success 96 | return TILEDB_MIT_OK; 97 | } 98 | 99 | 100 | 101 | 102 | /* ****************************** */ 103 | /* MUTATORS */ 104 | /* ****************************** */ 105 | 106 | int MetadataIterator::finalize() { 107 | int rc = array_it_->finalize(); 108 | delete array_it_; 109 | array_it_ = NULL; 110 | delete metadata_; 111 | metadata_ = NULL; 112 | 113 | // Error 114 | if(rc != TILEDB_AIT_OK) { 115 | tiledb_mit_errmsg = tiledb_ait_errmsg; 116 | return TILEDB_MIT_ERR; 117 | } 118 | 119 | // Success 120 | return TILEDB_MIT_OK; 121 | } 122 | 123 | int MetadataIterator::init( 124 | Metadata* metadata, 125 | void** buffers, 126 | size_t* buffer_sizes) { 127 | // Initialize an array iterator 128 | metadata_ = metadata; 129 | array_it_ = new ArrayIterator(); 130 | if(array_it_->init(metadata->array(), buffers, buffer_sizes) != 131 | TILEDB_AIT_OK) { 132 | delete array_it_; 133 | array_it_ = NULL; 134 | tiledb_mit_errmsg = tiledb_ait_errmsg; 135 | return TILEDB_MIT_ERR; 136 | } 137 | 138 | // Return 139 | return TILEDB_MIT_OK; 140 | } 141 | 142 | int MetadataIterator::next() { 143 | if(array_it_->next() != TILEDB_AIT_OK) { 144 | tiledb_mit_errmsg = tiledb_ait_errmsg; 145 | return TILEDB_MIT_ERR; 146 | } 147 | 148 | // Success 149 | return TILEDB_MIT_OK; 150 | } 151 | -------------------------------------------------------------------------------- /core/src/misc/hilbert_curve.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hilbert_curve.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * This file implements the HilbertCurve class. 31 | */ 32 | 33 | #include "hilbert_curve.h" 34 | #include 35 | #include 36 | 37 | 38 | 39 | 40 | /* ****************************** */ 41 | /* CONSTRUCTORS & DESTRUCTORS */ 42 | /* ****************************** */ 43 | 44 | HilbertCurve::HilbertCurve(int bits, int dim_num) 45 | : bits_(bits), dim_num_(dim_num) { 46 | assert(dim_num >=0 && dim_num < HC_MAX_DIM); 47 | assert(bits * dim_num <= int(sizeof(int64_t)*8)); 48 | } 49 | 50 | HilbertCurve::~HilbertCurve() { 51 | } 52 | 53 | 54 | 55 | 56 | /* ****************************** */ 57 | /* BASIC FUNCTIONS */ 58 | /* ****************************** */ 59 | 60 | void HilbertCurve::coords_to_hilbert(const int* coords, int64_t& hilbert) { 61 | // Copy coords to temporary storage 62 | memcpy(temp_, coords, dim_num_ * sizeof(int)); 63 | 64 | // Convert coords to the transpose form of the hilbert value 65 | AxestoTranspose(temp_, bits_, dim_num_); 66 | 67 | // Convert the hilbert transpose form into an int64_t hilbert value 68 | hilbert = 0; 69 | int64_t c = 1; // This is a bit shifted from right to left over temp_[i] 70 | int64_t h = 1; // This is a bit shifted from right to left over hilbert 71 | for(int j=0; j=0; --i, h <<= 1) { 73 | if(temp_[i] & c) 74 | hilbert |= h; 75 | } 76 | } 77 | } 78 | 79 | void HilbertCurve::hilbert_to_coords(int64_t hilbert, int* coords) { 80 | // Initialization 81 | for(int i=0; i=0; --i, h <<= 1) { 89 | if(hilbert & h) 90 | temp_[i] |= c; 91 | } 92 | } 93 | 94 | // Convert coords to the transpose form of the hilbert value 95 | TransposetoAxes(temp_, bits_, dim_num_); 96 | 97 | // Copy from the temporary storage to the (output) coords 98 | memcpy(coords, temp_, dim_num_ * sizeof(int)); 99 | } 100 | 101 | 102 | 103 | 104 | /* ****************************** */ 105 | /* PRIVATE METHODS */ 106 | /* ****************************** */ 107 | 108 | void HilbertCurve::AxestoTranspose(int* X, int b, int n) { 109 | int P, Q, t, i; 110 | 111 | // Inverse undo 112 | for(Q = 1 << (b - 1); Q > 1; Q >>= 1) { 113 | P = Q - 1; 114 | if(X[0] & Q) // invert 115 | X[0] ^= P; 116 | for(i = 1; i < n; i++) 117 | if(X[i] & Q) // invert 118 | X[0] ^= P; 119 | else { // exchange 120 | t = (X[0] ^ X[i]) & P; 121 | X[0] ^= t; 122 | X[i] ^= t; 123 | } 124 | } 125 | 126 | // Gray encode (inverse of decode) 127 | for(i = 1; i < n; i++) 128 | X[i] ^= X[i-1]; 129 | t = X[n-1]; 130 | for(i = 1; i < b; i <<= 1) 131 | X[n-1] ^= X[n-1] >> i; 132 | t ^= X[n-1]; 133 | for(i = n-2; i >= 0; i--) 134 | X[i] ^= t; 135 | } 136 | 137 | void HilbertCurve::TransposetoAxes(int* X, int b, int n) { 138 | int M, P, Q, t, i; 139 | 140 | // Gray decode by H ^ (H/2) 141 | t = X[n-1] >> 1; 142 | for(i = n-1; i; i--) 143 | X[i] ^= X[i-1]; 144 | X[0] ^= t; 145 | 146 | // Undo excess work 147 | M = 2 << (b - 1); 148 | for(Q = 2; Q != M; Q <<= 1) { 149 | P = Q - 1; 150 | for(i = n-1; i; i--) 151 | if(X[i] & Q) // invert 152 | X[0] ^= P; 153 | else { // exchange 154 | t = (X[0] ^ X[i]) & P; 155 | X[0] ^= t; 156 | X[i] ^= t; 157 | } 158 | if(X[0] & Q) // invert 159 | X[0] ^= P; 160 | } 161 | } 162 | 163 | -------------------------------------------------------------------------------- /core/src/misc/progress_bar.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file progress_bar.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * This file implements class ProgressBar. 31 | */ 32 | 33 | #include "progress_bar.h" 34 | #include 35 | 36 | 37 | 38 | 39 | /* ****************************** */ 40 | /* CONSTRUCTORS & DESTRUCTORS */ 41 | /* ****************************** */ 42 | 43 | ProgressBar::ProgressBar(double complete, int max_length, char filler) { 44 | complete_ = complete; 45 | filler_ = filler; 46 | length_ = 0; 47 | incomplete_ = 0; 48 | last_ratio_ = 0; 49 | max_length_ = max_length; 50 | ratio_ = 0; 51 | } 52 | 53 | ProgressBar::~ProgressBar() { 54 | } 55 | 56 | 57 | 58 | 59 | /* ****************************** */ 60 | /* METHODS */ 61 | /* ****************************** */ 62 | 63 | void ProgressBar::load(double amount) { 64 | incomplete_ += amount; 65 | if(incomplete_ > complete_) 66 | incomplete_ = complete_; 67 | 68 | ratio_ = (incomplete_ / complete_); 69 | length_ = ratio_ * max_length_; 70 | 71 | // Print bar 72 | if(ratio_ - last_ratio_ > PB_RATIO_STEP) { 73 | print(); 74 | last_ratio_ = ratio_; 75 | } 76 | } 77 | 78 | 79 | 80 | 81 | /* ****************************** */ 82 | /* PRIVATE METHODS */ 83 | /* ****************************** */ 84 | 85 | void ProgressBar::print() { 86 | fprintf(stdout, "%3d%% [", (int)(ratio_ * 100)); 87 | 88 | for(int i=0; i 35 | #include 36 | 37 | // Simply prints the input string to stdout 38 | void *print_upon_completion(void* s) { 39 | printf("%s\n", (char*) s); 40 | 41 | return NULL; 42 | } 43 | 44 | int main() { 45 | // Initialize context with the default configuration parameters 46 | TileDB_CTX* tiledb_ctx; 47 | tiledb_ctx_init(&tiledb_ctx, NULL); 48 | 49 | // Initialize array 50 | TileDB_Array* tiledb_array; 51 | tiledb_array_init( 52 | tiledb_ctx, // Context 53 | &tiledb_array, // Array object 54 | "my_workspace/dense_arrays/my_array_A", // Array name 55 | TILEDB_ARRAY_READ, // Mode 56 | NULL, // Whole domain 57 | NULL, // All attributes 58 | 0); // Number of attributes 59 | 60 | // Prepare subarray 61 | int64_t subarray[] = { 3, 4, 2, 4 }; // [3,4] on first dim, [2,4] on second 62 | 63 | // Prepare cell buffers 64 | int buffer_a1[16]; 65 | size_t buffer_a2[16]; 66 | char buffer_var_a2[40]; 67 | float buffer_a3[32]; 68 | void* buffers[] = { buffer_a1, buffer_a2, buffer_var_a2, buffer_a3 }; 69 | size_t buffer_sizes[] = 70 | { 71 | sizeof(buffer_a1), 72 | sizeof(buffer_a2), 73 | sizeof(buffer_var_a2), 74 | sizeof(buffer_a3) 75 | }; 76 | 77 | // Prepare AIO request 78 | TileDB_AIO_Request tiledb_aio_request; 79 | memset(&tiledb_aio_request, 0, sizeof(struct TileDB_AIO_Request)); 80 | tiledb_aio_request.buffers_ = buffers; 81 | tiledb_aio_request.buffer_sizes_ = buffer_sizes; 82 | tiledb_aio_request.subarray_ = subarray; 83 | tiledb_aio_request.completion_handle_ = print_upon_completion; 84 | char s[100] = "AIO request completed"; 85 | tiledb_aio_request.completion_data_ = s; 86 | 87 | // Read from array 88 | tiledb_array_aio_read(tiledb_array, &tiledb_aio_request); 89 | 90 | // Wait for AIO to complete 91 | printf("AIO in progress\n"); 92 | while(tiledb_aio_request.status_ != TILEDB_AIO_COMPLETED); 93 | 94 | // Print cell values 95 | int64_t result_num = buffer_sizes[0] / sizeof(int); 96 | printf(" a1\t a2\t (a3.first, a3.second)\n"); 97 | printf("-----------------------------------------\n"); 98 | for(int i=0; i 36 | 37 | // Simply prints the input string to stdout 38 | void *print_upon_completion(void* s) { 39 | printf("%s\n", (char*) s); 40 | 41 | return NULL; 42 | } 43 | 44 | int main() { 45 | // Initialize context with the default configuration parameters 46 | TileDB_CTX* tiledb_ctx; 47 | tiledb_ctx_init(&tiledb_ctx, NULL); 48 | 49 | // Initialize array 50 | TileDB_Array* tiledb_array; 51 | tiledb_array_init( 52 | tiledb_ctx, // Context 53 | &tiledb_array, // Array object 54 | "my_workspace/dense_arrays/my_array_A", // Array name 55 | TILEDB_ARRAY_WRITE, // Mode 56 | NULL, // Entire domain 57 | NULL, // All attributes 58 | 0); // Number of attributes 59 | 60 | // Prepare cell buffers 61 | int buffer_a1[] = 62 | { 63 | 0, 1, 2, 3, // Upper left tile 64 | 4, 5, 6, 7, // Upper right tile 65 | 8, 9, 10, 11, // Lower left tile 66 | 12, 13, 14, 15 // Lower right tile 67 | }; 68 | size_t buffer_a2[] = 69 | { 70 | 0, 1, 3, 6, // Upper left tile 71 | 10, 11, 13, 16, // Upper right tile 72 | 20, 21, 23, 26, // Lower left tile 73 | 30, 31, 33, 36 // Lower right tile 74 | }; 75 | char buffer_var_a2[] = 76 | "abbcccdddd" // Upper left tile 77 | "effggghhhh" // Upper right tile 78 | "ijjkkkllll" // Lower left tile 79 | "mnnooopppp"; // Lower right tile 80 | float buffer_a3[] = 81 | { 82 | 0.1, 0.2, 1.1, 1.2, 2.1, 2.2, 3.1, 3.2, // Upper left tile 83 | 4.1, 4.2, 5.1, 5.2, 6.1, 6.2, 7.1, 7.2, // Upper right tile 84 | 8.1, 8.2, 9.1, 9.2, 10.1, 10.2, 11.1, 11.2, // Lower left tile 85 | 12.1, 12.2, 13.1, 13.2, 14.1, 14.2, 15.1, 15.2, // Lower right tile 86 | }; 87 | void* buffers[] = { buffer_a1, buffer_a2, buffer_var_a2, buffer_a3 }; 88 | size_t buffer_sizes[] = 89 | { 90 | sizeof(buffer_a1), 91 | sizeof(buffer_a2), 92 | sizeof(buffer_var_a2)-1, // No need to store the last '\0' character 93 | sizeof(buffer_a3) 94 | }; 95 | 96 | // Prepare AIO request 97 | TileDB_AIO_Request tiledb_aio_request; 98 | // ALWAYS zero out the struct before populating it 99 | memset(&tiledb_aio_request, 0, sizeof(struct TileDB_AIO_Request)); 100 | tiledb_aio_request.buffers_ = buffers; 101 | tiledb_aio_request.buffer_sizes_ = buffer_sizes; 102 | tiledb_aio_request.completion_handle_ = print_upon_completion; 103 | char s[100] = "AIO request completed"; 104 | tiledb_aio_request.completion_data_ = s; 105 | 106 | // Write to array 107 | tiledb_array_aio_write(tiledb_array, &tiledb_aio_request); 108 | 109 | // Wait for AIO to complete 110 | printf("AIO in progress\n"); 111 | while(tiledb_aio_request.status_ != TILEDB_AIO_COMPLETED); 112 | 113 | // Finalize array 114 | tiledb_array_finalize(tiledb_array); 115 | 116 | // Finalize context 117 | tiledb_ctx_finalize(tiledb_ctx); 118 | 119 | return 0; 120 | } 121 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_consolidate.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_consolidate.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to consolidate arrays. 31 | */ 32 | 33 | #include "tiledb.h" 34 | 35 | int main() { 36 | // Initialize context with the default configuration parameters 37 | TileDB_CTX* tiledb_ctx; 38 | tiledb_ctx_init(&tiledb_ctx, NULL); 39 | 40 | // Consolidate the dense array 41 | tiledb_array_consolidate(tiledb_ctx, "my_workspace/dense_arrays/my_array_A"); 42 | 43 | // Consolidate the sparse array 44 | tiledb_array_consolidate(tiledb_ctx, "my_workspace/sparse_arrays/my_array_B"); 45 | 46 | // Finalize context 47 | tiledb_ctx_finalize(tiledb_ctx); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_create_dense.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_create_dense.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to create a dense array. 31 | */ 32 | 33 | #include "tiledb.h" 34 | 35 | int main() { 36 | // Initialize context with the default configuration parameters 37 | TileDB_CTX* tiledb_ctx; 38 | tiledb_ctx_init(&tiledb_ctx, NULL); 39 | 40 | // Prepare parameters for array schema 41 | const char* array_name = "my_workspace/dense_arrays/my_array_A"; 42 | const char* attributes[] = { "a1", "a2", "a3" }; // Three attributes 43 | const char* dimensions[] = { "d1", "d2" }; // Two dimensions 44 | int64_t domain[] = 45 | { 46 | 1, 4, // d1 47 | 1, 4 // d2 48 | }; 49 | const int cell_val_num[] = 50 | { 51 | 1, // a1 52 | TILEDB_VAR_NUM, // a2 53 | 2 // a3 54 | }; 55 | const int compression[] = 56 | { 57 | TILEDB_GZIP, // a1 58 | TILEDB_ZSTD, // a2 59 | TILEDB_LZ4, // a3 60 | TILEDB_NO_COMPRESSION // coordinates 61 | }; 62 | int64_t tile_extents[] = 63 | { 64 | 2, // d1 65 | 2 // d2 66 | }; 67 | const int types[] = 68 | { 69 | TILEDB_INT32, // a1 70 | TILEDB_CHAR, // a2 71 | TILEDB_FLOAT32, // a3 72 | TILEDB_INT64 // coordinates 73 | }; 74 | 75 | // Set array schema 76 | TileDB_ArraySchema array_schema; 77 | tiledb_array_set_schema( 78 | &array_schema, // Array schema struct 79 | array_name, // Array name 80 | attributes, // Attributes 81 | 3, // Number of attributes 82 | 2, // Capacity 83 | TILEDB_ROW_MAJOR, // Cell order 84 | cell_val_num, // Number of cell values per attribute 85 | compression, // Compression 86 | 1, // Dense array 87 | dimensions, // Dimensions 88 | 2, // Number of dimensions 89 | domain, // Domain 90 | 4*sizeof(int64_t), // Domain length in bytes 91 | tile_extents, // Tile extents 92 | 2*sizeof(int64_t), // Tile extents length in bytes 93 | TILEDB_ROW_MAJOR, // Tile order 94 | types // Types 95 | ); 96 | 97 | // Create array 98 | tiledb_array_create(tiledb_ctx, &array_schema); 99 | 100 | // Free array schema 101 | tiledb_array_free_schema(&array_schema); 102 | 103 | /* Finalize context. */ 104 | tiledb_ctx_finalize(tiledb_ctx); 105 | 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_create_sparse.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_create_sparse.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to create a sparse array. 31 | */ 32 | 33 | #include "tiledb.h" 34 | 35 | int main() { 36 | // Initialize context with the default configuration parameters 37 | TileDB_CTX* tiledb_ctx; 38 | tiledb_ctx_init(&tiledb_ctx, NULL); 39 | 40 | // Prepare parameters for array schema 41 | const char* array_name = "my_workspace/sparse_arrays/my_array_B"; 42 | const char* attributes[] = { "a1", "a2", "a3" }; // Three attributes 43 | const char* dimensions[] = { "d1", "d2" }; // Two dimensions 44 | int64_t domain[] = 45 | { 46 | 1, 4, // d1 47 | 1, 4 // d2 48 | }; 49 | const int cell_val_num[] = 50 | { 51 | 1, // a1 52 | TILEDB_VAR_NUM, // a2 53 | 2 // a3 54 | }; 55 | const int compression[] = 56 | { 57 | TILEDB_GZIP, // a1 58 | TILEDB_GZIP, // a2 59 | TILEDB_NO_COMPRESSION, // a3 60 | TILEDB_NO_COMPRESSION // coordinates 61 | }; 62 | int64_t tile_extents[] = 63 | { 64 | 2, // d1 65 | 2 // d2 66 | }; 67 | const int types[] = 68 | { 69 | TILEDB_INT32, // a1 70 | TILEDB_CHAR, // a2 71 | TILEDB_FLOAT32, // a3 72 | TILEDB_INT64 // coordinates 73 | }; 74 | 75 | // Set array schema 76 | TileDB_ArraySchema array_schema; 77 | tiledb_array_set_schema( 78 | &array_schema, // Array schema struct 79 | array_name, // Array name 80 | attributes, // Attributes 81 | 3, // Number of attributes 82 | 2, // Capacity 83 | TILEDB_ROW_MAJOR, // Cell order 84 | cell_val_num, // Number of cell values per attribute 85 | compression, // Compression 86 | 0, // Sparse array 87 | dimensions, // Dimensions 88 | 2, // Number of dimensions 89 | domain, // Domain 90 | 4*sizeof(int64_t), // Domain length in bytes 91 | tile_extents, // Tile extents 92 | 2*sizeof(int64_t), // Tile extents length in bytes 93 | TILEDB_ROW_MAJOR, // Tile order 94 | types // Types 95 | ); 96 | 97 | // Create array 98 | tiledb_array_create(tiledb_ctx, &array_schema); 99 | 100 | // Free array schema 101 | tiledb_array_free_schema(&array_schema); 102 | 103 | /* Finalize context. */ 104 | tiledb_ctx_finalize(tiledb_ctx); 105 | 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_iterator_dense.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_iterator_dense.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to use an iterator for dense arrays. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | int main() { 37 | // Initialize context with the default configuration parameters 38 | TileDB_CTX* tiledb_ctx; 39 | tiledb_ctx_init(&tiledb_ctx, NULL); 40 | 41 | // Prepare cell buffers 42 | int buffer_a1[3]; 43 | void* buffers[] = { buffer_a1 }; 44 | size_t buffer_sizes[] = { sizeof(buffer_a1) }; 45 | 46 | // Subarray and attributes 47 | int64_t subarray[] = { 3, 4, 2, 4 }; 48 | const char* attributes[] = { "a1" }; 49 | 50 | // Initialize array 51 | TileDB_ArrayIterator* tiledb_array_it; 52 | tiledb_array_iterator_init( 53 | tiledb_ctx, // Context 54 | &tiledb_array_it, // Array iterator 55 | "my_workspace/dense_arrays/my_array_A", // Array name 56 | TILEDB_ARRAY_READ, // Mode 57 | subarray, // Constrain in subarray 58 | attributes, // Subset on attributes 59 | 1, // Number of attributes 60 | buffers, // Buffers used internally 61 | buffer_sizes); // Buffer sizes 62 | 63 | // Iterate over all values in subarray 64 | printf(" a1\n----\n"); 65 | const int* a1_v; 66 | size_t a1_size; 67 | while(!tiledb_array_iterator_end(tiledb_array_it)) { 68 | // Get value 69 | tiledb_array_iterator_get_value( 70 | tiledb_array_it, // Array iterator 71 | 0, // Attribute id 72 | (const void**) &a1_v,// Value 73 | &a1_size); // Value size (useful in variable-sized attributes) 74 | printf("%3d\n", *a1_v); 75 | 76 | // Advance iterator 77 | tiledb_array_iterator_next(tiledb_array_it); 78 | } 79 | 80 | // Finalize array 81 | tiledb_array_iterator_finalize(tiledb_array_it); 82 | 83 | // Finalize context 84 | tiledb_ctx_finalize(tiledb_ctx); 85 | 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_iterator_sparse.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_iterator_sparse.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to use an iterator for sparse arrays. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | int main() { 37 | // Initialize context with the default configuration parameters 38 | TileDB_CTX* tiledb_ctx; 39 | tiledb_ctx_init(&tiledb_ctx, NULL); 40 | 41 | // Prepare cell buffers 42 | int buffer_a1[3]; 43 | void* buffers[] = { buffer_a1 }; 44 | size_t buffer_sizes[] = { sizeof(buffer_a1) }; 45 | 46 | // Subarray and attributes 47 | int64_t subarray[] = { 3, 4, 2, 4 }; 48 | const char* attributes[] = { "a1" }; 49 | 50 | // Initialize array 51 | TileDB_ArrayIterator* tiledb_array_it; 52 | tiledb_array_iterator_init( 53 | tiledb_ctx, // Context 54 | &tiledb_array_it, // Array iterator 55 | "my_workspace/sparse_arrays/my_array_B", // Array name 56 | TILEDB_ARRAY_READ, // Mode 57 | subarray, // Constrain in subarray 58 | attributes, // Subset on attributes 59 | 1, // Number of attributes 60 | buffers, // Buffers used internally 61 | buffer_sizes); // Buffer sizes 62 | 63 | // Iterate over all values in subarray 64 | printf(" a1\n----\n"); 65 | const int* a1_v; 66 | size_t a1_size; 67 | while(!tiledb_array_iterator_end(tiledb_array_it)) { 68 | // Get value 69 | tiledb_array_iterator_get_value( 70 | tiledb_array_it, // Array iterator 71 | 0, // Attribute id 72 | (const void**) &a1_v,// Value 73 | &a1_size); // Value size (useful in variable-sized attributes) 74 | 75 | // Print value (if not a deletion) 76 | if(*a1_v != TILEDB_EMPTY_INT32) 77 | printf("%3d\n", *a1_v); 78 | 79 | // Advance iterator 80 | tiledb_array_iterator_next(tiledb_array_it); 81 | } 82 | 83 | // Finalize array 84 | tiledb_array_iterator_finalize(tiledb_array_it); 85 | 86 | // Finalize context 87 | tiledb_ctx_finalize(tiledb_ctx); 88 | 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_parallel_read_mpi_io_dense.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_read_mpi_io_dense.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to read from a dense array in parallel with MPI, activating 31 | * also the MPI-IO read mode (although the latter is optional - the user 32 | * could alternatively use mmap or standard OS read). Note that the case 33 | * of sparse arrays is similar. 34 | */ 35 | 36 | #include "tiledb.h" 37 | #include 38 | #include 39 | 40 | 41 | 42 | #ifdef HAVE_MPI 43 | #include 44 | 45 | int main(int argc, char** argv) { 46 | // Initialize MPI and get rank 47 | MPI_Init(&argc, &argv); 48 | int rank; 49 | MPI_Comm mpi_comm = MPI_COMM_WORLD; 50 | MPI_Comm_rank(mpi_comm, &rank); 51 | 52 | // Properly set the configuration parameters 53 | TileDB_Config tiledb_config; 54 | memset(&tiledb_config, 0, sizeof(struct TileDB_Config)); 55 | tiledb_config.read_method_ = TILEDB_IO_MPI; // Activate MPI-IO 56 | tiledb_config.mpi_comm_ = &mpi_comm; 57 | 58 | // Initialize context with the default configuration parameters 59 | TileDB_CTX* tiledb_ctx; 60 | tiledb_ctx_init(&tiledb_ctx, &tiledb_config); 61 | 62 | // Array name 63 | const char* array_name = "my_workspace/dense_arrays/my_array_A"; 64 | 65 | // Prepare cell buffers 66 | // --- Upper left tile --- 67 | const int64_t subarray_0[] = { 1, 2, 1, 2 }; 68 | // --- Upper right tile --- 69 | const int64_t subarray_1[] = { 1, 2, 3, 4 }; 70 | // --- Lower left tile --- 71 | const int64_t subarray_2[] = { 3, 4, 1, 2 }; 72 | // --- Lower right tile --- 73 | const int64_t subarray_3[] = { 3, 4, 3, 4 }; 74 | 75 | // Set buffers 76 | int buffer[4]; 77 | void* buffers[] = { buffer }; 78 | size_t buffer_sizes[] = { sizeof(buffer) }; 79 | 80 | // Only attribute "a1" is needed 81 | const char* attributes[] = { "a1" }; 82 | 83 | // Choose subarray based on rank 84 | const int64_t* subarray; 85 | if(rank == 0) 86 | subarray = subarray_0; 87 | else if(rank == 1) 88 | subarray = subarray_1; 89 | else if(rank == 2) 90 | subarray = subarray_2; 91 | else if(rank == 3) 92 | subarray = subarray_3; 93 | 94 | // Initialize array 95 | TileDB_Array* tiledb_array; 96 | tiledb_array_init( 97 | tiledb_ctx, // Context 98 | &tiledb_array, // Array object 99 | array_name, // Array name 100 | TILEDB_ARRAY_READ, // Mode 101 | subarray, // Subarray 102 | attributes, // Subset on attributes 103 | 1); // Number of attributes 104 | 105 | // Read from array 106 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 107 | 108 | // Finalize array 109 | tiledb_array_finalize(tiledb_array); 110 | 111 | // Output result 112 | int total_count = 0; 113 | for(int i=0; i<4; ++i) 114 | if(buffer[i] > 10) 115 | ++total_count; 116 | printf("Process %d: Number of a1 values greater " 117 | "than 10: %d \n", rank, total_count); 118 | 119 | // Finalize context 120 | tiledb_ctx_finalize(tiledb_ctx); 121 | 122 | // Finalize MPI 123 | MPI_Finalize(); 124 | 125 | return 0; 126 | } 127 | 128 | #else 129 | 130 | int main() { 131 | printf("MPI not supported.\n"); 132 | 133 | return 0; 134 | } 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_parallel_read_sparse_1.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_parallel_read_sparse_1.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to read from a sparse array in parallel with pthreads. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | #include 36 | 37 | 38 | 39 | 40 | // The function to be computed in parallel 41 | void *parallel_read(void* args); 42 | 43 | // The arguments for each invocation of parallel_write 44 | typedef struct _thread_data_t { 45 | const TileDB_CTX* tiledb_ctx; 46 | const char* array_name; 47 | const void* subarray; 48 | void** buffers; 49 | size_t* buffer_sizes; 50 | int count; 51 | } thread_data_t; 52 | 53 | int main() { 54 | // Initialize context with the default configuration parameters 55 | TileDB_CTX* tiledb_ctx; 56 | tiledb_ctx_init(&tiledb_ctx, NULL); 57 | 58 | // Array name 59 | const char* array_name = "my_workspace/sparse_arrays/my_array_B"; 60 | 61 | // Prepare cell buffers 62 | // --- First read --- 63 | const int64_t subarray_1[] = { 1, 2, 1, 4 }; 64 | int buffer_a1_1[10]; 65 | void* buffers_1[] = { buffer_a1_1 }; 66 | size_t buffer_sizes_1[] = { sizeof(buffer_a1_1) }; 67 | // --- Upper right tile --- 68 | const int64_t subarray_2[] = { 3, 4, 1, 4 }; 69 | int buffer_a1_2[10]; 70 | void* buffers_2[] = { buffer_a1_2 }; 71 | size_t buffer_sizes_2[] = { sizeof(buffer_a1_2) }; 72 | 73 | // Initialize 2 pthreads and corresponding data 74 | pthread_t threads[2]; 75 | thread_data_t thread_data[2]; 76 | 77 | // Write in parallel 78 | for(int i=0; i<2; ++i) { 79 | // Populate the thread data 80 | thread_data[i].tiledb_ctx = tiledb_ctx; 81 | thread_data[i].array_name = array_name; 82 | if(i==0) { // First read 83 | thread_data[i].buffers = buffers_1; 84 | thread_data[i].buffer_sizes = buffer_sizes_1; 85 | thread_data[i].subarray = subarray_1; 86 | } else if(i==1) { // Second read 87 | thread_data[i].buffers = buffers_2; 88 | thread_data[i].buffer_sizes = buffer_sizes_2; 89 | thread_data[i].subarray = subarray_2; 90 | } 91 | 92 | // Create thread 93 | pthread_create(&threads[i], NULL, parallel_read, &thread_data[i]); 94 | } 95 | 96 | // Wait till all threads finish 97 | for(int i=0; i<2; ++i) 98 | pthread_join(threads[i], NULL); 99 | 100 | // Output result 101 | int total_count = 0; 102 | for(int i=0; i<2; ++i) 103 | total_count += thread_data[i].count; 104 | printf("Number of a1 values greater than 5: %d \n", total_count); 105 | 106 | // Finalize context 107 | tiledb_ctx_finalize(tiledb_ctx); 108 | 109 | return 0; 110 | } 111 | 112 | void *parallel_read(void* args) { 113 | // Get arguments 114 | thread_data_t* data = (thread_data_t*) args; 115 | 116 | // Only attribute "a1" is needed 117 | const char* attributes[] = { "a1" }; 118 | 119 | // Initialize array 120 | TileDB_Array* tiledb_array; 121 | tiledb_array_init( 122 | data->tiledb_ctx, // Context 123 | &tiledb_array, // Array object 124 | data->array_name, // Array name 125 | TILEDB_ARRAY_READ, // Mode 126 | data->subarray, // Subarray 127 | attributes, // Subset on attributes 128 | 1); // Number of attributes 129 | 130 | // Read from array 131 | tiledb_array_read(tiledb_array, data->buffers, data->buffer_sizes); 132 | 133 | // Count number of a1 values greater than 10 134 | data->count = 0; 135 | int* a1 = (int*) data->buffers[0]; 136 | int num = data->buffer_sizes[0] / sizeof(int); 137 | for(int i=0; i 5) 139 | ++data->count; 140 | 141 | // Finalize array 142 | tiledb_array_finalize(tiledb_array); 143 | 144 | return 0; 145 | } 146 | 147 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_parallel_read_sparse_2.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_parallel_read_sparse_2.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to read from a sparse array in parallel with OpenMP. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | #ifdef HAVE_OPENMP 37 | #include 38 | 39 | 40 | // The function to be computed in parallel 41 | void parallel_read( 42 | const TileDB_CTX* tiledb_ctx, 43 | const char* array_name, 44 | const void* subarray, 45 | void** buffers, 46 | size_t* buffer_sizes, 47 | int* count); 48 | 49 | int main() { 50 | // Initialize context with the default configuration parameters 51 | TileDB_CTX* tiledb_ctx; 52 | tiledb_ctx_init(&tiledb_ctx, NULL); 53 | 54 | // Array name 55 | const char* array_name = "my_workspace/sparse_arrays/my_array_B"; 56 | 57 | // Prepare cell buffers 58 | // --- First read --- 59 | const int64_t subarray_1[] = { 1, 2, 1, 4 }; 60 | int buffer_a1_1[4]; 61 | void* buffers_1[] = { buffer_a1_1 }; 62 | size_t buffer_sizes_1[] = { sizeof(buffer_a1_1) }; 63 | // --- Second read --- 64 | const int64_t subarray_2[] = { 3, 4, 1, 4 }; 65 | int buffer_a1_2[4]; 66 | void* buffers_2[] = { buffer_a1_2 }; 67 | size_t buffer_sizes_2[] = { sizeof(buffer_a1_2) }; 68 | 69 | // Buffer to store the individual thread counts 70 | int counts[2]; 71 | 72 | // Write in parallel 73 | #pragma omp parallel for 74 | for(int i=0; i<2; ++i) { 75 | // Populate the thread data 76 | void** buffers; 77 | size_t* buffer_sizes; 78 | const void* subarray; 79 | if(i==0) { // First read 80 | buffers = buffers_1; 81 | buffer_sizes = buffer_sizes_1; 82 | subarray = subarray_1; 83 | } else if(i==1) { // Second read 84 | buffers = buffers_2; 85 | buffer_sizes = buffer_sizes_2; 86 | subarray = subarray_2; 87 | } 88 | 89 | // Parallel read 90 | parallel_read( 91 | tiledb_ctx, 92 | array_name, 93 | subarray, 94 | buffers, 95 | buffer_sizes, 96 | &counts[i]); 97 | } 98 | 99 | // Output result 100 | int total_count = 0; 101 | for(int i=0; i<2; ++i) 102 | total_count += counts[i]; 103 | printf("Number of a1 values greater than 5: %d \n", total_count); 104 | 105 | // Finalize context 106 | tiledb_ctx_finalize(tiledb_ctx); 107 | 108 | return 0; 109 | } 110 | 111 | void parallel_read( 112 | const TileDB_CTX* tiledb_ctx, 113 | const char* array_name, 114 | const void* subarray, 115 | void** buffers, 116 | size_t* buffer_sizes, 117 | int* count) { 118 | // Only attribute "a1" is needed 119 | const char* attributes[] = { "a1" }; 120 | 121 | // Initialize array 122 | TileDB_Array* tiledb_array; 123 | tiledb_array_init( 124 | tiledb_ctx, // Context 125 | &tiledb_array, // Array object 126 | array_name, // Array name 127 | TILEDB_ARRAY_READ, // Mode 128 | subarray, // Subarray 129 | attributes, // Subset on attributes 130 | 1); // Number of attributes 131 | 132 | // Read from array 133 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 134 | 135 | // Count number of a1 values greater than 10 136 | *count = 0; 137 | int* a1 = (int*) buffers[0]; 138 | int num = buffer_sizes[0] / sizeof(int); 139 | for(int i=0; i 5) 141 | ++(*count); 142 | 143 | // Finalize array 144 | tiledb_array_finalize(tiledb_array); 145 | } 146 | 147 | #else 148 | 149 | int main() { 150 | printf("OpenMP not supported."); 151 | 152 | return 0; 153 | } 154 | 155 | #endif 156 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_parallel_write_sparse_1.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_parallel_write_sparse_1.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to write to a sparse array in parallel with pthreads. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | // The function to be computed in parallel 37 | void *parallel_write(void* args); 38 | 39 | // The arguments for each invocation of parallel_write 40 | typedef struct _thread_data_t { 41 | const TileDB_CTX* tiledb_ctx; 42 | const char* array_name; 43 | const void** buffers; 44 | const size_t* buffer_sizes; 45 | } thread_data_t; 46 | 47 | 48 | int main() { 49 | // Initialize context with the default configuration parameters 50 | TileDB_CTX* tiledb_ctx; 51 | tiledb_ctx_init(&tiledb_ctx, NULL); 52 | 53 | // Array name 54 | const char* array_name = "my_workspace/sparse_arrays/my_array_B"; 55 | 56 | // Prepare cell buffers 57 | // --- First write --- 58 | int buffer_a1_1[] = { 7, 5, 0 }; 59 | size_t buffer_a2_1[] = { 0, 4, 6 }; 60 | const char buffer_var_a2_1[] = "hhhhffa"; 61 | float buffer_a3_1[] = { 7.1, 7.2, 5.1, 5.2, 0.1, 0.2 }; 62 | int64_t buffer_coords_1[] = { 3, 4, 4, 2, 1, 1 }; 63 | const void* buffers_1[] = 64 | { 65 | buffer_a1_1, 66 | buffer_a2_1, 67 | buffer_var_a2_1, 68 | buffer_a3_1, 69 | buffer_coords_1 70 | }; 71 | size_t buffer_sizes_1[] = 72 | { 73 | sizeof(buffer_a1_1), 74 | sizeof(buffer_a2_1), 75 | sizeof(buffer_var_a2_1)-1, // No need to store the last '\0' character 76 | sizeof(buffer_a3_1), 77 | sizeof(buffer_coords_1) 78 | }; 79 | // --- Second write --- 80 | int buffer_a1_2[] = { 6, 4, 3, 1, 2 }; 81 | size_t buffer_a2_2[] = { 0, 3, 4, 8, 10 }; 82 | const char buffer_var_a2_2[] = "gggeddddbbccc"; 83 | float buffer_a3_2[] = 84 | { 6.1, 6.2, 4.1, 4.2, 3.1, 3.2, 1.1, 1.2, 2.1, 2.2 }; 85 | int64_t buffer_coords_2[] = { 3, 3, 3, 1, 2, 3, 1, 2, 1, 4 }; 86 | const void* buffers_2[] = 87 | { 88 | buffer_a1_2, 89 | buffer_a2_2, 90 | buffer_var_a2_2, 91 | buffer_a3_2, 92 | buffer_coords_2 93 | }; 94 | size_t buffer_sizes_2[] = 95 | { 96 | sizeof(buffer_a1_2), 97 | sizeof(buffer_a2_2), 98 | sizeof(buffer_var_a2_2)-1, // No need to store the last '\0' character 99 | sizeof(buffer_a3_2), 100 | sizeof(buffer_coords_2) 101 | }; 102 | 103 | // Initialize 2 pthreads and corresponding data 104 | pthread_t threads[2]; 105 | thread_data_t thread_data[2]; 106 | 107 | // Write in parallel 108 | for(int i=0; i<2; ++i) { 109 | // Populate the thread data 110 | thread_data[i].tiledb_ctx = tiledb_ctx; 111 | thread_data[i].array_name = array_name; 112 | if(i==0) { // First tile 113 | thread_data[i].buffers = buffers_1; 114 | thread_data[i].buffer_sizes = buffer_sizes_1; 115 | } else if(i==1) { // Second tile 116 | thread_data[i].buffers = buffers_2; 117 | thread_data[i].buffer_sizes = buffer_sizes_2; 118 | } 119 | 120 | // Create thread 121 | pthread_create(&threads[i], NULL, parallel_write, &thread_data[i]); 122 | } 123 | 124 | // Wait till all threads finish 125 | for(int i=0; i<2; ++i) 126 | pthread_join(threads[i], NULL); 127 | 128 | // Finalize context 129 | tiledb_ctx_finalize(tiledb_ctx); 130 | 131 | return 0; 132 | } 133 | 134 | void *parallel_write(void* args) { 135 | // Get arguments 136 | thread_data_t* data = (thread_data_t*) args; 137 | 138 | // Initialize array 139 | TileDB_Array* tiledb_array; 140 | tiledb_array_init( 141 | data->tiledb_ctx, // Context 142 | &tiledb_array, // Array object 143 | data->array_name, // Array name 144 | TILEDB_ARRAY_WRITE_UNSORTED, // Mode 145 | NULL, // Inapplicable 146 | NULL, // All attributes 147 | 0); // Number of attributes 148 | 149 | // Write to array 150 | tiledb_array_write(tiledb_array, data->buffers, data->buffer_sizes); 151 | 152 | // Finalize array 153 | tiledb_array_finalize(tiledb_array); 154 | 155 | return 0; 156 | } 157 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_parallel_write_sparse_2.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_parallel_write_sparse_2.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to write to a sparse array in parallel with OpenMP. 31 | */ 32 | 33 | #include "tiledb.h" 34 | 35 | #ifdef HAVE_OPENMP 36 | #include 37 | 38 | 39 | // The function to be computed in parallel 40 | void parallel_write( 41 | const TileDB_CTX* tiledb_ctx, 42 | const char* array_name, 43 | const void** buffers, 44 | const size_t* buffer_sizes); 45 | 46 | 47 | int main() { 48 | // Initialize context with the default configuration parameters 49 | TileDB_CTX* tiledb_ctx; 50 | tiledb_ctx_init(&tiledb_ctx, NULL); 51 | 52 | // Array name 53 | const char* array_name = "my_workspace/sparse_arrays/my_array_B"; 54 | 55 | // Prepare cell buffers 56 | // --- First write --- 57 | int buffer_a1_1[] = { 7, 5, 0 }; 58 | size_t buffer_a2_1[] = { 0, 4, 6 }; 59 | const char buffer_var_a2_1[] = "hhhhffa"; 60 | float buffer_a3_1[] = { 7.1, 7.2, 5.1, 5.2, 0.1, 0.2 }; 61 | int64_t buffer_coords_1[] = { 3, 4, 4, 2, 1, 1 }; 62 | const void* buffers_1[] = 63 | { 64 | buffer_a1_1, 65 | buffer_a2_1, 66 | buffer_var_a2_1, 67 | buffer_a3_1, 68 | buffer_coords_1 69 | }; 70 | size_t buffer_sizes_1[] = 71 | { 72 | sizeof(buffer_a1_1), 73 | sizeof(buffer_a2_1), 74 | sizeof(buffer_var_a2_1)-1, // No need to store the last '\0' character 75 | sizeof(buffer_a3_1), 76 | sizeof(buffer_coords_1) 77 | }; 78 | // --- Second write --- 79 | int buffer_a1_2[] = { 6, 4, 3, 1, 2 }; 80 | size_t buffer_a2_2[] = { 0, 3, 4, 8, 10 }; 81 | const char buffer_var_a2_2[] = "gggeddddbbccc"; 82 | float buffer_a3_2[] = 83 | { 6.1, 6.2, 4.1, 4.2, 3.1, 3.2, 1.1, 1.2, 2.1, 2.2 }; 84 | int64_t buffer_coords_2[] = { 3, 3, 3, 1, 2, 3, 1, 2, 1, 4 }; 85 | const void* buffers_2[] = 86 | { 87 | buffer_a1_2, 88 | buffer_a2_2, 89 | buffer_var_a2_2, 90 | buffer_a3_2, 91 | buffer_coords_2 92 | }; 93 | size_t buffer_sizes_2[] = 94 | { 95 | sizeof(buffer_a1_2), 96 | sizeof(buffer_a2_2), 97 | sizeof(buffer_var_a2_2)-1, // No need to store the last '\0' character 98 | sizeof(buffer_a3_2), 99 | sizeof(buffer_coords_2) 100 | }; 101 | 102 | 103 | #pragma omp parallel for 104 | // Write in parallel 105 | for(int i=0; i<2; ++i) { 106 | // Populate thread data 107 | const void** buffers; 108 | const size_t* buffer_sizes; 109 | if(i==0) { // First tile 110 | buffers = buffers_1; 111 | buffer_sizes = buffer_sizes_1; 112 | } else if(i==1) { // Second tile 113 | buffers = buffers_2; 114 | buffer_sizes = buffer_sizes_2; 115 | } 116 | 117 | // Write 118 | parallel_write( 119 | tiledb_ctx, 120 | array_name, 121 | buffers, 122 | buffer_sizes); 123 | } 124 | 125 | // Finalize context 126 | tiledb_ctx_finalize(tiledb_ctx); 127 | 128 | return 0; 129 | } 130 | 131 | void parallel_write( 132 | const TileDB_CTX* tiledb_ctx, 133 | const char* array_name, 134 | const void** buffers, 135 | const size_t* buffer_sizes) { 136 | // Initialize array 137 | TileDB_Array* tiledb_array; 138 | tiledb_array_init( 139 | tiledb_ctx, // Context 140 | &tiledb_array, // Array object 141 | array_name, // Array name 142 | TILEDB_ARRAY_WRITE_UNSORTED, // Mode 143 | NULL, // Inapplicable 144 | NULL, // All attributes 145 | 0); // Number of attributes 146 | 147 | // Write to array 148 | tiledb_array_write(tiledb_array, buffers, buffer_sizes); 149 | 150 | // Finalize array 151 | tiledb_array_finalize(tiledb_array); 152 | } 153 | 154 | #else 155 | 156 | #include 157 | 158 | int main() { 159 | printf("OpenMP not supported."); 160 | 161 | return 0; 162 | } 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_primitive.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_primitive.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to initialize/finalize an array, and explore its schema. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | // Prints some schema info (you can enhance this to print the entire schema) 37 | void print_some_array_schema_info(const TileDB_ArraySchema* array_schema); 38 | 39 | int main() { 40 | /* Initialize context with the default configuration parameters. */ 41 | TileDB_CTX* tiledb_ctx; 42 | tiledb_ctx_init(&tiledb_ctx, NULL); 43 | 44 | // ----- Dense array ----- // 45 | 46 | // Load array schema when the array is not initialized 47 | TileDB_ArraySchema array_schema; 48 | tiledb_array_load_schema( 49 | tiledb_ctx, // Context 50 | "my_workspace/dense_arrays/my_array_A", // Array name 51 | &array_schema); // Array schema struct 52 | 53 | // Print some array schema info 54 | print_some_array_schema_info(&array_schema); 55 | 56 | // Free array schema 57 | tiledb_array_free_schema(&array_schema); 58 | 59 | // ----- Sparse array ----- // 60 | 61 | // Initialize array 62 | TileDB_Array* tiledb_array; 63 | tiledb_array_init( 64 | tiledb_ctx, // Context 65 | &tiledb_array, // Array object 66 | "my_workspace/sparse_arrays/my_array_B", // Array name 67 | TILEDB_ARRAY_READ, // Mode 68 | NULL, // Subarray (whole domain) 69 | NULL, // Attributes (all attributes) 70 | 0); // Number of attributes 71 | 72 | // Get array schema when the array is initialized 73 | tiledb_array_get_schema(tiledb_array, &array_schema); 74 | 75 | // Print some schema info 76 | print_some_array_schema_info(&array_schema); 77 | 78 | // Free array schema 79 | tiledb_array_free_schema(&array_schema); 80 | 81 | // Finalize array 82 | tiledb_array_finalize(tiledb_array); 83 | 84 | // Finalize context 85 | tiledb_ctx_finalize(tiledb_ctx); 86 | 87 | return 0; 88 | } 89 | 90 | void print_some_array_schema_info(const TileDB_ArraySchema* array_schema) { 91 | printf("Array name: %s\n", array_schema->array_name_); 92 | printf("Attributes: "); 93 | for(int i=0; iattribute_num_; ++i) 94 | printf("%s ", array_schema->attributes_[i]); 95 | printf("\n"); 96 | if(array_schema->dense_) 97 | printf("The array is dense\n"); 98 | else 99 | printf("The array is sparse\n"); 100 | } 101 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_read_dense_1.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_read_dense_1.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to read a complete dense array. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | int main() { 37 | // Initialize context with the default configuration parameters 38 | TileDB_CTX* tiledb_ctx; 39 | tiledb_ctx_init(&tiledb_ctx, NULL); 40 | 41 | // Initialize array 42 | TileDB_Array* tiledb_array; 43 | tiledb_array_init( 44 | tiledb_ctx, // Context 45 | &tiledb_array, // Array object 46 | "my_workspace/dense_arrays/my_array_A", // Array name 47 | TILEDB_ARRAY_READ, // Mode 48 | NULL, // Whole domain 49 | NULL, // All attributes 50 | 0); // Number of attributes 51 | 52 | // Prepare cell buffers 53 | int buffer_a1[16]; 54 | size_t buffer_a2[16]; 55 | char buffer_var_a2[40]; 56 | float buffer_a3[32]; 57 | void* buffers[] = { buffer_a1, buffer_a2, buffer_var_a2, buffer_a3 }; 58 | size_t buffer_sizes[] = 59 | { 60 | sizeof(buffer_a1), 61 | sizeof(buffer_a2), 62 | sizeof(buffer_var_a2), 63 | sizeof(buffer_a3) 64 | }; 65 | 66 | // Read from array 67 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 68 | 69 | // Print only non-empty cell values 70 | int64_t result_num = buffer_sizes[0] / sizeof(int); 71 | printf(" a1\t a2\t (a3.first, a3.second)\n"); 72 | printf("-----------------------------------------\n"); 73 | for(int i=0; i 37 | 38 | int main() { 39 | // Initialize context with the default configuration parameters 40 | TileDB_CTX* tiledb_ctx; 41 | tiledb_ctx_init(&tiledb_ctx, NULL); 42 | 43 | // Subarray and attributes 44 | int64_t subarray[] = { 3, 4, 2, 4 }; 45 | const char* attributes[] = { "a1" }; 46 | 47 | // Initialize array 48 | TileDB_Array* tiledb_array; 49 | tiledb_array_init( 50 | tiledb_ctx, // Context 51 | &tiledb_array, // Array object 52 | "my_workspace/dense_arrays/my_array_A", // Array name 53 | TILEDB_ARRAY_READ, // Mode 54 | subarray, // Constrain in subarray 55 | attributes, // Subset on attributes 56 | 1); // Number of attributes 57 | 58 | // Prepare cell buffers 59 | int buffer_a1[3]; 60 | void* buffers[] = { buffer_a1 }; 61 | size_t buffer_sizes[] = { sizeof(buffer_a1) }; 62 | 63 | 64 | // Loop until no overflow 65 | printf(" a1\n----\n"); 66 | do { 67 | printf("Reading cells...\n"); 68 | 69 | // Read from array 70 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 71 | 72 | // Print cell values 73 | int64_t result_num = buffer_sizes[0] / sizeof(int); 74 | for(int i=0; i 35 | 36 | int main() { 37 | // Initialize context with the default configuration parameters 38 | TileDB_CTX* tiledb_ctx; 39 | tiledb_ctx_init(&tiledb_ctx, NULL); 40 | 41 | // Subarray and attributes 42 | int64_t subarray[] = { 3, 3, 2, 2 }; 43 | int64_t subarray_2[] = { 4, 4, 3, 3 }; 44 | const char* attributes[] = { "a1" }; 45 | const char* attributes_2[] = { "a2" }; 46 | 47 | // Initialize array 48 | TileDB_Array* tiledb_array; 49 | tiledb_array_init( 50 | tiledb_ctx, // Context 51 | &tiledb_array, // Array object 52 | "my_workspace/dense_arrays/my_array_A", // Array name 53 | TILEDB_ARRAY_READ, // Mode 54 | subarray, // Constrain in subarray 55 | attributes, // Subset on attributes 56 | 1); // Number of attributes 57 | 58 | // Prepare cell buffers 59 | int buffer_a1[1]; 60 | size_t buffer_a2[1]; 61 | char buffer_var_a2[10]; 62 | void* buffers[] = { buffer_a1 }; 63 | void* buffers_2[] = { buffer_a2, buffer_var_a2 }; 64 | size_t buffer_sizes[] = { sizeof(buffer_a1) }; 65 | size_t buffer_sizes_2[] = { sizeof(buffer_a2), sizeof(buffer_var_a2) }; 66 | 67 | // Read from array - #1 68 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 69 | printf("a1 for (3,2): %3d\n", buffer_a1[0]); 70 | 71 | // Reset subarray and attributes 72 | tiledb_array_reset_subarray(tiledb_array, subarray_2); 73 | tiledb_array_reset_attributes(tiledb_array, attributes_2, 1); 74 | 75 | // Read from array - #2 76 | tiledb_array_read(tiledb_array, buffers_2, buffer_sizes_2); 77 | printf("a2 for (4,3): %3.*s\n", int(buffer_sizes_2[1]), buffer_var_a2); 78 | 79 | // Finalize the array 80 | tiledb_array_finalize(tiledb_array); 81 | 82 | /* Finalize context. */ 83 | tiledb_ctx_finalize(tiledb_ctx); 84 | 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /examples/src/tiledb_array_read_dense_sorted.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_array_read_dense_sorted.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to read from a dense array, constraining the read 31 | * to a specific subarray and subset of attributes. The cells are copied to the 32 | * input buffers sorted in row-major order within the selected subarray. 33 | */ 34 | 35 | #include "tiledb.h" 36 | #include 37 | 38 | int main() { 39 | // Initialize context with the default configuration parameters 40 | TileDB_CTX* tiledb_ctx; 41 | tiledb_ctx_init(&tiledb_ctx, NULL); 42 | 43 | // Subarray and attributes 44 | int64_t subarray[] = { 3, 4, 2, 4 }; 45 | const char* attributes[] = { "a1" }; 46 | 47 | // Initialize array 48 | TileDB_Array* tiledb_array; 49 | tiledb_array_init( 50 | tiledb_ctx, // Context 51 | &tiledb_array, // Array object 52 | "my_workspace/dense_arrays/my_array_A", // Array name 53 | TILEDB_ARRAY_READ_SORTED_ROW, // Mode 54 | subarray, // Constrain in subarray 55 | attributes, // Subset on attributes 56 | 1); // Number of attributes 57 | 58 | // Prepare cell buffers 59 | int buffer_a1[3]; 60 | void* buffers[] = { buffer_a1 }; 61 | size_t buffer_sizes[] = { sizeof(buffer_a1) }; 62 | 63 | // Loop until no overflow 64 | printf(" a1\n----\n"); 65 | do { 66 | // Read from array 67 | printf("Reading cells...\n"); 68 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 69 | 70 | // Print cell values 71 | int64_t result_num = buffer_sizes[0] / sizeof(int); 72 | for(int i=0; i 35 | 36 | int main() { 37 | // Initialize context with the default configuration parameters 38 | TileDB_CTX* tiledb_ctx; 39 | tiledb_ctx_init(&tiledb_ctx, NULL); 40 | 41 | // Initialize array 42 | TileDB_Array* tiledb_array; 43 | tiledb_array_init( 44 | tiledb_ctx, // Context 45 | &tiledb_array, // Array object 46 | "my_workspace/sparse_arrays/my_array_B", // Array name 47 | TILEDB_ARRAY_READ, // Mode 48 | NULL, // Whole domain 49 | NULL, // All attributes 50 | 0); // Number of attributes 51 | 52 | // Prepare cell buffers 53 | int buffer_a1[10]; 54 | size_t buffer_a2[10]; 55 | char buffer_var_a2[30]; 56 | float buffer_a3[20]; 57 | int64_t buffer_coords[20]; 58 | void* buffers[] = 59 | { buffer_a1, buffer_a2, buffer_var_a2, buffer_a3, buffer_coords }; 60 | size_t buffer_sizes[] = 61 | { 62 | sizeof(buffer_a1), 63 | sizeof(buffer_a2), 64 | sizeof(buffer_var_a2), 65 | sizeof(buffer_a3), 66 | sizeof(buffer_coords) 67 | }; 68 | 69 | // Read from array 70 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 71 | 72 | // Print cell values 73 | int64_t result_num = buffer_sizes[0] / sizeof(int); 74 | printf("coords\t a1\t a2\t (a3.first, a3.second)\n"); 75 | printf("--------------------------------------------------\n"); 76 | for(int i=0; i 37 | 38 | int main() { 39 | // Initialize context with the default configuration parameters 40 | TileDB_CTX* tiledb_ctx; 41 | tiledb_ctx_init(&tiledb_ctx, NULL); 42 | 43 | // Subarray and attributes 44 | int64_t subarray[] = { 3, 4, 2, 4 }; 45 | const char* attributes[] = { "a1" }; 46 | 47 | // Initialize array 48 | TileDB_Array* tiledb_array; 49 | tiledb_array_init( 50 | tiledb_ctx, // Context 51 | &tiledb_array, // Array object 52 | "my_workspace/sparse_arrays/my_array_B", // Array name 53 | TILEDB_ARRAY_READ, // Mode 54 | subarray, // Constrain in subarray 55 | attributes, // Subset on attributes 56 | 1); // Number of attributes 57 | 58 | // Prepare cell buffers 59 | int buffer_a1[2]; 60 | void* buffers[] = { buffer_a1 }; 61 | size_t buffer_sizes[] = { sizeof(buffer_a1) }; 62 | 63 | 64 | // Loop until no overflow 65 | printf(" a1\n----\n"); 66 | do { 67 | printf("Reading cells...\n"); 68 | 69 | // Read from array 70 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 71 | 72 | // Print cell values 73 | int64_t result_num = buffer_sizes[0] / sizeof(int); 74 | for(int i=0; i 37 | 38 | int main() { 39 | // Initialize context with the default configuration parameters 40 | TileDB_CTX* tiledb_ctx; 41 | tiledb_ctx_init(&tiledb_ctx, NULL); 42 | 43 | // Subarray and attributes 44 | int64_t subarray[] = { 3, 4, 2, 4 }; 45 | const char* attributes[] = { "a1" }; 46 | 47 | // Initialize array 48 | TileDB_Array* tiledb_array; 49 | tiledb_array_init( 50 | tiledb_ctx, // Context 51 | &tiledb_array, // Array object 52 | "my_workspace/sparse_arrays/my_array_B", // Array name 53 | TILEDB_ARRAY_READ_SORTED_ROW, // Mode 54 | subarray, // Constrain in subarray 55 | attributes, // Subset on attributes 56 | 1); // Number of attributes 57 | 58 | // Prepare cell buffers 59 | int buffer_a1[2]; 60 | void* buffers[] = { buffer_a1 }; 61 | size_t buffer_sizes[] = { sizeof(buffer_a1) }; 62 | 63 | 64 | // Loop until no overflow 65 | printf(" a1\n----\n"); 66 | do { 67 | printf("Reading cells...\n"); 68 | 69 | // Read from array 70 | tiledb_array_read(tiledb_array, buffers, buffer_sizes); 71 | 72 | // Print cell values 73 | int64_t result_num = buffer_sizes[0] / sizeof(int); 74 | for(int i=0; i 35 | 36 | int main() { 37 | // Initialize context with the default configuration parameters 38 | TileDB_CTX* tiledb_ctx; 39 | tiledb_ctx_init(&tiledb_ctx, NULL); 40 | 41 | // Create a workspace 42 | int rc = tiledb_workspace_create(tiledb_ctx, "my_workspace"); 43 | if(rc == TILEDB_OK) 44 | printf("Workspace created successfully!\n"); 45 | else if(rc == TILEDB_ERR) 46 | printf("%s\n", tiledb_errmsg); 47 | 48 | // Create the same workspace again - ERROR 49 | rc = tiledb_workspace_create(tiledb_ctx, "my_workspace"); 50 | if(rc == TILEDB_OK) 51 | printf("Workspace created successfully!\n"); 52 | else if(rc == TILEDB_ERR) 53 | printf("%s\n", tiledb_errmsg); // Print the TileDB error message 54 | 55 | // Finalize context 56 | tiledb_ctx_finalize(tiledb_ctx); 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /examples/src/tiledb_clear_delete_move.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_clear_delete_move.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to clear, delete and move TileDB objects. 31 | */ 32 | 33 | #include "tiledb.h" 34 | 35 | int main() { 36 | // Initialize context with the default configuration parameters 37 | TileDB_CTX* tiledb_ctx; 38 | tiledb_ctx_init(&tiledb_ctx, NULL); 39 | 40 | // Clear an array 41 | tiledb_clear(tiledb_ctx, "my_workspace/sparse_arrays/my_array_B"); 42 | 43 | // Delete a group 44 | tiledb_delete(tiledb_ctx, "my_workspace/dense_arrays"); 45 | 46 | // Move a workspace 47 | tiledb_move(tiledb_ctx, "my_workspace", "my_workspace_2"); 48 | 49 | // Finalize context 50 | tiledb_ctx_finalize(tiledb_ctx); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /examples/src/tiledb_config.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_config.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to set the TileDB configuration parameters. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | int main() { 37 | /* Create a TileDB configuration. */ 38 | TileDB_Config tiledb_config; 39 | /* 40 | * IMPORTANT: You need to zero out the members of the config structure if you 41 | * are setting only a subset of them, so that the rest can take default 42 | * values. 43 | */ 44 | memset(&tiledb_config, 0, sizeof(struct TileDB_Config)); 45 | tiledb_config.home_ = "."; // TileDB home will be the current directory 46 | tiledb_config.read_method_ = TILEDB_IO_READ; // OS read instead of mmap 47 | 48 | // Initialize context with the default configuration parameters 49 | TileDB_CTX* tiledb_ctx; 50 | tiledb_ctx_init(&tiledb_ctx, &tiledb_config); 51 | 52 | /* --- Your code here --- */ 53 | 54 | /* Finalize context. */ 55 | tiledb_ctx_finalize(tiledb_ctx); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /examples/src/tiledb_ls.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_list.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to explore the contents of a TileDB directory. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | #include 36 | 37 | int main(int argc, char** argv) { 38 | // Sanity check 39 | if(argc != 2) { 40 | fprintf(stderr, "Usage: ./tiledb_list parent_dir\n"); 41 | return -1; 42 | } 43 | 44 | // Initialize context with the default configuration parameters 45 | TileDB_CTX* tiledb_ctx; 46 | tiledb_ctx_init(&tiledb_ctx, NULL); 47 | 48 | // Retrieve number of directories 49 | int dir_num; 50 | tiledb_ls_c(tiledb_ctx, argv[1], &dir_num); 51 | 52 | // Exit if there are not TileDB objects in the input directory_ 53 | if(dir_num == 0) 54 | return 0; 55 | 56 | // Initialize variables 57 | char** dirs = new char*[dir_num]; 58 | int* dir_types = new int[dir_num]; 59 | for(int i=0; i 35 | #include 36 | 37 | int main() { 38 | // Initialize context with the default configuration parameters 39 | TileDB_CTX* tiledb_ctx; 40 | tiledb_ctx_init(&tiledb_ctx, NULL); 41 | 42 | // Retrieve number of workspaces 43 | int workspace_num; 44 | tiledb_ls_workspaces_c(tiledb_ctx, &workspace_num); 45 | 46 | // Exit if there are no workspaces 47 | if(workspace_num == 0) 48 | return 0; 49 | 50 | // Allocate buffers 51 | char** workspaces = new char*[workspace_num]; 52 | for(int i=0; i 35 | 36 | int main() { 37 | /* Initialize context with the default configuration parameters. */ 38 | TileDB_CTX* tiledb_ctx; 39 | tiledb_ctx_init(&tiledb_ctx, NULL); 40 | 41 | // Subset over the attributes 42 | const char* attributes[] = { TILEDB_KEY }; 43 | 44 | // Prepare cell buffers 45 | size_t buffer_key[8]; 46 | char buffer_key_var[500]; 47 | void* buffers[] = { buffer_key, buffer_key_var }; 48 | size_t buffer_sizes[] = { sizeof(buffer_key), sizeof(buffer_key_var) }; 49 | 50 | // Initialize metadata iterator 51 | TileDB_MetadataIterator* tiledb_metadata_iterator; 52 | tiledb_metadata_iterator_init( 53 | tiledb_ctx, // Context 54 | &tiledb_metadata_iterator, // Metadata iterator 55 | "my_workspace/sparse_arrays/my_array_B/meta", // Metadata name 56 | attributes, // Attributes 57 | 1, // Number of attributes 58 | buffers, // Buffers for internal use 59 | buffer_sizes); // Sizes of buffers 60 | 61 | // Iterate over the metadata 62 | const char* key; 63 | size_t key_size; 64 | while(!tiledb_metadata_iterator_end(tiledb_metadata_iterator)) { 65 | // Get value 66 | tiledb_metadata_iterator_get_value( 67 | tiledb_metadata_iterator, // Metadata iterator 68 | 0, // Attribute id 69 | (const void**) &key, // Key 70 | &key_size); // Key size 71 | 72 | // Print only if it is not empty 73 | if(key[0] != TILEDB_EMPTY_CHAR) 74 | printf("%s\n", key); 75 | 76 | // Advance iterator 77 | tiledb_metadata_iterator_next(tiledb_metadata_iterator); 78 | } 79 | 80 | // Finalize metadata iterator 81 | tiledb_metadata_iterator_finalize(tiledb_metadata_iterator); 82 | 83 | // Finalize context 84 | tiledb_ctx_finalize(tiledb_ctx); 85 | 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /examples/src/tiledb_metadata_primitive.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_metadata_primitive.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to initialize/finalize a metadata object and explore its schema. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | // Prints some schema info (you can enhance this to print the entire schema) 37 | void print_some_metadata_schema_info( 38 | const TileDB_MetadataSchema* metadata_schema); 39 | 40 | int main() { 41 | /* Initialize context with the default configuration parameters. */ 42 | TileDB_CTX* tiledb_ctx; 43 | tiledb_ctx_init(&tiledb_ctx, NULL); 44 | 45 | // ----- Get schema without metadata initialization ----- // 46 | 47 | // Load metadata schema when the metadata object is not initialized 48 | TileDB_MetadataSchema metadata_schema; 49 | tiledb_metadata_load_schema( 50 | tiledb_ctx, // Context 51 | "my_workspace/sparse_arrays/my_array_B/meta", // Metadata name 52 | &metadata_schema); // Metadata schema struct 53 | 54 | // Print some metadata schema info 55 | print_some_metadata_schema_info(&metadata_schema); 56 | 57 | // Free metadata schema 58 | tiledb_metadata_free_schema(&metadata_schema); 59 | 60 | // ----- Get schema after metadata initialization ----- // 61 | 62 | // Initialize metadata 63 | TileDB_Metadata* tiledb_metadata; 64 | tiledb_metadata_init( 65 | tiledb_ctx, // Context 66 | &tiledb_metadata, // Array object 67 | "my_workspace/sparse_arrays/my_array_B/meta", // Array name 68 | TILEDB_METADATA_READ, // Mode 69 | NULL, // Attributes (all) 70 | 0); // Number of attributes 71 | 72 | // Get metadata schema when the metadata object is initialized 73 | tiledb_metadata_get_schema(tiledb_metadata, &metadata_schema); 74 | 75 | // Print some schema info 76 | print_some_metadata_schema_info(&metadata_schema); 77 | 78 | // Free metadata schema 79 | tiledb_metadata_free_schema(&metadata_schema); 80 | 81 | // Finalize metadata 82 | tiledb_metadata_finalize(tiledb_metadata); 83 | 84 | // Finalize context 85 | tiledb_ctx_finalize(tiledb_ctx); 86 | 87 | return 0; 88 | } 89 | 90 | void print_some_metadata_schema_info( 91 | const TileDB_MetadataSchema* metadata_schema) { 92 | printf("Metadata name: %s\n", metadata_schema->metadata_name_); 93 | printf("Attributes: "); 94 | for(int i=0; iattribute_num_; ++i) 95 | printf("%s ", metadata_schema->attributes_[i]); 96 | printf("\n"); 97 | } 98 | -------------------------------------------------------------------------------- /examples/src/tiledb_metadata_read.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_metadata_read.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to read from metadata. 31 | */ 32 | 33 | #include "tiledb.h" 34 | #include 35 | 36 | int main(int argc, char** argv) { 37 | // Sanity check 38 | if(argc != 2) { 39 | fprintf(stderr, "Usage: ./tiledb_metadata_read key\n"); 40 | return -1; 41 | } 42 | 43 | // Initialize context with the default configuration parameters 44 | TileDB_CTX* tiledb_ctx; 45 | tiledb_ctx_init(&tiledb_ctx, NULL); 46 | 47 | // Subset over attributes 48 | const char* attributes[] = { "a1", "a2" }; 49 | 50 | // Initialize metadata 51 | TileDB_Metadata* tiledb_metadata; 52 | tiledb_metadata_init( 53 | tiledb_ctx, // Context 54 | &tiledb_metadata, // Metadata object 55 | "my_workspace/sparse_arrays/my_array_B/meta", // Metadata name 56 | TILEDB_METADATA_READ, // Mode 57 | attributes, // Attributes 58 | 2); // Number of attributes 59 | 60 | // Prepare cell buffers 61 | int buffer_a1[1]; 62 | size_t buffer_a2[1]; 63 | char buffer_var_a2[2]; 64 | void* buffers[] = 65 | { 66 | buffer_a1, // a1 67 | buffer_a2, buffer_var_a2 // a2 68 | }; 69 | size_t buffer_sizes[] = 70 | { 71 | sizeof(buffer_a1), // a1 72 | sizeof(buffer_a2), sizeof(buffer_var_a2) // a2 73 | }; 74 | 75 | // Read from metadata 76 | tiledb_metadata_read(tiledb_metadata, argv[1], buffers, buffer_sizes); 77 | 78 | // Check existence 79 | if(buffer_sizes[0] == 0 && !tiledb_metadata_overflow(tiledb_metadata, 0)) { 80 | fprintf(stderr, "Key '%s' does not exist in the metadata!\n", argv[1]); 81 | } else if(buffer_sizes[2] == 0 && 82 | tiledb_metadata_overflow(tiledb_metadata, 1)) { 83 | // Check overflow for a2 84 | fprintf(stderr, "Reading value on attribute 'a2' for key '%s' resulted in " 85 | "a buffer overflow!\n", argv[1]); 86 | } else if(static_cast(buffers[0])[0] == TILEDB_EMPTY_INT32) { 87 | // Check if deleted 88 | fprintf(stderr, "Key '%s' has been deleted!\n", argv[1]); 89 | } else { 90 | // Print attribute values 91 | printf( 92 | "%s: a1=%d, a2=%.*s\n", 93 | argv[1], 94 | static_cast(buffers[0])[0], 95 | int(buffer_sizes[2]), 96 | static_cast(buffers[2])); 97 | } 98 | 99 | /* Finalize the array. */ 100 | tiledb_metadata_finalize(tiledb_metadata); 101 | 102 | /* Finalize context. */ 103 | tiledb_ctx_finalize(tiledb_ctx); 104 | 105 | return 0; 106 | } 107 | -------------------------------------------------------------------------------- /examples/src/tiledb_metadata_update.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_metadata_update.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to modify or delete a metadata item. 31 | */ 32 | 33 | #include "tiledb.h" 34 | 35 | int main() { 36 | // Initialize context with the default configuration parameters 37 | TileDB_CTX* tiledb_ctx; 38 | tiledb_ctx_init(&tiledb_ctx, NULL); 39 | 40 | // Initialize metadata 41 | TileDB_Metadata* tiledb_metadata; 42 | tiledb_metadata_init( 43 | tiledb_ctx, // Context 44 | &tiledb_metadata, // Metadata object 45 | "my_workspace/sparse_arrays/my_array_B/meta", // Metadata name 46 | TILEDB_METADATA_WRITE, // Mode 47 | NULL, // All attributes 48 | 0); // Number of attributes 49 | 50 | // Prepare cell buffers 51 | int buffer_a1[] = { 100, TILEDB_EMPTY_INT32 }; 52 | size_t buffer_a2[] = { 0, 1 }; 53 | char buffer_var_a2[] = { 'A', TILEDB_EMPTY_CHAR }; 54 | char keys[] = "k1\0k2"; 55 | size_t buffer_keys[] = { 0, 3 }; 56 | char buffer_var_keys[] = 57 | { 58 | 'k', '1', '\0', // k1 modified key value 59 | TILEDB_EMPTY_CHAR // k2 deleted value 60 | }; 61 | const void* buffers[] = 62 | { 63 | buffer_a1, // a1 64 | buffer_a2, buffer_var_a2, // a2 65 | buffer_keys, buffer_var_keys // TILEDB_KEY 66 | }; 67 | size_t buffer_sizes[] = { 68 | sizeof(buffer_a1), // a1 69 | sizeof(buffer_a2), sizeof(buffer_var_a2), // a2 70 | sizeof(buffer_keys), sizeof(buffer_var_keys) // TILEDB_KEY 71 | }; 72 | size_t keys_size = sizeof(keys); 73 | 74 | // Write metadata 75 | tiledb_metadata_write( 76 | tiledb_metadata, // Metadata object 77 | keys, // Keys 78 | keys_size, // Keys size 79 | buffers, // Attribute buffers 80 | buffer_sizes); // Attribute buffer sizes 81 | 82 | // Finalize the metadata 83 | tiledb_metadata_finalize(tiledb_metadata); 84 | 85 | // Finalize context 86 | tiledb_ctx_finalize(tiledb_ctx); 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /examples/src/tiledb_metadata_write.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_metadata_write.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It shows how to write metadata. 31 | */ 32 | 33 | #include "tiledb.h" 34 | 35 | int main() { 36 | // Initialize context with the default configuration parameters 37 | TileDB_CTX* tiledb_ctx; 38 | tiledb_ctx_init(&tiledb_ctx, NULL); 39 | 40 | // Initialize metadata 41 | TileDB_Metadata* tiledb_metadata; 42 | tiledb_metadata_init( 43 | tiledb_ctx, // Context 44 | &tiledb_metadata, // Metadata object 45 | "my_workspace/sparse_arrays/my_array_B/meta", // Metadata name 46 | TILEDB_METADATA_WRITE, // Mode 47 | NULL, // All attributes 48 | 0); // Number of attributes 49 | 50 | // Prepare cell buffers 51 | int buffer_a1[] = { 1, 2, 3 }; 52 | size_t buffer_a2[] = { 0, 1, 3 }; 53 | char buffer_var_a2[] = "abbccc"; 54 | size_t buffer_keys[] = { 0, 3, 6 }; 55 | char buffer_var_keys[] = "k1\0k2\0k3"; 56 | const void* buffers[] = 57 | { 58 | buffer_a1, // a1 59 | buffer_a2, buffer_var_a2, // a2 60 | buffer_keys, buffer_var_keys // TILEDB_KEY 61 | }; 62 | size_t buffer_sizes[] = { 63 | sizeof(buffer_a1), // a1 64 | sizeof(buffer_a2), sizeof(buffer_var_a2), // a2 65 | sizeof(buffer_keys), sizeof(buffer_var_keys) // TILEDB_KEY 66 | }; 67 | size_t keys_size = sizeof(buffer_var_keys); 68 | 69 | // Write metadata 70 | tiledb_metadata_write( 71 | tiledb_metadata, // Metadata object 72 | buffer_var_keys, // Keys 73 | keys_size, // Keys size 74 | buffers, // Attribute buffers 75 | buffer_sizes); // Attribute buffer sizes 76 | 77 | // Finalize the metadata 78 | tiledb_metadata_finalize(tiledb_metadata); 79 | 80 | // Finalize context 81 | tiledb_ctx_finalize(tiledb_ctx); 82 | 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /examples/src/tiledb_workspace_group_create.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tiledb_workspace_group_create.cc 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * It creates a workspace and two groups. 31 | */ 32 | 33 | #include "tiledb.h" 34 | 35 | int main() { 36 | // Initialize context with the default configuration parameters 37 | TileDB_CTX* tiledb_ctx; 38 | tiledb_ctx_init(&tiledb_ctx, NULL); 39 | 40 | // Create a workspace 41 | tiledb_workspace_create(tiledb_ctx, "my_workspace"); 42 | 43 | // Create a group in the worskpace 44 | tiledb_group_create(tiledb_ctx, "my_workspace/dense_arrays"); 45 | 46 | // Create two groups in the worskpace 47 | tiledb_group_create(tiledb_ctx, "my_workspace/sparse_arrays"); 48 | 49 | // Finalize context 50 | tiledb_ctx_finalize(tiledb_ctx); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # test/CMakeLists.txt 3 | # 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (c) 2016 MIT and Intel Corporation 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | # THE SOFTWARE. 26 | # 27 | 28 | # Include GTest headers 29 | include_directories(${GTEST_INCLUDE_DIRS}) 30 | 31 | # Include test header directories 32 | file(GLOB TILEDB_TEST_INCLUDE_DIRS "include/*") 33 | include_directories(${TILEDB_TEST_INCLUDE_DIRS}) 34 | 35 | # Include TileDB core header directories 36 | file(GLOB TILEDB_CORE_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/core/include/*") 37 | include_directories(${TILEDB_CORE_INCLUDE_DIRS}) 38 | 39 | # Get test source files 40 | file(GLOB_RECURSE TILEDB_TEST_SOURCES "src/*.cc") 41 | 42 | # Build tests 43 | add_executable(tiledb_test EXCLUDE_FROM_ALL ${TILEDB_TEST_SOURCES}) 44 | target_link_libraries( 45 | tiledb_test 46 | ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} 47 | tiledb_static ${TILEDB_LIB_DEPENDENCIES} 48 | ) 49 | add_test(tiledb_test tiledb_test) 50 | 51 | # Add custom target 'check' 52 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V DEPENDS tiledb_test) 53 | -------------------------------------------------------------------------------- /test/include/c_api/c_api_array_schema_spec.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file c_api_array_schema_spec.h 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * Declarations for testing the C API array schema spec. 31 | */ 32 | 33 | #ifndef __C_API_ARRAY_SCHEMA_SPEC_H__ 34 | #define __C_API_ARRAY_SCHEMA_SPEC_H__ 35 | 36 | #include "tiledb.h" 37 | #include 38 | 39 | 40 | /** Test fixture for the array schema. */ 41 | class ArraySchemaTestFixture: public testing::Test { 42 | 43 | public: 44 | /* ********************************* */ 45 | /* CONSTANTS */ 46 | /* ********************************* */ 47 | 48 | /** Workspace folder name. */ 49 | const std::string WORKSPACE = ".__workspace/"; 50 | /** 51 | * Array name. 52 | * Format: (x_x). 53 | */ 54 | const std::string ARRAYNAME = "dense_test_100x100_10x10"; 55 | 56 | 57 | 58 | 59 | /* ********************************* */ 60 | /* GTEST FUNCTIONS */ 61 | /* ********************************* */ 62 | 63 | /** Test initialization. */ 64 | virtual void SetUp(); 65 | 66 | /** Test finalization. */ 67 | virtual void TearDown(); 68 | 69 | 70 | 71 | 72 | /* ********************************* */ 73 | /* PUBLIC METHODS */ 74 | /* ********************************* */ 75 | 76 | /** 77 | * Creates a dense array. 78 | * 79 | * @return TILEDB_OK on success and TILEDB_ERR on error. 80 | */ 81 | int create_dense_array(); 82 | 83 | 84 | /* ********************************* */ 85 | /* PUBLIC ATTRIBUTES */ 86 | /* ********************************* */ 87 | 88 | /** Array name. */ 89 | std::string array_name_; 90 | /** Array schema object under test. */ 91 | TileDB_ArraySchema array_schema_; 92 | /** True if the array schema is set. */ 93 | bool array_schema_set_; 94 | /** TileDB context. */ 95 | TileDB_CTX* tiledb_ctx_; 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /test/include/misc/utils_spec.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file utils_spec.h 3 | * 4 | * @section LICENSE 5 | * 6 | * The MIT License 7 | * 8 | * @copyright Copyright (c) 2016 MIT and Intel Corporation 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | * 28 | * @section DESCRIPTION 29 | * 30 | * Declarations for testing various utility function specs. 31 | */ 32 | 33 | #ifndef __C_UTILS_SPEC_H__ 34 | #define __C_UTILS_SPEC_H__ 35 | 36 | #include "utils.h" 37 | #include 38 | 39 | 40 | /** Test fixture for the utility functions. */ 41 | class UtilsTestFixture: public testing::Test { 42 | 43 | public: 44 | 45 | /* ********************************* */ 46 | /* GTEST FUNCTIONS */ 47 | /* ********************************* */ 48 | 49 | /** Test initialization. */ 50 | virtual void SetUp(); 51 | 52 | /** Test finalization. */ 53 | virtual void TearDown(); 54 | }; 55 | 56 | #endif 57 | --------------------------------------------------------------------------------