Postgresql15安装插件madlib2.0

news2024/11/26 2:43:20

madlib2.0简介

Apache MADlib

在这里插入图片描述

madlib使用指南

MADlib: Main Page

madlib安装

Installation Guide - Apache MADlib - Apache Software Foundation

准备

  • cmake 3.5.2及以上版本
  • python3.9
  • postgresql15,源码编译时必须指定 –with-python
  • postgresql插件plpython3u

源码安装cmake3.16.2

cd /opt

wget https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2.tar.gz
tar -zxvf cmake-3.16.2.tar.gz

cd cmake-3.16.2

./configure --prefix=/usr/local/cmake

make -j 4

make install

echo 'export CMAKE_HOME=/usr/local/cmake
export PATH=$CMAKE_HOME/bin:$PATH' >> /etc/profile

source /etc/profile

postgresql15.2源码安装

Centos7.6安装postgresql15

su - postgres
psql etl -U postgres
--指定库建立插件plpython3u
create extension plpython3u;
--创建用户madlib作为超级管理员
create role madlib with superuser login password '000000';
--默认公开由madlib创建的表的查询权限
alter default privileges for role madlib grant select on tables to public;
\q
exit

madlib2.0源码安装

cd /opt

# 上传 apache-madlib-2.0.0-src.tar.gz
# 下载地址:https://dist.apache.org/repos/dist/release/madlib/2.0.0/apache-madlib-2.0.0-src.tar.gz
rz # apache-madlib-2.0.0-src.tar.gz

# 解压
tar -zxvf /opt/apache-madlib-2.0.0-src.tar.gz -C /usr/local/src

# 环境变量
# MADLIB_ROOT : 源码目录
# MADLIB_BUILD_ROOT : 构建目录
echo 'export MADLIB_ROOT=/usr/local/src/apache-madlib-2.0.0-src
export MADLIB_BUILD_ROOT=/usr/local/src/apache-madlib-2.0.0-src/build' >> /etc/profile

source /etc/profile

# 创建build目录
mkdir $MADLIB_ROOT/build

# 切到目录 $MADLIB_BUILD_ROOT 
cd $MADLIB_BUILD_ROOT

# 配置
cmake ..

在这里插入图片描述

# 编译
# 会在线下载一些文件,所以比较慢,注意,不要用并行
make
# 会发现编译报错
/usr/local/src/apache-madlib-2.0.0-src/methods/array_ops/src/pg_gp/array_ops.c:11:24: fatal error: utils/int8.h: No such file or directory
 #include "utils/int8.h"
                        ^
compilation terminated.
make[2]: *** [src/ports/postgres/15/CMakeFiles/madlib_postgresql_15.dir/__/__/__/__/methods/array_ops/src/pg_gp/array_ops.c.o] Error 1
make[1]: *** [src/ports/postgres/15/CMakeFiles/madlib_postgresql_15.dir/all] Error 2
make: *** [all] Error 2

在这里插入图片描述

# 修改源码,将第11行的 #include "utils/int8.h" 删除
sed -i 's@#include "utils/int8.h"@@g' /usr/local/src/apache-madlib-2.0.0-src/methods/array_ops/src/pg_gp/array_ops.c

# 然后重新编译
make

# 又报另外一个错
# 函数调用错误,实际pg15中的pg_md5_hash有4个参数,单数源码中调用只用了3个参数
/usr/local/src/apache-madlib-2.0.0-src/methods/sketch/src/pg_gp/sketch_support.c: In function ‘sketch_md5_bytea’:
/usr/local/src/apache-madlib-2.0.0-src/methods/sketch/src/pg_gp/sketch_support.c:322:9: error: too few arguments to function ‘pg_md5_hash’
         pg_md5_hash(datp, len, outbuf);
         ^
In file included from /usr/local/src/apache-madlib-2.0.0-src/methods/sketch/src/pg_gp/sketch_support.c:46:0:
/usr/local/pgsql/include/server/common/md5.h:29:13: note: declared here
 extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum,
             ^
