Skip to content

Practices

Shannon Data AI Lab edited this page Apr 17, 2024 · 8 revisions

The practice cases of ShannonBase.

0: Compiling & Installation

Getting Started

  • How to build ShannonBase from source code

step 0: Requirement Installation

1: compiling tools:

apt-get install -y g++
apt-get install -y libbison-dev
apt-get install -y flex
apt-get install -y clang-format
apt-get install -y lcov
apt-get install -y pkg-config

2: Cmake

apt-get install -y cmake

3: tools

apt-get install -y git
apt-get install -y wget
apt-get install -y tar
apt-get install -y bzip2
apt-get install -y unzip

4: openssl etc.

apt-get install -y libssl-dev
apt-get install -y libncurses-dev
apt-get install -y  libudev-dev
apt-get install -y libgsasl-dev
apt-get install -y libldap-dev

5: Boost [from source code]

wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2
tar -xvf boost_1_77_0.tar.bz2 && cd boost_1_77_0 && ./bootstrap.sh && ./b2  && ./b2 install

step 1: clone the source code from Shannonbase Repo

  git clone [email protected]:Shannon-Data/ShannonBase.git

step 2: makes a directory where we build the source code.

  cd ShannonBase && mkdir cmake_build && cd cmake_build

step 3: run cmake

 cmake ../ \
  -DWITH_BOOST=/path-to-boost-include-files/ \
  -DCMAKE_BUILD_TYPE=[Release|Debug]  \
  -DCMAKE_INSTALL_PREFIX=/path-to-shannon-bin \
  -DMYSQL_DATADIR=/home/path-to-shannon-bin/data \
  -DSYSCONFDIR=. \
  -DMYSQL_UNIX_ADDR=/home/path-to-shannon-bin/tmp/mysql.sock \
  -DWITH_EMBEDDED_SERVER=OFF \
  -DWITH_MYISAM_STORAGE_ENGINE=1 \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_PARTITION_STORAGE_ENGINE=1 \
  -DMYSQL_TCP_PORT=3306 \
  -DENABLED_LOCAL_INFILE=1 \
  -DEXTRA_CHARSETS=all \
  -DWITH_PROTOBUF=bundled \
  -DWITH_SSL_PATH=/path-to-open-ssl/ \
  -DDEFAULT_SET=community \
  -DWITH_UNIT_TESTS=OFF \
  [-DENABLE_GCOV=1 \ |
  -DWITH_ASAN=1 \    | 
  ]
  -DCOMPILATION_COMMENT="MySQL Community Server, and Shannon Data AI Alpha V.- (GPL)" 

step 4: compile and install

  make -j5 && make install

step 5: initialize the database

  /path-to-shannbase-bin/bin/mysqld --defaults-file=/path-to-shannonbase-bin/my.cnf --initialize  --user=xxx

step 6: run shannonbase

 /path-to-shannbase-bin/bin//mysqld --defaults-file=/path-to-shannonbase-bin/my.cnf   --user=xxx &  

1: Using TPC-H

the script of creating table and loading data can be found here. https://github.com/Shannon-Data/heatwave-tpch/tree/main/TPCH.

After we have loaded the data into rapid engine, then, start to run queries.

Taking NATION as an instance.

create database tpch_1024;
alter database tpch_1024 CHARACTER SET ascii COLLATE ascii_bin; 
use tpch_1024;

CREATE TABLE NATION  ( N_NATIONKEY  INTEGER NOT NULL,
                       N_NAME       CHAR(25) NOT NULL,
                       N_REGIONKEY  INTEGER NOT NULL,
                       N_COMMENT    VARCHAR(152),
                       PRIMARY KEY (N_NATIONKEY));

2: Using ML functions

3: Using automatic changes population

Load the data into rapid engine.

alter table NATION secondary_load;

and if you want to use rapid mandatorily.

set use_secondary_engine=forced;

or you can use it according to cost

set secondary_engine_cost_threshold = xxx;

then do query, it will use rapid to do query.

  select * from NATION;