diff --git a/python/obitools3/commands/test.pyx b/python/obitools3/commands/test.pyx index 8aee343..2fcf69c 100644 --- a/python/obitools3/commands/test.pyx +++ b/python/obitools3/commands/test.pyx @@ -20,10 +20,8 @@ QUALITY_COLUMN = "QUALITY" SPECIAL_COLUMNS = [NUC_SEQUENCE_COLUMN, ID_COLUMN, DEFINITION_COLUMN, QUALITY_COLUMN] -NAME_MAX_LEN = 50 +NAME_MAX_LEN = 200 COL_COMMENTS_MAX_LEN = 2048 -MAX_NB_ELEMENTS_PER_LINE = 20 -ELEMENT_NAME_MAX_LEN = int(2048 / MAX_NB_ELEMENTS_PER_LINE) MAX_INT = 2147483647 # used to generate random float values @@ -78,6 +76,14 @@ def random_unique_name(infos): return name +def random_unique_element_name(config, infos): + name = "" + while name == "" or name in infos['unique_names'] : + name = random_str_with_max_len(config['test']['elt_name_max_len']) + infos['unique_names'].append(name) + return name + + def print_test(config, sentence): if config['test']['verbose'] : print(sentence) @@ -180,10 +186,10 @@ def fill_column(config, infos, col) : def create_random_column(config, infos) : alias = random.choice(['', random_unique_name(infos)]) - nb_elements_per_line=random.randint(1, MAX_NB_ELEMENTS_PER_LINE) + nb_elements_per_line=random.randint(1, config['test']['maxelts']) elements_names = [] for i in range(nb_elements_per_line) : - elements_names.append(random_unique_name(infos)) + elements_names.append(random_unique_element_name(config, infos)) name = random_unique_name(infos) infos['view'].add_column(name, alias=alias, @@ -317,6 +323,14 @@ def addOptions(parser): help="Maximum number of lines in a column." "Default: 10000") + group.add_argument('--max_elts_per_line','-e', + action="store", dest="test:maxelts", + metavar='', + default=20, + type=int, + help="Maximum number of elements per line in a column." + "Default: 20") + group.add_argument('--verbose','-v', action="store_true", dest="test:verbose", default=False, @@ -333,8 +347,10 @@ def run(config): 'tests': [test_set_and_get, test_add_col, test_delete_col, test_col_alias, test_new_view] } + config['test']['elt_name_max_len'] = int((COL_COMMENTS_MAX_LEN - config['test']['maxelts']) / config['test']['maxelts']) + print("Initializing the DMS and the first view...") - + ini_dms_and_first_view(config, infos) i = 0 diff --git a/src/obiavl.h b/src/obiavl.h index 45793d3..d64e314 100644 --- a/src/obiavl.h +++ b/src/obiavl.h @@ -30,7 +30,7 @@ #include "encode.h" -#define MAX_NB_OF_AVLS_IN_GROUP (100) /**< The maximum number of AVL trees in a group. // TODO discuss +#define MAX_NB_OF_AVLS_IN_GROUP (1000) /**< The maximum number of AVL trees in a group. // TODO discuss */ #define MAX_NODE_COUNT_PER_AVL (10000000) /**< The maximum number of nodes in an AVL tree. * Only used to decide when to create a new AVL in a group, and to initialize the bloom filter // TODO discuss. @@ -42,7 +42,7 @@ */ #define AVL_MAX_DEPTH (1024) /**< The maximum depth of an AVL tree. Used to save paths through the tree. */ -#define AVL_MAX_NAME (1024) /**< The maximum length of an AVL tree name. +#define AVL_MAX_NAME (250) /**< The maximum length of an AVL tree name. */ #define AVL_GROWTH_FACTOR (2) /**< The growth factor when an AVL tree is enlarged. */ diff --git a/src/obidms.h b/src/obidms.h index 0765559..39c6499 100644 --- a/src/obidms.h +++ b/src/obidms.h @@ -26,7 +26,7 @@ #include "obitypes.h" -#define OBIDMS_MAX_NAME (2048) /**< The maximum length of an OBIDMS name. +#define OBIDMS_MAX_NAME (247) /**< The maximum length of an OBIDMS name. */ #define INDEXER_DIR_NAME "OBIBLOB_INDEXERS" /**< The name of the Obiblob indexer directory. */ @@ -34,11 +34,11 @@ */ #define TAXONOMY_DIR_NAME "TAXONOMY" /**< The name of the taxonomy directory. */ -#define MAX_NB_OPENED_COLUMNS (100) /**< The maximum number of columns open at the same time. +#define MAX_NB_OPENED_COLUMNS (1000) /**< The maximum number of columns open at the same time. */ -#define MAX_NB_OPENED_INDEXERS (100) /**< The maximum number of indexers open at the same time. +#define MAX_NB_OPENED_INDEXERS (1000) /**< The maximum number of indexers open at the same time. */ -#define MAX_PATH_LEN 4096 /**< Maximum length for the character string defining a +#define MAX_PATH_LEN (1024) /**< Maximum length for the character string defining a * file or directory path. */ diff --git a/src/obidmscolumn.h b/src/obidmscolumn.h index ddf7f81..4ecbcf7 100644 --- a/src/obidmscolumn.h +++ b/src/obidmscolumn.h @@ -28,7 +28,7 @@ #include "obiblob_indexer.h" -#define ELEMENTS_NAMES_MAX (2048) /**< The maximum length of the list of elements names. +#define ELEMENTS_NAMES_MAX (2048) /**< The maximum length of the list of elements names. // TODO Discuss */ #define COLUMN_GROWTH_FACTOR (2) /**< The growth factor when a column is enlarged. */ diff --git a/src/obiview.c b/src/obiview.c index 613be72..1666f93 100644 --- a/src/obiview.c +++ b/src/obiview.c @@ -1645,7 +1645,6 @@ int obi_view_add_column(Obiview_p view, int i; OBIDMS_column_p column; OBIDMS_column_p column_buffer; - OBIDMS_column_p current_line_selection; // Check that the view is not read-only if (view->read_only) @@ -1702,19 +1701,24 @@ int obi_view_add_column(Obiview_p view, if (create) { // Create column column = obi_create_column(view->dms, column_name, data_type, nb_lines, nb_elements_per_line, elements_names, indexer_name, associated_column_name, associated_column_version, comments); + if (column == NULL) + { + obidebug(1, "\nError creating a column to add to a view"); + return -1; + } (column->header)->lines_used = nb_lines; } else { // Open column - // TODO do we require that the column's line count is equal to the view's line count? - // or do we enlarge the column or the view as needed? column = obi_open_column(view->dms, column_name, version_number); - } - - if (column == NULL) - { - obidebug(1, "\nError creating or opening a column to add to a view"); - return -1; + if (column == NULL) + { + obidebug(1, "\nError opening a column to add to a view"); + return -1; + } + // Check that the column's line count is equal to the view's line count if there is no line selection. + // TODO But what if there is a line selection ??? imo should just check that col_line_count > line_selection_count + //if () } // Store column pointer in the view structure diff --git a/src/obiview.h b/src/obiview.h index 7a569eb..053e288 100644 --- a/src/obiview.h +++ b/src/obiview.h @@ -28,7 +28,7 @@ #include "hashtable.h" -#define OBIVIEW_NAME_MAX_LENGTH (255) /**< The maximum length of an OBIDMS view name. +#define OBIVIEW_NAME_MAX_LENGTH (249) /**< The maximum length of an OBIDMS view name, without the extension. */ #define VIEW_TYPE_MAX_LENGTH (1024) /**< The maximum length of the type name of a view. */