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

Function UnboxIntegerAsInt64

python/pyarrow/src/arrow/python/helpers.cc:445–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445Status UnboxIntegerAsInt64(PyObject* obj, int64_t* out) {
446 if (PyLong_Check(obj)) {
447 int overflow = 0;
448 *out = PyLong_AsLongLongAndOverflow(obj, &overflow);
449 if (overflow) {
450 return Status::Invalid("PyLong is too large to fit int64");
451 }
452 } else if (PyArray_IsScalar(obj, Byte)) {
453 *out = reinterpret_cast<PyByteScalarObject*>(obj)->obval;
454 } else if (PyArray_IsScalar(obj, UByte)) {
455 *out = reinterpret_cast<PyUByteScalarObject*>(obj)->obval;
456 } else if (PyArray_IsScalar(obj, Short)) {
457 *out = reinterpret_cast<PyShortScalarObject*>(obj)->obval;
458 } else if (PyArray_IsScalar(obj, UShort)) {
459 *out = reinterpret_cast<PyUShortScalarObject*>(obj)->obval;
460 } else if (PyArray_IsScalar(obj, Int)) {
461 *out = reinterpret_cast<PyIntScalarObject*>(obj)->obval;
462 } else if (PyArray_IsScalar(obj, UInt)) {
463 *out = reinterpret_cast<PyUIntScalarObject*>(obj)->obval;
464 } else if (PyArray_IsScalar(obj, Long)) {
465 *out = reinterpret_cast<PyLongScalarObject*>(obj)->obval;
466 } else if (PyArray_IsScalar(obj, ULong)) {
467 *out = reinterpret_cast<PyULongScalarObject*>(obj)->obval;
468 } else if (PyArray_IsScalar(obj, LongLong)) {
469 *out = reinterpret_cast<PyLongLongScalarObject*>(obj)->obval;
470 } else if (PyArray_IsScalar(obj, Int64)) {
471 *out = reinterpret_cast<PyInt64ScalarObject*>(obj)->obval;
472 } else if (PyArray_IsScalar(obj, ULongLong)) {
473 *out = reinterpret_cast<PyULongLongScalarObject*>(obj)->obval;
474 } else if (PyArray_IsScalar(obj, UInt64)) {
475 *out = reinterpret_cast<PyUInt64ScalarObject*>(obj)->obval;
476 } else {
477 return Status::Invalid("Integer scalar type not recognized");
478 }
479 return Status::OK();
480}
481
482Status IntegerScalarToDoubleSafe(PyObject* obj, double* out) {
483 int64_t value = 0;

Callers 2

Calls 2

InvalidFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected