Added tuple columns containing immutable indexed data arrays of any type

This commit is contained in:
Celine Mercier
2017-11-15 13:48:59 +01:00
parent 1684f96b79
commit 9a50803c00
32 changed files with 1097 additions and 284 deletions

View File

@ -1,6 +1,4 @@
#cython: language_level=3
from obitools3.dms.column import typed_column
__OBIDMS_COLUMN_CLASS__ = {}
@ -44,12 +42,12 @@ cdef class Column(OBIWrapper) :
@staticmethod
cdef type get_column_class(obitype_t obitype, bint multi_elts):
cdef type get_column_class(obitype_t obitype, bint multi_elts, bint tuples):
'''
Internal function returning the python class representing
a column for a given obitype.
'''
return __OBIDMS_COLUMN_CLASS__[(obitype, multi_elts)][0]
return __OBIDMS_COLUMN_CLASS__[(obitype, multi_elts, tuples)][0]
@staticmethod
@ -76,6 +74,7 @@ cdef class Column(OBIWrapper) :
obitype_t data_type,
index_t nb_elements_per_line=1,
list elements_names=None,
bint tuples=False,
object comments=b"",
object alias=b""):
# TODO indexer_name?
@ -115,6 +114,7 @@ cdef class Column(OBIWrapper) :
nb_lines = len(view),
nb_elements_per_line = nb_elements_per_line,
elements_names = elements_names_p,
tuples = tuples,
indexer_name = NULL,
associated_column_name = NULL,
associated_column_version = -1,
@ -150,7 +150,7 @@ cdef class Column(OBIWrapper) :
column_p = column_pp[0]
column_type = column_p.header.returned_data_type
column_class = Column.get_column_class(column_type, (column_p.header.nb_elements_per_line > 1))
column_class = Column.get_column_class(column_type, (column_p.header.nb_elements_per_line > 1), column_p.header.tuples)
column = OBIWrapper.new_wrapper(column_class, column_pp)
column._view = view
@ -184,6 +184,7 @@ cdef class Column(OBIWrapper) :
nb_lines = -1,
nb_elements_per_line = -1,
elements_names = NULL,
tuples = False,
indexer_name = NULL,
associated_column_name = NULL,
associated_column_version = -1,
@ -326,6 +327,13 @@ cdef class Column(OBIWrapper) :
raise OBIDeactivatedInstanceError()
return self.pointer().header.lines_used
# tuples property getter
@property
def tuples(self):
if not self.active() :
raise OBIDeactivatedInstanceError()
return self.pointer().header.tuples
# comments property getter
@property
def comments(self):
@ -436,6 +444,7 @@ cdef class Column_line :
cdef register_column_class(obitype_t obitype,
bint multi_elts,
bint tuples,
type obiclass,
type python_type):
'''
@ -446,7 +455,7 @@ cdef register_column_class(obitype_t obitype,
assert issubclass(obiclass, Column)
__OBIDMS_COLUMN_CLASS__[(obitype, multi_elts)] = (obiclass, python_type)
__OBIDMS_COLUMN_CLASS__[(obitype, multi_elts, tuples)] = (obiclass, python_type)
cdef register_all_column_classes() :