You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
Deep build refactoring phase 2 (#3564)
* configcpp refactored * chore(build): massive removals, auto add files to debian install file * chore(build): configure before autobake * chore(build): use custom cmake commands for components, mariadb-plugin-columnstore.install generated * chore(build): install deps as separate step for build-packages * more deps * chore(codemanagement, build): build refactoring stage2 * chore(safety): Locked Map for MessageqCpp with a simpler way Please enter the commit message for your changes. Lines starting * chore(codemanagement, ci): better coredumps handling, deps fixed * Delete build/bootstrap_mcs.py * Update charset.cpp (add license)
This commit is contained in:
@ -1,26 +1,28 @@
|
||||
# add_subdirectory(boost_idb)
|
||||
add_subdirectory(startup)
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(configcpp)
|
||||
add_subdirectory(loggingcpp)
|
||||
add_subdirectory(messageqcpp)
|
||||
add_subdirectory(threadpool)
|
||||
add_subdirectory(rwlock)
|
||||
add_subdirectory(dataconvert)
|
||||
add_subdirectory(joiner)
|
||||
add_subdirectory(rowgroup)
|
||||
add_subdirectory(cacheutils)
|
||||
add_subdirectory(funcexp)
|
||||
add_subdirectory(udfsdk)
|
||||
add_subdirectory(compress)
|
||||
add_subdirectory(batchloader)
|
||||
add_subdirectory(ddlcleanup)
|
||||
add_subdirectory(querystats)
|
||||
add_subdirectory(windowfunction)
|
||||
add_subdirectory(idbdatafile)
|
||||
add_subdirectory(querytele)
|
||||
add_subdirectory(libmysql_client)
|
||||
add_subdirectory(regr)
|
||||
add_subdirectory(cacheutils)
|
||||
add_subdirectory(cloudio)
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(compress)
|
||||
add_subdirectory(configcpp)
|
||||
add_subdirectory(dataconvert)
|
||||
add_subdirectory(ddlcleanup)
|
||||
add_subdirectory(funcexp)
|
||||
add_subdirectory(idbdatafile)
|
||||
add_subdirectory(joiner)
|
||||
add_subdirectory(libmarias3)
|
||||
add_subdirectory(libmysql_client)
|
||||
add_subdirectory(loggingcpp)
|
||||
add_subdirectory(mariadb_charset)
|
||||
add_subdirectory(messageqcpp)
|
||||
add_subdirectory(pron)
|
||||
add_subdirectory(querystats)
|
||||
add_subdirectory(querytele)
|
||||
add_subdirectory(regr)
|
||||
add_subdirectory(rowgroup)
|
||||
add_subdirectory(rwlock)
|
||||
add_subdirectory(startup)
|
||||
add_subdirectory(statistics_manager)
|
||||
add_subdirectory(threadpool)
|
||||
add_subdirectory(udfsdk)
|
||||
add_subdirectory(windowfunction)
|
||||
|
@ -6,4 +6,4 @@ set(batchloader_LIB_SRCS batchloader.cpp)
|
||||
|
||||
columnstore_library(batchloader ${batchloader_LIB_SRCS})
|
||||
|
||||
columnstore_link(batchloader ${NETSNMP_LIBRARIES} loggingcpp)
|
||||
columnstore_link(batchloader oamcpp loggingcpp)
|
||||
|
@ -5,4 +5,4 @@ include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
set(cacheutils_LIB_SRCS cacheutils.cpp)
|
||||
|
||||
columnstore_library(cacheutils ${cacheutils_LIB_SRCS})
|
||||
columnstore_link(cacheutils messageqcpp)
|
||||
columnstore_link(cacheutils messageqcpp boost_thread)
|
||||
|
@ -14,7 +14,7 @@ columnstore_library(cloudio ${cloudio_LIB_SRCS})
|
||||
|
||||
# IDBDataFile currently depends on cloudio, which is backward. Once cloudio has been turned into a proper plugin for
|
||||
# idbdatafile, we should be able to reverse the dependency like so:
|
||||
columnstore_link(cloudio idbdatafile messageqcpp)
|
||||
columnstore_link(cloudio idbdatafile messageqcpp boost_thread)
|
||||
|
||||
add_executable(cloudio_component_test component_test.cpp)
|
||||
add_executable(cloudio_end_to_end_test end_to_end_test.cpp)
|
||||
|
@ -9,10 +9,17 @@ set(common_LIB_SRCS
|
||||
MonitorProcMem.cpp
|
||||
nullvaluemanip.cpp
|
||||
threadnaming.cpp
|
||||
utils_utf8.cpp
|
||||
statistics.cpp
|
||||
string_prefixes.cpp
|
||||
)
|
||||
|
||||
columnstore_library(common ${common_LIB_SRCS})
|
||||
columnstore_link(common boost_filesystem configcpp loggingcpp messageqcpp)
|
||||
columnstore_link(
|
||||
common
|
||||
PRIVATE
|
||||
boost_filesystem
|
||||
configcpp
|
||||
loggingcpp
|
||||
messageqcpp
|
||||
idbdatafile
|
||||
mariadb_charset
|
||||
)
|
||||
|
@ -1,39 +0,0 @@
|
||||
/* Copyright (C) 2020 MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include <cstring>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
template <class To, class From>
|
||||
std::enable_if_t<
|
||||
sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> && std::is_trivially_copyable_v<To>, To>
|
||||
// constexpr support needs compiler magic
|
||||
bitCast(const From& src) noexcept
|
||||
{
|
||||
static_assert(std::is_trivially_constructible_v<To>,
|
||||
"This implementation additionally requires "
|
||||
"destination type to be trivially constructible");
|
||||
|
||||
To dst;
|
||||
std::memcpy(&dst, &src, sizeof(To));
|
||||
return dst;
|
||||
}
|
||||
} // namespace utils
|
@ -19,12 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
|
||||
#ifndef __builtin_expect
|
||||
#define __builtin_expect(x, expected_value) (x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LIKELY
|
||||
#define LIKELY(x) __builtin_expect((x), 1)
|
||||
#define UNLIKELY(x) __builtin_expect((x), 0)
|
||||
|
@ -17,6 +17,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <new>
|
||||
|
||||
#include "branchpred.h"
|
||||
|
||||
namespace utils
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "conststring.h"
|
||||
#include "basic/conststring.h"
|
||||
|
||||
namespace genericparser
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "hasher.h"
|
||||
#include "collation.h"
|
||||
#include "mariadb_charset/collation.h"
|
||||
|
||||
namespace utils
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include "exceptclasses.h"
|
||||
#include "conststring.h"
|
||||
#include "basic/conststring.h"
|
||||
#include "mcs_datatype_basic.h"
|
||||
|
||||
namespace utils
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
/* handling of the conversion of string prefixes to int64_t for quick range checking */
|
||||
|
||||
#include "collation.h"
|
||||
#include "mariadb_charset/collation.h"
|
||||
#include "joblisttypes.h"
|
||||
|
||||
#include "string_prefixes.h"
|
||||
|
@ -1,157 +0,0 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/** @file */
|
||||
|
||||
/*
|
||||
* classes isyncstream and osyncstream provide a C++ iostream interface
|
||||
* for C stdio FILE* streams. The current implementation does not provide
|
||||
* the necessary methods to support seeking. The I/O buffering of the
|
||||
* input FILE* is used. The C++ iostream library calls syncbuf::sync()
|
||||
* for every line, so output buffering is line-by-line.
|
||||
* */
|
||||
|
||||
/*
|
||||
#include "syncstream.h"
|
||||
|
||||
void copyStream(istream& iss, ostream& oss)
|
||||
{
|
||||
string line;
|
||||
getline(iss, line);
|
||||
while (iss.good())
|
||||
{
|
||||
oss << line << endl;
|
||||
getline(iss, line);
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
FILE* ifp;
|
||||
FILE* ofp;
|
||||
|
||||
...
|
||||
|
||||
isyncstream iss(ifp);
|
||||
osyncstream oss(ofp);
|
||||
|
||||
copyStream(iss, oss);
|
||||
|
||||
...
|
||||
}
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
namespace syncstream
|
||||
{
|
||||
/** A streambuf implementation for C stdio FILE* streams.
|
||||
*
|
||||
* Adapted from http://www.drdobbs.com/184401305
|
||||
*/
|
||||
class syncbuf : public std::streambuf
|
||||
{
|
||||
public:
|
||||
/** ctor */
|
||||
syncbuf(FILE* f) : std::streambuf(), fptr(f)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
/** Write character in the case of overflow */
|
||||
virtual int overflow(int c = EOF)
|
||||
{
|
||||
return (c != EOF ? fputc(c, fptr) : EOF);
|
||||
}
|
||||
/** Get character in the case of overflow */
|
||||
virtual int underflow()
|
||||
{
|
||||
int c = getc(fptr);
|
||||
|
||||
if (c != EOF)
|
||||
ungetc(c, fptr);
|
||||
|
||||
return c;
|
||||
}
|
||||
/** Get character in the case of overflow and advance get pointer */
|
||||
virtual int uflow()
|
||||
{
|
||||
return getc(fptr);
|
||||
}
|
||||
/** put character back in the case of backup underflow */
|
||||
virtual int pbackfail(int c = EOF)
|
||||
{
|
||||
return (c != EOF ? ungetc(c, fptr) : EOF);
|
||||
}
|
||||
/** Synchronize stream buffer */
|
||||
virtual int sync()
|
||||
{
|
||||
return fflush(fptr);
|
||||
}
|
||||
|
||||
private:
|
||||
FILE* fptr;
|
||||
};
|
||||
|
||||
/** An istream adaptor for input FILE* streams */
|
||||
class isyncstream : public std::istream
|
||||
{
|
||||
public:
|
||||
/** ctor */
|
||||
isyncstream() : istream(&buf), buf(0)
|
||||
{
|
||||
}
|
||||
/** ctor */
|
||||
isyncstream(FILE* fptr) : istream(&buf), buf(fptr)
|
||||
{
|
||||
}
|
||||
/** const streambuf accessor */
|
||||
const syncbuf* rdbuf() const
|
||||
{
|
||||
return &buf;
|
||||
}
|
||||
|
||||
private:
|
||||
syncbuf buf;
|
||||
};
|
||||
|
||||
/** An ostream adaptor for output FILE* streams */
|
||||
class osyncstream : public std::ostream
|
||||
{
|
||||
public:
|
||||
/** ctor */
|
||||
osyncstream() : ostream(&buf), buf(0)
|
||||
{
|
||||
}
|
||||
/** ctor */
|
||||
osyncstream(FILE* fptr) : ostream(&buf), buf(fptr)
|
||||
{
|
||||
}
|
||||
/** const streambuf accessor */
|
||||
const syncbuf* rdbuf() const
|
||||
{
|
||||
return &buf;
|
||||
}
|
||||
|
||||
private:
|
||||
syncbuf buf;
|
||||
};
|
||||
|
||||
} // namespace syncstream
|
@ -20,16 +20,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#if defined(__FreeBSD__)
|
||||
//#include <cstdlib>
|
||||
#else
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
|
||||
#include <clocale>
|
||||
#include "liboamcpp.h"
|
||||
|
||||
// Change the name from utf8. Even change the file name to something resembling char helper
|
||||
namespace utf8
|
||||
|
@ -2,4 +2,4 @@ include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
|
||||
set(ddlcleanuputil_LIB_SRCS ddlcleanuputil.cpp)
|
||||
columnstore_library(ddlcleanuputil ${ddlcleanuputil_LIB_SRCS})
|
||||
columnstore_link(ddlcleanuputil PRIVATE loggingcpp ${NETSNMP_LIBRARIES})
|
||||
columnstore_link(ddlcleanuputil PRIVATE loggingcpp)
|
||||
|
@ -150,6 +150,7 @@ columnstore_link(
|
||||
pron
|
||||
loggingcpp
|
||||
dataconvert
|
||||
${MARIADB_STRING_LIBS}
|
||||
${NETSNMP_LIBRARIES}
|
||||
mariadb_charset
|
||||
)
|
||||
|
||||
columnstore_link(funcexp PRIVATE ${MARIADB_STRING_LIBS})
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <my_sys.h>
|
||||
#include <json_lib.h>
|
||||
|
||||
#include "collation.h"
|
||||
#include "mariadb_charset/collation.h"
|
||||
#include "functor_bool.h"
|
||||
#include "functor_int.h"
|
||||
#include "functor_str.h"
|
||||
|
@ -10,10 +10,10 @@
|
||||
#include <my_sys.h>
|
||||
// #include <json_lib.h>
|
||||
|
||||
#include "collation.h"
|
||||
#include "mariadb_charset/collation.h"
|
||||
#include "functor_json.h"
|
||||
#include "functor_str.h"
|
||||
#include "collation.h"
|
||||
#include "mariadb_charset/collation.h"
|
||||
#include "rowgroup.h"
|
||||
#include "treenode.h"
|
||||
#include "functioncolumn.h"
|
||||
|
@ -14,4 +14,4 @@ set(idbdatafile_LIB_SRCS
|
||||
)
|
||||
|
||||
columnstore_library(idbdatafile ${idbdatafile_LIB_SRCS})
|
||||
columnstore_link(idbdatafile PRIVATE ${NETSNMP_LIBRARIES} ${ENGINE_OAM_LIBS} boost_filesystem boost_system)
|
||||
columnstore_link(idbdatafile PRIVATE ${ENGINE_OAM_LIBS} boost_filesystem boost_system compress)
|
||||
|
@ -5,4 +5,4 @@ include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
set(joiner_LIB_SRCS tuplejoiner.cpp joinpartition.cpp)
|
||||
|
||||
columnstore_library(joiner ${joiner_LIB_SRCS})
|
||||
columnstore_link(joiner PRIVATE loggingcpp)
|
||||
columnstore_link(joiner PRIVATE loggingcpp rowgroup datatypes compress)
|
||||
|
7
utils/mariadb_charset/CMakeLists.txt
Normal file
7
utils/mariadb_charset/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
|
||||
# ########## next target ###############
|
||||
|
||||
columnstore_static_library(mariadb_charset charset.cpp)
|
||||
columnstore_link(mariadb_charset PRIVATE ${MARIADB_STRING_LIBS})
|
||||
add_dependencies(mariadb_charset loggingcpp)
|
@ -1,8 +1,9 @@
|
||||
/* Copyright (C) 2020 MariaDB Corporation.
|
||||
/* Copyright (C) 2025 MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -11,11 +12,12 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
||||
|
||||
#include "utils_utf8.h"
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "mariadb_charset/collation.h"
|
||||
#include "mariadb_my_sys.h"
|
||||
#include "mcs_datatype.h"
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
@ -35,4 +37,3 @@ void Charset::setCharset(uint32_t charsetNumber)
|
||||
}
|
||||
|
||||
} // namespace datatypes
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "mcsconfig.h"
|
||||
|
||||
#include "exceptclasses.h"
|
||||
#include "conststring.h"
|
||||
#include "basic/conststring.h"
|
||||
|
||||
/*
|
||||
Redefine definitions used by MariaDB m_ctype.h.
|
@ -8,7 +8,6 @@ set(messageqcpp_LIB_SRCS
|
||||
iosocket.cpp
|
||||
messagequeue.cpp
|
||||
messagequeuepool.cpp
|
||||
samenodepseudosocket.cpp
|
||||
socketparms.cpp
|
||||
)
|
||||
|
||||
|
@ -25,40 +25,57 @@
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
namespace messageqcpp
|
||||
{
|
||||
|
||||
using ClientMapType = std::multimap<std::string, std::unique_ptr<ClientObject>>;
|
||||
|
||||
struct LockedClientMap
|
||||
template <class T>
|
||||
struct Immortal
|
||||
{
|
||||
LockedClientMap()
|
||||
template <class... Args>
|
||||
Immortal(Args&&... args)
|
||||
{
|
||||
::new (space) T(std::forward<Args>(args)...);
|
||||
}
|
||||
~LockedClientMap()
|
||||
|
||||
operator T&() & noexcept
|
||||
{
|
||||
return reinterpret_cast<T&>(space);
|
||||
}
|
||||
ClientMapType clientMap;
|
||||
std::mutex queueMutex;
|
||||
|
||||
private:
|
||||
alignas(T) unsigned char space[sizeof(T)];
|
||||
};
|
||||
|
||||
static int clientMapNiftyCounter;
|
||||
|
||||
static typename std::aligned_storage<sizeof(LockedClientMap), alignof(LockedClientMap)>::type clientMapBuf;
|
||||
|
||||
auto& lockedMap = reinterpret_cast<LockedClientMap&>(clientMapBuf);
|
||||
|
||||
|
||||
LockedClientMapInitilizer::LockedClientMapInitilizer ()
|
||||
class LockedClientMap
|
||||
{
|
||||
if (clientMapNiftyCounter++ == 0) new (&lockedMap) LockedClientMap (); // placement new
|
||||
}
|
||||
LockedClientMapInitilizer::~LockedClientMapInitilizer ()
|
||||
{
|
||||
if (--clientMapNiftyCounter == 0) (&lockedMap)->~LockedClientMap();
|
||||
}
|
||||
struct KeyToUsePrivateCtor
|
||||
{
|
||||
explicit KeyToUsePrivateCtor() = default;
|
||||
};
|
||||
|
||||
public:
|
||||
LockedClientMap(const LockedClientMap&) = delete;
|
||||
LockedClientMap& operator=(const LockedClientMap&) = delete;
|
||||
~LockedClientMap() = delete;
|
||||
|
||||
static LockedClientMap& getInstance()
|
||||
{
|
||||
static Immortal<LockedClientMap> instance(KeyToUsePrivateCtor{});
|
||||
return instance;
|
||||
}
|
||||
|
||||
LockedClientMap(KeyToUsePrivateCtor)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
ClientMapType clientMap;
|
||||
std::mutex queueMutex;
|
||||
|
||||
friend class MessageQueueClientPool;
|
||||
};
|
||||
|
||||
// 300 seconds idle until cleanup
|
||||
#define MAX_IDLE_TIME 300
|
||||
@ -70,7 +87,7 @@ static uint64_t TimeSpecToSeconds(struct timespec* ts)
|
||||
|
||||
MessageQueueClient* MessageQueueClientPool::getInstance(const std::string& dnOrIp, uint64_t port)
|
||||
{
|
||||
auto lock = std::scoped_lock(lockedMap.queueMutex);
|
||||
auto lock = std::scoped_lock(LockedClientMap::getInstance().queueMutex);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << dnOrIp << "_" << port;
|
||||
@ -93,14 +110,13 @@ MessageQueueClient* MessageQueueClientPool::getInstance(const std::string& dnOrI
|
||||
newClientObject->client.reset(new MessageQueueClient(dnOrIp, port));
|
||||
newClientObject->inUse = true;
|
||||
newClientObject->lastUsed = nowSeconds;
|
||||
lockedMap.clientMap.emplace(std::move(searchString), std::move(newClientObject));
|
||||
LockedClientMap::getInstance().clientMap.emplace(std::move(searchString), std::move(newClientObject));
|
||||
return newClientObject->client.get();
|
||||
}
|
||||
|
||||
MessageQueueClient* MessageQueueClientPool::getInstance(const std::string& module)
|
||||
{
|
||||
auto lock = std::scoped_lock(lockedMap.queueMutex);
|
||||
|
||||
auto lock = std::scoped_lock(LockedClientMap::getInstance().queueMutex);
|
||||
|
||||
MessageQueueClient* returnClient = MessageQueueClientPool::findInPool(module);
|
||||
|
||||
@ -116,13 +132,11 @@ MessageQueueClient* MessageQueueClientPool::getInstance(const std::string& modul
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
uint64_t nowSeconds = TimeSpecToSeconds(&now);
|
||||
|
||||
|
||||
|
||||
newClientObject->client.reset(new MessageQueueClient(module));
|
||||
newClientObject->inUse = true;
|
||||
newClientObject->lastUsed = nowSeconds;
|
||||
auto result = newClientObject->client.get();
|
||||
lockedMap.clientMap.emplace(std::move(module), std::move(newClientObject));
|
||||
LockedClientMap::getInstance().clientMap.emplace(std::move(module), std::move(newClientObject));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -133,11 +147,10 @@ MessageQueueClient* MessageQueueClientPool::findInPool(const std::string& search
|
||||
uint64_t nowSeconds = TimeSpecToSeconds(&now);
|
||||
MessageQueueClient* returnClient = NULL;
|
||||
|
||||
auto it = lockedMap.clientMap.begin();
|
||||
|
||||
auto it = LockedClientMap::getInstance().clientMap.begin();
|
||||
|
||||
// Scan pool
|
||||
while (it != lockedMap.clientMap.end())
|
||||
while (it != LockedClientMap::getInstance().clientMap.end())
|
||||
{
|
||||
ClientObject* clientObject = it->second.get();
|
||||
uint64_t elapsedTime = nowSeconds - clientObject->lastUsed;
|
||||
@ -149,7 +162,7 @@ MessageQueueClient* MessageQueueClientPool::findInPool(const std::string& search
|
||||
// Do this so we don't invalidate current interator
|
||||
auto toDelete = it;
|
||||
it++;
|
||||
lockedMap.clientMap.erase(toDelete);
|
||||
LockedClientMap::getInstance().clientMap.erase(toDelete);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -163,7 +176,7 @@ MessageQueueClient* MessageQueueClientPool::findInPool(const std::string& search
|
||||
// Do this so we don't invalidate current interator
|
||||
auto toDelete = it;
|
||||
it++;
|
||||
lockedMap.clientMap.erase(toDelete);
|
||||
LockedClientMap::getInstance().clientMap.erase(toDelete);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -193,10 +206,10 @@ void MessageQueueClientPool::releaseInstance(MessageQueueClient* client)
|
||||
if (client == NULL)
|
||||
return;
|
||||
|
||||
auto lock = std::scoped_lock(lockedMap.queueMutex);
|
||||
auto it = lockedMap.clientMap.begin();
|
||||
auto lock = std::scoped_lock(LockedClientMap::getInstance().queueMutex);
|
||||
auto it = LockedClientMap::getInstance().clientMap.begin();
|
||||
|
||||
while (it != lockedMap.clientMap.end())
|
||||
while (it != LockedClientMap::getInstance().clientMap.end())
|
||||
{
|
||||
if (it->second->client.get() == client)
|
||||
{
|
||||
@ -221,15 +234,14 @@ void MessageQueueClientPool::deleteInstance(MessageQueueClient* client)
|
||||
if (client == NULL)
|
||||
return;
|
||||
|
||||
auto lock = std::scoped_lock(LockedClientMap::getInstance().queueMutex);
|
||||
auto it = LockedClientMap::getInstance().clientMap.begin();
|
||||
|
||||
auto lock = std::scoped_lock(lockedMap.queueMutex);
|
||||
auto it = lockedMap.clientMap.begin();
|
||||
|
||||
while (it != lockedMap.clientMap.end())
|
||||
while (it != LockedClientMap::getInstance().clientMap.end())
|
||||
{
|
||||
if (it->second->client.get() == client)
|
||||
{
|
||||
lockedMap.clientMap.erase(it);
|
||||
LockedClientMap::getInstance().clientMap.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -26,12 +26,6 @@
|
||||
namespace messageqcpp
|
||||
{
|
||||
|
||||
|
||||
static struct LockedClientMapInitilizer {
|
||||
LockedClientMapInitilizer ();
|
||||
~LockedClientMapInitilizer ();
|
||||
} clientMapInitilizer; // static initializer for every translation unit
|
||||
|
||||
struct ClientObject
|
||||
{
|
||||
std::unique_ptr<MessageQueueClient> client;
|
||||
@ -49,8 +43,8 @@ class MessageQueueClientPool
|
||||
static MessageQueueClient* findInPool(const std::string& search);
|
||||
|
||||
private:
|
||||
MessageQueueClientPool(){};
|
||||
~MessageQueueClientPool(){};
|
||||
MessageQueueClientPool() {};
|
||||
~MessageQueueClientPool() {};
|
||||
};
|
||||
|
||||
} // namespace messageqcpp
|
||||
|
@ -1,127 +0,0 @@
|
||||
/* Copyright (C) 2024 MariaDB Corp.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "samenodepseudosocket.h"
|
||||
#include "iosocket.h"
|
||||
|
||||
namespace messageqcpp
|
||||
{
|
||||
SameNodePseudoSocket::SameNodePseudoSocket(joblist::DistributedEngineComm* exeMgrDecPtr) : dec_(exeMgrDecPtr)
|
||||
{
|
||||
assert(dec_);
|
||||
}
|
||||
|
||||
SameNodePseudoSocket::~SameNodePseudoSocket()
|
||||
{
|
||||
}
|
||||
|
||||
void SameNodePseudoSocket::open()
|
||||
{
|
||||
}
|
||||
|
||||
void SameNodePseudoSocket::close()
|
||||
{
|
||||
}
|
||||
|
||||
Socket* SameNodePseudoSocket::clone() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SameNodePseudoSocket::SameNodePseudoSocket(const SameNodePseudoSocket& /*rhs*/)
|
||||
{
|
||||
}
|
||||
|
||||
SameNodePseudoSocket& SameNodePseudoSocket::operator=(const SameNodePseudoSocket& /*rhs*/)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
const SBS SameNodePseudoSocket::read(const struct ::timespec* /*timeout*/, bool* /*isTimeOut*/, Stats* /*stats*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// This is the only working method of this class. It puts SBS directly into DEC queue.
|
||||
void SameNodePseudoSocket::write(SBS msg, Stats* /*stats*/)
|
||||
{
|
||||
dec_->addDataToOutput(msg);
|
||||
}
|
||||
|
||||
void SameNodePseudoSocket::write(const ByteStream& /*msg*/, Stats* /*stats*/)
|
||||
{
|
||||
}
|
||||
|
||||
void SameNodePseudoSocket::write_raw(const ByteStream& /*msg*/, Stats* /*stats*/) const
|
||||
{
|
||||
}
|
||||
|
||||
void SameNodePseudoSocket::connect(const sockaddr* /*serv_addr*/)
|
||||
{
|
||||
}
|
||||
|
||||
void SameNodePseudoSocket::bind(const sockaddr* /*serv_addr*/)
|
||||
{
|
||||
}
|
||||
|
||||
const IOSocket SameNodePseudoSocket::accept(const struct timespec* /*timeout*/)
|
||||
{
|
||||
return IOSocket();
|
||||
}
|
||||
|
||||
void SameNodePseudoSocket::listen(int /*backlog*/)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string SameNodePseudoSocket::toString() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const std::string SameNodePseudoSocket::addr2String() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
bool SameNodePseudoSocket::isSameAddr(const Socket* /*rhs*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SameNodePseudoSocket::isSameAddr(const struct in_addr& /*ipv4Addr*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int SameNodePseudoSocket::ping(const std::string& /*ipaddr*/, const struct timespec* /*timeout*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SameNodePseudoSocket::isConnected() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SameNodePseudoSocket::hasData() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace messageqcpp
|
@ -1,99 +0,0 @@
|
||||
/* Copyright (C) 2024 MariaDB Corp.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../dbcon/joblist/distributedenginecomm.h"
|
||||
|
||||
#include "socket.h"
|
||||
#include "socketparms.h"
|
||||
#include "bytestream.h"
|
||||
|
||||
namespace messageqcpp
|
||||
{
|
||||
class IOSocket;
|
||||
|
||||
// This class is a dummy replacement for a TCP socket
|
||||
// wrapper to communicate with the same node.
|
||||
class SameNodePseudoSocket : public Socket
|
||||
{
|
||||
public:
|
||||
explicit SameNodePseudoSocket(joblist::DistributedEngineComm* exeMgrDecPtr);
|
||||
~SameNodePseudoSocket() override;
|
||||
void write(SBS msg, Stats* stats = nullptr) override;
|
||||
|
||||
private:
|
||||
void bind(const sockaddr* serv_addr) override;
|
||||
SameNodePseudoSocket(const SameNodePseudoSocket& rhs);
|
||||
virtual SameNodePseudoSocket& operator=(const SameNodePseudoSocket& rhs);
|
||||
|
||||
void connectionTimeout(const struct ::timespec* /*timeout*/) override
|
||||
{
|
||||
}
|
||||
|
||||
void syncProto(bool /*use*/) override
|
||||
{
|
||||
}
|
||||
|
||||
int getConnectionNum() const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline void socketParms(const SocketParms& /*socket*/) override
|
||||
{
|
||||
}
|
||||
|
||||
inline const SocketParms socketParms() const override
|
||||
{
|
||||
return SocketParms();
|
||||
}
|
||||
|
||||
// all these virtual methods are to stay inaccessable.
|
||||
inline void sa(const sockaddr* sa) override;
|
||||
void open() override;
|
||||
void close() override;
|
||||
inline bool isOpen() const override;
|
||||
const SBS read(const struct timespec* timeout = nullptr, bool* isTimeOut = nullptr,
|
||||
Stats* stats = nullptr) const override;
|
||||
void write(const ByteStream& msg, Stats* stats = nullptr) override;
|
||||
void write_raw(const ByteStream& msg, Stats* stats = nullptr) const override;
|
||||
void listen(int backlog = 5) override;
|
||||
const IOSocket accept(const struct timespec* timeout = nullptr) override;
|
||||
void connect(const sockaddr* serv_addr) override;
|
||||
Socket* clone() const override;
|
||||
virtual const std::string toString() const;
|
||||
const std::string addr2String() const override;
|
||||
bool isSameAddr(const Socket* rhs) const override;
|
||||
bool isSameAddr(const struct in_addr& ipv4Addr) const override;
|
||||
static int ping(const std::string& ipaddr, const struct timespec* timeout = nullptr);
|
||||
bool isConnected() const override;
|
||||
bool hasData() const override;
|
||||
|
||||
joblist::DistributedEngineComm* dec_ = nullptr;
|
||||
};
|
||||
|
||||
inline bool SameNodePseudoSocket::isOpen() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void SameNodePseudoSocket::sa(const sockaddr* /*sa*/)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace messageqcpp
|
@ -5,4 +5,4 @@ include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
|
||||
set(querystats_LIB_SRCS querystats.cpp)
|
||||
columnstore_library(querystats ${querystats_LIB_SRCS})
|
||||
columnstore_link(querystats PRIVATE loggingcpp)
|
||||
columnstore_link(querystats PRIVATE loggingcpp messageqcpp)
|
||||
|
@ -5,7 +5,7 @@ set(querytele_LIB_SRCS querytele.cpp queryteleclient.cpp querytele_constants.cpp
|
||||
)
|
||||
|
||||
columnstore_library(querytele ${querytele_LIB_SRCS})
|
||||
columnstore_link(querytele ${THRIFT_LIBRARY})
|
||||
columnstore_link(querytele ${THRIFT_LIBRARY} boost_thread)
|
||||
target_include_directories(querytele PRIVATE ${THRIFT_INCLUDE_DIRS})
|
||||
|
||||
add_dependencies(querytele external_boost external_thrift)
|
||||
add_dependencies(querytele external_thrift)
|
||||
|
@ -21,11 +21,12 @@ set(regr_LIB_SRCS
|
||||
add_definitions(-DMYSQL_DYNAMIC_PLUGIN)
|
||||
|
||||
columnstore_library(regr ${regr_LIB_SRCS})
|
||||
columnstore_link(regr PRIVATE loggingcpp)
|
||||
columnstore_link(regr PRIVATE loggingcpp messageqcpp)
|
||||
|
||||
set(regr_mysql_LIB_SRCS regrmysql.cpp modamysql.cpp)
|
||||
|
||||
# Do anyone use it?
|
||||
columnstore_mysql_plugin_library(regr_mysql SHARED ${regr_mysql_LIB_SRCS})
|
||||
add_dependencies(regr_mysql external_boost)
|
||||
add_dependencies(regr_mysql external_boost GenError) # for "idb_mysql.h" that uses generated mysqld_error.h
|
||||
|
||||
set_target_properties(regr_mysql PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../../)
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "calpontsystemcatalog.h"
|
||||
#include "windowfunctioncolumn.h"
|
||||
#include "hasher.h"
|
||||
#include "collation.h"
|
||||
#include "mariadb_charset/collation.h"
|
||||
|
||||
#define EXPORT
|
||||
|
||||
@ -277,7 +277,7 @@ class Moda_impl_T<string> : public mcsv1_UDAF
|
||||
{
|
||||
public:
|
||||
// Defaults OK
|
||||
Moda_impl_T() : cs(8){};
|
||||
Moda_impl_T() : cs(8) {};
|
||||
~Moda_impl_T() override = default;
|
||||
|
||||
mcsv1_UDAF::ReturnCode init(mcsv1Context* context, ColumnDatum* colTypes) override;
|
||||
@ -305,7 +305,7 @@ class moda : public mcsv1_UDAF
|
||||
{
|
||||
public:
|
||||
// Defaults OK
|
||||
moda() : mcsv1_UDAF(){};
|
||||
moda() : mcsv1_UDAF() {};
|
||||
~moda() override = default;
|
||||
|
||||
mcsv1_UDAF::ReturnCode init(mcsv1Context* context, ColumnDatum* colTypes) override;
|
||||
|
@ -5,5 +5,5 @@ include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
set(rowgroup_LIB_SRCS rowaggregation.cpp rowgroup.cpp rowstorage.cpp)
|
||||
|
||||
columnstore_library(rowgroup ${rowgroup_LIB_SRCS})
|
||||
columnstore_link(rowgroup PRIVATE ${NETSNMP_LIBRARIES} funcexp loggingcpp)
|
||||
columnstore_link(rowgroup PRIVATE funcexp loggingcpp compress)
|
||||
add_dependencies(rowgroup external_boost)
|
||||
|
@ -53,7 +53,7 @@
|
||||
#include "branchpred.h"
|
||||
#include "datatypes/mcs_int128.h"
|
||||
|
||||
#include "collation.h"
|
||||
#include "mariadb_charset/collation.h"
|
||||
#include "common/hashfamily.h"
|
||||
#include "buffertypes.h"
|
||||
|
||||
|
6
utils/statistics_manager/CMakeLists.txt
Normal file
6
utils/statistics_manager/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
|
||||
# ########## next target ###############
|
||||
|
||||
columnstore_static_library(statistics_manager statistics.cpp)
|
||||
columnstore_link(statistics_manager PRIVATE rowgroup)
|
@ -116,9 +116,8 @@ void StatisticsManager::analyzeSample(bool traceOn)
|
||||
// MCV statistics.
|
||||
std::vector<pair<uint64_t, uint32_t>> mcvList(columnMCV.begin(), columnMCV.end());
|
||||
std::sort(mcvList.begin(), mcvList.end(),
|
||||
[](const std::pair<uint64_t, uint32_t>& a, const std::pair<uint64_t, uint32_t>& b) {
|
||||
return a.second > b.second;
|
||||
});
|
||||
[](const std::pair<uint64_t, uint32_t>& a, const std::pair<uint64_t, uint32_t>& b)
|
||||
{ return a.second > b.second; });
|
||||
|
||||
// 200 buckets as Microsoft does.
|
||||
const auto mcvSize = std::min(columnMCV.size(), static_cast<uint64_t>(200));
|
@ -2,6 +2,4 @@ include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
|
||||
set(threadpool_LIB_SRCS weightedthreadpool.cpp threadpool.cpp prioritythreadpool.cpp fair_threadpool.cpp)
|
||||
columnstore_library(threadpool ${threadpool_LIB_SRCS})
|
||||
columnstore_link(threadpool PRIVATE boost_chrono loggingcpp)
|
||||
|
||||
add_dependencies(threadpool external_boost)
|
||||
columnstore_link(threadpool PRIVATE boost_chrono boost_thread loggingcpp messageqcpp)
|
||||
|
@ -11,9 +11,11 @@ set(udfsdk_LIB_SRCS
|
||||
)
|
||||
|
||||
columnstore_library(udfsdk ${udfsdk_LIB_SRCS})
|
||||
columnstore_link(udfsdk PRIVATE loggingcpp)
|
||||
columnstore_link(udfsdk PRIVATE loggingcpp messageqcpp)
|
||||
|
||||
# Do anyone use it?
|
||||
add_definitions(-DMYSQL_DYNAMIC_PLUGIN)
|
||||
set(udf_mysql_LIB_SRCS udfmysql.cpp)
|
||||
columnstore_mysql_plugin_library(udf_mysql SHARED ${udf_mysql_LIB_SRCS})
|
||||
|
||||
add_dependencies(udf_mysql GenError) # for "idb_mysql.h" that uses generated mysqld_error.h
|
||||
|
Reference in New Issue
Block a user