Skip to content

Commit 00de02c

Browse files
Support madlib2 for lighting.
This commit, we support madlib2 for the version 3 of lightning.
1 parent 6555f60 commit 00de02c

File tree

18 files changed

+715
-8
lines changed

18 files changed

+715
-8
lines changed

methods/kmeans/src/pg_gp/kmeans.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ compute_metric(PGFunction inMetricFn, MemoryContext inMemContext, Datum inVec1,
8787
* in execUtils.c
8888
*/
8989

90-
#if GP_VERSION_NUM >= 70000
90+
#if defined(IS_CLOUDBERRY) || GP_VERSION_NUM >= 70000
9191
if(inMemContext->mem_allocated > 50000)
9292
#else
9393
if(inMemContext->allBytesAlloc - inMemContext->allBytesFreed > 50000)

src/config/Ports.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ postgres:
99

1010
greenplum:
1111
name: Greenplum DB
12+
13+
cloudberry:
14+
name: Cloudberry DB

src/madpack/madpack.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
for port in ports:
6565
portid_list.append(port)
6666

67-
SUPPORTED_PORTS = ('postgres', 'greenplum')
67+
SUPPORTED_PORTS = ('postgres', 'greenplum', 'cloudberry')
6868

6969
# Global variables
7070
portid = None # Target port ID (eg: pg90, gp40)
@@ -189,7 +189,8 @@ def _run_m4_and_append(schema, maddir_mod_py, module, sqlfile,
189189
'-I' + maddir_madpack,
190190
sqlfile]
191191
if ( (portid == 'postgres') &
192-
(is_rev_gte(get_rev_num(dbver), get_rev_num('14.0'))) ):
192+
(is_rev_gte(get_rev_num(dbver), get_rev_num('14.0'))) or
193+
(portid == 'cloudberry') ):
193194
m4args = ['m4',
194195
'-P',
195196
'-DMADLIB_SCHEMA=' + schema,
@@ -370,7 +371,7 @@ def _check_db_port(portid):
370371
if portid == 'postgres':
371372
if row[0]['version'].lower().find('greenplum') < 0:
372373
return True
373-
elif portid == 'greenplum':
374+
elif portid == 'greenplum' or portid == 'cloudberry':
374375
return True
375376
return False
376377
# ------------------------------------------------------------------------------
@@ -1240,6 +1241,7 @@ def create_install_madlib_sqlfile(args, madpack_cmd):
12401241
def get_madlib_function_drop_str(schema):
12411242

12421243
if ((portid == 'greenplum' and is_rev_gte(get_rev_num(dbver), get_rev_num('7.0'))) or
1244+
(portid == 'cloudberry') or
12431245
(portid == 'postgres')):
12441246
case_str = """
12451247
CASE p.prokind
@@ -1350,8 +1352,8 @@ def set_dynamic_library_path_in_database(dbver_split, madlib_library_path):
13501352
paths.append(madlib_library_path)
13511353
dynamic_library_path = ':'.join(paths)
13521354

1353-
if portid == 'greenplum':
1354-
if is_rev_gte(dbver_split, get_rev_num('6.0')):
1355+
if portid == 'greenplum' or portid == 'cloudberry':
1356+
if is_rev_gte(dbver_split, get_rev_num('6.0')) or portid == 'cloudberry':
13551357
ret = os.system('gpconfig -c dynamic_library_path -v \'{0}\''.format(dynamic_library_path))
13561358
else:
13571359
ret = os.system('gpconfig -c dynamic_library_path -v \'\\{0}\''.format(dynamic_library_path))
@@ -1482,6 +1484,9 @@ def main(argv):
14821484
else:
14831485
# only need the first two digits for <= 4.3.4
14841486
dbver = '.'.join(map(str, dbver_split[:2]))
1487+
elif portid == 'cloudberry':
1488+
# Assume Cloudberry will stick to semantic versioning
1489+
dbver = str(dbver_split[0])
14851490
elif portid == 'postgres':
14861491
if is_rev_gte(dbver_split, get_rev_num('10.0')):
14871492
# Postgres starting 10.0 uses semantic versioning. Hence,

src/madpack/utilities.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ def get_dbver(con_args, portid):
189189
# for Greenplum the 3rd digit is necessary to differentiate
190190
# 4.3.5+ from versions < 4.3.5
191191
match = re.search("Greenplum[a-zA-Z\s]*(\d+\.\d+\.\d+)", versionStr)
192+
elif portid == 'cloudberry':
193+
match = re.search("Cloudberry[a-zA-Z\s]*(\d+\.\d+\.\d+", versionStr)
192194
return None if match is None else match.group(1)
193195
except Exception:
194196
error_(this, "Failed reading database version", True)

src/ports/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
add_subdirectory(postgres)
22
add_subdirectory(greenplum)
3+
add_subdirectory(cloudberry)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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_cloudberry_version()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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_cloudberry_version()

0 commit comments

Comments
 (0)