MCPcopy Create free account
hub / github.com/TileDB-Inc/TileDB / export_

Method export_

tiledb/sm/cpp_api/arrow_io_impl.h:809–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

807}
808
809void ArrowExporter::export_(
810 const std::string& name, ArrowArray* array, ArrowSchema* schema) {
811 auto bufferinfo = this->buffer_info(name);
812
813 if (schema == nullptr || array == nullptr) {
814 throw tiledb::TileDBError(
815 "ArrowExporter: received invalid pointer to output array or schema.");
816 }
817
818 auto arrow_fmt = tiledb_buffer_arrow_fmt(bufferinfo);
819 auto arrow_flags = flags_for_buffer(bufferinfo);
820
821 // lifetime:
822 // - address is stored in ArrowSchema.private_data
823 // - delete is called by lambda stored in ArrowSchema.release
824 CPPArrowSchema* cpp_schema = new CPPArrowSchema(
825 name, arrow_fmt.fmt_, std::nullopt, arrow_flags, {}, {});
826
827 std::vector<void*> buffers;
828 if (bufferinfo.is_var) {
829 buffers = {nullptr, bufferinfo.offsets, bufferinfo.data};
830 } else {
831 buffers = {nullptr, bufferinfo.data};
832 }
833 cpp_schema->export_ptr(schema);
834
835 int64_t null_num = 0;
836 if (bufferinfo.is_nullable) {
837 null_num = bytemap_to_bitmap(bufferinfo.validity, bufferinfo.data_num);
838 buffers[0] = bufferinfo.validity;
839 }
840
841 size_t elem_num = 0;
842 if (bufferinfo.is_var) {
843 // adjust for offset unless empty result
844 elem_num = (bufferinfo.data_num == 0) ? 0 : bufferinfo.offsets_num - 1;
845 } else {
846 elem_num = bufferinfo.data_num;
847 }
848
849 auto cpp_arrow_array = new CPPArrowArray(
850 elem_num, // elem_num
851 null_num, // null_num
852 0, // offset
853 {}, // children
854 buffers);
855 cpp_arrow_array->export_ptr(array);
856}
857
858/* End TileDB Arrow IO internal implementation */
859/* ************************************************************************ */

Callers 2

export_bufferMethod · 0.80

Calls 6

buffer_infoMethod · 0.95
TileDBErrorClass · 0.85
tiledb_buffer_arrow_fmtFunction · 0.85
flags_for_bufferFunction · 0.85
bytemap_to_bitmapFunction · 0.85
export_ptrMethod · 0.45

Tested by

no test coverage detected