1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

File diff suppressed because it is too large Load Diff

View File

@ -44,21 +44,21 @@ namespace multicast
class MulticastImpl
{
public:
MulticastImpl(int min_receivers, const std::string& ifName, int portBase=9000, int bufSize=8*1024*1024);
~MulticastImpl();
MulticastImpl(int min_receivers, const std::string& ifName, int portBase = 9000, int bufSize = 8 * 1024 * 1024);
~MulticastImpl();
void startSender();
void doTransfer(const uint8_t* buf, uint32_t len);
void startSender();
void doTransfer(const uint8_t* buf, uint32_t len);
void startReceiver();
void receive(messageqcpp::SBS obs);
void startReceiver();
void receive(messageqcpp::SBS obs);
struct net_config fNet_config;
struct stat_config fStat_config;
struct client_config fClient_config;
std::string fIfName;
int fSock[3];
participantsDb_t fDb;
struct net_config fNet_config;
struct stat_config fStat_config;
struct client_config fClient_config;
std::string fIfName;
int fSock[3];
participantsDb_t fDb;
};
}

View File

@ -21,15 +21,16 @@
#include "threads.h"
#include "produconsum.h"
typedef struct fifo {
unsigned char *dataBuffer;
typedef struct fifo
{
unsigned char* dataBuffer;
unsigned int dataBufSize;
produconsum_t freeMemQueue; /* queue for free memory */
produconsum_t data; /* queue for received data or data received
produconsum_t data; /* queue for received data or data received
* from disk */
pthread_t thread;
} *fifo_t;
}* fifo_t;
#endif

View File

@ -38,31 +38,35 @@ namespace multicast
{
Multicast::Multicast() :
fPMCount(1),
fIFName("eth0"),
fPortBase(9000),
fBufSize(8 * 1024 * 1024)
fPMCount(1),
fIFName("eth0"),
fPortBase(9000),
fBufSize(8 * 1024 * 1024)
{
int tmp;
string stmp;
int tmp;
string stmp;
Config* cf = Config::makeConfig();
Config* cf = Config::makeConfig();
tmp = Config::fromText(cf->getConfig("PrimitiveServers", "Count"));
if (tmp > 0) fPMCount = tmp;
tmp = Config::fromText(cf->getConfig("PrimitiveServers", "Count"));
stmp = cf->getConfig("Multicast", "Interface");
if (!stmp.empty()) fIFName = stmp;
if (tmp > 0) fPMCount = tmp;
tmp = Config::fromText(cf->getConfig("Multicast", "PortBase"));
if (tmp > 0) fPortBase = tmp;
stmp = cf->getConfig("Multicast", "Interface");
tmp = Config::fromText(cf->getConfig("Multicast", "BufSize"));
if (tmp > 0) fBufSize = tmp;
if (!stmp.empty()) fIFName = stmp;
tmp = Config::fromText(cf->getConfig("Multicast", "PortBase"));
if (tmp > 0) fPortBase = tmp;
tmp = Config::fromText(cf->getConfig("Multicast", "BufSize"));
if (tmp > 0) fBufSize = tmp;
}
MulticastReceiver::MulticastReceiver() :
fPimpl(0)
fPimpl(0)
{
}
@ -72,12 +76,12 @@ MulticastReceiver::~MulticastReceiver()
SBS MulticastReceiver::receive()
{
throw runtime_error("Multicast is not available");
return fByteStream;
throw runtime_error("Multicast is not available");
return fByteStream;
}
MulticastSender::MulticastSender() :
fPimpl(0)
fPimpl(0)
{
}
@ -87,7 +91,7 @@ MulticastSender::~MulticastSender()
void MulticastSender::send(const ByteStream& msg)
{
throw runtime_error("Multicast is not available");
throw runtime_error("Multicast is not available");
}
} //namespace multicast

View File

