Skip to content

Commit 4fab538

Browse files
authored
use avx2 instructionset for bloommatch, use el8 to build (#16)
* avx2? * upgrade build pipeline to el8, fix avx2 handling * restore symlink name * use CFLAGS="-mavx2 -O3" and compatible types to automatically generate avx2 code * emacs auto indent * add missing return statement * inclde stdlib.h to avoid implicit declarations of functions malloc and free
1 parent f2d7107 commit 4fab538

4 files changed

Lines changed: 27 additions & 36 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM centos:7
2-
RUN yum -y install make automake autoconf libtool mariadb-devel
1+
FROM rockylinux:8
2+
RUN dnf -y install make automake autoconf libtool mariadb-devel
33
WORKDIR /code
44
COPY docker-entrypoint.sh /docker-entrypoint.sh
55
ENTRYPOINT [ "/docker-entrypoint.sh" ]

docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
cd /code || exit 1;
33
autoreconf -fvi
4-
bash configure
4+
CFLAGS="-mavx2 -O3" bash configure
55
make
66
make install DESTDIR=/code/buildroot

lib_mysqludf_bloom.c

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#include "config.h"
2828
#include <stdio.h>
29+
#include <stdlib.h>
30+
#include <stdint.h>
2931

3032
/* For Windows, define PACKAGE_STRING in the VS project */
3133
#ifndef __WIN__
@@ -69,38 +71,28 @@ void bloommatch_deinit(UDF_INIT *initid)
6971
{
7072
}
7173

72-
my_bool bloommatch(UDF_INIT *initid, UDF_ARGS *args, char* result, unsigned long* length, char *is_null, char *error)
73-
{
74-
if (args->lengths[0] > args->lengths[1])
75-
{
76-
return 0;
77-
}
7874

79-
char* b1=args->args[0];
80-
char* b2=args->args[1];
81-
int limit_a = args->lengths[0];
82-
int limit_b = args->lengths[1];
83-
if (limit_a != limit_b)
84-
{
85-
return 0;
86-
}
87-
88-
unsigned char a;
89-
unsigned char b;
90-
int i;
91-
for (i=0;i<limit_a;i++)
92-
{
93-
a = (unsigned char) b1[i];
94-
b = (unsigned char) b2[i];
95-
if ((a & b) != a)
96-
{
97-
return 0;
98-
}
99-
}
100-
return 1;
75+
my_bool bloommatch(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error)
76+
{
77+
if (args->lengths[0] != args->lengths[1])
78+
{
79+
return 0;
80+
}
81+
82+
const uint8_t *b1 = (const uint8_t *)args->args[0];
83+
const uint8_t *b2 = (const uint8_t *)args->args[1];
84+
85+
size_t limit = args->lengths[0];
86+
87+
for (size_t i = 0; i < limit; i++) {
88+
if ((b1[i] & b2[i]) != b1[i]) {
89+
return 0;
90+
}
91+
}
92+
93+
return 1;
10194
}
10295

103-
10496
my_bool bloomupdate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
10597
{
10698
/* make sure user has provided exactly two string arguments */
@@ -160,4 +152,3 @@ char* bloomupdate(UDF_INIT *initid, UDF_ARGS *args, char* result, unsigned long*
160152
*length = limit;
161153
return initid->ptr;
162154
}
163-

rpm.pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<packaging>rpm</packaging>
66
<modelVersion>4.0.0</modelVersion>
77
<artifactId>blf_02</artifactId>
8-
<version>${revision}${sha1}${changelist}.el7</version>
8+
<version>${revision}${sha1}${changelist}.el8</version>
99
<name>blf_02</name>
1010
<description>blf_02</description>
1111
<groupId>com.teragrep</groupId>
@@ -74,7 +74,7 @@
7474
<recurseDirectories>true</recurseDirectories>
7575
<sources>
7676
<source>
77-
<location>${project.basedir}/buildroot/usr/lib64/mysql/plugin</location>
77+
<location>${project.basedir}/buildroot/usr/lib64/mariadb/plugin</location>
7878
</source>
7979
</sources>
8080
</mapping>
@@ -98,7 +98,7 @@
9898
</mapping>
9999
<!-- symlink for the payload -->
100100
<mapping>
101-
<directory>/usr/lib64/mysql/plugin</directory>
101+
<directory>/usr/lib64/mariadb/plugin</directory>
102102
<sources>
103103
<softlinkSource>
104104
<location>/opt/teragrep/${project.artifactId}/lib/lib_mysqludf_bloom.so</location>

0 commit comments

Comments
 (0)