Fixed a bug where cloning a column would fail if the data was empty
This commit is contained in:
@ -604,17 +604,17 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
||||
size_t nb_elements_per_line,
|
||||
const char* elements_names)
|
||||
{
|
||||
OBIDMS_column_p new_column;
|
||||
OBIDMS_column_p new_column;
|
||||
OBIDMS_column_directory_p column_directory;
|
||||
OBIDMS_column_header_p header;
|
||||
size_t file_size;
|
||||
obiversion_t version_number;
|
||||
char* column_file_name;
|
||||
int column_file_descriptor;
|
||||
int column_dir_file_descriptor;
|
||||
size_t header_size;
|
||||
size_t data_size;
|
||||
size_t minimum_line_count;
|
||||
OBIDMS_column_header_p header;
|
||||
size_t file_size;
|
||||
obiversion_t version_number;
|
||||
char* column_file_name;
|
||||
int column_file_descriptor;
|
||||
int column_dir_file_descriptor;
|
||||
size_t header_size;
|
||||
size_t data_size;
|
||||
size_t minimum_line_count;
|
||||
|
||||
new_column = NULL;
|
||||
|
||||
@ -1041,8 +1041,8 @@ int obi_truncate_column_to_lines_used(OBIDMS_column_p column) // TODO is it nece
|
||||
int column_file_descriptor;
|
||||
char* column_file_name;
|
||||
|
||||
// Compute the new line count = the number of lines used rounded to the nearest multiple of page size
|
||||
multiple = ceil((double) ((column->header)->lines_used * (column->header)->nb_elements_per_line * obi_sizeof((column->header)->data_type)) / (double) getpagesize());
|
||||
// Compute the new line count = the number of lines used rounded to the nearest greater multiple of page size greater than 0
|
||||
multiple = ceil((double) (ONE_IF_ZERO((column->header)->lines_used) * (column->header)->nb_elements_per_line * obi_sizeof((column->header)->data_type)) / (double) getpagesize());
|
||||
new_line_count = (int) multiple * getpagesize();
|
||||
|
||||
// Check that it is actually greater than the current number of lines allocated in the file, otherwise no need to truncate
|
||||
@ -1558,13 +1558,14 @@ size_t obi_column_get_element_index_from_name(OBIDMS_column_p column, const char
|
||||
|
||||
size_t obi_column_get_nb_elements_per_line(OBIDMS_column_p column)
|
||||
{
|
||||
// TODO check that column is not NULL?
|
||||
return (column->header)->nb_elements_per_line;
|
||||
}
|
||||
|
||||
|
||||
char* obi_column_get_formatted_creation_date(OBIDMS_column_p column)
|
||||
{
|
||||
const char* formatted_time;
|
||||
char* formatted_time;
|
||||
struct tm* tmp;
|
||||
|
||||
formatted_time = (char*) malloc(FORMATTED_TIME_LENGTH*sizeof(char));
|
||||
@ -1597,7 +1598,7 @@ char* obi_column_get_formatted_creation_date_from_name(OBIDMS_p dms, const char*
|
||||
int column_dir_file_descriptor;
|
||||
size_t header_size;
|
||||
obiversion_t version_number;
|
||||
const char* formatted_time;
|
||||
char* formatted_time;
|
||||
struct tm* tmp;
|
||||
|
||||
// Get the column directory structure associated to the column
|
||||
|
@ -27,14 +27,16 @@
|
||||
#include "obidmscolumndir.h"
|
||||
|
||||
|
||||
#define ELEMENTS_NAMES_MAX (2048) /**< The maximum length of the list of elements names.
|
||||
*/
|
||||
#define GROWTH_FACTOR (2) /**< The growth factor when a column is enlarged.
|
||||
*/
|
||||
#define MAXIMUM_LINE_COUNT (1000000) /**< The maximum line count for the data of a column. //TODO
|
||||
*/
|
||||
#define FORMATTED_TIME_LENGTH (1024) /**< The length allocated for the character string containing a formatted date
|
||||
*/
|
||||
#define ONE_IF_ZERO(x) (((x)==0)?1:(x)) /**< If x is equal to 0, x takes the value 1.
|
||||
*/
|
||||
#define ELEMENTS_NAMES_MAX (2048) /**< The maximum length of the list of elements names.
|
||||
*/
|
||||
#define GROWTH_FACTOR (2) /**< The growth factor when a column is enlarged.
|
||||
*/
|
||||
#define MAXIMUM_LINE_COUNT (1000000) /**< The maximum line count for the data of a column. //TODO
|
||||
*/
|
||||
#define FORMATTED_TIME_LENGTH (1024) /**< The length allocated for the character string containing a formatted date
|
||||
*/
|
||||
|
||||
typedef int32_t obiversion_t; /**< Used to store the column version number
|
||||
*/
|
||||
|
Reference in New Issue
Block a user