@ -20,7 +20,7 @@
*
*****************************************************************************/
/** @file
/** @file
* class Multicast interface
*/
@ -41,50 +41,65 @@ class MulticastImpl;
class Multicast
{
public:
/** @brief ctor
* Base class
*/
Multicast();
/** @brief dtor
*/
virtual ~Multicast() { destroy(); }
/** @brief ctor
* Base class
*/
Multicast();
virtual void destroy() { }
/** @brief dtor
*/
virtual ~Multicast()
{
destroy();
}
int PMCount() const { return fPMCount; }
std::string iFName() const { return fIFName; }
int portBase() const { return fPortBase; }
int bufSize() const { return fBufSize; }
virtual void destroy() { }
int PMCount() const
{
return fPMCount;
}
std::string iFName() const
{
return fIFName;
}
int portBase() const
{
return fPortBase;
}
int bufSize() const
{
return fBufSize;
}
private:
int fPMCount;
std::string fIFName;
int fPortBase;
int fBufSize;
int fPMCount;
std::string fIFName;
int fPortBase;
int fBufSize;
};
class MulticastReceiver: public Multicast
{
public:
/** @brief ctor
*
*/
MulticastReceiver();
/** @brief ctor
*
*/
MulticastReceiver();
~MulticastReceiver();
messageqcpp::SBS receive();
~MulticastReceiver();
messageqcpp::SBS receive();
private:
// not copyable
MulticastReceiver(const MulticastReceiver& rhs);
MulticastReceiver& operator=(const MulticastReceiver& rhs);
// not copyable
MulticastReceiver(const MulticastReceiver& rhs);
MulticastReceiver& operator=(const MulticastReceiver& rhs);
messageqcpp::SBS fByteStream;
messageqcpp::SBS fByteStream;
MulticastImpl* fPimpl;
MulticastImpl* fPimpl;
};
@ -92,25 +107,25 @@ class MulticastSender : public Multicast
{
public:
/** @brief ctor
*
*/
MulticastSender();
/** @brief ctor
*
*/
MulticastSender();
~MulticastSender();
~MulticastSender();
/** @brief receive
*
* @param bytestream to send
*/
void send(const messageqcpp::ByteStream& bs);
/** @brief receive
*
* @param bytestream to send
*/
void send(const messageqcpp::ByteStream& bs);
private:
//Not copyable
MulticastSender(const MulticastSender& rhs);
MulticastSender& operator=(const MulticastSender& rhs);
//Not copyable
MulticastSender(const MulticastSender& rhs);
MulticastSender& operator=(const MulticastSender& rhs);
MulticastImpl* fPimpl;
MulticastImpl* fPimpl;
};
} //namespace

View File

@ -20,12 +20,12 @@
#define MAX_CLIENTS 1024
typedef struct participantsDb *participantsDb_t;
typedef struct participantsDb* participantsDb_t;
#define printNotSet udpc_printNotSet
#define printSet udpc_printSet
void udpc_printNotSet(participantsDb_t db, char *d);
void udpc_printSet(participantsDb_t db, char *d);
void udpc_printNotSet(participantsDb_t db, char* d);
void udpc_printSet(participantsDb_t db, char* d);
#endif

View File

