Skip to content
This repository was archived by the owner on Jun 12, 2023. It is now read-only.

Commit bc773aa

Browse files
Merge pull request #21 from Intel-HLS/dev
Thread-/process-safety and bug fixes
2 parents edb02e3 + 2cc1832 commit bc773aa

File tree

70 files changed

+3389
-596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3389
-596
lines changed

Makefile

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ifeq ($(BUILD),release)
4242
endif
4343

4444
ifeq ($(BUILD),debug)
45-
CPPFLAGS += -DDEBUG -gdwarf-3 -g3
45+
CPPFLAGS += -DDEBUG -gdwarf-3 -g3 -Wall
4646
endif
4747

4848
# --- Verbose mode handler --- #
@@ -239,7 +239,8 @@ clean_libtiledb:
239239
$(EXAMPLES_OBJ_DIR)/%.o: $(EXAMPLES_SRC_DIR)/%.cc
240240
@mkdir -p $(EXAMPLES_OBJ_DIR)
241241
@echo "Compiling $<"
242-
@$(CXX) $(CPPFLAGS) $(INCLUDE_PATHS) $(EXAMPLES_INCLUDE_PATHS) \
242+
@$(CXX) $(CPPFLAGS) -fopenmp $(INCLUDE_PATHS) \
243+
$(EXAMPLES_INCLUDE_PATHS) \
243244
$(CORE_INCLUDE_PATHS) -c $< -o $@
244245
@$(CXX) -MM $(EXAMPLES_INCLUDE_PATHS) \
245246
$(CORE_INCLUDE_PATHS) $< > $(@:.o=.d)
@@ -273,7 +274,7 @@ clean_examples:
273274
$(TEST_OBJ_DIR)/%.o: $(TEST_SRC_DIR)/%.cc
274275
@mkdir -p $(dir $@)
275276
@echo "Compiling $<"
276-
@$(CXX) $(CPPFLAGS) $(TEST_INCLUDE_PATHS) -c $< -o $@
277+
@$(CXX) $(CPPFLAGS) -fopenmp $(TEST_INCLUDE_PATHS) -c $< -o $@
277278
@$(CXX) -MM $(TEST_INCLUDE_PATHS) \
278279
$(CORE_INCLUDE_PATHS) $< > $(@:.o=.d)
279280
@mv -f $(@:.o=.d) $(@:.o=.d.tmp)

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
The TileDB documentation for users is hosted as
2-
a Github wiki: https://github.com/Intel-HLS/TileDB/wiki
1+
# TileDB
32

