├── .github └── pull_request_template.md ├── .gitignore ├── CMakeLists.txt ├── Jenkinsfile ├── LICENSE ├── NOTICE ├── README.md ├── RELEASE_NOTES ├── ReadMe_Build.txt ├── Release_Review_HOWTO.txt ├── cmake ├── CodeCoverage.cmake ├── LinuxUtils.cmake ├── OSXUtils.cmake ├── Options.cmake ├── TestIfNoUTF8BOM.py ├── UseLATEX.cmake └── Utils.cmake ├── configure ├── deploy ├── CMakeLists.txt ├── DEB │ ├── CMakeLists.txt │ ├── config │ ├── postinst │ ├── postrm │ ├── preinst │ └── templates ├── PGXN │ ├── CMakeLists.txt │ ├── META.json.in │ ├── ReadMe.txt │ ├── generate_package.sh.in │ └── zipignore.in ├── PackageMaker │ ├── CMakeLists.txt │ └── Welcome.html ├── RPM │ └── CMakeLists.txt ├── description.txt ├── gppkg │ ├── CMakeLists.txt │ ├── gppkg_spec.yml.in │ └── madlib.spec.in ├── madlib.spec.in ├── postflight.sh ├── preflight.sh ├── rpm_post.sh └── rpm_post_uninstall.sh ├── doc ├── .gitignore ├── CMakeLists.txt ├── bin │ ├── .gitignore │ ├── CMakeLists.txt │ ├── sql_filter.sh.in │ └── update_mathjax.sh.in ├── design │ ├── CMakeLists.txt │ ├── design.tex │ ├── figures │ │ ├── 2d_kdtree.pdf │ │ ├── basics_decision_tree.pdf │ │ ├── class_diagram-1.pdf │ │ ├── class_diagram.mp │ │ ├── decision_tree_linear_model.pdf │ │ ├── graph_example.pdf │ │ ├── hits_example.pdf │ │ ├── impurity_measures.pdf │ │ ├── lanczos_bidiag_segment.pdf │ │ ├── pagerank_example.pdf │ │ ├── svd_figure.pdf │ │ └── wcc_example.pdf │ ├── modules │ │ ├── ARIMA.tex │ │ ├── SVM.tex │ │ ├── convex-programming.tex │ │ ├── cox-proportional-hazards.tex │ │ ├── crf.tex │ │ ├── decision-trees.tex │ │ ├── glm.tex │ │ ├── graph.tex │ │ ├── k-means.tex │ │ ├── knn.tex │ │ ├── lda.tex │ │ ├── linear-systems.tex │ │ ├── low-rank-matrix-decomposition.tex │ │ ├── matrix-operations.tex │ │ ├── neural-network.tex │ │ ├── random-forests.tex │ │ ├── regression.tex │ │ ├── sampling.tex │ │ ├── sandwich-estimators.tex │ │ └── svd.tex │ └── other-chapters │ │ └── abstraction-layers.tex ├── etc │ ├── CMakeLists.txt │ ├── DoxygenLayout.xml │ ├── SQLCommon.m4_in │ ├── developer.doxyfile.in │ ├── header.html │ ├── madlib_extra.css │ └── user.doxyfile.in ├── example │ ├── madlib_pagerank_example.sql │ ├── madlib_wcc_example.sql │ └── madlib_xgboost_example.sql ├── imgs │ ├── agile-icon.png │ ├── architecture.png │ ├── deep-icon.png │ ├── madlib.png │ └── magnetic-icon.png ├── literature.bib ├── mainpage.dox.in └── src │ ├── sql.ll │ └── sql.yy ├── examples ├── README ├── datagen │ └── README ├── gpce │ ├── kmeans.sql │ ├── logistic-regress.sql │ ├── multi-lin-regress.sql │ ├── naive-bayes.sql │ ├── sketches.sql │ └── svm.sql ├── hello_world │ ├── iterative │ │ ├── simple_logistic.cpp │ │ ├── simple_logistic.hpp │ │ ├── simple_logistic.py_in │ │ └── simple_logistic.sql_in │ └── non-iterative │ │ ├── avg_var.cpp │ │ ├── avg_var.hpp │ │ └── avg_var.sql_in └── scenarios │ └── README ├── licenses ├── MADlib.txt └── third_party │ ├── Boost_Software_License_v1.txt │ ├── Eigen_v3.1.2.txt │ ├── PyXB_v1.2.6.txt │ ├── PyYAML_v3.10.txt │ ├── Python_License_v2.7.1.txt │ ├── UseLATEX_v1.9.4.txt │ ├── _M_widen_init.txt │ ├── argparse_v1.2.1.txt │ └── libstemmer_porter2.txt ├── methods ├── array_ops │ └── src │ │ └── pg_gp │ │ ├── array_ops.c │ │ ├── array_ops.sql_in │ │ └── test │ │ ├── array_ops.ic.sql_in │ │ └── array_ops.sql_in ├── kmeans │ └── src │ │ └── pg_gp │ │ └── kmeans.c ├── sketch │ └── src │ │ └── pg_gp │ │ ├── __init__.py_in │ │ ├── countmin.c │ │ ├── countmin.h │ │ ├── countmin.py_in │ │ ├── fm.c │ │ ├── mfvsketch.c │ │ ├── sketch.sql_in │ │ ├── sketch_support.c │ │ ├── sketch_support.h │ │ ├── sortasort.c │ │ ├── sortasort.h │ │ ├── sql │ │ ├── cm.sql_in │ │ ├── fm.sql_in │ │ ├── mfv.sql_in │ │ └── support.sql_in │ │ └── uncrustify.cfg ├── stemmer │ └── src │ │ └── pg_gp │ │ ├── porter_stemmer.c │ │ ├── porter_stemmer.sql_in │ │ └── test │ │ ├── porter_stemmer.ic.sql_in │ │ └── porter_stemmer.sql_in ├── svec │ └── src │ │ └── pg_gp │ │ ├── SparseData.c │ │ ├── SparseData.h │ │ ├── float_specials.h │ │ ├── operators.c │ │ ├── sparse_vector.c │ │ ├── sparse_vector.h │ │ └── svec.sql_in ├── svec_util │ └── src │ │ └── pg_gp │ │ ├── __init__.py_in │ │ ├── generate_svec.c │ │ ├── generate_svec.py_in │ │ ├── gp_sfv.c │ │ ├── sql │ │ ├── gp_sfv.sql_in.todo.sql │ │ ├── gp_sfv_sort_order.sql_in │ │ └── svec_test.sql_in │ │ ├── svec_util.c │ │ ├── svec_util.h │ │ └── svec_util.sql_in └── utils │ └── src │ └── pg_gp │ ├── exec_sql_using.c │ ├── noop.c │ └── to_char.c ├── pom.xml ├── src ├── .gitignore ├── CMakeLists.txt ├── bin │ ├── CMakeLists.txt │ └── madpack ├── config │ ├── CMakeLists.txt │ ├── Modules.yml │ ├── Ports.yml │ └── Version.yml ├── dbal │ ├── BoostIntegration │ │ ├── Assertions_impl.hpp │ │ ├── BoostIntegration.hpp │ │ └── MathToolkit_impl.hpp │ ├── ByteStreamHandleBuf_impl.hpp │ ├── ByteStreamHandleBuf_proto.hpp │ ├── ByteStream_impl.hpp │ ├── ByteStream_proto.hpp │ ├── DynamicStruct_impl.hpp │ ├── DynamicStruct_proto.hpp │ ├── EigenIntegration │ │ ├── EigenIntegration.hpp │ │ ├── EigenPlugin.hpp │ │ ├── HandleMap_impl.hpp │ │ ├── HandleMap_proto.hpp │ │ ├── SymmetricPositiveDefiniteEigenDecomposition_impl.hpp │ │ └── SymmetricPositiveDefiniteEigenDecomposition_proto.hpp │ ├── Exceptions │ │ └── NoSolutionFoundException_proto.hpp │ ├── OutputStreamBufferBase_impl.hpp │ ├── OutputStreamBufferBase_proto.hpp │ ├── Reference_impl.hpp │ ├── Reference_proto.hpp │ ├── dbal_impl.hpp │ └── dbal_proto.hpp ├── library.ver ├── libstemmer │ ├── include │ │ └── libstemmer.h │ ├── libstemmer │ │ ├── libstemmer.c │ │ ├── modules.h │ │ └── modules.txt │ ├── mkinc.mak │ ├── runtime │ │ ├── api.c │ │ ├── api.h │ │ ├── header.h │ │ └── utilities.c │ └── src_c │ │ ├── stem_ISO_8859_1_danish.c │ │ ├── stem_ISO_8859_1_danish.h │ │ ├── stem_ISO_8859_1_dutch.c │ │ ├── stem_ISO_8859_1_dutch.h │ │ ├── stem_ISO_8859_1_english.c │ │ ├── stem_ISO_8859_1_english.h │ │ ├── stem_ISO_8859_1_finnish.c │ │ ├── stem_ISO_8859_1_finnish.h │ │ ├── stem_ISO_8859_1_french.c │ │ ├── stem_ISO_8859_1_french.h │ │ ├── stem_ISO_8859_1_german.c │ │ ├── stem_ISO_8859_1_german.h │ │ ├── stem_ISO_8859_1_italian.c │ │ ├── stem_ISO_8859_1_italian.h │ │ ├── stem_ISO_8859_1_norwegian.c │ │ ├── stem_ISO_8859_1_norwegian.h │ │ ├── stem_ISO_8859_1_porter.c │ │ ├── stem_ISO_8859_1_porter.h │ │ ├── stem_ISO_8859_1_portuguese.c │ │ ├── stem_ISO_8859_1_portuguese.h │ │ ├── stem_ISO_8859_1_spanish.c │ │ ├── stem_ISO_8859_1_spanish.h │ │ ├── stem_ISO_8859_1_swedish.c │ │ ├── stem_ISO_8859_1_swedish.h │ │ ├── stem_ISO_8859_2_hungarian.c │ │ ├── stem_ISO_8859_2_hungarian.h │ │ ├── stem_ISO_8859_2_romanian.c │ │ ├── stem_ISO_8859_2_romanian.h │ │ ├── stem_KOI8_R_russian.c │ │ ├── stem_KOI8_R_russian.h │ │ ├── stem_UTF_8_danish.c │ │ ├── stem_UTF_8_danish.h │ │ ├── stem_UTF_8_dutch.c │ │ ├── stem_UTF_8_dutch.h │ │ ├── stem_UTF_8_english.c │ │ ├── stem_UTF_8_english.h │ │ ├── stem_UTF_8_finnish.c │ │ ├── stem_UTF_8_finnish.h │ │ ├── stem_UTF_8_french.c │ │ ├── stem_UTF_8_french.h │ │ ├── stem_UTF_8_german.c │ │ ├── stem_UTF_8_german.h │ │ ├── stem_UTF_8_hungarian.c │ │ ├── stem_UTF_8_hungarian.h │ │ ├── stem_UTF_8_italian.c │ │ ├── stem_UTF_8_italian.h │ │ ├── stem_UTF_8_norwegian.c │ │ ├── stem_UTF_8_norwegian.h │ │ ├── stem_UTF_8_porter.c │ │ ├── stem_UTF_8_porter.h │ │ ├── stem_UTF_8_portuguese.c │ │ ├── stem_UTF_8_portuguese.h │ │ ├── stem_UTF_8_romanian.c │ │ ├── stem_UTF_8_romanian.h │ │ ├── stem_UTF_8_russian.c │ │ ├── stem_UTF_8_russian.h │ │ ├── stem_UTF_8_spanish.c │ │ ├── stem_UTF_8_spanish.h │ │ ├── stem_UTF_8_swedish.c │ │ ├── stem_UTF_8_swedish.h │ │ ├── stem_UTF_8_turkish.c │ │ └── stem_UTF_8_turkish.h ├── madpack │ ├── CMakeLists.txt │ ├── __init__.py │ ├── argparse.py │ ├── changelist_1.10.0_1.11.yaml │ ├── changelist_1.11_1.12.yaml │ ├── changelist_1.12_1.13.yaml │ ├── changelist_1.13_1.14.yaml │ ├── changelist_1.14_1.15.yaml │ ├── changelist_1.15.1_1.16.yaml │ ├── changelist_1.15_1.15.1.yaml │ ├── changelist_1.16_1.17.0.yaml │ ├── changelist_1.17.0_1.18.0.yaml │ ├── changelist_1.18.0_1.19.0.yaml │ ├── changelist_1.19.0_1.20.0.yaml │ ├── changelist_1.20.0_1.21.0.yaml │ ├── changelist_1.9.1_1.10.0.yaml │ ├── configyml.py │ ├── create_changelist.py │ ├── diff_udf.sql │ ├── diff_udo.sql │ ├── diff_udoc.sql │ ├── diff_udt.sql │ ├── madpack.py │ ├── sort-module.py │ ├── template_changelist.yaml │ ├── upgrade_util.py │ ├── utilities.py │ └── yaml │ │ ├── LICENSE │ │ ├── __init__.py │ │ ├── composer.py │ │ ├── constructor.py │ │ ├── cyaml.py │ │ ├── dumper.py │ │ ├── emitter.py │ │ ├── error.py │ │ ├── events.py │ │ ├── loader.py │ │ ├── nodes.py │ │ ├── parser.py │ │ ├── reader.py │ │ ├── representer.py │ │ ├── resolver.py │ │ ├── scanner.py │ │ ├── serializer.py │ │ └── tokens.py ├── modules │ ├── assoc_rules │ │ ├── assoc_rules.cpp │ │ └── assoc_rules.hpp │ ├── convex │ │ ├── algo │ │ │ ├── gradient.hpp │ │ │ ├── gradient_norm.hpp │ │ │ ├── igd.hpp │ │ │ ├── loss.hpp │ │ │ └── newton.hpp │ │ ├── convex.hpp │ │ ├── linear_svm_igd.cpp │ │ ├── linear_svm_igd.hpp │ │ ├── lmf_igd.cpp │ │ ├── lmf_igd.hpp │ │ ├── mlp_igd.cpp │ │ ├── mlp_igd.hpp │ │ ├── newton.hpp │ │ ├── task │ │ │ ├── l1.hpp │ │ │ ├── l2.hpp │ │ │ ├── linear_svm.hpp │ │ │ ├── lmf.hpp │ │ │ ├── mlp.hpp │ │ │ └── ols.hpp │ │ ├── type │ │ │ ├── dependent_variable.hpp │ │ │ ├── hessian.hpp │ │ │ ├── independent_variables.hpp │ │ │ ├── model.hpp │ │ │ ├── state.hpp │ │ │ └── tuple.hpp │ │ ├── utils_regularization.cpp │ │ └── utils_regularization.hpp │ ├── crf │ │ ├── linear_crf.cpp │ │ ├── linear_crf.hpp │ │ ├── viterbi.cpp │ │ └── viterbi.hpp │ ├── declarations.hpp │ ├── elastic_net │ │ ├── elastic_net.hpp │ │ ├── elastic_net_binomial_fista.cpp │ │ ├── elastic_net_binomial_fista.hpp │ │ ├── elastic_net_binomial_igd.cpp │ │ ├── elastic_net_binomial_igd.hpp │ │ ├── elastic_net_gaussian_fista.cpp │ │ ├── elastic_net_gaussian_fista.hpp │ │ ├── elastic_net_gaussian_igd.cpp │ │ ├── elastic_net_gaussian_igd.hpp │ │ ├── elastic_net_optimizer_fista.hpp │ │ ├── elastic_net_optimizer_igd.hpp │ │ ├── elastic_net_utils.cpp │ │ ├── elastic_net_utils.hpp │ │ ├── share │ │ │ └── shared_utils.hpp │ │ └── state │ │ │ ├── fista.hpp │ │ │ └── igd.hpp │ ├── glm │ │ ├── GLM_impl.hpp │ │ ├── GLM_proto.hpp │ │ ├── MultiResponseGLM_impl.hpp │ │ ├── MultiResponseGLM_proto.hpp │ │ ├── Ordinal_impl.hpp │ │ ├── Ordinal_proto.hpp │ │ ├── family.hpp │ │ ├── glm.cpp │ │ ├── glm.hpp │ │ ├── link.hpp │ │ ├── multi_response_glm.cpp │ │ ├── multi_response_glm.hpp │ │ ├── ordinal.cpp │ │ └── ordinal.hpp │ ├── lda │ │ ├── lda.cpp │ │ └── lda.hpp │ ├── linalg │ │ ├── average.cpp │ │ ├── average.hpp │ │ ├── crossprod.cpp │ │ ├── crossprod.hpp │ │ ├── dim_conversion.cpp │ │ ├── dim_conversion.hpp │ │ ├── linalg.hpp │ │ ├── matrix_agg.cpp │ │ ├── matrix_agg.hpp │ │ ├── matrix_decomp.cpp │ │ ├── matrix_decomp.hpp │ │ ├── matrix_ops.cpp │ │ ├── matrix_ops.hpp │ │ ├── metric.cpp │ │ ├── metric.hpp │ │ ├── svd.cpp │ │ └── svd.hpp │ ├── linear_systems │ │ ├── dense_linear_systems.cpp │ │ ├── dense_linear_systems.hpp │ │ ├── dense_linear_systems_states.hpp │ │ ├── linear_systems.hpp │ │ ├── sparse_linear_systems.cpp │ │ ├── sparse_linear_systems.hpp │ │ └── sparse_linear_systems_states.hpp │ ├── prob │ │ ├── boost.cpp │ │ ├── boost.hpp │ │ ├── kolmogorov.cpp │ │ ├── kolmogorov.hpp │ │ ├── prob.hpp │ │ ├── student.cpp │ │ └── student.hpp │ ├── recursive_partitioning │ │ ├── ConSplits.hpp │ │ ├── DT_impl.hpp │ │ ├── DT_proto.hpp │ │ ├── decision_tree.cpp │ │ ├── decision_tree.hpp │ │ ├── feature_encoding.cpp │ │ ├── feature_encoding.hpp │ │ ├── random_forest.cpp │ │ └── random_forest.hpp │ ├── regress │ │ ├── LinearRegression_impl.hpp │ │ ├── LinearRegression_proto.hpp │ │ ├── clustered_errors.cpp │ │ ├── clustered_errors.hpp │ │ ├── clustered_errors_state.hpp │ │ ├── linear.cpp │ │ ├── linear.hpp │ │ ├── logistic.cpp │ │ ├── logistic.hpp │ │ ├── marginal.cpp │ │ ├── marginal.hpp │ │ ├── mlogr_margins.cpp │ │ ├── mlogr_margins.hpp │ │ ├── multilogistic.cpp │ │ ├── multilogistic.hpp │ │ └── regress.hpp │ ├── sample │ │ ├── WeightedSample_impl.hpp │ │ ├── WeightedSample_proto.hpp │ │ ├── random_process.cpp │ │ ├── random_process.hpp │ │ ├── sample.hpp │ │ ├── weighted_sample.cpp │ │ └── weighted_sample.hpp │ ├── shared │ │ └── HandleTraits.hpp │ ├── stats │ │ ├── CoxPHState.hpp │ │ ├── chi_squared_test.cpp │ │ ├── chi_squared_test.hpp │ │ ├── clustered_variance_coxph.cpp │ │ ├── clustered_variance_coxph.hpp │ │ ├── correlation.cpp │ │ ├── correlation.hpp │ │ ├── cox_prop_hazards.cpp │ │ ├── cox_prop_hazards.hpp │ │ ├── coxph_improved.cpp │ │ ├── coxph_improved.hpp │ │ ├── distribution.cpp │ │ ├── distribution.hpp │ │ ├── kolmogorov_smirnov_test.cpp │ │ ├── kolmogorov_smirnov_test.hpp │ │ ├── mann_whitney_test.cpp │ │ ├── mann_whitney_test.hpp │ │ ├── marginal_cox.cpp │ │ ├── marginal_cox.hpp │ │ ├── one_way_anova.cpp │ │ ├── one_way_anova.hpp │ │ ├── robust_variance_coxph.cpp │ │ ├── robust_variance_coxph.hpp │ │ ├── stats.hpp │ │ ├── t_test.cpp │ │ ├── t_test.hpp │ │ ├── wilcoxon_signed_rank_test.cpp │ │ └── wilcoxon_signed_rank_test.hpp │ ├── tsa │ │ ├── arima.cpp │ │ └── arima.hpp │ └── utilities │ │ ├── path.cpp │ │ ├── path.hpp │ │ └── utilities.hpp ├── patch │ ├── CMakeLists.txt │ └── PyXB.sh ├── ports │ ├── CMakeLists.txt │ ├── greenplum │ │ ├── 5 │ │ │ └── CMakeLists.txt │ │ ├── 6 │ │ │ └── CMakeLists.txt │ │ ├── 4.1 │ │ │ ├── CMakeLists.txt │ │ │ └── patch │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── Versions_4_1_0_to_4_1_1.sh.in │ │ ├── 4.2 │ │ │ └── CMakeLists.txt │ │ ├── 4.3 │ │ │ └── CMakeLists.txt │ │ ├── 4.3ORCA │ │ │ ├── CMakeLists.txt │ │ │ └── config │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── Modules.yml │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ │ ├── FindGreenplum.cmake │ │ │ ├── FindGreenplum_4_0.cmake │ │ │ ├── FindGreenplum_4_1.cmake │ │ │ ├── FindGreenplum_4_2.cmake │ │ │ ├── FindGreenplum_4_3.cmake │ │ │ ├── FindGreenplum_4_3ORCA.cmake │ │ │ ├── FindGreenplum_5.cmake │ │ │ ├── FindGreenplum_6.cmake │ │ │ └── GreenplumUtils.cmake │ │ └── dbconnector │ │ │ ├── Compatibility.hpp │ │ │ └── dbconnector.hpp │ └── postgres │ │ ├── 10 │ │ └── CMakeLists.txt │ │ ├── 11 │ │ └── CMakeLists.txt │ │ ├── 12 │ │ └── CMakeLists.txt │ │ ├── 8.4 │ │ ├── CMakeLists.txt │ │ └── patch │ │ │ ├── CMakeLists.txt │ │ │ └── Versions_8_4_and_below.sh.in │ │ ├── 9.0 │ │ └── CMakeLists.txt │ │ ├── 9.1 │ │ └── CMakeLists.txt │ │ ├── 9.2 │ │ └── CMakeLists.txt │ │ ├── 9.3 │ │ └── CMakeLists.txt │ │ ├── 9.4 │ │ └── CMakeLists.txt │ │ ├── 9.5 │ │ └── CMakeLists.txt │ │ ├── 9.6 │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ ├── FindPostgreSQL.cmake │ │ ├── FindPostgreSQL_10.cmake │ │ ├── FindPostgreSQL_11.cmake │ │ ├── FindPostgreSQL_12.cmake │ │ ├── FindPostgreSQL_8_4.cmake │ │ ├── FindPostgreSQL_9_0.cmake │ │ ├── FindPostgreSQL_9_1.cmake │ │ ├── FindPostgreSQL_9_2.cmake │ │ ├── FindPostgreSQL_9_3.cmake │ │ ├── FindPostgreSQL_9_4.cmake │ │ ├── FindPostgreSQL_9_5.cmake │ │ ├── FindPostgreSQL_9_6.cmake │ │ └── PostgreSQLUtils.cmake │ │ ├── dbconnector │ │ ├── Allocator_impl.hpp │ │ ├── Allocator_proto.hpp │ │ ├── AnyType_impl.hpp │ │ ├── AnyType_proto.hpp │ │ ├── ArrayHandle_impl.hpp │ │ ├── ArrayHandle_proto.hpp │ │ ├── ArrayWithNullException_proto.hpp │ │ ├── Backend.hpp │ │ ├── ByteString_impl.hpp │ │ ├── ByteString_proto.hpp │ │ ├── Compatibility.hpp │ │ ├── EigenIntegration_impl.hpp │ │ ├── EigenIntegration_proto.hpp │ │ ├── FunctionHandle_impl.hpp │ │ ├── FunctionHandle_proto.hpp │ │ ├── NativeRandomNumberGenerator_impl.hpp │ │ ├── NativeRandomNumberGenerator_proto.hpp │ │ ├── NewDelete.cpp │ │ ├── OutputStreamBuffer_impl.hpp │ │ ├── OutputStreamBuffer_proto.hpp │ │ ├── PGException_proto.hpp │ │ ├── SystemInformation_impl.hpp │ │ ├── SystemInformation_proto.hpp │ │ ├── TransparentHandle_impl.hpp │ │ ├── TransparentHandle_proto.hpp │ │ ├── TypeTraits_impl.hpp │ │ ├── TypeTraits_proto.hpp │ │ ├── UDF_impl.hpp │ │ ├── UDF_proto.hpp │ │ ├── dbconnector.hpp │ │ └── main.cpp │ │ ├── extension │ │ ├── madlib.control_in │ │ └── madlib.sql.base_in │ │ ├── madpack │ │ └── SQLCommon.m4_in │ │ └── modules │ │ ├── assoc_rules │ │ ├── __init__.py_in │ │ ├── assoc_rules.py_in │ │ ├── assoc_rules.sql_in │ │ └── test │ │ │ ├── assoc_rules.ic.sql_in │ │ │ └── assoc_rules.sql_in │ │ ├── bayes │ │ ├── __init__.py_in │ │ ├── bayes.py_in │ │ ├── bayes.sql_in │ │ └── test │ │ │ ├── bayes.ic.sql_in │ │ │ ├── bayes.sql_in │ │ │ └── gaussian_naive_bayes.sql_in │ │ ├── conjugate_gradient │ │ ├── conjugate_gradient.sql_in │ │ └── test │ │ │ ├── conj_grad.ic.sql_in │ │ │ └── conj_grad.sql_in │ │ ├── convex │ │ ├── __init__.py_in │ │ ├── lmf.sql_in │ │ ├── lmf_igd.py_in │ │ ├── mlp.sql_in │ │ ├── mlp_igd.py_in │ │ ├── test │ │ │ ├── lmf.ic.sql_in │ │ │ ├── lmf.sql_in │ │ │ ├── mlp.ic.sql_in │ │ │ ├── mlp.sql_in │ │ │ └── unit_tests │ │ │ │ ├── plpy_mock.py_in │ │ │ │ └── test_mlp_igd.py_in │ │ ├── utils_regularization.py_in │ │ └── utils_regularization.sql_in │ │ ├── crf │ │ ├── __init__.py_in │ │ ├── crf.py_in │ │ ├── crf.sql_in │ │ ├── crf_data_loader.sql_in │ │ ├── crf_feature_gen.py_in │ │ ├── crf_feature_gen.sql_in │ │ ├── test │ │ │ ├── crf_test_large.sql_in │ │ │ ├── crf_test_small.ic.sql_in │ │ │ ├── crf_test_small.sql_in │ │ │ ├── crf_train_large.sql_in │ │ │ ├── crf_train_small.ic.sql_in │ │ │ └── crf_train_small.sql_in │ │ ├── viterbi.py_in │ │ └── viterbi.sql_in │ │ ├── dbscan │ │ ├── __init__.py_in │ │ ├── dbscan.py_in │ │ ├── dbscan.sql_in │ │ └── test │ │ │ ├── dbscan.sql_in │ │ │ └── unit_tests │ │ │ ├── plpy_mock.py_in │ │ │ └── test_dbscan.py_in │ │ ├── deep_learning │ │ ├── __init__.py_in │ │ ├── gpu_info_from_tf.py_in │ │ ├── input_data_preprocessor.py_in │ │ ├── input_data_preprocessor.sql_in │ │ ├── keras_model_arch_table.py_in │ │ ├── keras_model_arch_table.sql_in │ │ ├── madlib_keras.py_in │ │ ├── madlib_keras.sql_in │ │ ├── madlib_keras_automl.py_in │ │ ├── madlib_keras_automl.sql_in │ │ ├── madlib_keras_automl_hyperband.py_in │ │ ├── madlib_keras_automl_hyperopt.py_in │ │ ├── madlib_keras_custom_function.py_in │ │ ├── madlib_keras_custom_function.sql_in │ │ ├── madlib_keras_fit_multiple_model.py_in │ │ ├── madlib_keras_fit_multiple_model.sql_in │ │ ├── madlib_keras_gpu_info.py_in │ │ ├── madlib_keras_gpu_info.sql_in │ │ ├── madlib_keras_helper.py_in │ │ ├── madlib_keras_model_selection.py_in │ │ ├── madlib_keras_model_selection.sql_in │ │ ├── madlib_keras_predict.py_in │ │ ├── madlib_keras_serializer.py_in │ │ ├── madlib_keras_validator.py_in │ │ ├── madlib_keras_wrapper.py_in │ │ ├── model_arch_info.py_in │ │ ├── predict_input_params.py_in │ │ └── test │ │ │ ├── input_data_preprocessor.sql_in │ │ │ ├── keras_model_arch_table.ic.sql_in │ │ │ ├── keras_model_arch_table.sql_in │ │ │ ├── madlib_keras_automl.sql_in │ │ │ ├── madlib_keras_cifar.setup.sql_in │ │ │ ├── madlib_keras_custom_function.setup.sql_in │ │ │ ├── madlib_keras_custom_function.sql_in │ │ │ ├── madlib_keras_evaluate.sql_in │ │ │ ├── madlib_keras_fit.sql_in │ │ │ ├── madlib_keras_fit_multiple.sql_in │ │ │ ├── madlib_keras_gpu_info.sql_in │ │ │ ├── madlib_keras_iris.setup.sql_in │ │ │ ├── madlib_keras_model_averaging_e2e.sql_in │ │ │ ├── madlib_keras_model_selection.sql_in │ │ │ ├── madlib_keras_model_selection_e2e.sql_in │ │ │ ├── madlib_keras_multi_io.sql_in │ │ │ ├── madlib_keras_predict.sql_in │ │ │ ├── madlib_keras_predict_byom.sql_in │ │ │ ├── madlib_keras_transfer_learning.sql_in │ │ │ └── unit_tests │ │ │ ├── plpy_mock.py_in │ │ │ ├── test_input_data_preprocessor.py_in │ │ │ ├── test_madlib_keras.py_in │ │ │ ├── test_madlib_keras_automl.py_in │ │ │ ├── test_madlib_keras_gpu_info.py_in │ │ │ └── test_madlib_keras_model_selection_table.py_in │ │ ├── elastic_net │ │ ├── __init__.py_in │ │ ├── elastic_net.py_in │ │ ├── elastic_net.sql_in │ │ ├── elastic_net_generate_result.py_in │ │ ├── elastic_net_models.py_in │ │ ├── elastic_net_optimizer_fista.py_in │ │ ├── elastic_net_optimizer_igd.py_in │ │ ├── elastic_net_utils.py_in │ │ └── test │ │ │ ├── elastic_net.ic.sql_in │ │ │ └── elastic_net.sql_in │ │ ├── glm │ │ ├── __init__.py_in │ │ ├── glm.py_in │ │ ├── glm.sql_in │ │ ├── multinom.py_in │ │ ├── multiresponseglm.sql_in │ │ ├── ordinal.py_in │ │ ├── ordinal.sql_in │ │ └── test │ │ │ ├── binomial.sql_in │ │ │ ├── gamma.sql_in │ │ │ ├── gaussian.sql_in │ │ │ ├── glm.ic.sql_in │ │ │ ├── inverse_gaussian.sql_in │ │ │ ├── multinom.sql_in │ │ │ ├── ordinal.sql_in │ │ │ └── poisson.sql_in │ │ ├── graph │ │ ├── __init__.py_in │ │ ├── apsp.py_in │ │ ├── apsp.sql_in │ │ ├── bfs.py_in │ │ ├── bfs.sql_in │ │ ├── graph_utils.py_in │ │ ├── hits.py_in │ │ ├── hits.sql_in │ │ ├── measures.py_in │ │ ├── measures.sql_in │ │ ├── pagerank.py_in │ │ ├── pagerank.sql_in │ │ ├── sssp.py_in │ │ ├── sssp.sql_in │ │ ├── test │ │ │ ├── apsp.sql_in │ │ │ ├── bfs.sql_in │ │ │ ├── graph.ic.sql_in │ │ │ ├── hits.sql_in │ │ │ ├── measures.sql_in │ │ │ ├── pagerank.sql_in │ │ │ ├── sssp.sql_in │ │ │ └── wcc.sql_in │ │ ├── wcc.py_in │ │ └── wcc.sql_in │ │ ├── internal │ │ ├── __init__.py_in │ │ └── db_utils.py_in │ │ ├── kmeans │ │ ├── __init__.py_in │ │ ├── kmeans.py_in │ │ ├── kmeans.sql_in │ │ ├── kmeans_auto.py_in │ │ └── test │ │ │ ├── kmeans.ic.sql_in │ │ │ ├── kmeans.sql_in │ │ │ └── unit_tests │ │ │ ├── plpy_mock.py_in │ │ │ └── test_kmeans_auto.py_in │ │ ├── knn │ │ ├── __init__.py_in │ │ ├── knn.py_in │ │ ├── knn.sql_in │ │ └── test │ │ │ ├── knn.ic.sql_in │ │ │ └── knn.sql_in │ │ ├── lda │ │ ├── __init__.py_in │ │ ├── lda.py_in │ │ ├── lda.sql_in │ │ └── test │ │ │ ├── lda.ic.sql_in │ │ │ └── lda.sql_in │ │ ├── linalg │ │ ├── __init__.py_in │ │ ├── linalg.sql_in │ │ ├── matrix_help_message.py_in │ │ ├── matrix_ops.py_in │ │ ├── matrix_ops.sql_in │ │ ├── pivotalr_arrayops.sql_in │ │ ├── svd.py_in │ │ ├── svd.sql_in │ │ └── test │ │ │ ├── linalg.ic.sql_in │ │ │ ├── linalg.sql_in │ │ │ ├── matrix_ops.ic.sql_in │ │ │ ├── matrix_ops.sql_in │ │ │ ├── svd.ic.sql_in │ │ │ └── svd.sql_in │ │ ├── linear_systems │ │ ├── __init__.py_in │ │ ├── dense_linear_systems.py_in │ │ ├── dense_linear_systems.sql_in │ │ ├── sparse_linear_systems.py_in │ │ ├── sparse_linear_systems.sql_in │ │ └── test │ │ │ ├── __init__.py_in │ │ │ ├── dense_linear_sytems.ic.sql_in │ │ │ ├── dense_linear_sytems.sql_in │ │ │ ├── sparse_linear_sytems.ic.sql_in │ │ │ └── sparse_linear_sytems.sql_in │ │ ├── mxgboost │ │ ├── __init__.py_in │ │ ├── madlib_xgboost.py_in │ │ ├── madlib_xgboost.sql_in │ │ └── test │ │ │ └── madlib_xgboost.sql_in │ │ ├── pca │ │ ├── __init__.py_in │ │ ├── pca.py_in │ │ ├── pca.sql_in │ │ ├── pca_project.py_in │ │ ├── pca_project.sql_in │ │ └── test │ │ │ ├── pca.ic.sql_in │ │ │ ├── pca.sql_in │ │ │ ├── pca_project.ic.sql_in │ │ │ └── pca_project.sql_in │ │ ├── pmml │ │ ├── __init__.py_in │ │ ├── binding.py_in │ │ ├── formula.py_in │ │ ├── pmml_builder.py_in │ │ ├── table_to_pmml.py_in │ │ ├── table_to_pmml.sql_in │ │ └── test │ │ │ ├── pmml.ic.sql_in │ │ │ ├── pmml_dt.sql_in │ │ │ ├── pmml_glm_binomial.sql_in │ │ │ ├── pmml_glm_gamma.sql_in │ │ │ ├── pmml_glm_ig.sql_in │ │ │ ├── pmml_glm_normal.sql_in │ │ │ ├── pmml_glm_poisson.sql_in │ │ │ ├── pmml_multinom.sql_in │ │ │ ├── pmml_ordinal.sql_in │ │ │ ├── pmml_rf.sql_in │ │ │ └── table_to_pmml.sql_in │ │ ├── prob │ │ ├── prob.sql_in │ │ └── test │ │ │ ├── prob.ic.sql_in │ │ │ └── prob.sql_in │ │ ├── recursive_partitioning │ │ ├── __init__.py_in │ │ ├── decision_tree.py_in │ │ ├── decision_tree.sql_in │ │ ├── random_forest.py_in │ │ ├── random_forest.sql_in │ │ └── test │ │ │ ├── decision_tree.ic.sql_in │ │ │ ├── decision_tree.sql_in │ │ │ ├── random_forest.ic.sql_in │ │ │ ├── random_forest.sql_in │ │ │ └── unit_tests │ │ │ ├── plpy_mock.py_in │ │ │ └── test_random_forest.py_in │ │ ├── regress │ │ ├── __init__.py_in │ │ ├── clustered_variance.py_in │ │ ├── clustered_variance.sql_in │ │ ├── linear.py_in │ │ ├── linear.sql_in │ │ ├── logistic.py_in │ │ ├── logistic.sql_in │ │ ├── marginal.py_in │ │ ├── marginal.sql_in │ │ ├── margins.py_in │ │ ├── margins_builder.py_in │ │ ├── multilogistic.py_in │ │ ├── multilogistic.sql_in │ │ ├── robust.sql_in │ │ ├── robust_linear.py_in │ │ ├── robust_logistic.py_in │ │ ├── robust_mlogistic.py_in │ │ └── test │ │ │ ├── clustered.ic.sql_in │ │ │ ├── clustered.sql_in │ │ │ ├── linear.ic.sql_in │ │ │ ├── linear.sql_in │ │ │ ├── logistic.ic.sql_in │ │ │ ├── logistic.sql_in │ │ │ ├── marginal.ic.sql_in │ │ │ ├── marginal.sql_in │ │ │ ├── multilogistic.ic.sql_in │ │ │ ├── multilogistic.sql_in │ │ │ ├── robust.ic.sql_in │ │ │ └── robust.sql_in │ │ ├── sample │ │ ├── __init__.py_in │ │ ├── balance_sample.py_in │ │ ├── balance_sample.sql_in │ │ ├── sample.sql_in │ │ ├── stratified_sample.py_in │ │ ├── stratified_sample.sql_in │ │ ├── test │ │ │ ├── balance_sample.ic.sql_in │ │ │ ├── balance_sample.sql_in │ │ │ ├── sample.ic.sql_in │ │ │ ├── sample.sql_in │ │ │ ├── stratified_sample.ic.sql_in │ │ │ ├── stratified_sample.sql_in │ │ │ ├── train_test_split.ic.sql_in │ │ │ └── train_test_split.sql_in │ │ ├── train_test_split.py_in │ │ └── train_test_split.sql_in │ │ ├── stats │ │ ├── __init__.py_in │ │ ├── clustered_variance_coxph.py_in │ │ ├── clustered_variance_coxph.sql_in │ │ ├── correlation.py_in │ │ ├── correlation.sql_in │ │ ├── cox_prop_hazards.py_in │ │ ├── cox_prop_hazards.sql_in │ │ ├── distribution.sql_in │ │ ├── hypothesis_tests.sql_in │ │ ├── pred_metrics.py_in │ │ ├── pred_metrics.sql_in │ │ ├── robust_variance_coxph.py_in │ │ ├── robust_variance_coxph.sql_in │ │ └── test │ │ │ ├── anova_test.ic.sql_in │ │ │ ├── anova_test.sql_in │ │ │ ├── chi2_test.ic.sql_in │ │ │ ├── chi2_test.sql_in │ │ │ ├── correlation.ic.sql_in │ │ │ ├── correlation.sql_in │ │ │ ├── cox_prop_hazards.ic.sql_in │ │ │ ├── cox_prop_hazards.sql_in │ │ │ ├── f_test.ic.sql_in │ │ │ ├── f_test.sql_in │ │ │ ├── ks_test.ic.sql_in │ │ │ ├── ks_test.sql_in │ │ │ ├── mw_test.ic.sql_in │ │ │ ├── mw_test.sql_in │ │ │ ├── pred_metrics.ic.sql_in │ │ │ ├── pred_metrics.sql_in │ │ │ ├── robust_and_clustered_variance_coxph.ic.sql_in │ │ │ ├── robust_and_clustered_variance_coxph.sql_in │ │ │ ├── t_test.ic.sql_in │ │ │ ├── t_test.sql_in │ │ │ ├── wsr_test.ic.sql_in │ │ │ └── wsr_test.sql_in │ │ ├── summary │ │ ├── Summarizer.py_in │ │ ├── __init__.py_in │ │ ├── summary.py_in │ │ ├── summary.sql_in │ │ └── test │ │ │ ├── summary.ic.sql_in │ │ │ └── summary.sql_in │ │ ├── svm │ │ ├── __init__.py_in │ │ ├── kernel_approximation.py_in │ │ ├── svm.py_in │ │ ├── svm.sql_in │ │ └── test │ │ │ ├── svm.ic.sql_in │ │ │ └── svm.sql_in │ │ ├── tsa │ │ ├── __init__.py_in │ │ ├── arima.py_in │ │ ├── arima.sql_in │ │ ├── arima_forecast.py_in │ │ └── test │ │ │ ├── arima.ic.sql_in │ │ │ ├── arima.sql_in │ │ │ └── arima_train.sql_in │ │ ├── utilities │ │ ├── __init__.py_in │ │ ├── admin.py_in │ │ ├── cols2vec.sql_in │ │ ├── control.py_in │ │ ├── control_composite.py_in │ │ ├── create_indicators.py_in │ │ ├── create_indicators.sql_in │ │ ├── debug.py_in │ │ ├── encode_categorical.py_in │ │ ├── encode_categorical.sql_in │ │ ├── group_control.py_in │ │ ├── in_mem_group_control.py_in │ │ ├── math_utils.py_in │ │ ├── mean_std_dev_calculator.py_in │ │ ├── minibatch_preprocessing.py_in │ │ ├── minibatch_preprocessing.sql_in │ │ ├── minibatch_validation.py_in │ │ ├── path.py_in │ │ ├── path.sql_in │ │ ├── pivot.py_in │ │ ├── pivot.sql_in │ │ ├── sessionize.py_in │ │ ├── sessionize.sql_in │ │ ├── test │ │ │ ├── encode_categorical.ic.sql_in │ │ │ ├── encode_categorical.sql_in │ │ │ ├── minibatch_preprocessing.ic.sql_in │ │ │ ├── minibatch_preprocessing.sql_in │ │ │ ├── path.ic.sql_in │ │ │ ├── path.sql_in │ │ │ ├── pivot.ic.sql_in │ │ │ ├── pivot.sql_in │ │ │ ├── sessionize.ic.sql_in │ │ │ ├── sessionize.sql_in │ │ │ ├── text_utilities.ic.sql_in │ │ │ ├── text_utilities.sql_in │ │ │ ├── transform_vec_cols.ic.sql_in │ │ │ ├── transform_vec_cols.sql_in │ │ │ ├── unit_tests │ │ │ │ ├── plpy_mock.py_in │ │ │ │ ├── test_control.py_in │ │ │ │ ├── test_minibatch_preprocessing.py_in │ │ │ │ ├── test_transform_vec_cols.py_in │ │ │ │ ├── test_utilities.py_in │ │ │ │ └── test_validate_args.py_in │ │ │ ├── utilities.ic.sql_in │ │ │ └── utilities.sql_in │ │ ├── text_utilities.py_in │ │ ├── text_utilities.sql_in │ │ ├── transform_vec_cols.py_in │ │ ├── utilities.py_in │ │ ├── utilities.sql_in │ │ ├── validate_args.py_in │ │ └── vec2cols.sql_in │ │ └── validation │ │ ├── __init__.py_in │ │ ├── cross_validation.py_in │ │ ├── cross_validation.sql_in │ │ ├── cv_utils.py_in │ │ ├── internal │ │ ├── __init__.py_in │ │ └── cross_validation.py_in │ │ └── test │ │ ├── cross_validation.ic.sql_in │ │ └── cross_validation.sql_in ├── unexported_symbols_list.txt └── utils │ ├── MallocAllocator.hpp │ ├── Math.hpp │ ├── Reference.hpp │ ├── libstdcxx-compatibility.cpp │ ├── memory.hpp │ └── shapeToExtents.hpp └── tool ├── docker └── base │ ├── Dockerfile_centos_5_gpdb_4_3_10 │ ├── Dockerfile_centos_7_postgres_10 │ ├── Dockerfile_centos_7_postgres_9_6 │ ├── Dockerfile_gpdb_4_3_10 │ ├── Dockerfile_postgres_10_Jenkins │ ├── Dockerfile_postgres_11_Jenkins │ ├── Dockerfile_postgres_9_6 │ ├── Dockerfile_postgres_9_6_Jenkins │ ├── Dockerfile_ubuntu16_postgres10 │ └── README.md ├── docker_start.sh └── jenkins ├── jenkins_build.sh ├── junit_export.py └── rat_check.sh /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | - [ ] Add the module name, JIRA# to PR/commit and description. 9 | - [ ] Add tests for the change. 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore build directory 2 | /build* 3 | /build-docker* 4 | /src/ports/postgres/modules/dbscan/test/perf/blobs 5 | /cmake-build-debug/ 6 | 7 | # Ignore generated code files 8 | *.so 9 | *.o 10 | *.pyc 11 | 12 | # Meta data of Mac OS X's Finder.app 13 | .DS_Store 14 | 15 | # LaTeX temporary files 16 | *.aux 17 | *.bbl 18 | *.blg 19 | *.log 20 | *.out 21 | *.synctex.gz 22 | *.toc 23 | *.thm 24 | auto 25 | _region_.tex 26 | auto 27 | *.swp 28 | *.fdb_latexmk 29 | *.swo # vim swap file 30 | \#*\# # emacs backup file 31 | 32 | # Biblatex temporary files 33 | *-blx.bib 34 | *.run.xml 35 | 36 | # Ignore specific generated files 37 | /doc/design/design.pdf 38 | /target/rat.txt 39 | 40 | # ctags, cscope files 41 | /cscope.files 42 | /refresh_index.sh 43 | /tags* 44 | .tags* 45 | 46 | /Makefile 47 | .predictive 48 | .Rhistory 49 | eproject.cfg 50 | *.project.vim 51 | .vscode 52 | .idea 53 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Apache MADlib 2 | Copyright 2016-2023 The Apache Software Foundation. 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | 7 | Portions Copyright (c) 2014-2015, Pivotal Inc. All rights reserved. 8 | 9 | Portions Copyright (c) 2010-2013 by EMC Corporation. All rights reserved. 10 | 11 | Portions Copyright (c) 2010-2013 by Regents of the University of California. All rights reserved. 12 | -------------------------------------------------------------------------------- /cmake/LinuxUtils.cmake: -------------------------------------------------------------------------------- 1 | # Get the RedHat/CentOS version 2 | macro(rh_version OUT_VERSION) 3 | if(EXISTS "/etc/redhat-release") 4 | file(READ "/etc/redhat-release" _REDHAT_RELEASE_CONTENT) 5 | string(REGEX REPLACE "[^0-9.]*([0-9.]+)[^0-9.]*\$" "\\1" ${OUT_VERSION} 6 | "${_REDHAT_RELEASE_CONTENT}" 7 | ) 8 | else(EXISTS "/etc/redhat-release") 9 | set(${OUT_VERSION} "${OUT_VERSION}-NOTFOUND") 10 | endif(EXISTS "/etc/redhat-release") 11 | 12 | if(EXISTS "/etc/photon-release") 13 | file(READ "/etc/photon-release" _PHOTON_RELEASE_CONTENT) 14 | string(REGEX REPLACE "VMware Photon OS ([0-9.]+)[0-9.]*$" "\\1" 15 | ${OUT_VERSION} 16 | "${_PHOTON_RELEASE_CONTENT}" 17 | ) 18 | endif(EXISTS "/etc/photon-release") 19 | endmacro(rh_version) 20 | 21 | # Get the Debian version 22 | # DEB_OUT_VERSION will have a number if /etc/issue exists, with an entry for Debian. 23 | # DEB_OUT_VERSION will have 'DEB_OUT_VERSION-NOTFOUND' if /etc/issue does not exist. 24 | # DEB_OUT_VERSION will be empty if some distribution which has /etc/issue, but not Debian in it. 25 | macro(debian_version DEB_OUT_VERSION) 26 | if(EXISTS "/etc/issue") 27 | file(READ "/etc/issue" _DEB_RELEASE_CONTENT) 28 | string(REGEX REPLACE "Debian[^0-9.]*([0-9.]+)[^0-9.]*\$" "\\1" 29 | ${DEB_OUT_VERSION} 30 | "${_DEB_RELEASE_CONTENT}" 31 | ) 32 | else(EXISTS "/etc/issue") 33 | set(${DEB_OUT_VERSION} "${DEB_OUT_VERSION}-NOTFOUND") 34 | endif(EXISTS "/etc/issue") 35 | endmacro(debian_version) 36 | 37 | -------------------------------------------------------------------------------- /cmake/OSXUtils.cmake: -------------------------------------------------------------------------------- 1 | # Get the architectures in a Mac OS X binary 2 | macro(osx_archs FILENAME OUT_ARCHS) 3 | execute_process( 4 | COMMAND /usr/bin/lipo -info ${FILENAME} 5 | OUTPUT_VARIABLE _LIPO_OUTPUT) 6 | string(REPLACE "\n" "" _LIPO_OUTPUT ${_LIPO_OUTPUT}) 7 | string(REGEX REPLACE ".*:[ ]*([^ ].*[^ ])[ ]*\$" "\\1" ${OUT_ARCHS} "${_LIPO_OUTPUT}") 8 | string(REPLACE " " ";" ${OUT_ARCHS} ${${OUT_ARCHS}}) 9 | endmacro(osx_archs) 10 | -------------------------------------------------------------------------------- /cmake/Options.cmake: -------------------------------------------------------------------------------- 1 | # ====================================================================== 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ====================================================================== 17 | 18 | OPTION(ENABLE_COVERAGE "Enable code coverage" OFF) 19 | 20 | IF(ENABLE_COVERAGE STREQUAL ON) 21 | INCLUDE(CodeCoverage) 22 | ENDIF(ENABLE_COVERAGE STREQUAL ON) 23 | -------------------------------------------------------------------------------- /cmake/TestIfNoUTF8BOM.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | 4 | 5 | def detectBOM(inFileName): 6 | file = open(inFileName, 'r') 7 | file.seek(0) 8 | head = map(ord, file.read(4)) 9 | if head == [0x00, 0x00, 0xFE, 0xFF]: 10 | return "utf_32_be" 11 | elif head == [0xFF, 0xFE, 0x00, 0x00]: 12 | return "utf_32_le" 13 | elif head[:2] == [0xFE, 0xFF]: 14 | return "utf_16_be" 15 | elif head[:2] == [0xFF, 0xFE]: 16 | return "utf_16_le" 17 | elif head[:3] == [0xEF, 0xBB, 0xBF]: 18 | return "utf_8" 19 | else: 20 | return "unknown" 21 | 22 | 23 | def main(argv=None): 24 | if argv is None: 25 | argv = sys.argv 26 | BOM = detectBOM(argv[1]) 27 | if BOM != "utf_8": 28 | return 0 29 | else: 30 | print ('Detected byte-order mark (%s) in file "%s".' % (BOM, argv[1])) 31 | return 1 32 | 33 | if __name__ == '__main__': 34 | sys.exit(main()) 35 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ABORT=no 4 | 5 | check_cmake() { 6 | (cmake --version) < /dev/null > /dev/null 2>&1 || { 7 | echo "error: cmake 2.8 or higher must be present to configure and install MADlib" 8 | ABORT=yes 9 | } 10 | } 11 | 12 | check_cmake 13 | test "$ABORT" = yes && exit -1 14 | 15 | cd `dirname $0` 16 | mkdir -p build 17 | cd build 18 | rm -f CMakeCache.txt 19 | cmake "$@" .. 20 | 21 | # Create top-directory Makefile 22 | cd .. 23 | 24 | cat <Makefile 25 | 26 | all: 27 | 28 | %: 29 | \$(MAKE) -C build \$@ 30 | clean: 31 | rm -f Makefile 32 | rm -rf build 33 | MAKEFILE 34 | 35 | if [ -e META.json ]; then 36 | cat <>Makefile 37 | install: extension-install 38 | # keep a tab to do nothing for install 39 | 40 | extension-install: 41 | \$(MAKE) -C build \$@ 42 | MAKEFILE 43 | fi 44 | -------------------------------------------------------------------------------- /deploy/DEB/config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # coding=utf-8 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, 16 | # software distributed under the License is distributed on an 17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 | # KIND, either express or implied. See the License for the 19 | # specific language governing permissions and limitations 20 | # under the License. 21 | 22 | # Exit on error 23 | set -e 24 | 25 | # Source debconf library. 26 | . /usr/share/debconf/confmodule 27 | 28 | # Ask user for custom install path 29 | db_input low madlib/installpath || true 30 | 31 | # Show interface 32 | db_go || true 33 | -------------------------------------------------------------------------------- /deploy/DEB/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # coding=utf-8 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, 16 | # software distributed under the License is distributed on an 17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 | # KIND, either express or implied. See the License for the 19 | # specific language governing permissions and limitations 20 | # under the License. 21 | 22 | # remove symlinks created during rpm install 23 | 24 | # Source debconf library. 25 | . /usr/share/debconf/confmodule 26 | 27 | # Fetching configuration from debconf 28 | db_get madlib/installpath 29 | MADLIB_INSTALL_PATH=$RET 30 | 31 | find $MADLIB_INSTALL_PATH/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null 32 | find $MADLIB_INSTALL_PATH/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null 33 | find $MADLIB_INSTALL_PATH/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null 34 | 35 | # remove "Versions" directory if it's empty 36 | rmdir $MADLIB_INSTALL_PATH/madlib/Versions 2>/dev/null 37 | exit 0 38 | -------------------------------------------------------------------------------- /deploy/DEB/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # coding=utf-8 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, 16 | # software distributed under the License is distributed on an 17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 | # KIND, either express or implied. See the License for the 19 | # specific language governing permissions and limitations 20 | # under the License. 21 | 22 | # Source debconf library. 23 | . /usr/share/debconf/confmodule 24 | 25 | MADLIB_INSTALL_PATH="InstallPathNotFound" 26 | 27 | # Fetching configuration from debconf 28 | db_get madlib/installpath 29 | MADLIB_INSTALL_PATH=$RET 30 | 31 | if [ -d "$MADLIB_INSTALL_PATH/madlib/Versions" ]; 32 | then 33 | cp -r $MADLIB_INSTALL_PATH/madlib/Versions/ $MADLIB_INSTALL_PATH/madlib/Versions.bak/ 34 | fi 35 | -------------------------------------------------------------------------------- /deploy/DEB/templates: -------------------------------------------------------------------------------- 1 | Template: madlib/installpath 2 | Type: string 3 | Default: /usr/local 4 | Description: Specify a custom install path if desired; installs to /usr/local by default. 5 | -------------------------------------------------------------------------------- /deploy/PGXN/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Packaging for the PostgreSQL Extension Network (PGXN), http://pgxn.org 3 | # ------------------------------------------------------------------------------ 4 | 5 | set(MADLIB_PGXN_RELEASE_NUMBER 1) 6 | # set(MADLIB_PGXN_VERSION_STR 7 | # "${MADLIB_VERSION_MAJOR}.${MADLIB_VERSION_MINOR}.${MADLIB_VERSION_PATCH}release${MADLIB_PGXN_RELEASE_NUMBER} 8 | set(MADLIB_PGXN_VERSION_STR 9 | "${MADLIB_VERSION_MAJOR}.${MADLIB_VERSION_MINOR}.${MADLIB_VERSION_PATCH}") 10 | set(MADLIB_PGXN_NAME "madlib-pgxn-${MADLIB_PGXN_VERSION_STR}") 11 | 12 | configure_file(META.json.in META.json) 13 | configure_file(generate_package.sh.in generate_package.sh @ONLY) 14 | configure_file(zipignore.in zipignore) 15 | configure_file(ReadMe.txt ReadMe.txt COPYONLY) 16 | add_custom_command( 17 | OUTPUT madlib.zip 18 | COMMAND "${CMAKE_COMMAND}" -E create_symlink 19 | "${CMAKE_CURRENT_BINARY_DIR}/META.json" 20 | "${CMAKE_SOURCE_DIR}/META.json" 21 | COMMAND "${CMAKE_CURRENT_BINARY_DIR}/generate_package.sh" 22 | COMMAND "${CMAKE_COMMAND}" -E remove 23 | "${CMAKE_SOURCE_DIR}/META.json" 24 | COMMENT "Creating PGXN zip file." 25 | VERBATIM 26 | ) 27 | add_custom_target(pgxn DEPENDS madlib.zip) 28 | -------------------------------------------------------------------------------- /deploy/PGXN/META.json.in: -------------------------------------------------------------------------------- 1 | { 2 | "name": "madlib", 3 | "abstract": "An open-source in-database analytics library", 4 | "description": "An open-source in-database analytics library", 5 | "version": "@MADLIB_PGXN_VERSION_STR@", 6 | "maintainer": "MADlib contributors ", 7 | "license": "apache_2_0", 8 | "provides": { 9 | "madlib": { 10 | "file": "madlib--@MADLIB_VERSION_MAJOR@.@MADLIB_VERSION_MINOR@.@MADLIB_VERSION_PATCH@.sql", 11 | "docfile": "deploy/PGXN/ReadMe.txt", 12 | "version": "@MADLIB_VERSION_MAJOR@.@MADLIB_VERSION_MINOR@.@MADLIB_VERSION_PATCH@" 13 | } 14 | }, 15 | "resources": { 16 | "homepage": "http://madlib.apache.org/", 17 | "bugtracker": { 18 | "web": "https://issues.apache.org/jira/browse/MADLIB/" 19 | }, 20 | "repository": { 21 | "url": "https://github.com/apache/madlib.git", 22 | "web": "https://github.com/apache/madlib", 23 | "type": "git" 24 | } 25 | }, 26 | "release_status": "stable", 27 | "tags": [ 28 | "machine learning", 29 | "analytics" 30 | ], 31 | 32 | "meta-spec": { 33 | "version": "1.0.0", 34 | "url": "http://pgxn.org/meta/spec.txt" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /deploy/PGXN/generate_package.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TEMPDIR=`mktemp -d -t madlib` 4 | "@CMAKE_COMMAND@" -E create_symlink \ 5 | "@CMAKE_SOURCE_DIR@" \ 6 | "${TEMPDIR}/@MADLIB_PGXN_NAME@" 7 | "@CMAKE_COMMAND@" -E create_symlink \ 8 | "@CMAKE_CURRENT_BINARY_DIR@/zipignore" \ 9 | "${TEMPDIR}/zipignore" 10 | cd "${TEMPDIR}" 11 | zip --exclude @zipignore \ 12 | -r "@CMAKE_CURRENT_BINARY_DIR@/@MADLIB_PGXN_NAME@.zip" \ 13 | "@MADLIB_PGXN_NAME@" 14 | -------------------------------------------------------------------------------- /deploy/PGXN/zipignore.in: -------------------------------------------------------------------------------- 1 | */.git/* 2 | */build* 3 | *.so 4 | *.o 5 | *.pyc 6 | */.DS_Store 7 | *.aux 8 | *.bbl 9 | *.blg 10 | *.log 11 | *.out 12 | *.synctex.gz 13 | *.toc 14 | *.thm 15 | *-blx.bib 16 | *.run.xml 17 | @MADLIB_PGXN_NAME@/doc/design/design.pdf 18 | -------------------------------------------------------------------------------- /deploy/PackageMaker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Packaging with MacOS X PackageMaker 3 | # ------------------------------------------------------------------------------ 4 | # 5 | # Important: Set variables using set(... PARENT_SCOPE), so that the scope of the 6 | # definition extends to the parent scope 7 | 8 | 9 | # -- Set PackageMaker-specific variables --------------------------------------- 10 | 11 | set(CPACK_RESOURCE_FILE_README 12 | "${CPACK_PACKAGE_DESCRIPTION_FILE}" PARENT_SCOPE) 13 | set(CPACK_RESOURCE_FILE_LICENSE 14 | "${CMAKE_SOURCE_DIR}/licenses/MADlib.txt" PARENT_SCOPE) 15 | set(CPACK_RESOURCE_FILE_WELCOME 16 | "${CMAKE_CURRENT_SOURCE_DIR}/Welcome.html" PARENT_SCOPE) 17 | set(CPACK_OSX_PACKAGE_VERSION "10.5" PARENT_SCOPE) 18 | #set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr/local/madlib/Versions/${MADLIB_VERSION_STRING}" PARENT_SCOPE) 19 | #set(CPACK_PACKAGING_INSTALL_PREFIX "/" PARENT_SCOPE) 20 | -------------------------------------------------------------------------------- /deploy/PackageMaker/Welcome.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Welcome to Apache MADlib 7 | 8 |