@ -18,7 +18,7 @@
#ifndef PRODUCONSUM_H
#define PRODUCONSUM_H
typedef struct produconsum *produconsum_t;
typedef struct produconsum* produconsum_t;
/**
* Get contiguous chunk of data

View File

@ -84,34 +84,36 @@
#ifdef LOSSTEST
int loseSendPacket(void);
void loseRecvPacket(int s);
void setWriteLoss(char *l);
void setReadLoss(char *l);
void setReadSwap(char *l);
void setWriteLoss(char* l);
void setReadLoss(char* l);
void setReadSwap(char* l);
void srandomTime(int printSeed);
int RecvMsg(int s, struct msghdr *msg, int flags);
int RecvMsg(int s, struct msghdr* msg, int flags);
#endif
struct net_if {
struct net_if
{
struct in_addr addr;
struct in_addr bcast;
const char *name;
const char* name;
#ifdef SIOCGIFINDEX
int index;
#endif
};
typedef struct net_if net_if_t;
typedef enum addr_type_t {
ADDR_TYPE_UCAST,
ADDR_TYPE_MCAST,
ADDR_TYPE_BCAST
typedef enum addr_type_t
{
ADDR_TYPE_UCAST,
ADDR_TYPE_MCAST,
ADDR_TYPE_BCAST
} addr_type_t;
void doAutoRateLimit(int sock, int dir, int qsize, int size);
int makeSockAddr(char *hostname, short port, struct sockaddr_in *addr);
int makeSockAddr(char* hostname, short port, struct sockaddr_in* addr);
void printMyIp(net_if_t *net_if);
void printMyIp(net_if_t* net_if);
int getSendBuf(int sock);
@ -124,34 +126,37 @@ int getSendBuf(int sock);
#define BCAST_CONTROL(s, msg) \
doSend(s, &msg, sizeof(msg), &net_config->controlMcastAddr)
void setIpFromString(struct sockaddr_in *addr, char *ip);
void setIpFromString(struct sockaddr_in* addr, char* ip);
unsigned long parseSize(char *sizeString);
unsigned long parseSize(char* sizeString);
int udpc_socklibFatal(int code);
#ifdef __MINGW32__ /* __MINGW32__ */
struct iovec {
void *iov_base;
struct iovec
{
void* iov_base;
int iov_len;
};
struct msghdr {
void *msg_name;
struct msghdr
{
void* msg_name;
int msg_namelen;
struct iovec *msg_iov;
struct iovec* msg_iov;
int msg_iovlen;
};
ssize_t sendmsg(int s, const struct msghdr *msg, int flags);
ssize_t recvmsg (int fd, struct msghdr *msg, int flags);
ssize_t sendmsg(int s, const struct msghdr* msg, int flags);
ssize_t recvmsg (int fd, struct msghdr* msg, int flags);
#define usleep(x) Sleep((x)/1000)
#define sleep(x) Sleep(1000L*(x))
#endif /* __MINGW32__ */
static inline void initMsgHdr(struct msghdr *hdr) {
static inline void initMsgHdr(struct msghdr* hdr)
{
#ifndef WINDOWS
hdr->msg_control = 0;
hdr->msg_controllen = 0;

View File

@ -19,24 +19,24 @@
#define STATISTICS_H
typedef struct receiver_stats *receiver_stats_t;
typedef struct sender_stats *sender_stats_t;
typedef struct receiver_stats* receiver_stats_t;
typedef struct sender_stats* sender_stats_t;
#define allocReadStats udpc_allocReadStats
#define receiverStatsStartTimer udpc_receiverStatsStartTimer
#define displayReceiverStats udpc_displayReceiverStats
receiver_stats_t udpc_allocReadStats(int fd, long statPeriod,
int printUncompressedPos);
int printUncompressedPos);
void udpc_receiverStatsStartTimer(receiver_stats_t);
void udpc_displayReceiverStats(receiver_stats_t, int isFinal);
#define allocSenderStats udpc_allocSenderStats
#define displaySenderStats udpc_displaySenderStats
sender_stats_t udpc_allocSenderStats(int fd, FILE *logfile, long bwPeriod,
long statPeriod, int printUncompressedPos);
void udpc_displaySenderStats(sender_stats_t,int blockSize, int sliceSize,
int isFinal);
sender_stats_t udpc_allocSenderStats(int fd, FILE* logfile, long bwPeriod,
long statPeriod, int printUncompressedPos);
void udpc_displaySenderStats(sender_stats_t, int blockSize, int sliceSize,
int isFinal);
#endif

View File

@ -28,107 +28,123 @@ typedef HANDLE pthread_t;
typedef CRITICAL_SECTION pthread_mutex_t;
typedef HANDLE pthread_cond_t;
struct timespec {
unsigned long tv_sec;
unsigned long tv_nsec;
struct timespec
{
unsigned long tv_sec;
unsigned long tv_nsec;
};
static inline int pthread_create(pthread_t *thread, void *dummy1,
LPTHREAD_START_ROUTINE start_routine,
void *arg) {
/* Start thread ...
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp
*/
static inline int pthread_create(pthread_t* thread, void* dummy1,
LPTHREAD_START_ROUTINE start_routine,
void* arg)
{
/* Start thread ...
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp
*/
*thread = CreateThread(NULL, /* lpThreadAttributes */
0, /* dwStackSize */
start_routine,
arg, /* lpParameter */
0, /* dwCreationFlags */
NULL /* lpThreadId */);
0, /* dwStackSize */
start_routine,
arg, /* lpParameter */
0, /* dwCreationFlags */
NULL /* lpThreadId */);
return *thread != NULL ? 0 : -1;
}
static inline int pthread_join(pthread_t th, void **thread_return) {
return WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
}
static inline int pthread_mutex_init(pthread_mutex_t *mutex, void *dummy) {
InitializeCriticalSection(mutex);
return 0;
}
static inline int pthread_mutex_lock(pthread_mutex_t *mutex) {
EnterCriticalSection(mutex);
return 0;
}
static inline int pthread_mutex_unlock(pthread_mutex_t *mutex) {
LeaveCriticalSection(mutex);
return 0;
}
static inline int pthread_cond_init(pthread_cond_t *cond, void *dummy) {
*cond = CreateEvent(NULL, TRUE, TRUE, NULL);
if(*cond == NULL)
return -1;
else
return 0;
}
static inline int pthread_cond_signal(pthread_cond_t *cond) {
return SetEvent(*cond) ? 0 : -1;
}
static inline int pthread_cond_wait(pthread_cond_t *cond,
pthread_mutex_t *mutex) {
int r;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
r= WaitForSingleObject(*cond, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
EnterCriticalSection(mutex);
return r;
}
static inline void pthread_cancel(pthread_t *thread)
static inline int pthread_join(pthread_t th, void** thread_return)
{
TerminateThread(thread, 0);
return WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
}
static inline int pthread_mutex_init(pthread_mutex_t* mutex, void* dummy)
{
InitializeCriticalSection(mutex);
return 0;
}
static inline int pthread_mutex_lock(pthread_mutex_t* mutex)
{
EnterCriticalSection(mutex);
return 0;
}
static inline int pthread_mutex_unlock(pthread_mutex_t* mutex)
{
LeaveCriticalSection(mutex);
return 0;
}
static inline int pthread_cond_init(pthread_cond_t* cond, void* dummy)
{
*cond = CreateEvent(NULL, TRUE, TRUE, NULL);
if (*cond == NULL)
return -1;
else
return 0;
}
static inline int pthread_cond_signal(pthread_cond_t* cond)
{
return SetEvent(*cond) ? 0 : -1;
}
static inline int pthread_cond_wait(pthread_cond_t* cond,
pthread_mutex_t* mutex)
{
int r;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
r = WaitForSingleObject(*cond, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
EnterCriticalSection(mutex);
return r;
}
static inline void pthread_cancel(pthread_t* thread)
{
TerminateThread(thread, 0);
}
#define ETIMEDOUT -2
#define MILLION 1000000
#define BILLION 1000000000
static inline int pthread_cond_timedwait(pthread_cond_t *cond,
pthread_mutex_t *mutex,
struct timespec *ts) {
int r;
struct timeval tv;
long delta;
static inline int pthread_cond_timedwait(pthread_cond_t* cond,
pthread_mutex_t* mutex,
struct timespec* ts)
{
int r;
struct timeval tv;
long delta;
gettimeofday(&tv, NULL);
gettimeofday(&tv, NULL);
delta = (ts->tv_sec - tv.tv_sec) * 1000 +
(ts->tv_nsec / BILLION - tv.tv_usec / MILLION);
if(delta < 0)
delta = 0;
delta = (ts->tv_sec - tv.tv_sec) * 1000 +
(ts->tv_nsec / BILLION - tv.tv_usec / MILLION);
ResetEvent(*cond);
LeaveCriticalSection(mutex);
switch(WaitForSingleObject(*cond, delta )) {
case WAIT_OBJECT_0:
r=0;
break;
case WAIT_TIMEOUT:
r=ETIMEDOUT;
break;
default:
r=-1;
break;
}
EnterCriticalSection(mutex);
return r;
if (delta < 0)
delta = 0;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
switch (WaitForSingleObject(*cond, delta ))
{
case WAIT_OBJECT_0:
r = 0;
break;
case WAIT_TIMEOUT:
r = ETIMEDOUT;
break;
default:
r = -1;
break;
}
EnterCriticalSection(mutex);
return r;
}
#define THREAD_RETURN DWORD WINAPI

View File

@ -24,7 +24,7 @@
#include "statistics.h"
#include "socklib.h"
extern FILE *udpc_log;
extern FILE* udpc_log;
struct fifo;
@ -33,9 +33,9 @@ struct fifo;
#define localReader udpc_localReader
#define doSend udpc_doSend
int openFile(struct disk_config *config);
int openPipe(struct disk_config *config, int in, int *pid);
int localReader(struct fifo *fifo, int in);
int openFile(struct disk_config* config);
int openPipe(struct disk_config* config, int in, int* pid);
int localReader(struct fifo* fifo, int in);
#define BCAST_DATA(s, msg) \
doSend(s, &msg, sizeof(msg), &net_config->dataMcastAddr)

View File

@ -26,7 +26,8 @@
/**
* This file describes the UDPCast protocol
*/
enum opCode {
enum opCode
{
/* Receiver to sender */
CMD_OK, /* all is ok, no need to retransmit anything */
@ -60,26 +61,30 @@ enum opCode {
* "unexpected opcode" on retransmitted hello */
#define CMD_HELLO 0x0500
struct connectReq {
unsigned short opCode;
short reserved;
int capabilities;
unsigned int rcvbuf;
};
struct retransmit {
unsigned short opCode;
short reserved;
int sliceNo;
int rxmit;
unsigned char map[MAX_SLICE_SIZE / BITS_PER_CHAR];
};
struct ok {
unsigned short opCode;
short reserved;
int sliceNo;
} ok;
struct connectReq
{
unsigned short opCode;
short reserved;
int capabilities;
unsigned int rcvbuf;
};
struct retransmit
{
unsigned short opCode;
short reserved;
int sliceNo;
int rxmit;
unsigned char map[MAX_SLICE_SIZE / BITS_PER_CHAR];
};
struct ok
{
unsigned short opCode;
short reserved;
int sliceNo;
} ok;
union message {
union message
{
unsigned short opCode;
struct ok ok;
@ -87,20 +92,23 @@ union message {
struct connectReq connectReq;
struct go {
unsigned short opCode;
short reserved;
struct go
{
unsigned short opCode;
short reserved;
} go;
struct disconnect {
unsigned short opCode;
short reserved;
struct disconnect
{
unsigned short opCode;
short reserved;
} disconnect;
};
struct connectReply {
struct connectReply
{
unsigned short opCode;
short reserved;
int clNr;
@ -109,7 +117,8 @@ struct connectReply {
unsigned char mcastAddr[16]; /* provide enough place for IPV6 */
};
struct hello {
struct hello
{
unsigned short opCode;
short reserved;
int capabilities;
@ -117,7 +126,8 @@ struct hello {
short blockSize;
};
union serverControlMsg {
union serverControlMsg
{
unsigned short opCode;
short reserved;
struct hello hello;
@ -126,7 +136,8 @@ union serverControlMsg {
};
struct dataBlock {
struct dataBlock
{
unsigned short opCode;
short reserved;
int sliceNo;
@ -135,7 +146,8 @@ struct dataBlock {
int bytes;
};
struct fecBlock {
struct fecBlock
{
unsigned short opCode;
short stripes;
int sliceNo;
@ -144,7 +156,8 @@ struct fecBlock {
int bytes;
};
struct reqack {
struct reqack
{
unsigned short opCode;
short reserved;
int sliceNo;
@ -152,7 +165,8 @@ struct reqack {
int rxmit;
};
union serverDataMsg {
union serverDataMsg
{
unsigned short opCode;
struct reqack reqack;
struct dataBlock dataBlock;

View File

@ -39,15 +39,16 @@ int udpc_writeSize(void);
int udpc_largeReadSize(void);
int udpc_smallReadSize(void);
int udpc_makeDataBuffer(int blocksize);
int udpc_parseCommand(char *pipeName, char **arg);
int udpc_parseCommand(char* pipeName, char** arg);
int udpc_printLongNum(unsigned long long x);
int udpc_waitForProcess(int pid, const char *message);
int udpc_waitForProcess(int pid, const char* message);
struct disk_config {
struct disk_config
{
int origOutFile;
const char *fileName;
char *pipeName;
const char* fileName;
char* pipeName;
int flags;
struct timeval stats_last_printed;
@ -55,26 +56,28 @@ struct disk_config {
#define MAX_GOVERNORS 10
struct net_config {
net_if_t *net_if; /* Network interface (eth0, isdn0, etc.) on which to
struct net_config
{
net_if_t* net_if; /* Network interface (eth0, isdn0, etc.) on which to
* multicast */
int portBase; /* Port base */
int blockSize;
int sliceSize;
struct sockaddr_in controlMcastAddr;
struct sockaddr_in dataMcastAddr;
const char *mcastRdv;
const char* mcastRdv;
int ttl;
int nrGovernors;
struct rateGovernor_t *rateGovernor[MAX_GOVERNORS];
void *rateGovernorData[MAX_GOVERNORS];
struct rateGovernor_t* rateGovernor[MAX_GOVERNORS];
void* rateGovernorData[MAX_GOVERNORS];
/*int async;*/
/*int pointopoint;*/
struct timeval ref_tv;
enum discovery {
DSC_DOUBLING,
DSC_REDUCING
enum discovery
{
DSC_DOUBLING,
DSC_REDUCING
} discovery;
/* int autoRate; do queue watching using TIOCOUTQ, to avoid overruns */
@ -117,8 +120,9 @@ struct net_config {
be retransmitted */
};
struct stat_config {
FILE *log; /* Log file for statistics */
struct stat_config
{
FILE* log; /* Log file for statistics */
long bwPeriod; /* How often are bandwidth estimations logged? */
int statPeriod;
@ -127,7 +131,8 @@ struct stat_config {
#define NR_CLIENT_SOCKS 4
struct client_config {
struct client_config
{
int socks[NR_CLIENT_SOCKS];
struct sockaddr_in serverAddr;
int clientNumber;
@ -136,10 +141,10 @@ struct client_config {
int sender_is_newgen;
};
void *rgInitGovernor(struct net_config *cfg, struct rateGovernor_t *gov);
void rgParseRateGovernor(struct net_config *net_config, char *rg);
void rgWaitAll(struct net_config *cfg, int sock, in_addr_t ip, int size);
void rgShutdownAll(struct net_config *cfg);
void* rgInitGovernor(struct net_config* cfg, struct rateGovernor_t* gov);
void rgParseRateGovernor(struct net_config* net_config, char* rg);
void rgWaitAll(struct net_config* cfg, int sock, in_addr_t ip, int size);
void rgShutdownAll(struct net_config* cfg);
/**
* Answers whether given fd is seekable