4-
TileDB official website: http://istc-bigdata.org/tiledb
3+
[![Travis](https://img.shields.io/travis/Intel-HLS/TileDB.svg?maxAge=2592000)]
4+
(https://travis-ci.org/Intel-HLS/TileDB)
5+
6+
The TileDB documentation for users is hosted as a [Github
7+
wiki](https://github.com/Intel-HLS/TileDB/wiki).
8+
9+
[TileDB official website](http://istc-bigdata.org/tiledb).

core/include/array/array.h

+21-8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include "array_read_state.h"
3737
#include "array_schema.h"
38+
#include "book_keeping.h"
3839
#include "constants.h"
3940
#include "fragment.h"
4041

@@ -140,10 +141,17 @@ class Array {
140141

141142
/**
142143
* Consolidates all fragments into a new single one, on a per-attribute basis.
144+
* Returns the new fragment (which has to be finalized outside this functions),
145+
* along with the names of the old (consolidated) fragments (which also have
146+
* to be deleted outside this function).
143147
*
148+
* @param new_fragment The new fragment to be returned.
149+
* @param old_fragment_names The names of the old fragments to be returned.
144150
* @return TILEDB_AR_OK for success and TILEDB_AR_ERR for error.
145151
*/
146-
int consolidate();
152+
int consolidate(
153+
Fragment*& new_fragment,
154+
std::vector<std::string>& old_fragment_names);
147155

148156
/**
149157
* Consolidates all fragment into a new single one, focusing on a specific
@@ -167,6 +175,9 @@ class Array {
167175
* Initializes a TileDB array object.
168176
*
169177
* @param array_schema The array schema.
178+
* @param fragment_names The names of the fragments of the array.
179+
* @param book_keeping The book-keeping structures of the fragments
180+
* of the array.
170181
* @param mode The mode of the array. It must be one of the following:
171182
* - TILEDB_ARRAY_WRITE
172183
* - TILEDB_ARRAY_WRITE_UNSORTED
@@ -184,6 +195,8 @@ class Array {
184195
*/
185196
int init(
186197
const ArraySchema* array_schema,
198+
const std::vector<std::string>& fragment_names,
199+
const std::vector<BookKeeping*>& book_keeping,
187200
int mode,
188201
const char** attributes,
189202
int attribute_num,
@@ -299,21 +312,21 @@ class Array {
299312
* After the new fragmemt is finalized, the array will change its name
300313
* by removing the leading '.' character.
301314
*
302-
* @return A new special fragment name.
315+
* @return A new special fragment name on success, or "" (empty string) on
316+
* error.
303317
*/
304318
std::string new_fragment_name() const;
305319

306320
/**
307321
* Opens the existing fragments in TILEDB_ARRAY_READ_MODE.
308322
*
323+
* @param fragment_names The vector with the fragment names.
324+
* @param book_keeping The book-keeping of the array fragments.
309325
* @return TILEDB_AR_OK for success and TILEDB_AR_ERR for error.
310326
*/
311-
int open_fragments();
312-
313-
/**
314-
* Appropriately sorts the fragment names based on their name timestamps.
315-
*/
316-
void sort_fragment_names(std::vector<std::string>& fragment_names) const;
327+
int open_fragments(
328+
const std::vector<std::string>& fragment_names,
329+
const std::vector<BookKeeping*>& book_keeping);
317330
};
318331

319332
#endif

core/include/array/array_iterator.h

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class ArrayIterator {
7171
/* ACCESSORS */
7272
/* ********************************* */
7373

74+
/** Return the array name. */
75+
const std::string& array_name() const;
76+
7477
/**
7578
* Checks if the the iterator has reached its end.
7679
*

core/include/array/array_schema.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ class ArraySchema {
511511
* may be a sub-domain of the array domain).
512512
* @param tile_coords The tile coordinates.
513513
* @return The tile position of *tile_coords* along the tile order of the
514-
* array inside the input domain.
514+
* array inside the input domain, or TILEDB_AS_ERR on error.
515515
*/
516516
template<class T>
517517
int64_t get_tile_pos(

core/include/c_api/c_api.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,13 @@ TILEDB_EXPORT int tiledb_array_overflow(
462462
/**
463463
* Consolidates the fragments of an array into a single fragment.
464464
*
465-
* @param tiledb_array The TileDB array to be consolidated.
465+
* @param tiledb_ctx The TileDB context.
466+
* @param array The name of the TileDB array to be consolidated.
466467
* @return TILEDB_OK on success, and TILEDB_ERR on error.
467468
*/
468-
TILEDB_EXPORT int tiledb_array_consolidate(const TileDB_Array* tiledb_array);
469+
TILEDB_EXPORT int tiledb_array_consolidate(
470+
const TileDB_CTX* tiledb_ctx,
471+
const char* array);
469472

470473
/**
471474
* Finalizes a TileDB array, properly freeing its memory space.
@@ -819,11 +822,13 @@ TILEDB_EXPORT int tiledb_metadata_overflow(
819822
/**
820823
* Consolidates the fragments of a metadata object into a single fragment.
821824
*
822-
* @param tiledb_metadata The TileDB metadata to be consolidated.
825+
* @param tiledb_ctx The TileDB context.
826+
* @param metadata The name of the TileDB metadata to be consolidated.
823827
* @return TILEDB_OK on success, and TILEDB_ERR on error.
824828
*/
825829
TILEDB_EXPORT int tiledb_metadata_consolidate(
826-
const TileDB_Metadata* tiledb_metadata);
830+
const TileDB_CTX* tiledb_ctx,
831+
const char* metadata);
827832

828833
/**
829834
* Finalizes a TileDB metadata object, properly freeing the memory space.

core/include/fragment/book_keeping.h

+25-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
#ifndef __BOOK_KEEPING_H__
3434
#define __BOOK_KEEPING_H__
3535

36-
#include "fragment.h"
36+
#include "array_schema.h"
37+
#include "constants.h"
3738
#include <vector>
3839
#include <zlib.h>
3940

@@ -53,8 +54,6 @@
5354

5455

5556

56-
class Fragment;
57-
5857
/** Stores the book-keeping structures of a fragment. */
5958
class BookKeeping {
6059
public:
@@ -65,9 +64,16 @@ class BookKeeping {
6564
/**
6665
* Constructor.
6766
*
68-
* @param fragment The fragment the book-keeping structure belongs to.
67+
* @param array_schema The array schema.
68+
* @param dense True if the fragment is dense, and false otherwise.
69+
* @param fragment_name The name of the fragment this book-keeping belongs to.
70+
* @param mode The mode in which the fragment was initialized in.
6971
*/
70-
BookKeeping(const Fragment* fragment);
72+
BookKeeping(
73+
const ArraySchema* array_schema,
74+
bool dense,
75+
const std::string& fragment_name,
76+
int mode);
7177

7278
/** Destructor. */
7379
~BookKeeping();
@@ -85,6 +91,12 @@ class BookKeeping {
8591
/** Returns the number of cells in the tile at the input position. */
8692
int64_t cell_num(int64_t tile_pos) const;
8793

94+
/**
95+
* Returns ture if the corresponding fragment is dense, and false if it
96+
* is sparse.
97+
*/
98+
bool dense() const;
99+
88100
/** Returns the (expanded) domain in which the fragment is constrained. */
89101
const void* domain() const;
90102

@@ -202,21 +214,27 @@ class BookKeeping {
202214
/* PRIVATE ATTRIBUTES */
203215
/* ********************************* */
204216

217+
/** The array schema */
218+
const ArraySchema* array_schema_;
205219
/** The first and last coordinates of each tile. */
206220
std::vector<void*> bounding_coords_;
221+
/** True if the fragment is dense, and false if it is sparse. */
222+
bool dense_;
207223
/**
208224
* The (expanded) domain in which the fragment is constrained. "Expanded"
209225
* means that the domain is enlarged minimally to coincide with tile
210226
* boundaries (if there is a tile grid imposed by tile extents). Note that the
211227
* type of the domain must be the same as the type of the array coordinates.
212228
*/
213229
void* domain_;
214-
/** The fragment the book-keeping belongs to. */
215-
const Fragment* fragment_;
230+
/** The name of the fragment the book-keeping belongs to. */
231+
std::string fragment_name_;
216232
/** Number of cells in the last tile (meaningful only in the sparse case). */
217233
int64_t last_tile_cell_num_;
218234
/** The MBRs (applicable only to the sparse case with irregular tiles). */
219235
std::vector<void*> mbrs_;
236+
/** The mode in which the fragment was initialized. */
237+
int mode_;
220238
/** The offsets of the next tile for each attribute. */
221239
std::vector<off_t> next_tile_offsets_;
222240
/** The offsets of the next variable tile for each attribute. */

core/include/fragment/fragment.h

+12-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "array.h"
3737
#include "array_schema.h"
3838
#include "book_keeping.h"
39-
#include "constants.h"
4039
#include "read_state.h"
4140
#include "write_state.h"
4241
#include <vector>
@@ -125,11 +124,10 @@ class Fragment {
125124
int finalize();
126125

127126
/**
128-
* Initializes a fragment.
127+
* Initializes a fragment in write mode.
129128
*
130129
* @param fragment_name The name that will be given to the fragment.
131130
* @param mode The fragment mode. It can be one of the following:
132-
* - TILEDB_READ
133131
* - TILEDB_WRITE
134132
* - TILEDB_WRITE_UNSORTED
135133
* @param subarray The subarray the fragment is constrained on.
@@ -140,6 +138,17 @@ class Fragment {
140138
int mode,
141139
const void* subarray);
142140

141+
/**
142+
* Initializes a fragment in read mode.
143+
*
144+
* @param fragment_name The name that will be given to the fragment.
145+
* @param book_keeping The book-keeping of the fragment.
146+
* @return TILEDB_FG_OK on success and TILEDB_FG_ERR on error.
147+
*/
148+
int init(
149+
const std::string& fragment_name,
150+
BookKeeping* book_keeping);
151+
143152
/** Resets the read state (typically to start a new read). */
144153
void reset_read_state();
145154

core/include/fragment/read_state.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454

5555

56-
class BookKeeping;
56+
class Fragment;
5757

5858
/** Stores the state necessary when reading cells from a fragment. */
5959
class ReadState {

core/include/metadata/metadata.h

+16-4
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,18 @@ class Metadata {
117117
/* ********************************* */
118118

119119
/**
120-
* Consolidates the fragments of a metadata object into a single fragment.
121-
*
122-
* @return TILEDB_MT_OK on success, and TILEDB_MT_ERR on error.
120+
* Consolidates all fragments into a new single one, on a per-attribute basis.
121+
* Returns the new fragment (which has to be finalized outside this functions),
122+
* along with the names of the old (consolidated) fragments (which also have
123+
* to be deleted outside this function).
124+
*
125+
* @param new_fragment The new fragment to be returned.
126+
* @param old_fragment_names The names of the old fragments to be returned.
127+
* @return TILEDB_AR_OK for success and TILEDB_AR_ERR for error.
123128
*/
124-
int consolidate();
129+
int consolidate(
130+
Fragment*& new_fragment,
131+
std::vector<std::string>& old_fragment_names);
125132

126133
/**
127134
* Finalizes the metadata, properly freeing up the memory space.
@@ -134,6 +141,9 @@ class Metadata {
134141
* Initializes a TileDB metadata object.
135142
*
136143
* @param array_schema This essentially encapsulates the metadata schema.
144+
* @param fragment_names The names of the fragments of the array.
145+
* @param book_keeping The book-keeping structures of the fragments
146+
* of the array.
137147
* @param mode The mode of the metadata. It must be one of the following:
138148
* - TILEDB_METADATA_WRITE
139149
* - TILEDB_METADATA_READ
@@ -146,6 +156,8 @@ class Metadata {
146156
*/
147157
int init(
148158
const ArraySchema* array_schema,
159+
const std::vector<std::string>& fragment_names,
160+
const std::vector<BookKeeping*>& book_keeping,
149161
int mode,
150162
const char** attributes,
151163
int attribute_num);

core/include/metadata/metadata_iterator.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class MetadataIterator {
6969
/* ACCESSORS */
7070
/* ********************************* */
7171

72+
/** Return the metadata name. */
73+
const std::string& metadata_name() const;
74+
7275
/**
7376
* Checks if the the iterator has reached its end.
7477
*
@@ -134,8 +137,10 @@ class MetadataIterator {
134137
private:
135138
// PRIVATE ATTRIBUTES
136139

137-
// TODO
140+
/** The array iterator that implements the metadata iterator. */
138141
ArrayIterator* array_it_;
142+
/** The metadata this iterator belongs to. */
143+
Metadata* metadata_;
139144
};
140145

141146
#endif

0 commit comments

Comments
 (0)