Welcome to Apache MADlib

9 |

10 | This installer will guide you through the process of installing MADlib onto 11 | your computer. 12 |

13 | 14 | 15 | -------------------------------------------------------------------------------- /deploy/RPM/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Packaging with RPM 3 | # ------------------------------------------------------------------------------ 4 | # 5 | # Important: Set variables using set(... PARENT_SCOPE), so that the scope of the 6 | # definition extends to the parent scope 7 | 8 | 9 | # Get information about the environment 10 | rh_version(RH_VERSION) 11 | 12 | # -- Set RPM-specific variables ------------------------------------------------ 13 | 14 | set(CPACK_RPM_PACKAGE_ARCHITECTURE x86_64 PARENT_SCOPE) 15 | set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0" PARENT_SCOPE) 16 | set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries" PARENT_SCOPE) 17 | set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local/madlib/Versions/${MADLIB_VERSION_STRING}" PARENT_SCOPE) 18 | 19 | set(_PACKAGE_REQUIRES "m4 >= 1.4") 20 | if(RH_VERSION AND RH_VERSION VERSION_LESS "6.0") 21 | # on RH/CentOS 5, there is no Python 2.6 or higher in the default 22 | # repositories. 23 | set(CPACK_RPM_PACKAGE_REQUIRES "python, ${_PACKAGE_REQUIRES}" PARENT_SCOPE) 24 | else() 25 | set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.6, ${_PACKAGE_REQUIRES}" PARENT_SCOPE) 26 | endif() 27 | 28 | # We do all deployment preparation with our CMake build script, so we do 29 | # not want to do any post-processing as part of the RPM generation. 30 | set(CPACK_RPM_SPEC_MORE_DEFINE "%undefine __os_install_post" PARENT_SCOPE) 31 | 32 | -------------------------------------------------------------------------------- /deploy/description.txt: -------------------------------------------------------------------------------- 1 | Apache MADlib analytics. It provides data-parallel implementations of mathematical, 2 | statistical and machine learning methods for structured and 3 | unstructured data. 4 | 5 | The MADlib mission: to foster widespread development of scalable 6 | analytic skills, by harnessing efforts from commercial practice, 7 | academic research, and open-source development. 8 | 9 | To more information, please see the MADlib wiki at 10 | https://cwiki.apache.org/confluence/display/MADLIB 11 | -------------------------------------------------------------------------------- /deploy/gppkg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Packaging for Greenplum's gppkg 3 | # ------------------------------------------------------------------------------ 4 | 5 | set(MADLIB_GPPKG_RELEASE_NUMBER 1) 6 | 7 | set(MADLIB_GPPKG_RPM_SOURCE_DIR 8 | "${CMAKE_BINARY_DIR}/_CPack_Packages/Linux/RPM/${CPACK_PACKAGE_FILE_NAME}" 9 | ) 10 | # gppkg expects that the file name for the RPM from which the gppkg is generated 11 | # follows the pattern "--..rpm". Otherwise, 12 | # uninstallation will not work (MPP-18078). Note that has to be 13 | # consistent with the version in madlib.spec.in. gppkg deduces the 14 | # uninstallation command line options from the filename! 15 | set(MADLIB_GPPKG_RPM_FILE_NAME 16 | "madlib-${MADLIB_VERSION_STRING_NO_HYPHEN}-${MADLIB_GPPKG_RELEASE_NUMBER}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") 17 | 18 | find_program( 19 | GPPKG_BINARY 20 | gppkg 21 | PATH /usr/local/greenplum-db/bin 22 | DOC "Path to gppkg" 23 | ) 24 | find_program( 25 | RPMBUILD_BINARY 26 | rpmbuild 27 | DOC "Path to rpmbuild" 28 | ) 29 | file(READ "${CPACK_PACKAGE_DESCRIPTION_FILE}" CPACK_RPM_PACKAGE_DESCRIPTION) 30 | 31 | # The target gppkg is a meta target that depends on all version-specific 32 | # gppkg targets 33 | add_custom_target(gppkg 34 | COMMENT "Generating all gppkg installers" 35 | ) 36 | 37 | # We now run generated files, one for each Greenplum version 38 | file(GLOB GPPKG_VERSIONS "${CMAKE_CURRENT_BINARY_DIR}/*_gppkg.cmake") 39 | foreach(GPPKG_VERSION ${GPPKG_VERSIONS}) 40 | include("${GPPKG_VERSION}") 41 | endforeach(GPPKG_VERSION) 42 | 43 | set(CPACK_RPM_SPEC_MORE_DEFINE "%undefine __os_install_post" PARENT_SCOPE) 44 | -------------------------------------------------------------------------------- /deploy/gppkg/gppkg_spec.yml.in: -------------------------------------------------------------------------------- 1 | Pkgname: madlib 2 | Architecture: @CPACK_RPM_PACKAGE_ARCHITECTURE@ 3 | Version: @MADLIB_VERSION_STRING_NO_HYPHEN@@GPPKG_VER@-@GPDB_VARIANT_SHORT@@GPDB_VERSION_LC@ 4 | OS: rhel@RH_MAJOR_VERSION@ 5 | GPDBVersion: @GPDB_VERSION_LC@ 6 | Description: Madlib is an open source library which provides scalable in-database analytics. It provides data-parallel implementations of mathematical, statistical and machine learning methods for structured and unstructured data. 7 | PostInstall: 8 | - Master: "echo 'Please run the following command to deploy MADlib'; 9 | echo 'usage: madpack install [-s schema_name] -p @PORT_NAME@ -c user@host:port/database'; 10 | echo 'Example:'; 11 | echo ' $ $GPHOME/madlib/bin/madpack install -s madlib -p @PORT_NAME@ -c gpadmin@mdw:5432/testdb'; 12 | echo ' This will install MADlib objects into a @GPDB_VARIANT@ database named \"testdb\"'; 13 | echo ' running on server \"mdw\" on port 5432. Installer will try to login as \"gpadmin\"'; 14 | echo ' and will prompt for password. The target schema will be \"madlib\".'; 15 | echo ' To upgrade to a new version of MADlib from version v@UPGRADE_SUPPORT@ or later, use option \"upgrade\",'; 16 | echo ' instead of \"install\" '; 17 | echo 'For additional options run:'; 18 | echo '$ madpack --help'; 19 | echo 'Release notes and additional documentation can be found at http://madlib.apache.org';" 20 | -------------------------------------------------------------------------------- /deploy/madlib.spec.in: -------------------------------------------------------------------------------- 1 | # -*- rpm-spec -*- 2 | %define _rpmdir @CPACK_RPM_DIRECTORY@ 3 | %define _rpmfilename @CPACK_RPM_FILE_NAME@ 4 | %define _unpackaged_files_terminate_build 0 5 | %define _topdir @CPACK_RPM_DIRECTORY@ 6 | %define _madlib_version @CPACK_PACKAGE_VERSION@ 7 | 8 | BuildRoot: @CPACK_RPM_DIRECTORY@/@CPACK_PACKAGE_FILE_NAME@@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH@ 9 | Summary: @CPACK_RPM_PACKAGE_SUMMARY@ 10 | Name: @CPACK_RPM_PACKAGE_NAME@ 11 | Version: @CPACK_RPM_PACKAGE_VERSION@ 12 | Release: @CPACK_RPM_PACKAGE_RELEASE@ 13 | License: @CPACK_RPM_PACKAGE_LICENSE@ 14 | Group: @CPACK_RPM_PACKAGE_GROUP@ 15 | Prefix: /usr/local 16 | Vendor: @CPACK_RPM_PACKAGE_VENDOR@ 17 | 18 | @TMP_RPM_URL@ 19 | @TMP_RPM_REQUIRES@ 20 | @TMP_RPM_PROVIDES@ 21 | @TMP_RPM_OBSOLETES@ 22 | @TMP_RPM_BUILDARCH@ 23 | 24 | @TMP_RPM_SPEC_INSTALL_POST@ 25 | @CPACK_RPM_SPEC_MORE_DEFINE@ 26 | @CPACK_RPM_COMPRESSION_TYPE_TMP@ 27 | 28 | %description 29 | @CPACK_RPM_PACKAGE_DESCRIPTION@ 30 | 31 | %prep 32 | mv $RPM_BUILD_ROOT "@CPACK_TOPLEVEL_DIRECTORY@/tmpBBroot" 33 | 34 | #p build 35 | 36 | %install 37 | if [ -e $RPM_BUILD_ROOT ]; 38 | then 39 | rm -rf $RPM_BUILD_ROOT 40 | fi 41 | mv "@CPACK_TOPLEVEL_DIRECTORY@/tmpBBroot" $RPM_BUILD_ROOT 42 | 43 | %clean 44 | 45 | %post 46 | @CPACK_RPM_SPEC_POSTINSTALL@ 47 | 48 | %postun 49 | @CPACK_RPM_SPEC_POSTUNINSTALL@ 50 | 51 | %pre 52 | @CPACK_RPM_SPEC_PREINSTALL@ 53 | 54 | %preun 55 | @CPACK_RPM_SPEC_PREUNINSTALL@ 56 | 57 | %files 58 | %defattr(-,root,root,-) 59 | @CPACK_RPM_INSTALL_FILES@ 60 | 61 | %changelog 62 | * Fri May 3 2013 Rahul Iyer 63 | Replaced Cpack autogenerated spec file with this file. 64 | -------------------------------------------------------------------------------- /deploy/postflight.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # $0 - Script Path, $1 - Package Path, $2 - Target Location, and $3 - Target Volume 4 | 5 | MADLIB_VERSION=1.22.0-dev 6 | 7 | # Remove existing soft links 8 | find $2/usr/local/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null 9 | find $2/usr/local/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null 10 | find $2/usr/local/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null 11 | 12 | # Create new soft links 13 | ln -nsf $2/usr/local/madlib/Versions/$MADLIB_VERSION $2/usr/local/madlib/Current 14 | ln -nsf $2/usr/local/madlib/Current/bin $2/usr/local/madlib/bin 15 | ln -nsf $2/usr/local/madlib/Current/doc $2/usr/local/madlib/doc 16 | 17 | if [ -d "$2/usr/local/madlib/Versions.bak" ]; 18 | then 19 | mv -f $2/usr/local/madlib/Versions.bak/* $2/usr/local/madlib/Versions/ 20 | rm -rf $2/usr/local/madlib/Versions.bak 21 | fi 22 | -------------------------------------------------------------------------------- /deploy/preflight.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # $0 - Script Path, $1 - Package Path, $2 - Target Location, and $3 - Target Volume 4 | 5 | if [ -d "$2/usr/local/madlib/Versions" ] 6 | then 7 | mv $2/usr/local/madlib/Versions $2/usr/local/madlib/Versions.bak 8 | fi 9 | -------------------------------------------------------------------------------- /deploy/rpm_post.sh: -------------------------------------------------------------------------------- 1 | # Remove existing soft links 2 | find $RPM_INSTALL_PREFIX/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null 3 | find $RPM_INSTALL_PREFIX/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null 4 | find $RPM_INSTALL_PREFIX/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null 5 | 6 | 7 | # RPM version is setup with underscore replaced for hyphen but 8 | # the actual version contains a hyphen. The symlink created on disk 9 | # is with a hyphen instead of the underscore. 10 | MADLIB_VERSION_NO_HYPHEN=%{_madlib_version} 11 | MADLIB_VERSION="${MADLIB_VERSION_NO_HYPHEN/_/-}" 12 | ln -nsf $RPM_INSTALL_PREFIX/madlib/Versions/$MADLIB_VERSION $RPM_INSTALL_PREFIX/madlib/Current 13 | ln -nsf $RPM_INSTALL_PREFIX/madlib/Current/bin $RPM_INSTALL_PREFIX/madlib/bin 14 | ln -nsf $RPM_INSTALL_PREFIX/madlib/Current/doc $RPM_INSTALL_PREFIX/madlib/doc 15 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore generated API references 2 | /developer 3 | /user 4 | -------------------------------------------------------------------------------- /doc/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore generated files 2 | /doxysql 3 | -------------------------------------------------------------------------------- /doc/bin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # MADlib Documentation Executable Files 3 | # ------------------------------------------------------------------------------ 4 | 5 | # set(BIN_FILES 6 | # doxypy.py 7 | # ) 8 | # add_files(BIN_TARGET_FILES . "${CMAKE_CURRENT_BINARY_DIR}" ${BIN_FILES}) 9 | # add_custom_target(doxyBinFiles ALL DEPENDS ${BIN_TARGET_FILES}) 10 | 11 | list(APPEND M4_ARGUMENTS 12 | "\"-DMADLIB_SCHEMA=madlib\"" 13 | "\"-I${CMAKE_BINARY_DIR}/doc/etc\"" 14 | ) 15 | join_strings(_M4_ARGUMENTS " " "${M4_ARGUMENTS}") 16 | set(_M4_ARGUMENTS "${_M4_ARGUMENTS}") 17 | 18 | # configure_file(py_filter.sh.in py_filter.sh @ONLY) 19 | configure_file(sql_filter.sh.in sql_filter.sh @ONLY) 20 | configure_file(update_mathjax.sh.in update_mathjax.sh @ONLY) 21 | -------------------------------------------------------------------------------- /doc/bin/sql_filter.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | FILTER="../bin/doxysql" 3 | 4 | @M4_BINARY@ @_M4_ARGUMENTS@ $1 | ${FILTER} -f '$(@M4_BINARY@ @_M4_ARGUMENTS@'"$1)" 5 | -------------------------------------------------------------------------------- /doc/design/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # MADlib Design Document 3 | # ------------------------------------------------------------------------------ 4 | 5 | find_program( 6 | LATEX_BINARY 7 | latex 8 | DOC "Path to latex" 9 | ) 10 | find_program( 11 | BIBTEX_BINARY 12 | latex 13 | DOC "Path to bibtex" 14 | ) 15 | find_program( 16 | MAKEINDEX_BINARY 17 | makeindex 18 | DOC "Path to makeindex" 19 | ) 20 | 21 | file(GLOB_RECURSE DESIGN_DOC_MODULES 22 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 23 | "${CMAKE_CURRENT_SOURCE_DIR}/latex/*.sty" 24 | "${CMAKE_CURRENT_SOURCE_DIR}/modules/*.tex" 25 | "${CMAKE_CURRENT_SOURCE_DIR}/other-chapters/*.tex" 26 | "${CMAKE_CURRENT_SOURCE_DIR}/figures/*") 27 | 28 | if(LATEX_BINARY AND BIBTEX_BINARY AND MAKEINDEX_BINARY) 29 | include(UseLATEX) 30 | 31 | add_latex_document(design.tex 32 | BIBFILES ../literature.bib 33 | INPUTS 34 | ${DESIGN_DOC_MODULES} 35 | EXCLUDE_FROM_ALL 36 | ) 37 | else() 38 | message(STATUS "A complete LaTeX installation could not be found. " 39 | "Compiling the design document will not be possible.") 40 | endif(LATEX_BINARY AND BIBTEX_BINARY AND MAKEINDEX_BINARY) 41 | -------------------------------------------------------------------------------- /doc/design/figures/2d_kdtree.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/2d_kdtree.pdf -------------------------------------------------------------------------------- /doc/design/figures/basics_decision_tree.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/basics_decision_tree.pdf -------------------------------------------------------------------------------- /doc/design/figures/class_diagram-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/class_diagram-1.pdf -------------------------------------------------------------------------------- /doc/design/figures/decision_tree_linear_model.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/decision_tree_linear_model.pdf -------------------------------------------------------------------------------- /doc/design/figures/graph_example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/graph_example.pdf -------------------------------------------------------------------------------- /doc/design/figures/hits_example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/hits_example.pdf -------------------------------------------------------------------------------- /doc/design/figures/impurity_measures.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/impurity_measures.pdf -------------------------------------------------------------------------------- /doc/design/figures/lanczos_bidiag_segment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/lanczos_bidiag_segment.pdf -------------------------------------------------------------------------------- /doc/design/figures/pagerank_example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/pagerank_example.pdf -------------------------------------------------------------------------------- /doc/design/figures/svd_figure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/svd_figure.pdf -------------------------------------------------------------------------------- /doc/design/figures/wcc_example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/design/figures/wcc_example.pdf -------------------------------------------------------------------------------- /doc/etc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # MADlib Documentation Configuration Files 3 | # ------------------------------------------------------------------------------ 4 | 5 | configure_file(user.doxyfile.in user.doxyfile) 6 | configure_file(developer.doxyfile.in developer.doxyfile) 7 | configure_file(SQLCommon.m4_in SQLCommon.m4) 8 | -------------------------------------------------------------------------------- /doc/etc/SQLCommon.m4_in: -------------------------------------------------------------------------------- 1 | /* 2 | * During build time, macro definitions will be inserted here. 3 | */ 4 | @M4_DEFINES_CODE@ 5 | -------------------------------------------------------------------------------- /doc/imgs/agile-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/imgs/agile-icon.png -------------------------------------------------------------------------------- /doc/imgs/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/imgs/architecture.png -------------------------------------------------------------------------------- /doc/imgs/deep-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/imgs/deep-icon.png -------------------------------------------------------------------------------- /doc/imgs/madlib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/imgs/madlib.png -------------------------------------------------------------------------------- /doc/imgs/magnetic-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/doc/imgs/magnetic-icon.png -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | This directory will hold data generators and example scenarios. 2 | -------------------------------------------------------------------------------- /examples/datagen/README: -------------------------------------------------------------------------------- 1 | This directory will hold data generators to be used in examples. 2 | -------------------------------------------------------------------------------- /examples/gpce/sketches.sql: -------------------------------------------------------------------------------- 1 | \qecho ================================================================= 2 | \qecho === Running: sketches =========================================== 3 | \qecho ================================================================= 4 | \qecho 5 | 6 | \qecho === CM : count ================================================== 7 | SELECT pronamespace, madlib.cmsketch_count(pronargs, 3) 8 | FROM pg_proc 9 | GROUP BY pronamespace; 10 | 11 | \qecho === CM : rangecount ============================================= 12 | SELECT pronamespace, madlib.cmsketch_rangecount(pronargs, 3, 5) 13 | FROM pg_proc 14 | GROUP BY pronamespace; 15 | 16 | \qecho === CM : centile ================================================ 17 | SELECT relnamespace, madlib.cmsketch_centile(oid::int8, 75) 18 | FROM pg_class 19 | GROUP BY relnamespace; 20 | 21 | \qecho === CM : cmsketch_depth_histogram =============================== 22 | SELECT madlib.cmsketch_width_histogram(madlib.cmsketch(oid::int8), min(oid::int8), max(oid::int8), 10) 23 | FROM pg_class; 24 | 25 | \qecho === CM : count ================================================== 26 | SELECT madlib.cmsketch_depth_histogram(oid::int8, 10) 27 | FROM pg_class; 28 | 29 | \qecho === FM : distinct count ========================================= 30 | SELECT pronargs, madlib.fmsketch_dcount(proname) AS distinct_hat, count(proname) 31 | FROM pg_proc 32 | GROUP BY pronargs; 33 | 34 | \qecho === MFV : mfvsketch_top_histogram ================================ 35 | SELECT madlib.mfvsketch_top_histogram(proname, 4) 36 | FROM pg_proc; 37 | 38 | \qecho === MFV : mfvsketch_quick_histogram ============================== 39 | SELECT madlib.mfvsketch_quick_histogram(proname, 4) 40 | FROM pg_proc; 41 | -------------------------------------------------------------------------------- /examples/hello_world/non-iterative/avg_var.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /* ----------------------------------------------------------------------- *//** 20 | * 21 | * @file avg_var.hpp 22 | * 23 | *//* ----------------------------------------------------------------------- */ 24 | 25 | /** 26 | * @brief average and variance: Transition function 27 | */ 28 | DECLARE_UDF(hello_world, avg_var_transition) 29 | 30 | /** 31 | * @brief average and variance: State merge function 32 | */ 33 | DECLARE_UDF(hello_world, avg_var_merge_states) 34 | 35 | /** 36 | * @brief average and variance: Final function 37 | */ 38 | DECLARE_UDF(hello_world, avg_var_final) 39 | -------------------------------------------------------------------------------- /examples/scenarios/README: -------------------------------------------------------------------------------- 1 | This directory will hold usage scenarios for the libraries. 2 | -------------------------------------------------------------------------------- /licenses/MADlib.txt: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /licenses/third_party/Boost_Software_License_v1.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /licenses/third_party/PyYAML_v3.10.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006 Kirill Simonov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /licenses/third_party/UseLATEX_v1.9.4.txt: -------------------------------------------------------------------------------- 1 | From the header comments of UseLATEX.cmake 2 | (obtained from http://www.cmake.org/Wiki/CMakeUserUseLATEX): 3 | 4 | # Author: Kenneth Moreland 5 | # 6 | # Copyright 2004 Sandia Corporation. 7 | # Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive 8 | # license for use of this work by or on behalf of the 9 | # U.S. Government. Redistribution and use in source and binary forms, with 10 | # or without modification, are permitted provided that this Notice and any 11 | # statement of authorship are reproduced on all copies. 12 | -------------------------------------------------------------------------------- /licenses/third_party/argparse_v1.2.1.txt: -------------------------------------------------------------------------------- 1 | argparse is (c) 2006-2009 Steven J. Bethard . 2 | 3 | The argparse module was contributed to Python as of Python 2.7 and thus 4 | was licensed under the Python license. Same license applies to all files in 5 | the argparse package project. 6 | 7 | For details about the Python License, please see Python_License_v2.7.1.txt. 8 | 9 | History 10 | ------- 11 | 12 | Before (and including) argparse 1.1, the argparse package was licensed under 13 | Apache License v2.0. 14 | 15 | After argparse 1.1, all project files from the argparse project were deleted 16 | due to license compatibility issues between Apache License 2.0 and GNU GPL v2. 17 | 18 | The project repository then had a clean start with some files taken from 19 | Python 2.7.1, so definitely all files are under Python License now. 20 | -------------------------------------------------------------------------------- /methods/sketch/src/pg_gp/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/methods/sketch/src/pg_gp/__init__.py_in -------------------------------------------------------------------------------- /methods/sketch/src/pg_gp/sketch_support.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file sketch_support.h 3 | * 4 | * \brief header file for sketch support routines 5 | */ 6 | #ifndef SKETCH_SUPPORT_H 7 | #define SKETCH_SUPPORT_H 8 | 9 | #define MD5_HASHLEN 16 10 | #define MD5_HASHLEN_BITS 8*MD5_HASHLEN /*! md5 hash length in bits */ 11 | 12 | #ifndef MAXINT8LEN 13 | #define MAXINT8LEN 25 /*! number of chars to hold an int8 */ 14 | #endif 15 | 16 | #ifndef CHAR_BIT 17 | #include 18 | #endif 19 | 20 | Datum array_set_bit_in_place(bytea *, int32, int32, int32, int32); 21 | uint32 rightmost_one(uint8 *, size_t, size_t, size_t); 22 | uint32 leftmost_zero(uint8 *, size_t, size_t, size_t); 23 | uint32 ui_rightmost_one(uint32 v); 24 | void hex_to_bytes(char *hex, uint8 *bytes, size_t); 25 | void bit_print(uint8 *c, int numbytes); 26 | Datum md5_cstring(char *); 27 | bytea *sketch_md5_bytea(Datum, Oid); 28 | int32 safe_log2(int64); 29 | void int64_big_endianize(uint64 *, uint32, bool); 30 | 31 | /*! macro to convert a pointer into a marshalled array of Datums into a Datum */ 32 | #define PointerExtractDatum(x, byVal) (byVal ? (*(Datum *)x) : (PointerGetDatum(x))) 33 | /*! macro to convert a Datum into a pointer suitable for memcpy */ 34 | #define DatumExtractPointer(x, byVal) (byVal ? (void *)&x : DatumGetPointer(x)) 35 | 36 | size_t ExtractDatumLen(Datum x, int len, bool byVal, size_t capacity); 37 | #endif /* SKETCH_SUPPORT_H */ 38 | -------------------------------------------------------------------------------- /methods/svec_util/src/pg_gp/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/methods/svec_util/src/pg_gp/__init__.py_in -------------------------------------------------------------------------------- /methods/svec_util/src/pg_gp/svec_util.h: -------------------------------------------------------------------------------- 1 | #ifndef SVECUTIL_H 2 | #define SVECUTIL_H 3 | 4 | Datum svec_l2norm(PG_FUNCTION_ARGS); 5 | Datum svec_count(PG_FUNCTION_ARGS); 6 | Datum svec_log(PG_FUNCTION_ARGS); 7 | Datum svec_unnest(PG_FUNCTION_ARGS); 8 | Datum svec_pivot(PG_FUNCTION_ARGS); 9 | Datum svec_hash(PG_FUNCTION_ARGS); 10 | 11 | Datum svec_svec_l1norm(PG_FUNCTION_ARGS); 12 | Datum svec_svec_l2norm(PG_FUNCTION_ARGS); 13 | Datum svec_svec_angle(PG_FUNCTION_ARGS); 14 | Datum svec_svec_tanimoto_distance(PG_FUNCTION_ARGS); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /methods/utils/src/pg_gp/noop.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | PG_FUNCTION_INFO_V1(noop); 5 | Datum 6 | noop(PG_FUNCTION_ARGS) { 7 | (void) fcinfo; 8 | PG_RETURN_VOID(); 9 | } 10 | -------------------------------------------------------------------------------- /methods/utils/src/pg_gp/to_char.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef NO_PG_MODULE_MAGIC 7 | PG_MODULE_MAGIC; 8 | #endif 9 | 10 | PG_FUNCTION_INFO_V1(__to_text); 11 | /* 12 | * @brief Cast a value to text. On some databases, there 13 | * are no such casts for certain data types, such as 14 | * the cast for bit to text. 15 | * 16 | * @param value The value with any specific type 17 | * 18 | * @note This is a strict function. 19 | * 20 | */ 21 | Datum 22 | __to_text(PG_FUNCTION_ARGS) { 23 | Datum value = PG_GETARG_DATUM(0); 24 | Oid valtype = get_fn_expr_argtype(fcinfo->flinfo, 0); 25 | Oid typoutput = 0; 26 | bool typIsVarlena = 0; 27 | char *result = NULL; 28 | 29 | getTypeOutputInfo(valtype, &typoutput, &typIsVarlena); 30 | 31 | // call the output function of the type to convert 32 | result = OidOutputFunctionCall(typoutput, value); 33 | 34 | PG_RETURN_TEXT_P(cstring_to_text(result)); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /src/bin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # MADlib binary files 3 | # ------------------------------------------------------------------------------ 4 | 5 | 6 | # -- 1. Copy files ------------------------------------------------------------- 7 | 8 | set(MADPACK_BINARIES 9 | madpack 10 | ) 11 | add_files(BINARY_TARGET_FILES . "${CMAKE_CURRENT_BINARY_DIR}" ${MADPACK_BINARIES}) 12 | add_custom_target(binaryFiles ALL DEPENDS ${BINARY_TARGET_FILES}) 13 | add_dependencies(binaryFiles madpackFiles) 14 | 15 | 16 | # -- 2. Install binary files to $MADLIB_ROOT/bin ------------------------------- 17 | 18 | install(PROGRAMS ${BINARY_TARGET_FILES} 19 | DESTINATION bin 20 | COMPONENT core 21 | ) 22 | -------------------------------------------------------------------------------- /src/config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # MADlib configuration files (these are configuration files used by the 3 | # installer). End users are not supposed to make modifications. 4 | # ------------------------------------------------------------------------------ 5 | 6 | 7 | # -- 1. Copy all *.yml files --------------------------------------------------- 8 | 9 | file(GLOB_RECURSE CONFIG_FILES 10 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 11 | "*.yml" 12 | ) 13 | add_files(CONFIG_TARGET_FILES . "${CMAKE_CURRENT_BINARY_DIR}" ${CONFIG_FILES}) 14 | add_custom_target(configFiles ALL DEPENDS ${CONFIG_TARGET_FILES}) 15 | 16 | 17 | 18 | # -- 2. Install config files to $MADLIB_ROOT/config ---------------------------- 19 | 20 | install(FILES ${CONFIG_TARGET_FILES} 21 | DESTINATION config 22 | COMPONENT core 23 | ) 24 | -------------------------------------------------------------------------------- /src/config/Modules.yml: -------------------------------------------------------------------------------- 1 | ### 2 | # List of methods/modules and their dependencies: 3 | ### 4 | modules: 5 | - name: array_ops 6 | - name: assoc_rules 7 | depends: ['svec_util'] 8 | - name: bayes 9 | - name: conjugate_gradient 10 | depends: ['array_ops'] 11 | - name: convex 12 | depends: ['utilities'] 13 | - name: crf 14 | - name: dbscan 15 | depends: ['utilities'] 16 | - name: deep_learning 17 | depends: ['utilities'] 18 | - name: elastic_net 19 | - name: glm 20 | depends: ['utilities'] 21 | - name: graph 22 | depends: ['utilities'] 23 | - name: kmeans 24 | depends: ['array_ops', 'svec_util', 'sample'] 25 | - name: knn 26 | depends: ['array_ops'] 27 | - name: lda 28 | depends: ['array_ops'] 29 | - name: linalg 30 | - name: linear_systems 31 | depends: ['utilities'] 32 | - name: mxgboost 33 | depends: ['utilities'] 34 | - name: pca 35 | depends: ['linalg', 'convex'] 36 | - name: pmml 37 | - name: prob 38 | - name: recursive_partitioning 39 | depends: ['utilities'] 40 | - name: regress 41 | depends: ['utilities', 'array_ops'] 42 | - name: sample 43 | depends: ['utilities', 'stats'] 44 | - name: sketch 45 | - name: stats 46 | depends: ['array_ops'] 47 | - name: summary 48 | depends: ['utilities', 'sketch'] 49 | - name: svec 50 | - name: svec_util 51 | depends: ['svec'] 52 | - name: svm 53 | - name: tsa 54 | - name: utilities 55 | depends: ['linalg'] 56 | - name: validation 57 | depends: ['array_ops', 'regress'] 58 | - name: stemmer 59 | -------------------------------------------------------------------------------- /src/config/Ports.yml: -------------------------------------------------------------------------------- 1 | # List of DB Ports to compile MADlib for. 2 | # 3 | # Synopsis: 4 | # - name : descriptive name of the new DB port 5 | # 6 | 7 | postgres: 8 | name: PostgreSQL 9 | 10 | greenplum: 11 | name: Greenplum DB 12 | -------------------------------------------------------------------------------- /src/config/Version.yml: -------------------------------------------------------------------------------- 1 | version: 1.22.0-dev 2 | -------------------------------------------------------------------------------- /src/dbal/BoostIntegration/BoostIntegration.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file BoostIntegration.hpp 4 | * 5 | * Implementing the Boost assertion handlers and user-defined functions is not 6 | * without issues. 7 | * 8 | * On system with a flat namespace (Linux), the main image might also have 9 | * definitions of the boost assertion handlers, which would be used (unless 10 | * the connector library is loaded with RTLD_LOCAL ORed in to the call to 11 | * dlopen). 12 | * 13 | * On systems with layered namespace (direct binding), the "one definition rule" 14 | * could be violated. 15 | * 16 | *//* ----------------------------------------------------------------------- */ 17 | 18 | #ifndef MADLIB_DBAL_BOOST_INTEGRATION_HPP 19 | #define MADLIB_DBAL_BOOST_INTEGRATION_HPP 20 | 21 | // See dbal/BoostIntegration/Assertions_impl.hpp 22 | #define BOOST_ENABLE_ASSERT_HANDLER 23 | 24 | #include "Assertions_impl.hpp" 25 | #include "MathToolkit_impl.hpp" 26 | 27 | #endif // !defined(MADLIB_BOOST_INTEGRATION_HPP) 28 | -------------------------------------------------------------------------------- /src/dbal/EigenIntegration/EigenPlugin.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file EigenPlugin.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | // Workaround for Doxygen: Ignore if not included by EigenIntegration.hpp 8 | #ifdef MADLIB_DBAL_EIGEN_INTEGRATION_HPP 9 | 10 | inline bool is_finite() const { 11 | for (Index j = 0; j < size(); ++j) 12 | if (!boost::math::isfinite(this->coeff(j))) 13 | return false; 14 | return true; 15 | } 16 | 17 | #endif // MADLIB_DBAL_EIGEN_INTEGRATION_HPP (workaround for Doxygen) 18 | -------------------------------------------------------------------------------- /src/dbal/Exceptions/NoSolutionFoundException_proto.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file NoSolutionFoundException_proto.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_DBAL_NOSOLUTIONFOUNDEXCEPTION_PROTO_HPP 8 | #define MADLIB_DBAL_NOSOLUTIONFOUNDEXCEPTION_PROTO_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbal { 13 | 14 | /** 15 | * @brief Exception indicating that no solution was found, e.g., because 16 | * convergence was not reached 17 | */ 18 | class NoSolutionFoundException 19 | : public std::runtime_error { 20 | 21 | public: 22 | explicit 23 | NoSolutionFoundException() 24 | : std::runtime_error("Could not find a solution.") { } 25 | 26 | explicit 27 | NoSolutionFoundException(const std::string& inMsg) 28 | : std::runtime_error(inMsg) { } 29 | }; 30 | 31 | } // namespace dbal 32 | 33 | } // namespace madlib 34 | 35 | #endif // defined(MADLIB_DBAL_NOSOLUTIONFOUNDEXCEPTION_PROTO_HPP) 36 | -------------------------------------------------------------------------------- /src/dbal/dbal_impl.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file dbal_impl.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_DBAL_IMPL_HPP 8 | #define MADLIB_DBAL_IMPL_HPP 9 | 10 | // FIXME: Eigen can only be included here because it depends on the memory 11 | // allocator 12 | #include "EigenIntegration/EigenIntegration.hpp" 13 | 14 | #include "ByteStream_impl.hpp" 15 | #include "ByteStreamHandleBuf_impl.hpp" 16 | #include "DynamicStruct_impl.hpp" 17 | #include "OutputStreamBufferBase_impl.hpp" 18 | #include "Reference_impl.hpp" 19 | 20 | #endif // defined(MADLIB_DBAL_IMPL_HPP) 21 | -------------------------------------------------------------------------------- /src/libstemmer/runtime/api.c: -------------------------------------------------------------------------------- 1 | 2 | #include /* for calloc, free */ 3 | #include "header.h" 4 | 5 | extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size) 6 | { 7 | struct SN_env * z = (struct SN_env *) calloc(1, sizeof(struct SN_env)); 8 | if (z == NULL) return NULL; 9 | z->p = create_s(); 10 | if (z->p == NULL) goto error; 11 | if (S_size) 12 | { 13 | int i; 14 | z->S = (symbol * *) calloc(S_size, sizeof(symbol *)); 15 | if (z->S == NULL) goto error; 16 | 17 | for (i = 0; i < S_size; i++) 18 | { 19 | z->S[i] = create_s(); 20 | if (z->S[i] == NULL) goto error; 21 | } 22 | } 23 | 24 | if (I_size) 25 | { 26 | z->I = (int *) calloc(I_size, sizeof(int)); 27 | if (z->I == NULL) goto error; 28 | } 29 | 30 | if (B_size) 31 | { 32 | z->B = (unsigned char *) calloc(B_size, sizeof(unsigned char)); 33 | if (z->B == NULL) goto error; 34 | } 35 | 36 | return z; 37 | error: 38 | SN_close_env(z, S_size); 39 | return NULL; 40 | } 41 | 42 | extern void SN_close_env(struct SN_env * z, int S_size) 43 | { 44 | if (z == NULL) return; 45 | if (S_size) 46 | { 47 | int i; 48 | for (i = 0; i < S_size; i++) 49 | { 50 | lose_s(z->S[i]); 51 | } 52 | free(z->S); 53 | } 54 | free(z->I); 55 | free(z->B); 56 | if (z->p) lose_s(z->p); 57 | free(z); 58 | } 59 | 60 | extern int SN_set_current(struct SN_env * z, int size, const symbol * s) 61 | { 62 | int err = replace_s(z, 0, z->l, size, s, NULL); 63 | z->c = 0; 64 | return err; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/libstemmer/runtime/api.h: -------------------------------------------------------------------------------- 1 | 2 | typedef unsigned char symbol; 3 | 4 | /* Or replace 'char' above with 'short' for 16 bit characters. 5 | 6 | More precisely, replace 'char' with whatever type guarantees the 7 | character width you need. Note however that sizeof(symbol) should divide 8 | HEAD, defined in header.h as 2*sizeof(int), without remainder, otherwise 9 | there is an alignment problem. In the unlikely event of a problem here, 10 | consult Martin Porter. 11 | 12 | */ 13 | 14 | struct SN_env { 15 | symbol * p; 16 | int c; int l; int lb; int bra; int ket; 17 | symbol * * S; 18 | int * I; 19 | unsigned char * B; 20 | }; 21 | 22 | extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size); 23 | extern void SN_close_env(struct SN_env * z, int S_size); 24 | 25 | extern int SN_set_current(struct SN_env * z, int size, const symbol * s); 26 | 27 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_danish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * danish_ISO_8859_1_create_env(void); 9 | extern void danish_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int danish_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_dutch.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * dutch_ISO_8859_1_create_env(void); 9 | extern void dutch_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int dutch_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_english.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * english_ISO_8859_1_create_env(void); 9 | extern void english_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int english_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_finnish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * finnish_ISO_8859_1_create_env(void); 9 | extern void finnish_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int finnish_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_french.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * french_ISO_8859_1_create_env(void); 9 | extern void french_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int french_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_german.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * german_ISO_8859_1_create_env(void); 9 | extern void german_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int german_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_italian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * italian_ISO_8859_1_create_env(void); 9 | extern void italian_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int italian_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_norwegian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * norwegian_ISO_8859_1_create_env(void); 9 | extern void norwegian_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int norwegian_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_porter.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * porter_ISO_8859_1_create_env(void); 9 | extern void porter_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int porter_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_portuguese.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * portuguese_ISO_8859_1_create_env(void); 9 | extern void portuguese_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int portuguese_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_spanish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * spanish_ISO_8859_1_create_env(void); 9 | extern void spanish_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int spanish_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_1_swedish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * swedish_ISO_8859_1_create_env(void); 9 | extern void swedish_ISO_8859_1_close_env(struct SN_env * z); 10 | 11 | extern int swedish_ISO_8859_1_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_2_hungarian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * hungarian_ISO_8859_2_create_env(void); 9 | extern void hungarian_ISO_8859_2_close_env(struct SN_env * z); 10 | 11 | extern int hungarian_ISO_8859_2_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_ISO_8859_2_romanian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * romanian_ISO_8859_2_create_env(void); 9 | extern void romanian_ISO_8859_2_close_env(struct SN_env * z); 10 | 11 | extern int romanian_ISO_8859_2_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_KOI8_R_russian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * russian_KOI8_R_create_env(void); 9 | extern void russian_KOI8_R_close_env(struct SN_env * z); 10 | 11 | extern int russian_KOI8_R_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_danish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * danish_UTF_8_create_env(void); 9 | extern void danish_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int danish_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_dutch.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * dutch_UTF_8_create_env(void); 9 | extern void dutch_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int dutch_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_english.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * english_UTF_8_create_env(void); 9 | extern void english_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int english_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_finnish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * finnish_UTF_8_create_env(void); 9 | extern void finnish_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int finnish_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_french.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * french_UTF_8_create_env(void); 9 | extern void french_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int french_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_german.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * german_UTF_8_create_env(void); 9 | extern void german_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int german_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_hungarian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * hungarian_UTF_8_create_env(void); 9 | extern void hungarian_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int hungarian_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_italian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * italian_UTF_8_create_env(void); 9 | extern void italian_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int italian_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_norwegian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * norwegian_UTF_8_create_env(void); 9 | extern void norwegian_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int norwegian_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_porter.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * porter_UTF_8_create_env(void); 9 | extern void porter_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int porter_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_portuguese.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * portuguese_UTF_8_create_env(void); 9 | extern void portuguese_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int portuguese_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_romanian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * romanian_UTF_8_create_env(void); 9 | extern void romanian_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int romanian_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_russian.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * russian_UTF_8_create_env(void); 9 | extern void russian_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int russian_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_spanish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * spanish_UTF_8_create_env(void); 9 | extern void spanish_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int spanish_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_swedish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * swedish_UTF_8_create_env(void); 9 | extern void swedish_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int swedish_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/libstemmer/src_c/stem_UTF_8_turkish.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by the Snowball to ANSI C compiler */ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern struct SN_env * turkish_UTF_8_create_env(void); 9 | extern void turkish_UTF_8_close_env(struct SN_env * z); 10 | 11 | extern int turkish_UTF_8_stem(struct SN_env * z); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/madpack/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # madpack source files 3 | # ------------------------------------------------------------------------------ 4 | 5 | # -- 1. Copy all *.py files ---------------------------------------------------- 6 | 7 | file(GLOB_RECURSE MADPACK_FILES 8 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 9 | "*.py" 10 | "*.m4" 11 | "changelist*.yaml" 12 | ) 13 | add_files(MADPACK_TARGET_FILES . "${CMAKE_CURRENT_BINARY_DIR}" ${MADPACK_FILES}) 14 | add_custom_target(madpackFiles ALL DEPENDS ${MADPACK_TARGET_FILES}) 15 | 16 | 17 | # -- 2. Install madpack files to $MADLIB_ROOT/madpack, set executable flags 18 | # for madpack.py --------------------------------------------------------- 19 | 20 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 21 | DESTINATION . 22 | USE_SOURCE_PERMISSIONS 23 | COMPONENT core 24 | FILES_MATCHING 25 | PATTERN "*.py" 26 | PATTERN "changelist*.yaml" 27 | PATTERN ".DS_Store" EXCLUDE 28 | ) 29 | 30 | -------------------------------------------------------------------------------- /src/madpack/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/madpack/__init__.py -------------------------------------------------------------------------------- /src/madpack/yaml/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006 Kirill Simonov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/madpack/yaml/loader.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['BaseLoader', 'SafeLoader', 'Loader'] 3 | 4 | from reader import * 5 | from scanner import * 6 | from parser import * 7 | from composer import * 8 | from constructor import * 9 | from resolver import * 10 | 11 | class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolver): 12 | 13 | def __init__(self, stream): 14 | Reader.__init__(self, stream) 15 | Scanner.__init__(self) 16 | Parser.__init__(self) 17 | Composer.__init__(self) 18 | BaseConstructor.__init__(self) 19 | BaseResolver.__init__(self) 20 | 21 | class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, Resolver): 22 | 23 | def __init__(self, stream): 24 | Reader.__init__(self, stream) 25 | Scanner.__init__(self) 26 | Parser.__init__(self) 27 | Composer.__init__(self) 28 | SafeConstructor.__init__(self) 29 | Resolver.__init__(self) 30 | 31 | class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver): 32 | 33 | def __init__(self, stream): 34 | Reader.__init__(self, stream) 35 | Scanner.__init__(self) 36 | Parser.__init__(self) 37 | Composer.__init__(self) 38 | Constructor.__init__(self) 39 | Resolver.__init__(self) 40 | 41 | -------------------------------------------------------------------------------- /src/madpack/yaml/nodes.py: -------------------------------------------------------------------------------- 1 | 2 | class Node(object): 3 | def __init__(self, tag, value, start_mark, end_mark): 4 | self.tag = tag 5 | self.value = value 6 | self.start_mark = start_mark 7 | self.end_mark = end_mark 8 | def __repr__(self): 9 | value = self.value 10 | #if isinstance(value, list): 11 | # if len(value) == 0: 12 | # value = '' 13 | # elif len(value) == 1: 14 | # value = '<1 item>' 15 | # else: 16 | # value = '<%d items>' % len(value) 17 | #else: 18 | # if len(value) > 75: 19 | # value = repr(value[:70]+u' ... ') 20 | # else: 21 | # value = repr(value) 22 | value = repr(value) 23 | return '%s(tag=%r, value=%s)' % (self.__class__.__name__, self.tag, value) 24 | 25 | class ScalarNode(Node): 26 | id = 'scalar' 27 | def __init__(self, tag, value, 28 | start_mark=None, end_mark=None, style=None): 29 | self.tag = tag 30 | self.value = value 31 | self.start_mark = start_mark 32 | self.end_mark = end_mark 33 | self.style = style 34 | 35 | class CollectionNode(Node): 36 | def __init__(self, tag, value, 37 | start_mark=None, end_mark=None, flow_style=None): 38 | self.tag = tag 39 | self.value = value 40 | self.start_mark = start_mark 41 | self.end_mark = end_mark 42 | self.flow_style = flow_style 43 | 44 | class SequenceNode(CollectionNode): 45 | id = 'sequence' 46 | 47 | class MappingNode(CollectionNode): 48 | id = 'mapping' 49 | 50 | -------------------------------------------------------------------------------- /src/modules/assoc_rules/assoc_rules.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file assoc_rules.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Given the text form of a closed frequent pattern (cfp), this function 9 | * generates the association rules for that pattern. We use text format 10 | * because text values are hash joinable. The output is a set of text 11 | * array. For example, assuming the input pattern is '1,2,3'. 12 | * The result rules: 13 | * array['1', '2,3'] 14 | * array['2', '1,3'] 15 | * array['3', '1,2'] 16 | * array['1,2', '3'] 17 | * array['1,3', '2'] 18 | * array['2,3', '1'] 19 | * Note that two meaningless rules will be excluded: 20 | * array['1,2,3', NULL] 21 | * array[NULL, '1,2,3'] 22 | * 23 | * @param arg 1 The text form of a closed frequent pattern. 24 | * @param arg 2 The number of items in the pattern. 25 | * 26 | * @return A set of text array. Each array has two elements, corresponding to 27 | * the left and right parts of an association rule. 28 | * 29 | */ 30 | DECLARE_SR_UDF(assoc_rules, gen_rules_from_cfp) 31 | 32 | -------------------------------------------------------------------------------- /src/modules/convex/convex.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * 3 | * @file convex.hpp 4 | * 5 | * @brief Umbrella header that includes all convex task headers 6 | * 7 | * -------------------------------------------------------------------------- */ 8 | 9 | #include "lmf_igd.hpp" 10 | #include "utils_regularization.hpp" 11 | //#include "ridge_newton.hpp" 12 | #include "linear_svm_igd.hpp" 13 | #include "mlp_igd.hpp" 14 | 15 | -------------------------------------------------------------------------------- /src/modules/convex/linear_svm_igd.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file linear_svm_igd.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Linear support vector machine (incremental gradient): Transition function 9 | */ 10 | DECLARE_UDF(convex, linear_svm_igd_transition) 11 | 12 | /** 13 | * @brief Linear support vector machine (incremental gradient): State merge function 14 | */ 15 | DECLARE_UDF(convex, linear_svm_igd_merge) 16 | 17 | /** 18 | * @brief Linear support vector machine (incremental gradient): Final function 19 | */ 20 | DECLARE_UDF(convex, linear_svm_igd_final) 21 | 22 | /** 23 | * @brief Linear support vector machine (incremental gradient): Difference in 24 | * log-likelihood between two transition states 25 | */ 26 | DECLARE_UDF(convex, internal_linear_svm_igd_distance) 27 | 28 | /** 29 | * @brief Linear support vector machine (incremental gradient): Convert 30 | * transition state to result tuple 31 | */ 32 | DECLARE_UDF(convex, internal_linear_svm_igd_result) 33 | 34 | -------------------------------------------------------------------------------- /src/modules/convex/lmf_igd.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file lmf_igd.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Low-rank matrix factorization (incremental gradient): Transition function 9 | */ 10 | DECLARE_UDF(convex, lmf_igd_transition) 11 | 12 | /** 13 | * @brief Low-rank matrix factorization (incremental gradient): State merge function 14 | */ 15 | DECLARE_UDF(convex, lmf_igd_merge) 16 | 17 | /** 18 | * @brief Low-rank matrix factorization (incremental gradient): Final function 19 | */ 20 | DECLARE_UDF(convex, lmf_igd_final) 21 | 22 | /** 23 | * @brief Low-rank matrix factorization (incremental gradient): Difference in 24 | * log-likelihood between two transition states 25 | */ 26 | DECLARE_UDF(convex, internal_lmf_igd_distance) 27 | 28 | /** 29 | * @brief Low-rank matrix factorization (incremental gradient): Convert 30 | * transition state to result tuple 31 | */ 32 | DECLARE_UDF(convex, internal_lmf_igd_result) 33 | 34 | -------------------------------------------------------------------------------- /src/modules/convex/type/dependent_variable.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file dependent_variable.hpp 4 | * 5 | * Types of dependent variable can be simply scalars that are offered by 6 | * internal, standard or third party libraries. Classes in this files are 7 | * for some special ones. 8 | * 9 | *//* ----------------------------------------------------------------------- */ 10 | 11 | #ifndef MADLIB_MODULES_CONVEX_TYPE_DEPENDENT_VARIABLE_HPP_ 12 | #define MADLIB_MODULES_CONVEX_TYPE_DEPENDENT_VARIABLE_HPP_ 13 | 14 | namespace madlib { 15 | 16 | namespace modules { 17 | 18 | namespace convex { 19 | 20 | } // namespace convex 21 | 22 | } // namespace modules 23 | 24 | } // namespace madlib 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/modules/convex/type/hessian.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file hessian.hpp 4 | * 5 | * This file contians classes of Hessian, which usually has 6 | * fields that maps to transition states for user-defined aggregates. 7 | * The necessity of these wrappers is to allow classes in algo/ and task/ to 8 | * have a type that they can template over. 9 | * 10 | *//* ----------------------------------------------------------------------- */ 11 | 12 | #ifndef MADLIB_MODULES_CONVEX_TYPE_HESSIAN_HPP_ 13 | #define MADLIB_MODULES_CONVEX_TYPE_HESSIAN_HPP_ 14 | 15 | #include 16 | 17 | namespace madlib { 18 | 19 | namespace modules { 20 | 21 | namespace convex { 22 | 23 | typedef 24 | HandleTraits >::MatrixTransparentHandleMap 25 | GLMHessian; 26 | 27 | } // namespace convex 28 | 29 | } // namespace modules 30 | 31 | } // namespace madlib 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /src/modules/convex/type/independent_variables.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file independent_variables.hpp 4 | * 5 | * Types of independent variables can be simply vectors/matrices that are 6 | * offered by standard or third party libraries. Classes in this files are 7 | * for some special ones. 8 | * 9 | *//* ----------------------------------------------------------------------- */ 10 | 11 | #ifndef MADLIB_MODULES_CONVEX_TYPE_INDEPENDENT_VARIABLES_HPP_ 12 | #define MADLIB_MODULES_CONVEX_TYPE_INDEPENDENT_VARIABLES_HPP_ 13 | 14 | namespace madlib { 15 | 16 | namespace modules { 17 | 18 | namespace convex { 19 | 20 | struct MatrixIndex { 21 | int32_t i; 22 | int32_t j; 23 | }; 24 | 25 | } // namespace convex 26 | 27 | } // namespace modules 28 | 29 | } // namespace madlib 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /src/modules/convex/utils_regularization.hpp: -------------------------------------------------------------------------------- 1 | 2 | DECLARE_UDF(convex, utils_var_scales_transition) 3 | DECLARE_UDF(convex, utils_var_scales_merge) 4 | DECLARE_UDF(convex, utils_var_scales_final) 5 | DECLARE_UDF(convex, __utils_var_scales_result) 6 | DECLARE_UDF(convex, utils_normalize_data) 7 | DECLARE_UDF(convex, utils_var_scales_non_zero_std_final) 8 | -------------------------------------------------------------------------------- /src/modules/crf/linear_crf.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file linear_crf.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | /** 7 | * @brief Linear-chain CRF (L-BFGS step): Transition function 8 | */ 9 | DECLARE_UDF(crf, lincrf_lbfgs_step_transition) 10 | 11 | /** 12 | * @brief Linear-chain CRF (L-BFGS step): State merge function 13 | */ 14 | DECLARE_UDF(crf, lincrf_lbfgs_step_merge_states) 15 | 16 | /** 17 | * @brief Linear-chain CRF (L-BFGS step): Final function 18 | */ 19 | DECLARE_UDF(crf, lincrf_lbfgs_step_final) 20 | 21 | /** 22 | * @brief Linear-chain CRF (L-BFGS) Return status which indicates whether L-BFGS converge or not 23 | */ 24 | DECLARE_UDF(crf, internal_lincrf_lbfgs_converge) 25 | 26 | /** 27 | * @brief Linear-chain CRF (L-BFGS): Convert transition state to 28 | * result tuple 29 | */ 30 | DECLARE_UDF(crf, internal_lincrf_lbfgs_result) 31 | 32 | -------------------------------------------------------------------------------- /src/modules/crf/viterbi.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file viterbi.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | /** 7 | * @brief Viterbi inferencing for best label sequence. 8 | */ 9 | DECLARE_UDF(crf, vcrf_top1_label) 10 | -------------------------------------------------------------------------------- /src/modules/declarations.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file declarations.hpp 4 | * 5 | * @brief Declaration of all functions. 6 | * 7 | *//* ----------------------------------------------------------------------- */ 8 | 9 | #include "linalg/linalg.hpp" 10 | #include "prob/prob.hpp" 11 | #include "regress/regress.hpp" 12 | #include "glm/glm.hpp" 13 | #include "glm/multi_response_glm.hpp" 14 | #include "glm/ordinal.hpp" 15 | #include "linear_systems/linear_systems.hpp" 16 | #include "sample/sample.hpp" 17 | #include "stats/stats.hpp" 18 | #include "convex/convex.hpp" 19 | #include "crf/linear_crf.hpp" 20 | #include "crf/viterbi.hpp" 21 | #include "assoc_rules/assoc_rules.hpp" 22 | #include "lda/lda.hpp" 23 | #include "elastic_net/elastic_net.hpp" 24 | #include "linalg/matrix_ops.hpp" 25 | #include "linalg/matrix_decomp.hpp" 26 | #include "linalg/svd.hpp" 27 | #include "tsa/arima.hpp" 28 | #include "recursive_partitioning/decision_tree.hpp" 29 | #include "recursive_partitioning/random_forest.hpp" 30 | #include "recursive_partitioning/feature_encoding.hpp" 31 | #include "utilities/utilities.hpp" 32 | -------------------------------------------------------------------------------- /src/modules/elastic_net/elastic_net.hpp: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------------ 2 | * 3 | * @file elastic_net.hpp 4 | * 5 | * @brief Umbrella header that includes all elastic_net task headers 6 | * 7 | * ------------------------------------------------------------------------ */ 8 | 9 | #include "elastic_net_gaussian_igd.hpp" 10 | #include "elastic_net_gaussian_fista.hpp" 11 | #include "elastic_net_binomial_igd.hpp" 12 | #include "elastic_net_binomial_fista.hpp" 13 | #include "elastic_net_utils.hpp" 14 | -------------------------------------------------------------------------------- /src/modules/elastic_net/elastic_net_binomial_fista.hpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Elastic net regularization for logistic regression using FISTA optimizer 4 | */ 5 | 6 | /** 7 | * @brief Logistic regression (incremental gradient): Transition function 8 | */ 9 | DECLARE_UDF(elastic_net, binomial_fista_transition) 10 | 11 | /** 12 | * @brief Logistic regression (incremental gradient): State merge function 13 | */ 14 | DECLARE_UDF(elastic_net, binomial_fista_merge) 15 | 16 | /** 17 | * @brief Logistic regression (incremental gradient): Final function 18 | */ 19 | DECLARE_UDF(elastic_net, binomial_fista_final) 20 | 21 | /** 22 | * @brief Logistic regression (incremental gradient): measure the difference 23 | * between two consecutive states 24 | */ 25 | DECLARE_UDF(elastic_net, __binomial_fista_state_diff) 26 | 27 | /** 28 | * @brief Logistic regression (incremental gradient): Convert 29 | * transition state to result tuple 30 | */ 31 | DECLARE_UDF(elastic_net, __binomial_fista_result) 32 | 33 | -------------------------------------------------------------------------------- /src/modules/elastic_net/elastic_net_binomial_igd.hpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Elastic net regularization for logistic regression using IGD optimizer 4 | */ 5 | 6 | /** 7 | * @brief Logistic regression (incremental gradient): Transition function 8 | */ 9 | DECLARE_UDF(elastic_net, binomial_igd_transition) 10 | 11 | /** 12 | * @brief Logistic regression (incremental gradient): State merge function 13 | */ 14 | DECLARE_UDF(elastic_net, binomial_igd_merge) 15 | 16 | /** 17 | * @brief Logistic regression (incremental gradient): Final function 18 | */ 19 | DECLARE_UDF(elastic_net, binomial_igd_final) 20 | 21 | /** 22 | * @brief Logistic regression (incremental gradient): measure the difference 23 | * between two consecutive states 24 | */ 25 | DECLARE_UDF(elastic_net, __binomial_igd_state_diff) 26 | 27 | /** 28 | * @brief Logistic regression (incremental gradient): Convert 29 | * transition state to result tuple 30 | */ 31 | DECLARE_UDF(elastic_net, __binomial_igd_result) 32 | -------------------------------------------------------------------------------- /src/modules/elastic_net/elastic_net_gaussian_fista.hpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Elastic net regulation for linear regression using FISTA optimizer 4 | */ 5 | 6 | /** 7 | * @brief Linear regression (incremental gradient): Transition function 8 | */ 9 | DECLARE_UDF(elastic_net, gaussian_fista_transition) 10 | 11 | /** 12 | * @brief Linear regression (incremental gradient): State merge function 13 | */ 14 | DECLARE_UDF(elastic_net, gaussian_fista_merge) 15 | 16 | /** 17 | * @brief Linear regression (incremental gradient): Final function 18 | */ 19 | DECLARE_UDF(elastic_net, gaussian_fista_final) 20 | 21 | /** 22 | * @brief Linear regression (incremental gradient): Difference in 23 | * log-likelihood between two transition states 24 | */ 25 | DECLARE_UDF(elastic_net, __gaussian_fista_state_diff) 26 | 27 | /** 28 | * @brief Linear regression (incremental gradient): Convert 29 | * transition state to result tuple 30 | */ 31 | DECLARE_UDF(elastic_net, __gaussian_fista_result) 32 | 33 | // /** 34 | // * @brief (incremental gradient): Prediction 35 | // */ 36 | // DECLARE_UDF(elastic_net, gaussian_igd_predict) 37 | -------------------------------------------------------------------------------- /src/modules/elastic_net/elastic_net_gaussian_igd.hpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Elastic net regulation for linear regression using IGD optimizer 4 | */ 5 | 6 | /** 7 | * @brief Linear regression (incremental gradient): Transition function 8 | */ 9 | DECLARE_UDF(elastic_net, gaussian_igd_transition) 10 | 11 | /** 12 | * @brief Linear regression (incremental gradient): State merge function 13 | */ 14 | DECLARE_UDF(elastic_net, gaussian_igd_merge) 15 | 16 | /** 17 | * @brief Linear regression (incremental gradient): Final function 18 | */ 19 | DECLARE_UDF(elastic_net, gaussian_igd_final) 20 | 21 | /** 22 | * @brief Linear regression (incremental gradient): Difference in 23 | * log-likelihood between two transition states 24 | */ 25 | DECLARE_UDF(elastic_net, __gaussian_igd_state_diff) 26 | 27 | /** 28 | * @brief Linear regression (incremental gradient): Convert 29 | * transition state to result tuple 30 | */ 31 | DECLARE_UDF(elastic_net, __gaussian_igd_result) 32 | 33 | // /** 34 | // * @brief (incremental gradient): Prediction 35 | // */ 36 | // DECLARE_UDF(elastic_net, gaussian_igd_predict) 37 | -------------------------------------------------------------------------------- /src/modules/elastic_net/elastic_net_utils.hpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Utility functions for elastic net 4 | */ 5 | 6 | DECLARE_UDF(elastic_net, __elastic_net_gaussian_predict) 7 | 8 | // compute the True/False prediction 9 | DECLARE_UDF(elastic_net, __elastic_net_binomial_predict) 10 | 11 | // compute probabilities for class True 12 | DECLARE_UDF(elastic_net, __elastic_net_binomial_prob) 13 | 14 | // compute log-likelihood 15 | DECLARE_UDF(elastic_net, __elastic_net_binomial_loglikelihood) 16 | 17 | -------------------------------------------------------------------------------- /src/modules/glm/multi_response_glm.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file multi_response_glm.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Multivariate response Generalized linear model: Transition function 9 | */ 10 | DECLARE_UDF(glm, multi_response_glm_multinom_logit_transition) 11 | 12 | /** 13 | * @brief Multivariate response Generalized linear model: State merge function 14 | */ 15 | DECLARE_UDF(glm, multi_response_glm_merge_states) 16 | 17 | /** 18 | * @brief Multivariate response Generalized linear model: Final function 19 | */ 20 | DECLARE_UDF(glm, multi_response_glm_final) 21 | 22 | /** 23 | * @brief Multivariate response Generalized linear model: Result function 24 | */ 25 | DECLARE_UDF(glm, multi_response_glm_result_z_stats) 26 | 27 | /** 28 | * @brief Multivariate response Generalized linear model: Distance function 29 | */ 30 | DECLARE_UDF(glm, multi_response_glm_loglik_diff) 31 | -------------------------------------------------------------------------------- /src/modules/glm/ordinal.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file ordinal.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Ordinal linear model: Transition function 9 | */ 10 | DECLARE_UDF(glm, ordinal_logit_transition) 11 | DECLARE_UDF(glm, ordinal_probit_transition) 12 | 13 | /** 14 | * @brief Ordinal linear model: State merge function 15 | */ 16 | DECLARE_UDF(glm, ordinal_merge_states) 17 | 18 | /** 19 | * @brief Ordinal linear model: Final function 20 | */ 21 | DECLARE_UDF(glm, ordinal_final) 22 | 23 | /** 24 | * @brief Ordinal linear model: Result function 25 | */ 26 | DECLARE_UDF(glm, ordinal_result) 27 | 28 | /** 29 | * @brief Ordinal linear model: Distance function 30 | */ 31 | DECLARE_UDF(glm, ordinal_loglik_diff) 32 | -------------------------------------------------------------------------------- /src/modules/lda/lda.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file lda.hpp 4 | * 5 | * @brief Parallel Latent Dirichlet Allocation 6 | * 7 | *//* ----------------------------------------------------------------------- */ 8 | 9 | DECLARE_UDF(lda, lda_random_assign) 10 | DECLARE_UDF(lda, lda_gibbs_sample) 11 | 12 | DECLARE_UDF(lda, lda_count_topic_sfunc) 13 | DECLARE_UDF(lda, lda_count_topic_prefunc) 14 | 15 | DECLARE_UDF(lda, lda_transpose) 16 | DECLARE_SR_UDF(lda, lda_unnest_transpose) 17 | DECLARE_SR_UDF(lda, lda_unnest) 18 | 19 | DECLARE_UDF(lda, lda_perplexity_sfunc) 20 | DECLARE_UDF(lda, lda_perplexity_prefunc) 21 | DECLARE_UDF(lda, lda_perplexity_ffunc) 22 | 23 | DECLARE_UDF(lda, lda_check_count_ceiling) 24 | 25 | DECLARE_UDF(lda, l1_norm_with_smoothing) 26 | DECLARE_UDF(lda, lda_parse_model) 27 | -------------------------------------------------------------------------------- /src/modules/linalg/average.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file average.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Average of vectors: Transition function 9 | */ 10 | DECLARE_UDF(linalg, avg_vector_transition) 11 | 12 | /** 13 | * @brief Average of vectors: State merge function 14 | */ 15 | DECLARE_UDF(linalg, avg_vector_merge) 16 | 17 | /** 18 | * @brief Average of vectors: Final function 19 | */ 20 | DECLARE_UDF(linalg, avg_vector_final) 21 | 22 | 23 | /** 24 | * @brief Normalized average of vectors: Transition function 25 | */ 26 | DECLARE_UDF(linalg, normalized_avg_vector_transition) 27 | 28 | /** 29 | * @brief Normalized average of vectors: Final function 30 | */ 31 | DECLARE_UDF(linalg, normalized_avg_vector_final) 32 | -------------------------------------------------------------------------------- /src/modules/linalg/crossprod.hpp: -------------------------------------------------------------------------------- 1 | 2 | DECLARE_UDF(linalg, __pivotalr_crossprod_transition) 3 | DECLARE_UDF(linalg, __pivotalr_crossprod_merge) 4 | DECLARE_UDF(linalg, __pivotalr_crossprod_sym_transition) 5 | -------------------------------------------------------------------------------- /src/modules/linalg/dim_conversion.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file dim_conversion.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | DECLARE_UDF(linalg, array_to_1d) 8 | DECLARE_UDF(linalg, array_to_2d) 9 | 10 | /** 11 | * @brief a row(i) function for 2-D array 12 | */ 13 | DECLARE_UDF(linalg, get_row_from_2d_array) 14 | 15 | /** 16 | * @brief a col(i) function for 2-D array 17 | */ 18 | DECLARE_UDF(linalg, get_col_from_2d_array) 19 | 20 | /** 21 | * @brief deconstruct a 2-D MxN array to a M-row N-col table 22 | */ 23 | DECLARE_SR_UDF(linalg, deconstruct_2d_array) 24 | 25 | /** 26 | * @brief deconstruct lower-triangle of a 2-D array to to a M-col M-row table 27 | */ 28 | DECLARE_SR_UDF(linalg, deconstruct_lower_triangle) 29 | -------------------------------------------------------------------------------- /src/modules/linalg/linalg.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file linalg.hpp 4 | * 5 | * @brief Umbrella header that includes all linear-algebra operations 6 | * 7 | *//* ----------------------------------------------------------------------- */ 8 | 9 | #include "average.hpp" 10 | #include "matrix_agg.hpp" 11 | #include "metric.hpp" 12 | #include "crossprod.hpp" 13 | #include "dim_conversion.hpp" 14 | -------------------------------------------------------------------------------- /src/modules/linalg/matrix_agg.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file matrix_agg.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Aggregate matrix from columns: Transition function 9 | */ 10 | DECLARE_UDF(linalg, matrix_agg_transition) 11 | 12 | /** 13 | * @brief Aggregate matrix from columns: Final function 14 | */ 15 | DECLARE_UDF(linalg, matrix_agg_final) 16 | 17 | /** 18 | * @brief Return the column of a matrix 19 | */ 20 | DECLARE_UDF(linalg, matrix_column) 21 | -------------------------------------------------------------------------------- /src/modules/linalg/matrix_decomp.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file matrix_decomp.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Aggregate matrix from dense representation: transition 9 | */ 10 | DECLARE_UDF(linalg, matrix_compose_dense_transition) 11 | 12 | /** 13 | * @brief Aggregate matrix from sparse representation: transition 14 | */ 15 | DECLARE_UDF(linalg, matrix_compose_sparse_transition) 16 | 17 | /** 18 | * @brief Aggregate matrix: merge 19 | */ 20 | DECLARE_UDF(linalg, matrix_compose_merge) 21 | 22 | /** 23 | * @brief Return the inverse of a matrix 24 | */ 25 | DECLARE_UDF(linalg, matrix_inv) 26 | 27 | /** 28 | * @brief Return the eigen values of a matrix 29 | */ 30 | DECLARE_UDF(linalg, matrix_eigen) 31 | 32 | /** 33 | * @brief Return the standard cholesky decomposition of a matrix 34 | */ 35 | DECLARE_UDF(linalg, matrix_cholesky) 36 | 37 | /** 38 | * @brief Return the standard qr decomposition of a matrix 39 | */ 40 | DECLARE_UDF(linalg, matrix_qr) 41 | 42 | /** 43 | * @brief Return the rank of a matrix 44 | */ 45 | DECLARE_UDF(linalg, matrix_rank) 46 | 47 | /** 48 | * @brief Return the LU decomposition of a matrix 49 | */ 50 | DECLARE_UDF(linalg, matrix_lu) 51 | 52 | /** 53 | * @brief Return the nuclear norm of a matrix 54 | */ 55 | DECLARE_UDF(linalg, matrix_nuclear_norm) 56 | 57 | /** 58 | * @brief Return the generalized inverse of a matrix 59 | */ 60 | DECLARE_UDF(linalg, matrix_pinv) 61 | -------------------------------------------------------------------------------- /src/modules/linalg/matrix_ops.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file matrix_ops.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | DECLARE_UDF(linalg, matrix_mem_mult) 8 | // DECLARE_UDF(linalg, matrix_vec_mem_mult) 9 | DECLARE_UDF(linalg, matrix_mem_trans) 10 | 11 | DECLARE_UDF(linalg, matrix_densify_sfunc) 12 | DECLARE_UDF(linalg, matrix_blockize_sfunc) 13 | DECLARE_UDF(linalg, matrix_unblockize_sfunc) 14 | DECLARE_UDF(linalg, matrix_mem_sum_sfunc) 15 | 16 | DECLARE_UDF(linalg, rand_block) 17 | DECLARE_UDF(linalg, rand_vector) 18 | DECLARE_UDF(linalg, uniform_vector) 19 | DECLARE_UDF(linalg, bernoulli_vector) 20 | DECLARE_UDF(linalg, normal_vector) 21 | DECLARE_UDF(linalg, matrix_vec_mult_in_mem_2d) 22 | DECLARE_UDF(linalg, matrix_vec_mult_in_mem_1d) 23 | DECLARE_UDF(linalg, row_fold) 24 | DECLARE_SR_UDF(linalg, row_split) 25 | DECLARE_SR_UDF(linalg, unnest_block) 26 | -------------------------------------------------------------------------------- /src/modules/linalg/svd.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file svd.hpp 4 | * 5 | * @brief Singular Value Decomposition 6 | * 7 | *//* ----------------------------------------------------------------------- */ 8 | 9 | DECLARE_UDF(linalg, svd_unit_vector) 10 | 11 | DECLARE_UDF(linalg, svd_lanczos_sfunc) 12 | DECLARE_UDF(linalg, svd_lanczos_prefunc) 13 | 14 | DECLARE_UDF(linalg, svd_lanczos_pvec) 15 | DECLARE_UDF(linalg, svd_lanczos_qvec) 16 | 17 | DECLARE_UDF(linalg, svd_gram_schmidt_orthogonalize_sfunc) 18 | DECLARE_UDF(linalg, svd_gram_schmidt_orthogonalize_ffunc) 19 | DECLARE_UDF(linalg, svd_gram_schmidt_orthogonalize_prefunc) 20 | 21 | DECLARE_UDF(linalg, svd_decompose_bidiagonal_sfunc) 22 | DECLARE_UDF(linalg, svd_decompose_bidiagonal_ffunc) 23 | DECLARE_UDF(linalg, svd_decompose_bidiagonal_prefunc) 24 | 25 | DECLARE_UDF(linalg, svd_block_lanczos_sfunc) 26 | DECLARE_UDF(linalg, svd_sparse_lanczos_sfunc) 27 | DECLARE_UDF(linalg, svd_decompose_bidiag) 28 | 29 | DECLARE_UDF(linalg, svd_vec_mult_matrix) 30 | DECLARE_SR_UDF(linalg, svd_vec_trans_mult_matrix) 31 | -------------------------------------------------------------------------------- /src/modules/linear_systems/dense_linear_systems.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file dense_linear_systems.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Direct Dense Linear Systems: Transition function 9 | */ 10 | DECLARE_UDF(linear_systems, dense_direct_linear_system_transition) 11 | 12 | /** 13 | * @brief Direct Dense Linear Systems: State Merge function 14 | */ 15 | DECLARE_UDF(linear_systems, dense_direct_linear_system_merge_states) 16 | 17 | /** 18 | * @brief Direct Dense Linear Systems: Final function 19 | */ 20 | DECLARE_UDF(linear_systems, dense_direct_linear_system_final) 21 | 22 | 23 | 24 | /** 25 | * @brief Direct Dense Linear Systems: Transition function 26 | */ 27 | DECLARE_UDF(linear_systems, dense_residual_norm_transition) 28 | 29 | /** 30 | * @brief Direct Dense Linear Systems: State Merge function 31 | */ 32 | DECLARE_UDF(linear_systems, dense_residual_norm_merge_states) 33 | 34 | /** 35 | * @brief Direct Dense Linear Systems: Final function 36 | */ 37 | DECLARE_UDF(linear_systems, dense_residual_norm_final) 38 | -------------------------------------------------------------------------------- /src/modules/linear_systems/linear_systems.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * 3 | * @file linear_systems.hpp 4 | * 5 | * @brief Umbrella header that includes all linear systems headers 6 | * 7 | * -------------------------------------------------------------------------- */ 8 | 9 | #include "dense_linear_systems.hpp" 10 | #include "sparse_linear_systems.hpp" 11 | -------------------------------------------------------------------------------- /src/modules/linear_systems/sparse_linear_systems.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file sparse_linear_systems.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Direct sparse Linear Systems: Transition function 9 | */ 10 | DECLARE_UDF(linear_systems, sparse_direct_linear_system_transition) 11 | 12 | /** 13 | * @brief Direct sparse Linear Systems: State Merge function 14 | */ 15 | DECLARE_UDF(linear_systems, sparse_direct_linear_system_merge_states) 16 | 17 | /** 18 | * @brief Direct sparse Linear Systems: Final function 19 | */ 20 | DECLARE_UDF(linear_systems, sparse_direct_linear_system_final) 21 | 22 | 23 | 24 | /** 25 | * @brief inmem_iterative sparse Linear Systems: Transition function 26 | */ 27 | DECLARE_UDF(linear_systems, sparse_inmem_iterative_linear_system_transition) 28 | 29 | /** 30 | * @brief inmem_iterative sparse Linear Systems: State Merge function 31 | */ 32 | DECLARE_UDF(linear_systems, sparse_inmem_iterative_linear_system_merge_states) 33 | 34 | /** 35 | * @brief inmem_iterative sparse Linear Systems: Final function 36 | */ 37 | DECLARE_UDF(linear_systems, sparse_inmem_iterative_linear_system_final) 38 | 39 | -------------------------------------------------------------------------------- /src/modules/prob/prob.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * 3 | * @file prob.hpp 4 | * 5 | * @brief Umbrella header that includes all probability functions 6 | * 7 | * -------------------------------------------------------------------------- */ 8 | 9 | #include "boost.hpp" 10 | #include "kolmogorov.hpp" 11 | #include "student.hpp" 12 | -------------------------------------------------------------------------------- /src/modules/prob/student.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file student.cpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #include 8 | 9 | #include "student.hpp" 10 | 11 | namespace madlib { 12 | 13 | namespace modules { 14 | 15 | namespace prob { 16 | 17 | /** 18 | * @brief Student's t cumulative distribution function: In-database interface 19 | */ 20 | AnyType 21 | students_t_cdf::run(AnyType &args) { 22 | return prob::cdf( 23 | students_t(args[1].getAs()), 24 | args[0].getAs() 25 | ); 26 | } 27 | 28 | /** 29 | * @brief Student's t probability density function: In-database interface 30 | */ 31 | AnyType 32 | students_t_pdf::run(AnyType &args) { 33 | return prob::pdf( 34 | students_t(args[1].getAs()), 35 | args[0].getAs() 36 | ); 37 | } 38 | 39 | /** 40 | * @brief Student's t quantile function: In-database interface 41 | */ 42 | AnyType 43 | students_t_quantile::run(AnyType &args) { 44 | return prob::quantile( 45 | students_t(args[1].getAs()), 46 | args[0].getAs() 47 | ); 48 | } 49 | 50 | } // namespace prob 51 | 52 | } // namespace modules 53 | 54 | } // namespace madlib 55 | -------------------------------------------------------------------------------- /src/modules/recursive_partitioning/decision_tree.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file decision_tree.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | DECLARE_UDF(recursive_partitioning, initialize_decision_tree) 8 | 9 | DECLARE_UDF(recursive_partitioning, compute_leaf_stats_transition) 10 | DECLARE_UDF(recursive_partitioning, compute_leaf_stats_merge) 11 | DECLARE_UDF(recursive_partitioning, dt_apply) 12 | 13 | DECLARE_UDF(recursive_partitioning, compute_surr_stats_transition) 14 | DECLARE_UDF(recursive_partitioning, dt_surr_apply) 15 | 16 | DECLARE_UDF(recursive_partitioning, print_decision_tree) 17 | DECLARE_UDF(recursive_partitioning, compute_variable_importance) 18 | DECLARE_UDF(recursive_partitioning, predict_dt_response) 19 | DECLARE_UDF(recursive_partitioning, predict_dt_prob) 20 | 21 | DECLARE_UDF(recursive_partitioning, display_decision_tree) 22 | DECLARE_UDF(recursive_partitioning, display_decision_tree_surrogate) 23 | DECLARE_UDF(recursive_partitioning, display_text_tree) 24 | 25 | DECLARE_UDF(recursive_partitioning, convert_to_rpart_format) 26 | DECLARE_UDF(recursive_partitioning, get_split_thresholds) 27 | DECLARE_UDF(recursive_partitioning, prune_and_cplist) 28 | 29 | DECLARE_UDF(recursive_partitioning, convert_to_random_forest_format) 30 | -------------------------------------------------------------------------------- /src/modules/recursive_partitioning/feature_encoding.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file feature_encoding.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | DECLARE_UDF(recursive_partitioning, dst_compute_con_splits_transition) 8 | DECLARE_UDF(recursive_partitioning, dst_compute_con_splits_final) 9 | 10 | DECLARE_UDF(recursive_partitioning, dst_compute_entropy_transition) 11 | DECLARE_UDF(recursive_partitioning, dst_compute_entropy_merge) 12 | DECLARE_UDF(recursive_partitioning, dst_compute_entropy_final) 13 | 14 | DECLARE_UDF(recursive_partitioning, map_catlevel_to_int) 15 | DECLARE_UDF(recursive_partitioning, print_con_splits) 16 | 17 | DECLARE_UDF(recursive_partitioning, get_bin_value_by_index) 18 | DECLARE_UDF(recursive_partitioning, get_bin_index_by_value) 19 | DECLARE_UDF(recursive_partitioning, get_bin_indices_by_values) 20 | -------------------------------------------------------------------------------- /src/modules/recursive_partitioning/random_forest.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file random_forest.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | 8 | DECLARE_UDF(recursive_partitioning, rf_cat_imp_score) 9 | DECLARE_UDF(recursive_partitioning, rf_con_imp_score) 10 | DECLARE_UDF(recursive_partitioning, normalize_sum_array) 11 | -------------------------------------------------------------------------------- /src/modules/regress/clustered_errors.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* ----------------------------------------------------------------------- *//** 3 | * 4 | * @file clustered_errors.hpp 5 | * 6 | *//* ----------------------------------------------------------------------- */ 7 | 8 | // transition, merge and final functions for linear regression clustered errors 9 | 10 | DECLARE_UDF(regress, __clustered_err_lin_transition) 11 | 12 | DECLARE_UDF(regress, __clustered_err_lin_merge) 13 | 14 | DECLARE_UDF(regress, __clustered_err_lin_final) 15 | 16 | DECLARE_UDF(regress, clustered_lin_compute_stats) 17 | 18 | DECLARE_UDF(regress, __clustered_err_log_transition) 19 | 20 | DECLARE_UDF(regress, __clustered_err_log_merge) 21 | 22 | DECLARE_UDF(regress, __clustered_err_log_final) 23 | 24 | DECLARE_UDF(regress, clustered_log_compute_stats) 25 | 26 | 27 | DECLARE_UDF(regress, __clustered_err_mlog_transition) 28 | 29 | DECLARE_UDF(regress, __clustered_err_mlog_merge) 30 | 31 | DECLARE_UDF(regress, __clustered_err_mlog_final) 32 | 33 | DECLARE_UDF(regress, clustered_mlog_compute_stats) 34 | 35 | -------------------------------------------------------------------------------- /src/modules/regress/linear.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file linear.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Linear regression: Transition function 9 | */ 10 | DECLARE_UDF(regress, linregr_transition) 11 | 12 | /** 13 | * @brief Linear regression: State merge function 14 | */ 15 | DECLARE_UDF(regress, linregr_merge_states) 16 | 17 | /** 18 | * @brief Linear regression: Final function 19 | */ 20 | DECLARE_UDF(regress, linregr_final) 21 | 22 | /** 23 | * @brief Test for hetereskedasticity: Transition function 24 | */ 25 | DECLARE_UDF(regress, hetero_linregr_transition) 26 | 27 | /** 28 | * @brief Test for hetereskedasticity: State merge function 29 | */ 30 | DECLARE_UDF(regress, hetero_linregr_merge_states) 31 | 32 | /** 33 | * @brief Test for hetereskedasticity: Final function 34 | */ 35 | DECLARE_UDF(regress, hetero_linregr_final) 36 | 37 | 38 | /** 39 | * @brief Robust Linear regression: Transition function 40 | */ 41 | DECLARE_UDF(regress, robust_linregr_transition) 42 | 43 | /** 44 | * @brief Robust Linear regression: State merge function 45 | */ 46 | DECLARE_UDF(regress, robust_linregr_merge_states) 47 | 48 | /** 49 | * @brief Robust Linear regression: Final function 50 | */ 51 | DECLARE_UDF(regress, robust_linregr_final) 52 | -------------------------------------------------------------------------------- /src/modules/regress/marginal.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @brief Marginal Effects Logistic regression step: Transition function 3 | */ 4 | DECLARE_UDF(regress, margins_logregr_int_transition) 5 | 6 | /** 7 | * @brief Marginal effects Logistic regression: State merge function 8 | */ 9 | DECLARE_UDF(regress, margins_logregr_int_merge) 10 | 11 | /** 12 | * @brief Marginal Effects Logistic regression: Final function 13 | */ 14 | DECLARE_UDF(regress, margins_logregr_int_final) 15 | 16 | /** 17 | * @brief Marginal Effects Linear regression step: Transition function 18 | */ 19 | DECLARE_UDF(regress, margins_linregr_int_transition) 20 | 21 | /** 22 | * @brief Marginal effects linear regression: State merge function 23 | */ 24 | DECLARE_UDF(regress, margins_linregr_int_merge) 25 | 26 | /** 27 | * @brief Marginal Effects linear regression: Final function 28 | */ 29 | DECLARE_UDF(regress, margins_linregr_int_final) 30 | 31 | /** 32 | * @brief Marginal Effects multinomial logistic regression step: Transition function 33 | */ 34 | DECLARE_UDF(regress, margins_mlogregr_int_transition) 35 | 36 | /** 37 | * @brief Marginal effects multinomial logistic regression: State merge function 38 | */ 39 | DECLARE_UDF(regress, margins_mlogregr_int_merge) 40 | 41 | /** 42 | * @brief Marginal Effects multinomial logistic regression: Final function 43 | */ 44 | DECLARE_UDF(regress, margins_mlogregr_int_final) 45 | -------------------------------------------------------------------------------- /src/modules/regress/mlogr_margins.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @brief Marginal Effects Logistic regression step: Transition function 3 | */ 4 | DECLARE_UDF(regress, mlogregr_marginal_step_transition) 5 | 6 | /** 7 | * @brief Marginal effects Logistic regression step: State merge function 8 | */ 9 | DECLARE_UDF(regress, mlogregr_marginal_step_merge_states) 10 | 11 | /** 12 | * @brief Marginal Effects Logistic regression step: Final function 13 | */ 14 | DECLARE_UDF(regress, mlogregr_marginal_step_final) 15 | -------------------------------------------------------------------------------- /src/modules/regress/regress.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * 3 | * @file regress.hpp 4 | * 5 | * @brief Umbrella header that includes all linear/logistic regression headers 6 | * 7 | * -------------------------------------------------------------------------- */ 8 | 9 | #include "linear.hpp" 10 | #include "clustered_errors.hpp" 11 | #include "logistic.hpp" 12 | #include "marginal.hpp" 13 | #include "multilogistic.hpp" 14 | #include "mlogr_margins.hpp" 15 | -------------------------------------------------------------------------------- /src/modules/sample/random_process.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file random_process.cpp 4 | * 5 | * @brief Generate a random number from a random process 6 | * 7 | *//* ----------------------------------------------------------------------- */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "random_process.hpp" 15 | 16 | using boost::poisson_distribution; 17 | using boost::gamma_distribution; 18 | using boost::variate_generator; 19 | 20 | namespace madlib { 21 | 22 | namespace modules { 23 | 24 | namespace sample { 25 | 26 | /** 27 | * @brief Poisson distributed random variables given mean 28 | */ 29 | AnyType 30 | poisson_random::run(AnyType &args) { 31 | double mean = args[0].getAs(); 32 | poisson_distribution pdist(mean); 33 | NativeRandomNumberGenerator generator; 34 | variate_generator > 35 | rvt(generator, pdist); 36 | 37 | return rvt(); 38 | } 39 | 40 | /** 41 | * @brief Gamma distributed random variables given alpha 42 | */ 43 | AnyType 44 | gamma_random::run(AnyType &args) { 45 | double alpha = args[0].getAs(); 46 | gamma_distribution<> gdist(alpha); 47 | NativeRandomNumberGenerator generator; 48 | variate_generator > 49 | rvt(generator, gdist); 50 | 51 | return rvt(); 52 | } 53 | 54 | } // namespace sample 55 | 56 | } // namespace modules 57 | 58 | } // namespace madlib 59 | -------------------------------------------------------------------------------- /src/modules/sample/random_process.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file random_process.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Poisson random process 9 | */ 10 | DECLARE_UDF(sample, poisson_random) 11 | DECLARE_UDF(sample, gamma_random) 12 | -------------------------------------------------------------------------------- /src/modules/sample/sample.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * 3 | * @file sample.hpp 4 | * 5 | * @brief Umbrella header that includes all sampling headers 6 | * 7 | * -------------------------------------------------------------------------- */ 8 | 9 | #include "weighted_sample.hpp" 10 | #include "random_process.hpp" 11 | -------------------------------------------------------------------------------- /src/modules/sample/weighted_sample.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file weighted_sample.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Weighted random sample: Transition function 9 | */ 10 | DECLARE_UDF(sample, weighted_sample_transition_int64) 11 | DECLARE_UDF(sample, weighted_sample_transition_vector) 12 | 13 | /** 14 | * @brief Weighted random sample: State merge function 15 | */ 16 | DECLARE_UDF(sample, weighted_sample_merge_int64) 17 | DECLARE_UDF(sample, weighted_sample_merge_vector) 18 | 19 | /** 20 | * @brief Weighted random sample: Final function 21 | */ 22 | DECLARE_UDF(sample, weighted_sample_final_int64) 23 | DECLARE_UDF(sample, weighted_sample_final_vector) 24 | 25 | /** 26 | * @brief In-memory weighted sample, returning index 27 | */ 28 | DECLARE_UDF(sample, index_weighted_sample) 29 | -------------------------------------------------------------------------------- /src/modules/stats/chi_squared_test.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file chi_squared_test.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Pearson's chi-squared test: Transition function 9 | */ 10 | DECLARE_UDF(stats, chi2_gof_test_transition) 11 | 12 | /** 13 | * @brief Pearson's chi-squared test: State merge function 14 | */ 15 | DECLARE_UDF(stats, chi2_gof_test_merge_states) 16 | 17 | /** 18 | * @brief Pearson's chi-squared test: Final function 19 | */ 20 | DECLARE_UDF(stats, chi2_gof_test_final) 21 | -------------------------------------------------------------------------------- /src/modules/stats/clustered_variance_coxph.hpp: -------------------------------------------------------------------------------- 1 | 2 | DECLARE_UDF(stats, coxph_a_b_transition) 3 | DECLARE_UDF(stats, coxph_a_b_merge) 4 | DECLARE_UDF(stats, coxph_a_b_final) 5 | 6 | DECLARE_UDF(stats, coxph_compute_w) 7 | DECLARE_UDF(stats, coxph_compute_clustered_stats) 8 | -------------------------------------------------------------------------------- /src/modules/stats/correlation.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file correlation.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief correlatin function transistion function 9 | */ 10 | DECLARE_UDF(stats, correlation_transition) 11 | 12 | 13 | /** 14 | * @brief correlation: State merge function 15 | */ 16 | DECLARE_UDF(stats, correlation_merge_states) 17 | 18 | /** 19 | * @brief correlatin: Final function 20 | */ 21 | DECLARE_UDF(stats, correlation_final) 22 | -------------------------------------------------------------------------------- /src/modules/stats/cox_prop_hazards.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file cox_prop_hazards.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | DECLARE_UDF(stats, coxph_step_inner_final) 8 | 9 | /** 10 | * @brief Cox proportional Hazards: Transition and merge function 11 | */ 12 | DECLARE_UDF(stats, coxph_step_outer_transition) 13 | 14 | /** 15 | * @brief Schoenfeld residuals: Transition and merge function 16 | */ 17 | DECLARE_UDF(stats, zph_transition) 18 | DECLARE_UDF(stats, zph_merge) 19 | DECLARE_UDF(stats, zph_final) 20 | 21 | /** 22 | * @brief Correlation aggregates: Transition, merge, final function 23 | */ 24 | DECLARE_UDF(stats, array_elem_corr_transition) 25 | DECLARE_UDF(stats, array_elem_corr_merge) 26 | DECLARE_UDF(stats, array_elem_corr_final) 27 | 28 | /** 29 | * @brief Metric aggregates: Transition, merge, final function 30 | */ 31 | DECLARE_UDF(stats, coxph_resid_stat_transition) 32 | DECLARE_UDF(stats, coxph_resid_stat_merge) 33 | DECLARE_UDF(stats, coxph_resid_stat_final) 34 | 35 | /** 36 | * @brief Scale residuals 37 | */ 38 | DECLARE_UDF(stats, coxph_scale_resid) 39 | 40 | /** 41 | * @Brief Prediction function 42 | */ 43 | DECLARE_UDF(stats, coxph_predict_resp) 44 | DECLARE_UDF(stats, coxph_predict_terms) 45 | -------------------------------------------------------------------------------- /src/modules/stats/coxph_improved.hpp: -------------------------------------------------------------------------------- 1 | DECLARE_UDF(stats, compute_grpid) 2 | 3 | DECLARE_UDF(stats, split_transition) 4 | DECLARE_UDF(stats, split_merge) 5 | DECLARE_UDF(stats, split_final) 6 | 7 | DECLARE_UDF(stats, compute_coxph_result) 8 | 9 | DECLARE_UDF(stats, coxph_improved_step_transition) 10 | DECLARE_UDF(stats, coxph_improved_step_final) 11 | DECLARE_UDF(stats, coxph_improved_strata_step_final) 12 | 13 | DECLARE_UDF(stats, array_avg_transition) 14 | DECLARE_UDF(stats, array_avg_merge) 15 | DECLARE_UDF(stats, array_avg_final) 16 | 17 | DECLARE_UDF(stats, array_element_min) 18 | DECLARE_UDF(stats, array_element_max) 19 | -------------------------------------------------------------------------------- /src/modules/stats/distribution.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file distribution.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | DECLARE_UDF(stats, vectorized_distribution_transition) 8 | DECLARE_UDF(stats, vectorized_distribution_final) 9 | 10 | DECLARE_UDF(stats, discrete_distribution_transition) 11 | DECLARE_UDF(stats, discrete_distribution_final) 12 | -------------------------------------------------------------------------------- /src/modules/stats/kolmogorov_smirnov_test.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file kolmogorov_smirnov_test.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Kolmogorov-Smirnov Test: Transition function 9 | */ 10 | DECLARE_UDF(stats, ks_test_transition) 11 | 12 | /** 13 | * @brief Kolmogorov-Smirnov Test: Final function 14 | */ 15 | DECLARE_UDF(stats, ks_test_final) 16 | -------------------------------------------------------------------------------- /src/modules/stats/mann_whitney_test.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file mann_whitney_test.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Mann-Whitney U Test: Transition function 9 | */ 10 | DECLARE_UDF(stats, mw_test_transition) 11 | 12 | /** 13 | * @brief Mann-Whitney U Test: Final function 14 | */ 15 | DECLARE_UDF(stats, mw_test_final) 16 | -------------------------------------------------------------------------------- /src/modules/stats/marginal_cox.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file marginal_cox.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Cox Proportional Hazards: Margins Transition function 9 | */ 10 | DECLARE_UDF(stats, margins_coxph_int_transition) 11 | DECLARE_UDF(stats, margins_coxph_int_merge) 12 | DECLARE_UDF(stats, margins_coxph_int_final) 13 | DECLARE_UDF(stats, margins_compute_stats) 14 | -------------------------------------------------------------------------------- /src/modules/stats/one_way_anova.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file one_way_anova.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief One-way ANOVA: Transition function 9 | */ 10 | DECLARE_UDF(stats, one_way_anova_transition) 11 | 12 | /** 13 | * @brief One-way ANOVA: State merge function 14 | */ 15 | DECLARE_UDF(stats, one_way_anova_merge_states) 16 | 17 | /** 18 | * @brief One-way ANOVA: Final function 19 | */ 20 | DECLARE_UDF(stats, one_way_anova_final) 21 | -------------------------------------------------------------------------------- /src/modules/stats/robust_variance_coxph.hpp: -------------------------------------------------------------------------------- 1 | 2 | DECLARE_UDF(stats, rb_coxph_step_transition) 3 | DECLARE_UDF(stats, rb_coxph_step_final) 4 | DECLARE_UDF(stats, coxph_h_s_transition) 5 | DECLARE_UDF(stats, coxph_h_s_merge) 6 | DECLARE_UDF(stats, coxph_h_s_final) 7 | DECLARE_UDF(stats, rb_coxph_strata_step_final) 8 | DECLARE_UDF(stats, rb_sum_strata_transition) 9 | DECLARE_UDF(stats, rb_sum_strata_final) 10 | -------------------------------------------------------------------------------- /src/modules/stats/stats.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * 3 | * @file stats.hpp 4 | * 5 | * @brief Umbrella header that includes all statistics headers 6 | * 7 | * -------------------------------------------------------------------------- */ 8 | 9 | #include "chi_squared_test.hpp" 10 | #include "kolmogorov_smirnov_test.hpp" 11 | #include "mann_whitney_test.hpp" 12 | #include "one_way_anova.hpp" 13 | #include "t_test.hpp" 14 | #include "wilcoxon_signed_rank_test.hpp" 15 | #include "cox_prop_hazards.hpp" 16 | #include "marginal_cox.hpp" 17 | #include "robust_variance_coxph.hpp" 18 | #include "clustered_variance_coxph.hpp" 19 | #include "coxph_improved.hpp" 20 | #include "correlation.hpp" 21 | #include "distribution.hpp" 22 | -------------------------------------------------------------------------------- /src/modules/stats/t_test.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file t_test.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief One-sample t-Test: Transition function 9 | */ 10 | DECLARE_UDF(stats, t_test_one_transition) 11 | 12 | /** 13 | * @brief Two-sample t-Test: Transition function 14 | */ 15 | DECLARE_UDF(stats, t_test_two_transition) 16 | 17 | /** 18 | * @brief t-Test: State merge function 19 | */ 20 | DECLARE_UDF(stats, t_test_merge_states) 21 | 22 | /** 23 | * @brief One-sample t-Test: Final function 24 | */ 25 | DECLARE_UDF(stats, t_test_one_final) 26 | 27 | /** 28 | * @brief Two-sample pooled t-Test: Final function 29 | */ 30 | DECLARE_UDF(stats, t_test_two_pooled_final) 31 | 32 | /** 33 | * @brief Two-sample unpooled t-Test: Final function 34 | */ 35 | DECLARE_UDF(stats, t_test_two_unpooled_final) 36 | 37 | 38 | /** 39 | * @brief Two-sample unpooled t-Test: Final function 40 | */ 41 | DECLARE_UDF(stats, f_test_final) 42 | -------------------------------------------------------------------------------- /src/modules/stats/wilcoxon_signed_rank_test.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file wilcoxon_signed_rank_test.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | /** 8 | * @brief Wilcoxon-Signed-Rank Test: Transition function 9 | */ 10 | DECLARE_UDF(stats, wsr_test_transition) 11 | 12 | /** 13 | * @brief Wilcoxon-Signed-Rank Test: Final function 14 | */ 15 | DECLARE_UDF(stats, wsr_test_final) 16 | -------------------------------------------------------------------------------- /src/modules/tsa/arima.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file arima.hpp 4 | * 5 | * @brief ARIMA 6 | * 7 | *//* ----------------------------------------------------------------------- */ 8 | 9 | DECLARE_UDF(tsa, arima_residual) 10 | 11 | DECLARE_UDF(tsa, arima_diff) 12 | DECLARE_UDF(tsa, arima_adjust) 13 | 14 | DECLARE_UDF(tsa, arima_lm_delta) 15 | 16 | DECLARE_UDF(tsa, arima_lm) 17 | 18 | DECLARE_UDF(tsa, arima_lm_result_sfunc) 19 | DECLARE_UDF(tsa, arima_lm_result_pfunc) 20 | DECLARE_UDF(tsa, arima_lm_result_ffunc) 21 | 22 | DECLARE_UDF(tsa, arima_lm_stat_sfunc) 23 | DECLARE_UDF(tsa, arima_lm_stat_ffunc) 24 | -------------------------------------------------------------------------------- /src/modules/utilities/path.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | * 19 | * @file path.hpp 20 | * 21 | *//* ----------------------------------------------------------------------- */ 22 | 23 | DECLARE_UDF(utilities, path_pattern_match) 24 | -------------------------------------------------------------------------------- /src/modules/utilities/utilities.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | * 19 | * @file utilities.hpp 20 | * 21 | * @brief Umbrella header that includes all utilities task headers 22 | * 23 | * -------------------------------------------------------------------------- */ 24 | 25 | #include "path.hpp" 26 | -------------------------------------------------------------------------------- /src/patch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(madlibPatches ALL DEPENDS ${MADLIB_TARGET_PATCH_FILES}) 2 | add_dependencies(madlibPatches EP_eigen) 3 | -------------------------------------------------------------------------------- /src/ports/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(postgres) 2 | add_subdirectory(greenplum) 3 | -------------------------------------------------------------------------------- /src/ports/greenplum/4.1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_greenplum_version() 2 | 3 | if(GREENPLUM_4_1_FOUND) 4 | # Old versions of Greenplum ship with header files that need a patch to be 5 | # compatible with C++ 6 | 7 | add_subdirectory(patch) 8 | 9 | # Append directory with patched header file at beginning 10 | 11 | include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_BINARY_DIR}/patch/server) 12 | endif(GREENPLUM_4_1_FOUND) 13 | -------------------------------------------------------------------------------- /src/ports/greenplum/4.1/patch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Greenplum Patch Scripts 3 | # ------------------------------------------------------------------------------ 4 | 5 | configure_file(Versions_4_1_0_to_4_1_1.sh.in Versions_4_1_0_to_4_1_1.sh @ONLY) 6 | 7 | # Version 4.1 of Greenplum has a bug in one of its header files that 8 | # needs to be fixed when building with C++. 9 | set(VERSION "${${DBMS_UC}_VERSION_MAJOR}.${${DBMS_UC}_VERSION_MINOR}.${${DBMS_UC}_VERSION_PATCH}") 10 | if(${GREENPLUM_4_1_VERSION_PATCH} EQUAL 0 OR ${GREENPLUM_4_1_VERSION_PATCH} EQUAL 1) 11 | message(STATUS "Installed Greenplum version has bug in header file. " 12 | "Will apply patch for versions 4.1.0 to 4.1.1.") 13 | 14 | add_custom_command( 15 | OUTPUT 16 | "${CMAKE_CURRENT_BINARY_DIR}/server/utils/syncbitvector.h" 17 | COMMAND 18 | "${CMAKE_CURRENT_BINARY_DIR}/Versions_4_1_0_to_4_1_1.sh" 19 | DEPENDS 20 | "${GREENPLUM_4_1_SERVER_INCLUDE_DIR}/utils/syncbitvector.h" 21 | "${CMAKE_CURRENT_BINARY_DIR}/Versions_4_1_0_to_4_1_1.sh" 22 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 23 | COMMENT "Patching syncbitvector.h: Add missing key word \"typedef\"." 24 | ) 25 | 26 | add_custom_target(patches_greenplum_4_1 27 | ALL DEPENDS 28 | "${CMAKE_CURRENT_BINARY_DIR}/server/utils/syncbitvector.h" 29 | ) 30 | 31 | add_dependencies(madlib_greenplum_4_1 patches_greenplum_4_1) 32 | endif(${GREENPLUM_4_1_VERSION_PATCH} EQUAL 0 OR ${GREENPLUM_4_1_VERSION_PATCH} EQUAL 1) 33 | -------------------------------------------------------------------------------- /src/ports/greenplum/4.1/patch/Versions_4_1_0_to_4_1_1.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | "@CMAKE_COMMAND@" -E make_directory server/utils 4 | 5 | sed 's/^struct SyncBitvectorContainer_s$/typedef struct SyncBitvectorContainer_s/g' \ 6 | "@GREENPLUM_4_1_SERVER_INCLUDE_DIR@/utils/syncbitvector.h" > \ 7 | server/utils/syncbitvector.h 8 | -------------------------------------------------------------------------------- /src/ports/greenplum/4.2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_greenplum_version() 2 | -------------------------------------------------------------------------------- /src/ports/greenplum/4.3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_greenplum_version() 2 | -------------------------------------------------------------------------------- /src/ports/greenplum/4.3ORCA/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_greenplum_version() 2 | add_subdirectory(config) 3 | -------------------------------------------------------------------------------- /src/ports/greenplum/4.3ORCA/config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | 19 | add_current_greenplum_version() 20 | 21 | # -- 1. Copy all *.yml files --------------------------------------------------- 22 | 23 | file(GLOB_RECURSE CONFIG_FILES 24 | RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" 25 | "*.yml" 26 | ) 27 | add_files(CONFIG_TARGET_FILES . "${CMAKE_CURRENT_BINARY_DIR}" ${CONFIG_FILES}) 28 | add_custom_target(configFilesgp43 ALL DEPENDS ${CONFIG_TARGET_FILES}) 29 | 30 | 31 | # -- 2. Install config files to config ---------------------------- 32 | 33 | install(FILES ${CONFIG_TARGET_FILES} 34 | DESTINATION ports/greenplum/4.3ORCA/config 35 | COMPONENT core 36 | ) 37 | -------------------------------------------------------------------------------- /src/ports/greenplum/5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | add_current_greenplum_version() 20 | -------------------------------------------------------------------------------- /src/ports/greenplum/6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | add_current_greenplum_version() 20 | -------------------------------------------------------------------------------- /src/ports/greenplum/cmake/FindGreenplum.cmake: -------------------------------------------------------------------------------- 1 | # Set defaults that can be overridden by files that include this file: 2 | if(NOT DEFINED _FIND_PACKAGE_FILE) 3 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 4 | endif(NOT DEFINED _FIND_PACKAGE_FILE) 5 | 6 | # Set parameters for calling FindPostgreSQL.cmake 7 | set(_NEEDED_PG_CONFIG_PACKAGE_NAME "Greenplum Database") 8 | set(_PG_CONFIG_VERSION_NUM_MACRO "GP_VERSION_NUM") 9 | set(_PG_CONFIG_VERSION_MACRO "GP_VERSION") 10 | set(_SEARCH_PATH_HINTS 11 | "/usr/local/greenplum-db/bin" 12 | "$ENV{GPHOME}/bin" 13 | ) 14 | 15 | include("${CMAKE_CURRENT_LIST_DIR}/../../postgres/cmake/FindPostgreSQL.cmake") 16 | 17 | if(${PKG_NAME}_FOUND) 18 | # server/funcapi.h ultimately includes server/access/xact.h, from which 19 | # cdb/cdbpathlocus.h is included 20 | execute_process(COMMAND ${${PKG_NAME}_PG_CONFIG} --pkgincludedir 21 | OUTPUT_VARIABLE ${PKG_NAME}_ADDITIONAL_INCLUDE_DIRS 22 | OUTPUT_STRIP_TRAILING_WHITESPACE 23 | ) 24 | set(${PKG_NAME}_ADDITIONAL_INCLUDE_DIRS 25 | "${${PKG_NAME}_ADDITIONAL_INCLUDE_DIRS}/internal") 26 | endif(${PKG_NAME}_FOUND) 27 | -------------------------------------------------------------------------------- /src/ports/greenplum/cmake/FindGreenplum_4_0.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindGreenplum.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/greenplum/cmake/FindGreenplum_4_1.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindGreenplum.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/greenplum/cmake/FindGreenplum_4_2.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindGreenplum.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/greenplum/cmake/FindGreenplum_4_3.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindGreenplum.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/greenplum/cmake/FindGreenplum_4_3ORCA.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindGreenplum.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/greenplum/cmake/FindGreenplum_5.cmake: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 19 | include("${CMAKE_CURRENT_LIST_DIR}/FindGreenplum.cmake") 20 | -------------------------------------------------------------------------------- /src/ports/greenplum/cmake/FindGreenplum_6.cmake: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 19 | include("${CMAKE_CURRENT_LIST_DIR}/FindGreenplum.cmake") 20 | -------------------------------------------------------------------------------- /src/ports/greenplum/dbconnector/dbconnector.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file dbconnector.hpp 4 | * 5 | * @brief This file should be included by user code (and nothing else) 6 | * 7 | *//* ----------------------------------------------------------------------- */ 8 | 9 | #ifndef MADLIB_GREENPLUM_DBCONNECTOR_HPP 10 | #define MADLIB_GREENPLUM_DBCONNECTOR_HPP 11 | 12 | // On platforms based on PostgreSQL we can include a different set of headers. 13 | #define MADLIB_POSTGRES_HEADERS 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include // Greenplum requires this for GetAttributeByNum() 21 | #include // Memory allocation, e.g., HOLD_INTERRUPTS 22 | #include 23 | #include 24 | #include // needed for format_procedure() 25 | #include 26 | #include // for type lookup, e.g., type_is_rowtype 27 | #include 28 | #include // for direct access to catalog, e.g., SearchSysCache() 29 | #include // type conversion, e.g., lookup_rowtype_tupdesc 30 | #include "../../../../methods/svec/src/pg_gp/sparse_vector.h" // Legacy sparse vectors 31 | } // extern "C" 32 | 33 | #include "Compatibility.hpp" 34 | 35 | #include "../../postgres/dbconnector/dbconnector.hpp" 36 | 37 | #endif // defined(MADLIB_GREENPLUM_DBCONNECTOR_HPP) 38 | -------------------------------------------------------------------------------- /src/ports/postgres/10/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | add_current_postgresql_version() 21 | add_extension_support() 22 | -------------------------------------------------------------------------------- /src/ports/postgres/11/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | add_current_postgresql_version() 21 | add_extension_support() 22 | -------------------------------------------------------------------------------- /src/ports/postgres/12/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | add_current_postgresql_version() 21 | add_extension_support() 22 | 23 | -------------------------------------------------------------------------------- /src/ports/postgres/8.4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_postgresql_version() 2 | 3 | if(POSTGRESQL_8_4_FOUND) 4 | # Old versions of PostgreSQL ship with header files that need a patch to be 5 | # compatible with C++ 6 | add_subdirectory(patch) 7 | 8 | # Append directory with patched header file at beginning 9 | 10 | include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_BINARY_DIR}/patch/server) 11 | endif(POSTGRESQL_8_4_FOUND) 12 | 13 | -------------------------------------------------------------------------------- /src/ports/postgres/9.0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_postgresql_version() 2 | -------------------------------------------------------------------------------- /src/ports/postgres/9.1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_postgresql_version() 2 | add_extension_support() 3 | -------------------------------------------------------------------------------- /src/ports/postgres/9.2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_postgresql_version() 2 | add_extension_support() 3 | -------------------------------------------------------------------------------- /src/ports/postgres/9.3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_postgresql_version() 2 | add_extension_support() 3 | -------------------------------------------------------------------------------- /src/ports/postgres/9.4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_current_postgresql_version() 2 | add_extension_support() 3 | -------------------------------------------------------------------------------- /src/ports/postgres/9.5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | add_current_postgresql_version() 21 | add_extension_support() 22 | -------------------------------------------------------------------------------- /src/ports/postgres/9.6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | add_current_postgresql_version() 21 | add_extension_support() 22 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_10.cmake: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 21 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 22 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_11.cmake: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 21 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 22 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_12.cmake: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 21 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 22 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_8_4.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_9_0.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_9_1.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_9_2.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_9_3.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_9_4.cmake: -------------------------------------------------------------------------------- 1 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 2 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 3 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_9_5.cmake: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 21 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 22 | -------------------------------------------------------------------------------- /src/ports/postgres/cmake/FindPostgreSQL_9_6.cmake: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # ------------------------------------------------------------------------------ 19 | 20 | set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") 21 | include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") 22 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/ArrayWithNullException_proto.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file ArrayWithNullException_proto.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_ARRAYWITHNULLEXCEPTION_PROTO_HPP 8 | #define MADLIB_POSTGRES_ARRAYWITHNULLEXCEPTION_PROTO_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | /** 17 | * @brief Unspecified PostgreSQL backend expcetion 18 | */ 19 | class ArrayWithNullException : public std::runtime_error { 20 | public: 21 | explicit 22 | ArrayWithNullException() 23 | : std::runtime_error("Error converting an array w/ NULL values to dense format."), array_size_(0) { } 24 | 25 | explicit 26 | ArrayWithNullException(size_t array_size) 27 | : std::runtime_error("Error converting an array w/ NULL values to dense format."), array_size_(array_size) { } 28 | 29 | size_t getArraySize() const { return array_size_; } 30 | 31 | protected: 32 | const size_t array_size_; 33 | }; 34 | 35 | } // namespace postgres 36 | 37 | } // namespace dbconnector 38 | 39 | } // namespace madlib 40 | 41 | #endif // defined(MADLIB_POSTGRES_ARRAYWITHNULLEXCEPTION_PROTO_HPP) 42 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/ByteString_proto.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file ByteString_proto.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_BYTESTRING_PROTO_HPP 8 | #define MADLIB_POSTGRES_BYTESTRING_PROTO_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | template 17 | class Reference; 18 | 19 | class ByteString { 20 | public: 21 | enum { isMutable = dbal::Immutable }; 22 | enum { kEffectiveHeaderSize 23 | = ((VARHDRSZ - 1) & ~(MAXIMUM_ALIGNOF - 1)) + MAXIMUM_ALIGNOF }; 24 | 25 | typedef char char_type; 26 | 27 | ByteString(const bytea* inByteString); 28 | 29 | const char_type* ptr() const; 30 | size_t size() const; 31 | const bytea* byteString() const; 32 | const char_type& operator[](size_t inIndex) const; 33 | 34 | protected: 35 | const bytea* mByteString; 36 | }; 37 | 38 | 39 | class MutableByteString : public ByteString { 40 | typedef ByteString Base; 41 | 42 | public: 43 | enum { isMutable = dbal::Mutable }; 44 | 45 | MutableByteString(bytea* inByteString); 46 | 47 | using Base::ptr; 48 | using Base::byteString; 49 | 50 | char_type* ptr(); 51 | bytea* byteString(); 52 | char_type& operator[](size_t inIndex); 53 | }; 54 | 55 | } // namespace postgres 56 | 57 | } // namespace dbconnector 58 | 59 | } // namespace madlib 60 | 61 | #endif // defined(MADLIB_POSTGRES_BYTESTRING_PROTO_HPP) 62 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/NativeRandomNumberGenerator_proto.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file NativeRandomNumberGenerator_proto.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_NATIVERANDOMNUMBERGENERATOR_PROTO_HPP 8 | #define MADLIB_POSTGRES_NATIVERANDOMNUMBERGENERATOR_PROTO_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | /** 17 | * @brief Front-end to the RDBMS random number generator 18 | * 19 | * This pseudo-RNG is special in that it has no own state. Instead, its state is 20 | * externally defined. It is therefore not necessary to keep a global instance 21 | * of this RNG. 22 | */ 23 | class NativeRandomNumberGenerator { 24 | public: 25 | typedef double result_type; 26 | 27 | #if _GLIBCXX_USE_CXX11_ABI 28 | #define CONST_EXPR constexpr 29 | #else 30 | #define CONST_EXPR 31 | #endif 32 | 33 | NativeRandomNumberGenerator(); 34 | void seed(result_type inSeed); 35 | result_type operator()(); 36 | static CONST_EXPR result_type min(); 37 | static CONST_EXPR result_type max(); 38 | }; 39 | 40 | } // namespace postgres 41 | 42 | } // namespace dbconnector 43 | 44 | } // namespace madlib 45 | 46 | #endif // defined(MADLIB_POSTGRES_NATIVERANDOMNUMBERGENERATOR_PROTO_HPP) 47 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/OutputStreamBuffer_impl.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file OutputStreamBuffer_impl.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_OUTPUTSTREAMBUFFER_IMPL_HPP 8 | #define MADLIB_POSTGRES_OUTPUTSTREAMBUFFER_IMPL_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | /** 17 | * @brief Output a null-terminated C string. 18 | * 19 | * @param inMsg Null-terminated C string 20 | * @param inLength length of inMsg 21 | */ 22 | template class Allocator> 23 | inline 24 | void 25 | OutputStreamBuffer::output(char *inMsg, 26 | std::size_t /* inLength */) const { 27 | 28 | volatile bool errorOccurred = false; 29 | PG_TRY(); { 30 | ereport(ErrorLevel, 31 | (errmsg("%s", inMsg))); // Don't supply strings as format strings! 32 | } PG_CATCH(); { 33 | errorOccurred = true; 34 | } PG_END_TRY(); 35 | 36 | if (errorOccurred) 37 | throw std::runtime_error("An exception occured during message output."); 38 | } 39 | 40 | } // namespace postgres 41 | 42 | } // namespace dbconnector 43 | 44 | } // namespace madlib 45 | 46 | #endif // defined(MADLIB_POSTGRES_OUTPUTSTREAMBUFFER_IMPL_HPP) 47 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/OutputStreamBuffer_proto.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file OutputStreamBuffer_proto.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_OUTPUTSTREAMBUFFER_PROTO_HPP 8 | #define MADLIB_POSTGRES_OUTPUTSTREAMBUFFER_PROTO_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | /** 17 | * @brief Stream buffer that dispatches all output to PostgreSQL's ereport 18 | * function 19 | */ 20 | template class Allocator = std::allocator> 21 | class OutputStreamBuffer 22 | : public dbal::OutputStreamBufferBase< 23 | OutputStreamBuffer, char, Allocator > { 24 | 25 | public: 26 | void output(char *inMsg, std::size_t inLength) const; 27 | }; 28 | 29 | } // namespace postgres 30 | 31 | } // namespace dbconnector 32 | 33 | } // namespace madlib 34 | 35 | #endif // defined(MADLIB_POSTGRES_OUTPUTSTREAMBUFFER_PROTO_HPP) 36 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/PGException_proto.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file PGException_proto.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_PGEXCEPTION_PROTO_HPP 8 | #define MADLIB_POSTGRES_PGEXCEPTION_PROTO_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | /** 17 | * @brief Unspecified PostgreSQL backend expcetion 18 | */ 19 | class PGException : public std::runtime_error { 20 | public: 21 | explicit 22 | PGException() 23 | : std::runtime_error("The backend raised an exception.") { } 24 | 25 | // FIXME: Do something useful with inErrorData 26 | PGException(ErrorData* /* inErrorData */) 27 | : std::runtime_error("The backend raised an exception.") { } 28 | }; 29 | 30 | } // namespace postgres 31 | 32 | } // namespace dbconnector 33 | 34 | } // namespace madlib 35 | 36 | #endif // defined(MADLIB_POSTGRES_PGEXCEPTION_PROTO_HPP) 37 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/TransparentHandle_impl.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file TransparentHandle_impl.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_TRANSPARENTHANDLE_IMPL_HPP 8 | #define MADLIB_POSTGRES_TRANSPARENTHANDLE_IMPL_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | template 17 | TransparentHandle::TransparentHandle(val_type* inPtr) 18 | : mPtr(inPtr) { } 19 | 20 | /** 21 | * @brief Return the (constant) pointer of this handle 22 | */ 23 | template 24 | inline 25 | typename TransparentHandle::val_type* 26 | TransparentHandle::ptr() const { 27 | return mPtr; 28 | } 29 | 30 | // TransparentHandle 31 | 32 | template 33 | TransparentHandle::TransparentHandle(val_type* inPtr) 34 | : Base(inPtr) { } 35 | 36 | /** 37 | * @brief Return the pointer of this handle 38 | */ 39 | template 40 | inline 41 | typename TransparentHandle::val_type* 42 | TransparentHandle::ptr() { 43 | return const_cast(static_cast(this)->ptr()); 44 | } 45 | 46 | } // namespace postgres 47 | 48 | } // namespace dbconnector 49 | 50 | } // namespace madlib 51 | 52 | #endif // defined(MADLIB_POSTGRES_TRANSPARENTHANDLE_IMPL_HPP) 53 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/TypeTraits_proto.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file TypeTraits_proto.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_TYPETRAITS_PROTO_HPP 8 | #define MADLIB_POSTGRES_TYPETRAITS_PROTO_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | template 17 | struct TypeTraits; 18 | 19 | } // namespace postgres 20 | 21 | } // namespace dbconnector 22 | 23 | } // namespace madlib 24 | 25 | #endif // defined(MADLIB_POSTGRES_TYPETRAITS_PROTO_HPP) 26 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/UDF_proto.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file UDF_proto.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_POSTGRES_UDF_PROTO_HPP 8 | #define MADLIB_POSTGRES_UDF_PROTO_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace dbconnector { 13 | 14 | namespace postgres { 15 | 16 | /** 17 | * @brief User-defined function 18 | */ 19 | class UDF : public Allocator { 20 | public: 21 | typedef AnyType (*Pointer)(AnyType&); 22 | 23 | UDF() { } 24 | 25 | template 26 | static Datum call(FunctionCallInfo fcinfo); 27 | 28 | template 29 | static AnyType invoke(AnyType& args); 30 | 31 | // FIXME: The following code until the end of this class is a dirty hack 32 | // that needs to go 33 | template 34 | static Datum SRF_invoke(FunctionCallInfo fcinfo); 35 | 36 | protected: 37 | template 38 | static FuncCallContext* SRF_percall_setup(FunctionCallInfo fcinfo); 39 | 40 | template 41 | static bool SRF_is_firstcall(FunctionCallInfo fcinfo); 42 | }; 43 | 44 | template 45 | UDF::Pointer funcPtr() { 46 | return UDF::invoke; 47 | } 48 | 49 | } // namespace postgres 50 | 51 | } // namespace dbconnector 52 | 53 | } // namespace madlib 54 | 55 | #endif // defined(MADLIB_POSTGRES_UDF_PROTO_HPP) 56 | -------------------------------------------------------------------------------- /src/ports/postgres/dbconnector/main.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file main.cpp 4 | * 5 | * @brief Main file containing the entrance points into the C++ modules 6 | * 7 | *//* ----------------------------------------------------------------------- */ 8 | 9 | // We do not write #include "dbconnector.hpp" here because we want to rely on 10 | // the search paths, which might point to a port-specific dbconnector.hpp 11 | #include 12 | #include 13 | 14 | extern "C" { 15 | PG_MODULE_MAGIC; 16 | } // extern "C" 17 | 18 | namespace madlib { 19 | 20 | namespace dbconnector { 21 | 22 | namespace postgres { 23 | 24 | bool AnyType::sLazyConversionToDatum = false; 25 | 26 | namespace { 27 | 28 | // No need to export these names to other translation units. 29 | #ifndef NDEBUG 30 | OutputStreamBuffer gOutStreamBuffer; 31 | OutputStreamBuffer gErrStreamBuffer; 32 | #endif 33 | 34 | } 35 | 36 | #ifndef NDEBUG 37 | /** 38 | * @brief Informational output stream 39 | */ 40 | std::ostream dbout(&gOutStreamBuffer); 41 | 42 | /** 43 | * @brief Warning and non-fatal error output stream 44 | */ 45 | std::ostream dberr(&gErrStreamBuffer); 46 | #endif 47 | } // namespace postgres 48 | 49 | } // namespace dbconnector 50 | 51 | } // namespace madlib 52 | 53 | // Include declarations declarations 54 | #include 55 | 56 | // Now export the symbols 57 | #undef DECLARE_UDF 58 | #undef DECLARE_SR_UDF 59 | #define DECLARE_UDF DECLARE_UDF_EXTERNAL 60 | #define DECLARE_SR_UDF DECLARE_UDF_EXTERNAL 61 | #include 62 | -------------------------------------------------------------------------------- /src/ports/postgres/extension/madlib.control_in: -------------------------------------------------------------------------------- 1 | default_version = '@MADLIB_VERSION_MAJOR@.@MADLIB_VERSION_MINOR@.@MADLIB_VERSION_PATCH@' 2 | comment = 'A scalable in-database analytics library' 3 | relocatable = false 4 | module_pathname = 'libmadlib.so' 5 | requires = 'plpythonu' 6 | -------------------------------------------------------------------------------- /src/ports/postgres/extension/madlib.sql.base_in: -------------------------------------------------------------------------------- 1 | CREATE TABLE @extschema@.migrationhistory( 2 | id serial, version varchar(255), applied timestamp default current_timestamp 3 | ); 4 | INSERT INTO @extschema@.migrationhistory(version) 5 | VALUES('@MADLIB_VERSION_STRING@'::text); 6 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/assoc_rules/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/assoc_rules/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/bayes/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/bayes/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/convex/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/convex/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/convex/test/unit_tests/plpy_mock.py_in: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | 20 | m4_changequote(`') 21 | def __init__(self): 22 | pass 23 | 24 | def error(message): 25 | raise PLPYException(message) 26 | 27 | def execute(query): 28 | pass 29 | 30 | def warning(query): 31 | pass 32 | 33 | def info(query): 34 | print query 35 | 36 | 37 | class PLPYException(Exception): 38 | def __init__(self, message): 39 | super(PLPYException, self).__init__() 40 | self.message = message 41 | 42 | def __str__(self): 43 | return repr(self.message) 44 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/crf/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/crf/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/dbscan/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/dbscan/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/dbscan/test/unit_tests/plpy_mock.py_in: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | 20 | m4_changequote(`') 21 | def __init__(self): 22 | pass 23 | 24 | def error(message): 25 | raise PLPYException(message) 26 | 27 | def execute(query): 28 | pass 29 | 30 | def warning(query): 31 | pass 32 | 33 | def info(query): 34 | print query 35 | 36 | 37 | class PLPYException(Exception): 38 | def __init__(self, message): 39 | super(PLPYException, self).__init__() 40 | self.message = message 41 | 42 | def __str__(self): 43 | return repr(self.message) 44 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/deep_learning/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/deep_learning/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/deep_learning/gpu_info_from_tf.py_in: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | """ 20 | @file gpu_info_from_tf.py_in 21 | 22 | @brief This file prints out the gpu descriptions using tensorflow API. This file 23 | is intended to be called using subprocess. See madlib_keras_gpu_info.py_in 24 | for more details. 25 | """ 26 | 27 | import tensorflow as tf 28 | from tensorflow.python.client import device_lib 29 | from tensorflow.keras import backend as K 30 | 31 | config = tf.ConfigProto() 32 | config.gpu_options.allow_growth = True 33 | sess = tf.Session(config=config) 34 | local_device_protos = device_lib.list_local_devices() 35 | K.clear_session() 36 | sess.close() 37 | if local_device_protos: 38 | for x in local_device_protos: 39 | if x.device_type == 'GPU': 40 | print x.physical_device_desc 41 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/deep_learning/test/unit_tests/plpy_mock.py_in: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | 20 | m4_changequote(`') 21 | def __init__(self): 22 | pass 23 | 24 | def error(message): 25 | raise PLPYException(message) 26 | 27 | def execute(query): 28 | pass 29 | 30 | def warning(query): 31 | pass 32 | 33 | def info(query): 34 | print query 35 | 36 | 37 | class PLPYException(Exception): 38 | def __init__(self, message): 39 | super(PLPYException, self).__init__() 40 | self.message = message 41 | 42 | def __str__(self): 43 | return repr(self.message) 44 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/elastic_net/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/elastic_net/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/glm/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/glm/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/graph/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/graph/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/internal/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/internal/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/kmeans/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/kmeans/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/kmeans/test/unit_tests/plpy_mock.py_in: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | 20 | m4_changequote(`') 21 | def __init__(self): 22 | pass 23 | 24 | def error(message): 25 | raise PLPYException(message) 26 | 27 | def execute(query): 28 | pass 29 | 30 | def warning(query): 31 | pass 32 | 33 | def info(query): 34 | print query 35 | 36 | 37 | class PLPYException(Exception): 38 | def __init__(self, message): 39 | super(PLPYException, self).__init__() 40 | self.message = message 41 | 42 | def __str__(self): 43 | return repr(self.message) 44 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/knn/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/knn/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/lda/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/lda/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/linalg/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/linalg/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/linear_systems/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/linear_systems/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/linear_systems/test/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/linear_systems/test/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/mxgboost/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/mxgboost/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/pca/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/pca/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/pmml/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/pmml/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/recursive_partitioning/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/recursive_partitioning/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/recursive_partitioning/test/unit_tests/plpy_mock.py_in: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | 20 | m4_changequote(`') 21 | def __init__(self): 22 | pass 23 | 24 | def error(message): 25 | raise PLPYException(message) 26 | 27 | def execute(query): 28 | pass 29 | 30 | def warning(query): 31 | pass 32 | 33 | def info(query): 34 | print query 35 | 36 | 37 | class PLPYException(Exception): 38 | def __init__(self, message): 39 | super(PLPYException, self).__init__() 40 | self.message = message 41 | 42 | def __str__(self): 43 | return repr(self.message) 44 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/regress/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/regress/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/sample/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/sample/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/sample/test/balance_sample.ic.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | *//* ----------------------------------------------------------------------- */ 21 | 22 | DROP TABLE IF EXISTS "TEST_s" CASCADE; 23 | 24 | CREATE TABLE "TEST_s"( 25 | id1 INTEGER, 26 | id2 INTEGER, 27 | gr1 INTEGER, 28 | gr2 INTEGER, 29 | gr3 TEXT 30 | ); 31 | 32 | INSERT INTO "TEST_s" VALUES 33 | (1,0,1,1,'a'), 34 | (1,0,1,1,'b'), 35 | (1,0,1,2,'b'), 36 | (30,30,6,6,'d'), 37 | (40,40,6,6,'d'), 38 | (700,70,NULL,2,'e'); 39 | 40 | -- --- Test for random undersampling with replacement 41 | DROP TABLE IF EXISTS out_sr2; 42 | SELECT balance_sample('"TEST_s"', 'out_sr2', 'gr1', 'undersample ', NULL, NULL, TRUE, TRUE); 43 | 44 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/sample/test/sample.ic.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | *//* ----------------------------------------------------------------------- */ 21 | 22 | /* ----------------------------------------------------------------------------- 23 | * Test random sampling. 24 | * -------------------------------------------------------------------------- */ 25 | 26 | SELECT weighted_sample(i, i) AS value 27 | FROM generate_series(1,10) AS i; 28 | 29 | SELECT *, poisson_random(1.0) 30 | FROM generate_series(1,5); 31 | 32 | SELECT *, gamma_random(5) 33 | FROM generate_series(1,5); 34 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/sample/test/stratified_sample.ic.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | *//* ----------------------------------------------------------------------- */ 21 | 22 | DROP TABLE IF EXISTS "TEST"; 23 | 24 | CREATE TABLE "TEST"( 25 | id1 INTEGER, 26 | "ID2" INTEGER, 27 | gr1 INTEGER, 28 | gr2 INTEGER 29 | ); 30 | 31 | INSERT INTO "TEST" VALUES 32 | (1,0,1,1), 33 | (9,0,1,1), 34 | (0,2,1,2), 35 | (0,3,1,2), 36 | (30,30,2,2), 37 | (70,70,2,2) 38 | ; 39 | 40 | DROP TABLE IF EXISTS out; 41 | SELECT stratified_sample('"TEST"', 'out', 0.5, NULL, 'id1,"ID2",gr1,gr2', FALSE); 42 | 43 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/sample/test/train_test_split.ic.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | *//* ----------------------------------------------------------------------- */ 21 | 22 | DROP TABLE IF EXISTS test; 23 | 24 | CREATE TABLE test( 25 | id1 INTEGER, 26 | id2 INTEGER, 27 | gr1 INTEGER, 28 | gr2 INTEGER 29 | ); 30 | 31 | INSERT INTO test VALUES 32 | (1,0,1,1), 33 | (9,0,1,1), 34 | (0,2,1,2), 35 | (0,3,1,2), 36 | (30,30,2,2), 37 | (70,70,2,2) 38 | ; 39 | 40 | SELECT setseed(0); 41 | 42 | DROP TABLE IF EXISTS out_train,out_test,out; 43 | SELECT train_test_split('test', 'out', 0.1, 0.2, NULL, 'id1,id2,gr1,gr2', FALSE, TRUE); 44 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/stats/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/stats/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/stats/test/anova_test.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * Test ANOVA. 3 | * 4 | * Example taken from: 5 | * http://www.itl.nist.gov/div898/handbook/prc/section4/prc433.htm 6 | * -------------------------------------------------------------------------- */ 7 | 8 | CREATE TABLE nist_anova_test ( 9 | id SERIAL, 10 | resistance FLOAT8[] 11 | ); 12 | 13 | COPY nist_anova_test(resistance) FROM stdin; 14 | {6.9,8.3,8.0} 15 | {5.4,6.8,10.5} 16 | {5.8,7.8,8.1} 17 | {4.6,9.2,6.9} 18 | {4.0,6.5,9.3} 19 | \. 20 | 21 | CREATE TABLE one_way_anova_nist AS 22 | SELECT (one_way_anova(level, value)).* FROM ( 23 | SELECT level, resistance[level] AS value 24 | FROM 25 | nist_anova_test, ( 26 | SELECT * FROM generate_series(1,3) level 27 | ) q 28 | ) q; 29 | 30 | SELECT * FROM one_way_anova_nist; 31 | SELECT assert( 32 | relative_error(statistic, 9.59) < 0.001 AND 33 | relative_error(sum_squares_between, 27.897) < 0.001 AND 34 | relative_error(sum_squares_within, 17.452) < 0.001 AND 35 | df_between = 2 AND 36 | df_within = 12 AND 37 | relative_error(mean_squares_between, 13.949) < 0.001 AND 38 | relative_error(mean_squares_within, 1.454) < 0.001, 39 | 'One-way ANOVA: Wrong results' 40 | ) FROM one_way_anova_nist; 41 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/stats/test/correlation.ic.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | *//* ----------------------------------------------------------------------- */ 21 | 22 | CREATE TABLE rand_numeric (a int2, b int4, c int8, d float4, e float8, f real); 23 | INSERT INTO rand_numeric 24 | SELECT 25 | random() * 1000, 26 | random() * 1000, 27 | random() * 1000, 28 | random() * 1000, 29 | random() * 1000, 30 | random() * 1000 31 | FROM 32 | generate_series(1, 5); 33 | 34 | DROP TABLE IF EXISTS corr_output, corr_output_summary; 35 | SELECT * FROM correlation('rand_numeric', 'corr_output', 'a, c, e'); 36 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/stats/test/mw_test.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * Test Mann-Whitney-test. 3 | * 4 | * Example taken from: 5 | * http://www.itl.nist.gov/div898/handbook/prc/section3/prc35.htm 6 | * -------------------------------------------------------------------------- */ 7 | 8 | m4_include(`SQLCommon.m4') 9 | m4_changequote() 10 | m4_ifdef(,) 53 | m4_changequote(,) 54 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/stats/test/t_test.ic.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | *//* ----------------------------------------------------------------------- */ 21 | 22 | /* ----------------------------------------------------------------------------- 23 | * Test one-sample t-test. 24 | * 25 | * Example ("ZARR13.DAT") taken from: 26 | * http://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm 27 | * -------------------------------------------------------------------------- */ 28 | 29 | CREATE TABLE ZARR13 ( 30 | id SERIAL, 31 | value FLOAT8 32 | ); 33 | 34 | COPY ZARR13(value) FROM stdin; 35 | 9.206343 36 | 9.299992 37 | 9.277895 38 | 9.288454 39 | 9.216746 40 | 9.274107 41 | 9.273776 42 | \. 43 | 44 | CREATE TABLE t_test_one AS 45 | SELECT (t_test_one(value - 5.0)).* FROM zarr13; 46 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/summary/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/summary/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/summary/test/summary.ic.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | *//* ----------------------------------------------------------------------- */ 21 | 22 | -- table with data types that cannot be casted into text 23 | CREATE TABLE bit_data ( 24 | a bit(3), 25 | b bit varying(5) 26 | ); 27 | 28 | COPY bit_data (a, b) FROM stdin; 29 | 101 00 30 | \. 31 | 32 | DROP TABLE IF EXISTS bit_data_summary; 33 | SELECT summary('bit_data', 'bit_data_summary', NULL, 'a'); 34 | 35 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/svm/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/svm/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/tsa/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/tsa/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/utilities/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/utilities/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/utilities/math_utils.py_in: -------------------------------------------------------------------------------- 1 | 2 | 3 | def compute_dot(vector1, vector2): 4 | """ Compute dot product of two lists 5 | 6 | @brief Compute the dot product of two numeric lists by iterating over 7 | the two lists and adding the elementwise product. 8 | Ideally, numpy dot product functionality should be employed. This function 9 | can be used in cases where numpy is not accessible. 10 | 11 | Args: 12 | @param vector1 list, List of numbers 13 | @param vector2 list, List of numbers 14 | 15 | Returns: 16 | Numeric. Float or int (depending on type of input) 17 | If either of the two inputs are invalid or empty then zero is returned. 18 | If the lists are of unequal length then the longer list is truncated to 19 | the length of the shorter list and then the dot product is returned. 20 | """ 21 | if not vector1 or not vector2: 22 | return 0 23 | # zip is used to truncate longer list to shorter length 24 | return sum(p*q for p,q in zip(vector1, vector2)) 25 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/utilities/test/pivot.ic.sql_in: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | *//* ----------------------------------------------------------------------- */ 21 | 22 | DROP TABLE IF EXISTS "PIVSET"; 23 | 24 | CREATE TABLE "PIVSET"( 25 | id INTEGER, 26 | piv INTEGER, 27 | val INTEGER 28 | ); 29 | 30 | INSERT INTO "PIVSET" VALUES 31 | (0, 10, 1), 32 | (0, 10, 2), 33 | (0, 20, 3), 34 | (1, 20, 4), 35 | (1, 30, 5), 36 | (1, 30, 6), 37 | (1, 10, 7), 38 | (NULL, 10, 8), 39 | (0, NULL, 9), 40 | (0, 10, NULL); 41 | 42 | DROP TABLE IF EXISTS pivout; 43 | SELECT pivot('"PIVSET"', 'pivout', 'id', 'piv', 'val'); 44 | SELECT * FROM pivout; 45 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/utilities/test/unit_tests/plpy_mock.py_in: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | 20 | m4_changequote(`') 21 | def __init__(self): 22 | pass 23 | 24 | def error(message): 25 | raise PLPYException(message) 26 | 27 | def execute(query): 28 | pass 29 | 30 | def warning(query): 31 | pass 32 | 33 | def info(query): 34 | print query 35 | 36 | 37 | class SPIError(Exception): 38 | def __init__(self, message): 39 | super(SPIError, self).__init__() 40 | self.message = message 41 | 42 | def __str__(self): 43 | return repr(self.message) 44 | 45 | class PLPYException(Exception): 46 | def __init__(self, message): 47 | super(PLPYException, self).__init__() 48 | self.message = message 49 | 50 | def __str__(self): 51 | return repr(self.message) 52 | -------------------------------------------------------------------------------- /src/ports/postgres/modules/validation/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/validation/__init__.py_in -------------------------------------------------------------------------------- /src/ports/postgres/modules/validation/internal/__init__.py_in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/madlib/d9a4ee58ad40597ec346c442e80bc8e6c95bffe2/src/ports/postgres/modules/validation/internal/__init__.py_in -------------------------------------------------------------------------------- /src/unexported_symbols_list.txt: -------------------------------------------------------------------------------- 1 | __Znwm 2 | __ZnwmRKSt9nothrow_t 3 | __ZdlPv 4 | __ZdlPvRKSt9nothrow_t 5 | __Znam 6 | __ZnamRKSt9nothrow_t 7 | __ZdaPv 8 | __ZdaPvRKSt9nothrow_t 9 | -------------------------------------------------------------------------------- /src/utils/memory.hpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- *//** 2 | * 3 | * @file memory.hpp 4 | * 5 | *//* ----------------------------------------------------------------------- */ 6 | 7 | #ifndef MADLIB_MEMORY_HPP 8 | #define MADLIB_MEMORY_HPP 9 | 10 | namespace madlib { 11 | 12 | namespace utils { 13 | 14 | namespace memory { 15 | 16 | template 17 | struct ArrayDeleter { 18 | void operator()(T *p) { 19 | delete [] p; 20 | } 21 | }; 22 | 23 | template 24 | struct NoDeleter { 25 | void operator()(T * /* p */) { } 26 | }; 27 | 28 | } // namespace prob 29 | 30 | } // namespace modules 31 | 32 | } // namespace regress 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tool/docker/base/README.md: -------------------------------------------------------------------------------- 1 | Docker Images 2 | ======================= 3 | 4 | ## Following docker configs are based on Debian (jessie) images: 5 | 6 | 1) Dockerfile_postgres_9_6: Plese use this configuration for development purposes. Please refer to the [top level README](https://github.com/apache/madlib/blob/master/README.md) for setup instructions. 7 | 8 | 2) Dockerfile_postgres_11_Jenkins: This configuration is used by the Jenkins builds (https://ci-builds.apache.org/job/Madlib/job/madlib-build/job/master and https://ci-builds.apache.org/job/Madlib/job/madlib-build/view/change-requests/). 9 | 10 | ## The rest of the configs are based on CentOS images: 11 | 12 | 1) Dockerfile_centos_7_postgres_9.6 : Used for automated testing on centos 7 with postgres 9.6. 13 | 2) Dockerfile_centos_7_postgres_10 : Used for automated testing on centos 7 with postgres 10. 14 | 15 | 3) Dockerfile_centos_5_gpdb_4_3_10: This is work in progress, does not work at the moment. 16 | --------------------------------------------------------------------------------