MCPcopy Create free account
hub / github.com/apache/arrow / Visit

Method Visit

python/pyarrow/src/arrow/python/inference.cc:423–494  ·  view source on GitHub ↗

\param[in] obj a Python object in the sequence \param[out] keep_going if sufficient information has been gathered to attempt to begin converting the sequence, *keep_going will be set to true to signal to the calling visitor loop to terminate

Source from the content-addressed store, hash-verified

421 /// attempt to begin converting the sequence, *keep_going will be set to true
422 /// to signal to the calling visitor loop to terminate
423 Status Visit(PyObject* obj, bool* keep_going) {
424 ++total_count_;
425
426 if (obj == Py_None || (pandas_null_sentinels_ && internal::PandasObjectIsNull(obj))) {
427 ++none_count_;
428 } else if (PyBool_Check(obj)) {
429 ++bool_count_;
430 *keep_going = make_unions_;
431 } else if (PyFloat_Check(obj)) {
432 ++float_count_;
433 *keep_going = make_unions_;
434 } else if (internal::IsPyInteger(obj)) {
435 ++int_count_;
436 } else if (PyDateTime_Check(obj)) {
437 // infer timezone from the first encountered datetime object
438 if (!timestamp_micro_count_) {
439 OwnedRef tzinfo(PyObject_GetAttrString(obj, "tzinfo"));
440 if (tzinfo.obj() != nullptr && tzinfo.obj() != Py_None) {
441 ARROW_ASSIGN_OR_RAISE(timezone_, internal::TzinfoToString(tzinfo.obj()));
442 }
443 }
444 ++timestamp_micro_count_;
445 *keep_going = make_unions_;
446 } else if (PyDelta_Check(obj)) {
447 ++duration_count_;
448 *keep_going = make_unions_;
449 } else if (PyDate_Check(obj)) {
450 ++date_count_;
451 *keep_going = make_unions_;
452 } else if (PyTime_Check(obj)) {
453 ++time_count_;
454 *keep_going = make_unions_;
455 } else if (internal::IsPyBinary(obj)) {
456 ++binary_count_;
457 *keep_going = make_unions_;
458 } else if (PyUnicode_Check(obj)) {
459 ++unicode_count_;
460 *keep_going = make_unions_;
461 } else if (arrow::py::is_scalar(obj)) {
462 RETURN_NOT_OK(VisitArrowScalar(obj, keep_going));
463 } else if (has_numpy() && PyArray_CheckAnyScalarExact(obj)) {
464 RETURN_NOT_OK(VisitDType(PyArray_DescrFromScalar(obj), keep_going));
465 } else if (PySet_Check(obj) || (Py_TYPE(obj) == &PyDictValues_Type)) {
466 RETURN_NOT_OK(VisitSet(obj, keep_going));
467 } else if (has_numpy() && PyArray_Check(obj)) {
468 RETURN_NOT_OK(VisitNdarray(obj, keep_going));
469 } else if (PyDict_Check(obj)) {
470 RETURN_NOT_OK(VisitDict(obj));
471 } else if (PyList_Check(obj) ||
472 (PyTuple_Check(obj) &&
473 !PyObject_IsInstance(obj, PyTuple_GetItem(interval_types_.obj(), 0)))) {
474 RETURN_NOT_OK(VisitList(obj, keep_going));
475 } else if (PyObject_IsInstance(obj, decimal_type_.obj())) {
476 RETURN_NOT_OK(max_decimal_metadata_.Update(obj));
477 ++decimal_count_;
478 } else if (PyObject_IsInstance(obj, interval_types_.obj())) {
479 ++interval_count_;
480 } else if (internal::IsPyUuid(obj)) {

Callers 1

VisitDictMethod · 0.45

Calls 12

IsPyIntegerFunction · 0.85
TzinfoToStringFunction · 0.85
IsPyBinaryFunction · 0.85
is_scalarFunction · 0.85
has_numpyFunction · 0.85
IsPyUuidFunction · 0.85
InvalidValueFunction · 0.85
ValidateFunction · 0.85
PandasObjectIsNullFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.50
OKFunction · 0.50
UpdateMethod · 0.45

Tested by

no test coverage detected