|
12 | 12 | #include <velox/common/memory/Memory.h> |
13 | 13 | #include <velox/type/Type.h> |
14 | 14 | #include <velox/vector/TypeAliases.h> |
15 | | -#include <iostream> |
16 | 15 | #include <memory> |
17 | 16 |
|
18 | 17 | #include "bindings.h" |
|
23 | 22 | #include "velox/buffer/StringViewBufferHolder.h" |
24 | 23 | #include "velox/common/base/Exceptions.h" |
25 | 24 | #include "velox/functions/prestosql/registration/RegistrationFunctions.h" |
26 | | -#include "velox/type/Type.h" |
27 | | -#include "velox/vector/TypeAliases.h" |
28 | 25 | #include "velox/vector/arrow/Abi.h" |
29 | 26 | #include "velox/vector/arrow/Bridge.h" |
| 27 | +#include "pyvelox/pyvelox.h" |
| 28 | +#include <iostream> |
30 | 29 |
|
31 | 30 | #ifdef USE_TORCH |
32 | 31 | #include <torch/csrc/utils/pybind.h> // @manual |
@@ -136,12 +135,6 @@ py::class_<SimpleColumn<T>, BaseColumn> declareSimpleType( |
136 | 135 | }); |
137 | 136 |
|
138 | 137 | using I = typename velox::TypeTraits<kind>::ImplType; |
139 | | - py::class_<I, velox::Type, std::shared_ptr<I>>( |
140 | | - m, |
141 | | - (std::string("VeloxType_") + velox::TypeTraits<kind>::name).c_str(), |
142 | | - // TODO: Move the Koksi binding of Velox type to OSS |
143 | | - py::module_local()) |
144 | | - .def(py::init()); |
145 | 138 |
|
146 | 139 | // Empty Column |
147 | 140 | m.def("Column", [](std::shared_ptr<I> type) { |
@@ -681,23 +674,12 @@ void declareArrayType(py::module& m) { |
681 | 674 | .def("withElements", &ArrayColumn::withElements); |
682 | 675 |
|
683 | 676 | using I = typename velox::TypeTraits<velox::TypeKind::ARRAY>::ImplType; |
684 | | - py::class_<I, velox::Type, std::shared_ptr<I>>( |
685 | | - m, |
686 | | - "VeloxArrayType", |
687 | | - // TODO: Move the Koksi binding of Velox type to OSS |
688 | | - py::module_local()) |
689 | | - .def(py::init<velox::TypePtr>()) |
690 | | - .def("element_type", &velox::ArrayType::elementType); |
691 | | - |
692 | | - using J = typename velox::FixedSizeArrayType; |
693 | | - py::class_<J, velox::Type, std::shared_ptr<J>>( |
694 | | - m, "VeloxFixedArrayType", py::module_local()) |
695 | | - .def(py::init<int, velox::TypePtr>()) |
696 | | - .def("element_type", &velox::FixedSizeArrayType::elementType) |
697 | | - .def("fixed_width", &velox::FixedSizeArrayType::fixedElementsWidth); |
| 677 | + |
| 678 | + using J = typename velox::FixedSizeArrayType; |
698 | 679 |
|
699 | 680 | // Empty Column |
700 | 681 | m.def("Column", [](std::shared_ptr<I> type) { |
| 682 | + std::cout<<"In array column..\n"; |
701 | 683 | return std::make_unique<ArrayColumn>(type); |
702 | 684 | }); |
703 | 685 | m.def("Column", [](std::shared_ptr<J> type) { |
@@ -737,14 +719,6 @@ void declareMapType(py::module& m) { |
737 | 719 | .def("slice", &MapColumn::slice); |
738 | 720 |
|
739 | 721 | using I = typename velox::TypeTraits<velox::TypeKind::MAP>::ImplType; |
740 | | - py::class_<I, velox::Type, std::shared_ptr<I>>( |
741 | | - m, |
742 | | - "VeloxMapType", |
743 | | - // TODO: Move the Koksi binding of Velox type to OSS |
744 | | - py::module_local()) |
745 | | - .def(py::init<velox::TypePtr, velox::TypePtr>()) |
746 | | - .def("key_type", &velox::MapType::keyType) |
747 | | - .def("value_type", &velox::MapType::valueType); |
748 | 722 |
|
749 | 723 | m.def("Column", [](std::shared_ptr<I> type) { |
750 | 724 | return std::make_unique<MapColumn>(type); |
@@ -772,19 +746,6 @@ void declareRowType(py::module& m) { |
772 | 746 | }); |
773 | 747 |
|
774 | 748 | using I = typename velox::TypeTraits<velox::TypeKind::ROW>::ImplType; |
775 | | - py::class_<I, velox::Type, std::shared_ptr<I>>( |
776 | | - m, |
777 | | - "VeloxRowType", |
778 | | - // TODO: Move the Koksi binding of Velox type to OSS |
779 | | - py::module_local()) |
780 | | - .def(py::init< |
781 | | - std::vector<std::string>&&, |
782 | | - std::vector<std::shared_ptr<const velox::Type>>&&>()) |
783 | | - .def("size", &I::size) |
784 | | - .def("get_child_idx", &I::getChildIdx) |
785 | | - .def("contains_child", &I::containsChild) |
786 | | - .def("name_of", &I::nameOf) |
787 | | - .def("child_at", &I::childAt); |
788 | 749 | m.def("Column", [](std::shared_ptr<I> type) { |
789 | 750 | return std::make_unique<RowColumn>(type); |
790 | 751 | }); |
@@ -833,33 +794,8 @@ PYBIND11_MODULE(_torcharrow, m) { |
833 | 794 | .def_property_readonly("length", &BaseColumn::getLength) |
834 | 795 | .def("__len__", &BaseColumn::getLength); |
835 | 796 |
|
836 | | - py::enum_<velox::TypeKind>( |
837 | | - m, |
838 | | - "TypeKind", // TODO: Move the Koksi binding of Velox type to OSS |
839 | | - py::module_local()) |
840 | | - .value("BOOLEAN", velox::TypeKind::BOOLEAN) |
841 | | - .value("TINYINT", velox::TypeKind::TINYINT) |
842 | | - .value("SMALLINT", velox::TypeKind::SMALLINT) |
843 | | - .value("INTEGER", velox::TypeKind::INTEGER) |
844 | | - .value("BIGINT", velox::TypeKind::BIGINT) |
845 | | - .value("REAL", velox::TypeKind::REAL) |
846 | | - .value("DOUBLE", velox::TypeKind::DOUBLE) |
847 | | - .value("VARCHAR", velox::TypeKind::VARCHAR) |
848 | | - .value("VARBINARY", velox::TypeKind::VARBINARY) |
849 | | - .value("TIMESTAMP", velox::TypeKind::TIMESTAMP) |
850 | | - .value("ARRAY", velox::TypeKind::ARRAY) |
851 | | - .value("MAP", velox::TypeKind::MAP) |
852 | | - .value("ROW", velox::TypeKind::ROW) |
853 | | - .export_values(); |
854 | | - |
855 | | - py::class_<velox::Type, std::shared_ptr<velox::Type>>( |
856 | | - m, |
857 | | - "VeloxType", |
858 | | - // TODO: Move the Koksi binding of Velox type to OSS |
859 | | - py::module_local()) |
860 | | - .def("kind", &velox::Type::kind) |
861 | | - .def("kind_name", &velox::Type::kindName); |
862 | 797 |
|
| 798 | + pyvelox::addVeloxBindings(m); |
863 | 799 | declareIntegralType<velox::TypeKind::BIGINT>(m); |
864 | 800 | declareIntegralType<velox::TypeKind::INTEGER>(m); |
865 | 801 | declareIntegralType<velox::TypeKind::SMALLINT>(m); |
|
0 commit comments