Skip to content

Commit 4dd92ab

Browse files
Internal change: refactoring of Arrow schema handling.
1 parent 331a33b commit 4dd92ab

File tree

10 files changed

+463
-408
lines changed

10 files changed

+463
-408
lines changed

src/oracledb/arrow_impl.pxd

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ cdef extern from "nanoarrow.h":
8686
NANOARROW_TIME_UNIT_MICRO
8787
NANOARROW_TIME_UNIT_NANO
8888

89+
cdef class ArrowSchemaImpl:
8990

90-
cdef class ArrowArrayImpl:
9191
cdef:
9292
int32_t precision
9393
int32_t scale
@@ -96,17 +96,28 @@ cdef class ArrowArrayImpl:
9696
ArrowType arrow_type
9797
ArrowTimeUnit time_unit
9898
int time_factor
99-
ArrowArray *arrow_array
10099
ArrowSchema *arrow_schema
101100
ArrowType child_arrow_type
102101
int child_element_size
103102

103+
cdef bint _is_sparse_vector(self) except*
104+
cdef int _set_child_arrow_type(self, ArrowType child_arrow_type) except -1
105+
cdef int _set_time_unit(self, ArrowTimeUnit time_unit) except -1
106+
cdef int populate_from_schema(self, ArrowSchema* schema) except -1
107+
cdef int populate_from_metadata(self, ArrowType arrow_type, str name,
108+
int8_t precision, int8_t scale,
109+
ArrowTimeUnit time_unit,
110+
ArrowType child_arrow_type) except -1
111+
112+
113+
cdef class ArrowArrayImpl:
114+
cdef:
115+
ArrowArray *arrow_array
116+
ArrowSchemaImpl schema_impl
117+
104118
cdef int _get_is_null(self, int64_t index, bint* is_null) except -1
105119
cdef int _get_list_info(self, int64_t index, ArrowArray* arrow_array,
106120
int64_t* offset, int64_t* num_elements) except -1
107-
cdef bint _is_sparse_vector(self) except *
108-
cdef int _set_child_arrow_type(self, ArrowType child_arrow_type) except -1
109-
cdef int _set_time_unit(self, ArrowTimeUnit time_unit) except -1
110121
cdef int append_bytes(self, void* ptr, int64_t num_bytes) except -1
111122
cdef int append_decimal(self, void* ptr, int64_t num_bytes) except -1
112123
cdef int append_double(self, double value) except -1
@@ -135,10 +146,7 @@ cdef class ArrowArrayImpl:
135146
cdef object get_vector(self, int64_t index, bint* is_null)
136147
cdef int populate_from_array(self, ArrowSchema* schema,
137148
ArrowArray* array) except -1
138-
cdef int populate_from_metadata(self, ArrowType arrow_type, str name,
139-
int8_t precision, int8_t scale,
140-
ArrowTimeUnit time_unit,
141-
ArrowType child_arrow_type) except -1
149+
cdef int populate_from_schema(self, ArrowSchemaImpl schema_impl) except -1
142150

143151

144152
cdef class DataFrameImpl:

src/oracledb/arrow_impl.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ else:
5252
uint32_template = array.array("L")
5353

5454
include "impl/arrow/utils.pyx"
55+
include "impl/arrow/schema.pyx"
5556
include "impl/arrow/array.pyx"
5657
include "impl/arrow/dataframe.pyx"

src/oracledb/base_impl.pxd

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ from .arrow_impl cimport (
4343
ArrowTimeUnit,
4444
ArrowType,
4545
ArrowArrayImpl,
46+
ArrowSchemaImpl
4647
)
4748

4849
cdef enum:
@@ -444,14 +445,14 @@ cdef class OracleMetadata:
444445
readonly uint32_t vector_dimensions
445446
readonly uint8_t vector_format
446447
readonly uint8_t vector_flags
447-
ArrowType _arrow_type
448+
ArrowSchemaImpl _schema_impl
448449
uint8_t _py_type_num
449450

450451
cdef int _finalize_init(self) except -1
451-
cdef int _set_arrow_type(self) except -1
452+
cdef int _set_arrow_schema(self) except -1
452453
cdef OracleMetadata copy(self)
453454
@staticmethod
454-
cdef OracleMetadata from_arrow_array(ArrowArrayImpl array)
455+
cdef OracleMetadata from_arrow_schema(ArrowSchemaImpl schema_impl)
455456
@staticmethod
456457
cdef OracleMetadata from_type(object typ)
457458
@staticmethod
@@ -750,8 +751,6 @@ cdef class BaseVarImpl:
750751
cdef object _get_scalar_value(self, uint32_t pos)
751752
cdef int _on_reset_bind(self, uint32_t num_rows) except -1
752753
cdef int _resize(self, uint32_t new_size) except -1
753-
cdef int _set_metadata_from_arrow_array(self,
754-
ArrowArrayImpl array) except -1
755754
cdef int _set_metadata_from_type(self, object typ) except -1
756755
cdef int _set_metadata_from_value(self, object value,
757756
bint is_plsql) except -1
@@ -986,12 +985,12 @@ cdef struct OracleData:
986985

987986
cdef object convert_arrow_to_oracle_data(OracleMetadata metadata,
988987
OracleData* data,
989-
ArrowArrayImpl arrow_array,
988+
ArrowArrayImpl array_impl,
990989
ssize_t array_index)
991990
cdef int convert_oracle_data_to_arrow(OracleMetadata from_metadata,
992991
OracleMetadata to_metadatda,
993992
OracleData* data,
994-
ArrowArrayImpl arrow_array) except -1
993+
ArrowArrayImpl array_impl) except -1
995994
cdef object convert_oracle_data_to_python(OracleMetadata from_metadata,
996995
OracleMetadata to_metadatda,
997996
OracleData* data,
@@ -1000,7 +999,7 @@ cdef object convert_oracle_data_to_python(OracleMetadata from_metadata,
1000999
cdef object convert_python_to_oracle_data(OracleMetadata metadata,
10011000
OracleData* data,
10021001
object value)
1003-
cdef int convert_vector_to_arrow(ArrowArrayImpl arrow_array,
1002+
cdef int convert_vector_to_arrow(ArrowArrayImpl array_impl,
10041003
object vector) except -1
10051004
cdef cydatetime.datetime convert_date_to_python(OracleDataBuffer *buffer)
10061005
cdef uint16_t decode_uint16be(const char_type *buf)

0 commit comments

Comments
 (0)