make[2]: *** [src/ports/postgres/15/CMakeFiles/madlib_postgresql_15.dir/__/__/__/__/methods/sketch/src/pg_gp/sketch_support.c.o] Error 1
make[1]: *** [src/ports/postgres/15/CMakeFiles/madlib_postgresql_15.dir/all] Error 2
make: *** [all] Error 2

在这里插入图片描述

# 定位到321行的else,如下图操作
vi /usr/local/src/apache-madlib-2.0.0-src/methods/sketch/src/pg_gp/sketch_support.c
# 增加
const char *errstr = NULL;
# 修改
pg_md5_hash(datp, len, outbuf, &errstr);

在这里插入图片描述
在这里插入图片描述

# 再次编译,此时已经编译成功
make

在这里插入图片描述

# 将源码目录授权给postgres用户
chown -R postgres.postgres $MADLIB_ROOT

# 切换到postgres用户
su - postgres

# 开始安装
$MADLIB_ROOT/src/bin/madpack -s madlib -c madlib/000000@localhost:5432/etl install --platform postgres
# 报错
m4:/usr/local/src/apache-madlib-2.0.0-src/src/ports/postgres/modules/validation/cross_validation.sql_in:14: cannot open `SQLCommon.m4': No such file or directory
madpack.py: INFO : Installing MADlib:
madpack.py: ERROR : Failed executing /tmp/madlib.Niatpe/madlib_install.sql
madpack.py: ERROR : Check the log at /tmp/madlib.Niatpe/madlib_install.sql.log
madpack.py: INFO : MADlib install unsuccessful.
madpack.py: INFO : All changes are rolled back.
INFO: Log files saved in /tmp/madlib.Niatpe

在这里插入图片描述

# 查找文件 SQLCommon.m4
find $MADLIB_ROOT -name SQLCommon.m4
/usr/local/src/apache-madlib-2.0.0-src/build/src/ports/postgres/15/madpack/SQLCommon.m4

# 切到该目录
cd /usr/local/src/apache-madlib-2.0.0-src/build/src/ports/postgres/15/madpack/

# 重新安装
$MADLIB_ROOT/src/bin/madpack -s madlib -c madlib/000000@localhost:5432/etl install --platform postgres

# 依然报错
madpack.py: INFO : Detected PostgreSQL version 15.2.
madpack.py: INFO : *** Installing MADlib ***
madpack.py: INFO : MADlib tools version    = 2.0.0 (/usr/local/src/apache-madlib-2.0.0-src/src/bin/../madpack/madpack.py)
madpack.py: INFO : MADlib database version = None (host=localhost:5432, db=etl, schema=madlib)
madpack.py: INFO : Testing PL/Python environment...
madpack.py: INFO : > PL/Python environment OK (version: 3.9.17)
madpack.py: INFO : > Preparing objects for the following modules:
madpack.py: INFO : > - bayes
madpack.py: INFO : > - crf
madpack.py: INFO : > - elastic_net
madpack.py: INFO : > - linalg
madpack.py: INFO : > - pmml
madpack.py: INFO : > - prob
madpack.py: INFO : > - svm
madpack.py: INFO : > - tsa
madpack.py: INFO : > - conjugate_gradient
madpack.py: INFO : > - knn
madpack.py: INFO : > - lda
madpack.py: INFO : > - stats
madpack.py: INFO : > - utilities
madpack.py: INFO : > - assoc_rules
madpack.py: INFO : > - convex
madpack.py: INFO : > - dbscan
madpack.py: INFO : > - deep_learning
madpack.py: INFO : > - glm
madpack.py: INFO : > - graph
madpack.py: INFO : > - linear_systems
madpack.py: INFO : > - mxgboost
madpack.py: INFO : > - recursive_partitioning
madpack.py: INFO : > - regress
madpack.py: INFO : > - sample
madpack.py: INFO : > - summary
madpack.py: INFO : > - kmeans
madpack.py: INFO : > - pca
madpack.py: INFO : > - validation
madpack.py: INFO : Installing MADlib:
madpack.py: ERROR : Failed executing /tmp/madlib.QJOwWI/madlib_install.sql
madpack.py: ERROR : Check the log at /tmp/madlib.QJOwWI/madlib_install.sql.log
madpack.py: INFO : MADlib install unsuccessful.
madpack.py: INFO : All changes are rolled back.
INFO: Log files saved in /tmp/madlib.QJOwWI

在这里插入图片描述

# 查看日志
cat /tmp/madlib.QJOwWI/madlib_install.sql.log | tail -4
CREATE OR REPLACE FUNCTION madlib.vcrf_top1_label(mArray DOUBLE PRECISION[], rArray DOUBLE PRECISION[], nlabel int)
returns int[] as 'libmadlib.so' language c strict;
psql:/tmp/madlib.QJOwWI/madlib_install.sql:464: ERROR:  could not access file "libmadlib.so": No such file or directory

在这里插入图片描述

# 查找该文件
find $MADLIB_ROOT -name libmadlib.so
/usr/local/src/apache-madlib-2.0.0-src/build/src/ports/postgres/15/lib/libmadlib.so

# 编辑pg的数据目录下的postgresql.auto.conf文件
vi $PGDATA/postgresql.auto.conf
dynamic_library_path = '/usr/local/src/apache-madlib-2.0.0-src/build/src/ports/postgres/15/lib'

# 重启postgresql
pg_ctl restart -mf

# 再次重新安装
$MADLIB_ROOT/src/bin/madpack -s madlib -c madlib/000000@localhost:5432/etl install --platform postgres

# 依然报错
madpack.py: INFO : Detected PostgreSQL version 15.2.
server signaled
madpack.py: INFO : *** Installing MADlib ***
madpack.py: INFO : MADlib tools version    = 2.0.0 (/usr/local/src/apache-madlib-2.0.0-src/src/bin/../madpack/madpack.py)
madpack.py: INFO : MADlib database version = None (host=localhost:5432, db=etl, schema=madlib)
madpack.py: INFO : Testing PL/Python environment...
madpack.py: INFO : > PL/Python environment OK (version: 3.9.17)
madpack.py: INFO : > Preparing objects for the following modules:
madpack.py: INFO : > - bayes
madpack.py: INFO : > - crf
madpack.py: INFO : > - elastic_net
madpack.py: INFO : > - linalg
madpack.py: INFO : > - pmml
madpack.py: INFO : > - prob
madpack.py: INFO : > - svm
madpack.py: INFO : > - tsa
madpack.py: INFO : > - conjugate_gradient
madpack.py: INFO : > - knn
madpack.py: INFO : > - lda
madpack.py: INFO : > - stats
madpack.py: INFO : > - utilities
madpack.py: INFO : > - assoc_rules
madpack.py: INFO : > - convex
madpack.py: INFO : > - dbscan
madpack.py: INFO : > - deep_learning
madpack.py: INFO : > - glm
madpack.py: INFO : > - graph
madpack.py: INFO : > - linear_systems
madpack.py: INFO : > - mxgboost
madpack.py: INFO : > - recursive_partitioning
madpack.py: INFO : > - regress
madpack.py: INFO : > - sample
madpack.py: INFO : > - summary
madpack.py: INFO : > - kmeans
madpack.py: INFO : > - pca
madpack.py: INFO : > - validation
madpack.py: INFO : Installing MADlib:
madpack.py: ERROR : Failed executing /tmp/madlib.pSbRNZ/madlib_install.sql
madpack.py: ERROR : Check the log at /tmp/madlib.pSbRNZ/madlib_install.sql.log
madpack.py: INFO : MADlib install unsuccessful.
madpack.py: INFO : All changes are rolled back.
INFO: Log files saved in /tmp/madlib.pSbRNZ

在这里插入图片描述

# 查看日志 报错:函数不存在
cat /tmp/madlib.pSbRNZ/madlib_install.sql.log | tail -5
madlib.array_union(anyarray) (
    SFUNC = array_cat,
    STYPE = anyarray
);
psql:/tmp/madlib.pSbRNZ/madlib_install.sql:571: ERROR:  function array_cat(anyarray, anyarray) does not exist

在这里插入图片描述

# 自己建函数 array_cat(anyarray, anyarray)
psql etl -U madlib
CREATE OR REPLACE FUNCTION public.array_cat(anyarray, anyarray)
 RETURNS anyarray
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
begin
    return array_cat($1,$2);
end;
$function$
;
\q

# 再次安装
$MADLIB_ROOT/src/bin/madpack -s madlib -c madlib/000000@localhost:5432/etl install --platform postgres

# 依然报错
madpack.py: INFO : Detected PostgreSQL version 15.2.
madpack.py: INFO : *** Installing MADlib ***
madpack.py: INFO : MADlib tools version    = 2.0.0 (/usr/local/src/apache-madlib-2.0.0-src/src/bin/../madpack/madpack.py)
madpack.py: INFO : MADlib database version = None (host=localhost:5432, db=etl, schema=madlib)
madpack.py: INFO : Testing PL/Python environment...
madpack.py: INFO : > PL/Python environment OK (version: 3.9.17)
madpack.py: INFO : > Preparing objects for the following modules:
madpack.py: INFO : > - bayes
madpack.py: INFO : > - crf
madpack.py: INFO : > - elastic_net
madpack.py: INFO : > - linalg
madpack.py: INFO : > - pmml
madpack.py: INFO : > - prob
madpack.py: INFO : > - svm
madpack.py: INFO : > - tsa
madpack.py: INFO : > - conjugate_gradient
madpack.py: INFO : > - knn
madpack.py: INFO : > - lda
madpack.py: INFO : > - stats
madpack.py: INFO : > - utilities
madpack.py: INFO : > - assoc_rules
madpack.py: INFO : > - convex
madpack.py: INFO : > - dbscan
madpack.py: INFO : > - deep_learning
madpack.py: INFO : > - glm
madpack.py: INFO : > - graph
madpack.py: INFO : > - linear_systems
madpack.py: INFO : > - mxgboost
madpack.py: INFO : > - recursive_partitioning
madpack.py: INFO : > - regress
madpack.py: INFO : > - sample
madpack.py: INFO : > - summary
madpack.py: INFO : > - kmeans
madpack.py: INFO : > - pca
madpack.py: INFO : > - validation
madpack.py: INFO : Installing MADlib:
madpack.py: ERROR : Failed executing /tmp/madlib.IB61Bf/madlib_install.sql
madpack.py: ERROR : Check the log at /tmp/madlib.IB61Bf/madlib_install.sql.log
madpack.py: INFO : MADlib install unsuccessful.
madpack.py: INFO : All changes are rolled back.
INFO: Log files saved in /tmp/madlib.IB61Bf 

在这里插入图片描述

# 查看日志 报错:函数不存在
cat /tmp/madlib.IB61Bf/madlib_install.sql.log | tail -7
CREATE AGGREGATE madlib.agg_array_concat(REAL[]) (
   SFUNC = array_cat,
   PREFUNC = array_cat,
   STYPE = REAL[]
   );
psql:/tmp/madlib.IB61Bf/madlib_install.sql:15416: WARNING:  aggregate attribute "prefunc" not recognized
psql:/tmp/madlib.IB61Bf/madlib_install.sql:15416: ERROR:  function array_cat(real[], real[]) does not exist

在这里插入图片描述

# 自己建函数 array_cat(real[], real[])
psql etl -U madlib
CREATE OR REPLACE FUNCTION public.array_cat(real[], real[])
 RETURNS real[]
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
begin
    return array_cat($1,$2);
end;
$function$
;
\q

# 再次安装
$MADLIB_ROOT/src/bin/madpack -s madlib -c madlib/000000@localhost:5432/etl install --platform postgres

# 依然报错
madpack.py: INFO : Detected PostgreSQL version 15.2.
madpack.py: INFO : *** Installing MADlib ***
madpack.py: INFO : MADlib tools version    = 2.0.0 (/usr/local/src/apache-madlib-2.0.0-src/src/bin/../madpack/madpack.py)
madpack.py: INFO : MADlib database version = None (host=localhost:5432, db=etl, schema=madlib)
madpack.py: INFO : Testing PL/Python environment...
madpack.py: INFO : > PL/Python environment OK (version: 3.9.17)
madpack.py: INFO : > Preparing objects for the following modules:
madpack.py: INFO : > - bayes
madpack.py: INFO : > - crf
madpack.py: INFO : > - elastic_net
madpack.py: INFO : > - linalg
madpack.py: INFO : > - pmml
madpack.py: INFO : > - prob
madpack.py: INFO : > - svm
madpack.py: INFO : > - tsa
madpack.py: INFO : > - conjugate_gradient
madpack.py: INFO : > - knn
madpack.py: INFO : > - lda
madpack.py: INFO : > - stats
madpack.py: INFO : > - utilities
madpack.py: INFO : > - assoc_rules
madpack.py: INFO : > - convex
madpack.py: INFO : > - dbscan
madpack.py: INFO : > - deep_learning
madpack.py: INFO : > - glm
madpack.py: INFO : > - graph
madpack.py: INFO : > - linear_systems
madpack.py: INFO : > - mxgboost
madpack.py: INFO : > - recursive_partitioning
madpack.py: INFO : > - regress
madpack.py: INFO : > - sample
madpack.py: INFO : > - summary
madpack.py: INFO : > - kmeans
madpack.py: INFO : > - pca
madpack.py: INFO : > - validation
madpack.py: INFO : Installing MADlib:
madpack.py: ERROR : Failed executing /tmp/madlib.rjqeeK/madlib_install.sql
madpack.py: ERROR : Check the log at /tmp/madlib.rjqeeK/madlib_install.sql.log
madpack.py: INFO : MADlib install unsuccessful.
madpack.py: INFO : All changes are rolled back.
INFO: Log files saved in /tmp/madlib.rjqeeK

在这里插入图片描述

# 查看日志 报错:函数不存在
cat /tmp/madlib.rjqeeK/madlib_install.sql.log | tail -7
CREATE AGGREGATE madlib.agg_array_concat(SMALLINT[]) (
   SFUNC = array_cat,
   PREFUNC = array_cat,
   STYPE = SMALLINT[]
   );
psql:/tmp/madlib.rjqeeK/madlib_install.sql:15423: WARNING:  aggregate attribute "prefunc" not recognized
psql:/tmp/madlib.rjqeeK/madlib_install.sql:15423: ERROR:  function array_cat(smallint[], smallint[]) does not exist

在这里插入图片描述

# 自己建函数 array_cat(real[], real[])
psql etl -U madlib
CREATE OR REPLACE FUNCTION public.array_cat(smallint[], smallint[])
 RETURNS smallint[]
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
begin
    return array_cat($1,$2);
end;
$function$
;
\q

# 再次安装
$MADLIB_ROOT/src/bin/madpack -s madlib -c madlib/000000@localhost:5432/etl install --platform postgres

# 安装成功
madpack.py: INFO : Detected PostgreSQL version 15.2.
madpack.py: INFO : *** Installing MADlib ***
madpack.py: INFO : MADlib tools version    = 2.0.0 (/usr/local/src/apache-madlib-2.0.0-src/src/bin/../madpack/madpack.py)
madpack.py: INFO : MADlib database version = None (host=localhost:5432, db=etl, schema=madlib)
madpack.py: INFO : Testing PL/Python environment...
madpack.py: INFO : > PL/Python environment OK (version: 3.9.17)
madpack.py: INFO : > Preparing objects for the following modules:
madpack.py: INFO : > - bayes
madpack.py: INFO : > - crf
madpack.py: INFO : > - elastic_net
madpack.py: INFO : > - linalg
madpack.py: INFO : > - pmml
madpack.py: INFO : > - prob
madpack.py: INFO : > - svm
madpack.py: INFO : > - tsa
madpack.py: INFO : > - conjugate_gradient
madpack.py: INFO : > - knn
madpack.py: INFO : > - lda
madpack.py: INFO : > - stats
madpack.py: INFO : > - utilities
madpack.py: INFO : > - assoc_rules
madpack.py: INFO : > - convex
madpack.py: INFO : > - dbscan
madpack.py: INFO : > - deep_learning
madpack.py: INFO : > - glm
madpack.py: INFO : > - graph
madpack.py: INFO : > - linear_systems
madpack.py: INFO : > - mxgboost
madpack.py: INFO : > - recursive_partitioning
madpack.py: INFO : > - regress
madpack.py: INFO : > - sample
madpack.py: INFO : > - summary
madpack.py: INFO : > - kmeans
madpack.py: INFO : > - pca
madpack.py: INFO : > - validation
madpack.py: INFO : Installing MADlib:
madpack.py: INFO : > Created madlib schema
madpack.py: INFO : > Created madlib.MigrationHistory table
madpack.py: INFO : > Wrote version info in MigrationHistory table
madpack.py: INFO : MADlib 2.0.0 installed successfully in madlib schema.

在这里插入图片描述

# 如果依然报错函数错误,也可能是没有函数array_union(pg_catalog.anyarray)
psql etl -U madlib
CREATE OR REPLACE AGGREGATE public.array_union(pg_catalog.anyarray) (
	SFUNC = public.array_cat,
	STYPE = anyarray
);
\q
# 权限
psql etl -U postgres
--回收madlib的超级用户权限
alter role madlib with nosuperuser;
--授权madlib用户madlib模式的所有权限
grant all on schema madlib to madlib;
--授权public用户组madlib模式的使用权限
grant usage on schema madlib to public;
--回收madlib在public模式上函数的执行权限,也就是的函数得显式授权
alter default privileges for role madlib revoke execute on functions from public;
--回收在madlib模式上的public的执行权限,也就是madlib模式下的函数得显式授权才能使用
alter default privileges in schema madlib revoke execute on functions from public;
--默认公开在模式madlib下表的查询权限
alter default privileges in schema madlib grant select on tables to public;

测试

DROP TABLE IF EXISTS test;
CREATE TABLE test(
    id1 INTEGER,
    id2 INTEGER,
    gr1 INTEGER,
    gr2 INTEGER
);
INSERT INTO test VALUES
(1,0,1,1),
(2,0,1,1),
(3,0,1,1),
(4,0,1,1),
(5,0,1,1),
(6,0,1,1),
(7,0,1,1),
(8,0,1,1),
(9,0,1,1),
(9,0,1,1),
(9,0,1,1),
(9,0,1,1),
(0,1,1,2),
(0,2,1,2),
(0,3,1,2),
(0,4,1,2),
(0,5,1,2),
(0,6,1,2),
(10,10,2,2),
(20,20,2,2),
(30,30,2,2),
(40,40,2,2),
(50,50,2,2),
(60,60,2,2),
(70,70,2,2);
DROP TABLE IF EXISTS out;
SELECT madlib.stratified_sample(
    'test',    -- Source table
    'out',     -- Output table
    0.5,       -- Sample proportion
    'gr1,gr2', -- Strata definition
    'id1,id2', -- Columns to output
    false
);    -- Sample without replacement
SELECT * FROM out ORDER BY gr1,gr2,id1,id2;
  • 报错:ERROR: ImportError: cannot import name ‘stratified_sample’ from ‘sample’ (unknown location)
    在这里插入图片描述
  • 查看源码

在这里插入图片描述

# 发现/usr/local/src/apache-madlib-2.0.0-src/src/lib/python目录都不存在
cd /usr/local/src/apache-madlib-2.0.0-src/src/lib/python
-bash: cd: /usr/local/src/apache-madlib-2.0.0-src/src/lib/python: No such file or directory

# 发现不是py文件
ls /usr/local/src/apache-madlib-2.0.0-src/src/modules/sample
random_process.cpp  random_process.hpp  sample.hpp  weighted_sample.cpp  weighted_sample.hpp  WeightedSample_impl.hpp  WeightedSample_proto.hpp

在这里插入图片描述

find / -name python


find $MADLIB_ROOT -name sample
/usr/local/src/apache-madlib-2.0.0-src/build/third_party/src/EP_boost/libs/geometry/doc/src/docutils/tools/doxygen_xml2qbk/sample
/usr/local/src/apache-madlib-2.0.0-src/build/src/ports/greenplum/modules/sample
/usr/local/src/apache-madlib-2.0.0-src/build/src/ports/postgres/15/CMakeFiles/madlib_postgresql_15.dir/__/__/__/modules/sample
/usr/local/src/apache-madlib-2.0.0-src/build/src/ports/postgres/15/modules/sample
/usr/local/src/apache-madlib-2.0.0-src/build/src/ports/postgres/modules/sample
/usr/local/src/apache-madlib-2.0.0-src/src/ports/postgres/modules/sample
/usr/local/src/apache-madlib-2.0.0-src/src/modules/sample


在这里插入图片描述

在这里插入图片描述

su - postgres
mkdir -p /usr/local/src/apache-madlib-2.0.0-src/src/lib
# 创建软连接
ln -s /export/anaconda3/lib/python3.9 /usr/local/src/apache-madlib-2.0.0-src/src/lib/python

# 重命名
mv /usr/local/src/apache-madlib-2.0.0-src/src/modules /usr/local/src/apache-madlib-2.0.0-src/src/modules_bak
# 创建软连接
ln -s /usr/local/src/apache-madlib-2.0.0-src/build/src/ports/postgres/15/modules /usr/local/src/apache-madlib-2.0.0-src/src/modules
  • 重新测试
DROP TABLE IF EXISTS out;
SELECT madlib.stratified_sample(
    'test',    -- Source table
    'out',     -- Output table
    0.5,       -- Sample proportion
    'gr1,gr2', -- Strata definition
    'id1,id2', -- Columns to output
    false
);    -- Sample without replacement

SELECT * FROM out ORDER BY gr1,gr2,id1,id2;

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/844840.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【Autolayout自动布局介绍2 Objective-C语言】

一、好,我们继续来介绍Autolayout 1.好,那么,我们接下来,开始上课了, 刚才,给大家介绍了一下,我们就是屏幕布局里面,用到的,主要就是这四个按钮: 1)第一个:是用来做对齐的 2)第二个:是用来做固定的 3)第三个:是用来解决自动布局中出现的一些问题的 4)第四…

元组是什么,python怎么使用元组

目录 引言 元组的概念 作用和优势 元组的应用 Python中如何使用元组 注意事项 总结 引言 在Python编程语言中,元组(Tuple)是一种不可变的数据结构,它允许我们以有序且不可修改的方式存储多个元素。与列表不同,…

简单游戏截图_可控截取内容2

一个需求 我需要在场景中截取不同层级的截图(如只截模型或只截UI或只截外部相加看到的画面 或全都截或和Shader配合呈现人眼夜视仪热成像的画面切换) 将截图排到列表中,在场景UI中展示出来 如何做 相机要能够看到不同的画面 将当前帧画面存储下来 将存储的画面展示出…

利用文档管理系统软件实现信息共享与知识沉淀

在当今信息的时代,各个企业和组织面临着大量的信息管理和知识沉淀的问题。为了更好地实现信息共享和知识沉淀,许多企业开始使用文档管理软件,该软件通过整合和管理各种文档,并提供强大的搜索和分享功能,有效促进了信息…

Java容器之Stack和Deque

Java容器之Stack和Deque 目录概述需求: 设计思路实现思路分析1.Java中Deque和Stack都是用于实现栈(stack)数据结构的类,但它们有一些区别。2.实现方式不同3.用途不同 拓展实现 参考资料和推荐阅读 Survive by day and develop by …

代驾小程序怎么做

代驾小程序是一款专门为用户提供代驾服务的手机应用程序。它具有以下功能: 1. 预约代驾:代驾小程序允许用户在需要代驾服务时提前进行预约。用户可以选择出发地点、目的地以及预计用车时间,系统会自动匹配最合适的代驾司机,并确保…

Ref从入门到入土

首先做个对比: 功能一:引用一个值做持久化记忆 场景:清除定时器 import { useRef } from "react" import { useState } from "react" // ref:1.引用一个值 做持久化记忆 // let num useRef(1) // console.log(num.cur…

Pandaer的iPhone手机壳

哇塞,Pandaer的设计太棒了!手机壳的花样多到让我眼花缭乱,好多系列设计都很有意思,让人有集齐的冲动。我最近入手了几个iPhone的手机壳,它有亮色和透明的款式,亮色的壳内部也是亮的,因为手机壳全…

宝塔一键安装包安装魔众XX系统

1 环境安装 1.1 一定先看 在阅读本文档安装系统时,请确保您已经 熟练掌握 如何使用 apache 或 nginx 的进行网站系统的配置方法。 如果您 不是很了解 或 了解甚少,请直接购买我们的 付费安装服务,同时把服务器信息、需要安装的系统源码提供给…

8月1日上课内容 第一章web基础与http协议

dns与域名 网络是基于tcp/ip协议进行通信和连接的 应用层--传输层---网络层----数据链路层-----物理层 ip地址,我们每一台主机都有一个唯一的地址标识(固定的ip地址),区分用户和计算机通信。 ip地址:32位二进制数组成的,不方便记忆 192.168.…

Android Ble蓝牙App(三)特性和属性

Ble蓝牙App(三)特性使用 前言正文一、获取属性列表二、属性适配器三、获取特性名称四、特性适配器五、加载特性六、显示特性和属性七、源码 前言 在上一篇中我们完成了连接和发现服务两个动作,那么再发现服务之后要做什么呢?发现服…

Java循环:探索迭代的世界

文章目录 1. for循环2. while循环3. do-while循环总结 循环是编程中的重要概念,它允许我们重复执行特定的代码块,帮助我们简化复杂的任务和提高代码的效率。在Java中,循环有多种形式,包括for循环、while循环和do-while循环。本篇博…

玩转SWAT模型——最全面SWAT模型教程【建模方法、实例应用、高级进阶】

目录 第一部分:SWAT模型实践部分 第二部分:SWAT模型【进阶部分】 更多推荐 【专家】:刘老师【副教授】,北京重点高校资深专家,和美国SWAT软件开发方长期合作,拥有丰富的科研及工程技术经验,长…

虫情监测仪介绍—技术原理、功能优势是什么?

KH-CQPest虫情监测仪是做好虫情监测的重要设备,利用虫情监测仪能够对农业大田、智慧温室、林业等场景的害虫分布情况及害虫种类进行监测,协助人们制定合理的防治措施。 1.技术原理: KH-CQPest虫情监测仪采用光学诱虫原理,配合传感…

【嵌入式学习笔记】嵌入式入门3——串口USART

1.数据通信的基础概念 1.1.串行/并行通信 数据通信按数据通信方式分类:串行通信、并行通信 1.2.单工/半双工/全双工通信 数据通信按数据传输方向分类:单工通信、半双工通信、全双工通信 单工通信:数据只能沿一个方向传输半双工通信&…

架构训练营学习笔记:6-2 微服务基础选型

基础选型 微服务基础设施架构 优先级 其中,核心 就是服务注册、服务发现、服务路由。 模式1-嵌入SDK 模式2-反向代理式 模式3-网络代理式(Service Mesh) 模式对比 常见微服务框架选择 嵌入SDK-dubbo Spring Cloud 反向代理式 APISIX …

【Docker】性能测试监控平台搭建:InfluxDB+Grafana+Jmeter+cAdvisor

前言 在做性能测试时,如果有一个性能测试结果实时展示的页面,可以极大的提高我们对系统性能表现的掌握程度,进而提高我们的测试效率。但是我们每次打开Jmeter都会有几个硕大的字提示别用GUI模式进行负载测试,而且它自带的监视器效…

LeetCode-Java(06)

24. 两两交换链表中的节点 非递归解法 class Solution {public ListNode swapPairs(ListNode head) {ListNode pre new ListNode(0);pre.next head;ListNode temp pre;while(temp.next ! null && temp.next.next ! null) {ListNode start temp.next;ListNode end …

指标体系构建与验证

文章目录 知网论文1 本土化计算思维评价指标体系的构建与探索——基于1410名高中生的样本分析与验证2 企业集团人力资源管理质量评价指标体系的构建3 基于知识管理的创新型企业评价指标体系的构建及验证4 中国公民科学素质测评指标体系研究5 中国企业劳动关系评价指标体系的改进…

Linux ❀ Yum源安装RPM包常见问题与解决方法

文章目录 1、Yum源仓库检查2、执行安装报错2.1 RPM包缺失2.2 进程锁定2.3 未完成事务2.4 RPM包冲突 1、Yum源仓库检查 404错误多为yum源无法访问导致,检查yum仓库是否配置正确,同时确认baseurl连通性。 $ cd /etc/yum.repos.d/ $ cat ${yum_file} | gr…