↰ Return to documentation for file (morpheus/_lib/src/objects/python_data_table.cpp
)
#include "morpheus/objects/python_data_table.hpp"
#include "morpheus/objects/table_info.hpp"
#include "morpheus/utilities/cudf_util.hpp"
#include <cudf/types.hpp>
#include <pybind11/cast.h>// for object::cast
#include <pybind11/gil.h>
#include <pybind11/pybind11.h>
#include <utility>
namespace morpheus {
/****** Component public implementations *******************/
/****** PyDataTable****************************************/
PyDataTable::PyDataTable(pybind11::object &&py_table) : m_py_table(std::move(py_table)) {}
PyDataTable::~PyDataTable()
{
if (m_py_table)
{
pybind11::gil_scoped_acquire gil;
// Clear out the python object
m_py_table = pybind11::object();
}
}
cudf::size_type PyDataTable::count() const
{
pybind11::gil_scoped_acquire gil;
return m_py_table.attr("_num_rows").cast<cudf::size_type>();
}
TableInfo PyDataTable::get_info() const
{
pybind11::gil_scoped_acquire gil;
// auto info = proxy_table_info_from_table((PyTable *) m_py_table.ptr(), this->shared_from_this());
auto info = proxy_table_info_from_table(m_py_table, this->shared_from_this());
return info;
}
const pybind11::object &PyDataTable::get_py_object() const
{
return m_py_table;
}
} // namespace morpheus