Columns: elements names informations are now kept in a memory arena of

adapted size in the header, and added a boolean in the header indicating
whether the values should be evaluated (typically character strings to
be evaluated in Python)
This commit is contained in:
Celine Mercier
2017-12-13 22:46:50 +01:00
parent 2df5932b67
commit 1fd3323372
10 changed files with 177 additions and 111 deletions

View File

@ -32,6 +32,7 @@ cdef extern from "obidmscolumn.h" nogil:
OBIType_t returned_data_type
OBIType_t stored_data_type
bint tuples
bint to_eval
time_t creation_date
obiversion_t version
obiversion_t cloned_from

View File

@ -86,7 +86,9 @@ cdef extern from "obiview.h" nogil:
index_t nb_lines,
index_t nb_elements_per_line,
char* elements_names,
bint elt_names_formatted,
bint tuples,
bint to_eval,
const_char_p indexer_name,
const_char_p associated_column_name,
obiversion_t associated_column_version,

View File

@ -56,6 +56,9 @@ cdef class Column_str(Column_idx):
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
if value == OBIStr_NA :
result = None
# For columns containing character strings that should be evaluated:
elif self.to_eval:
result = eval(value)
else :
result = <bytes> value # NOTE: value is not freed because the pointer points to a mmapped region in an AVL data file.
return result

View File

@ -330,6 +330,7 @@ cdef class View(OBIWrapper) :
line = self[idx]
for k in item :
# If setting from another View Line and the column doesn't exist, create it based on the informations from the other View
# TODO use clone_column
if isinstance(item, Line) and tostr(k) not in self:
col = item.view[k]
Column.new_column(self,
@ -337,6 +338,8 @@ cdef class View(OBIWrapper) :
col.data_type_int,
nb_elements_per_line = col.nb_elements_per_line,
elements_names = col.elements_names,
tuples = col.tuples,
to_eval = col.to_eval,
comments = col.comments,
alias=k
)