sf_binlog_writer removes global variable: g_sf_binlog_data_path
parent
db858fc048
commit
fb7ffa0b1d
|
|
@ -34,8 +34,6 @@
|
||||||
#include "sf_func.h"
|
#include "sf_func.h"
|
||||||
#include "sf_binlog_writer.h"
|
#include "sf_binlog_writer.h"
|
||||||
|
|
||||||
char *g_sf_binlog_data_path = NULL;
|
|
||||||
|
|
||||||
static inline void binlog_writer_set_next_version(SFBinlogWriterInfo *writer,
|
static inline void binlog_writer_set_next_version(SFBinlogWriterInfo *writer,
|
||||||
const uint64_t next_version)
|
const uint64_t next_version)
|
||||||
{
|
{
|
||||||
|
|
@ -341,16 +339,18 @@ static int binlog_wbuffer_alloc_init(void *element, void *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
int sf_binlog_writer_init_normal(SFBinlogWriterInfo *writer,
|
int sf_binlog_writer_init_normal(SFBinlogWriterInfo *writer,
|
||||||
const char *subdir_name, const int buffer_size)
|
const char *data_path, const char *subdir_name,
|
||||||
|
const int buffer_size)
|
||||||
{
|
{
|
||||||
writer->flush.in_queue = false;
|
writer->flush.in_queue = false;
|
||||||
return sf_file_writer_init_normal(&writer->fw,
|
return sf_file_writer_init_normal(&writer->fw,
|
||||||
g_sf_binlog_data_path, subdir_name, buffer_size);
|
data_path, subdir_name, buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sf_binlog_writer_init_by_version(SFBinlogWriterInfo *writer,
|
int sf_binlog_writer_init_by_version(SFBinlogWriterInfo *writer,
|
||||||
const char *subdir_name, const uint64_t next_version,
|
const char *data_path, const char *subdir_name,
|
||||||
const int buffer_size, const int ring_size)
|
const uint64_t next_version, const int buffer_size,
|
||||||
|
const int ring_size)
|
||||||
{
|
{
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
|
|
@ -366,7 +366,8 @@ int sf_binlog_writer_init_by_version(SFBinlogWriterInfo *writer,
|
||||||
writer->version_ctx.change_count = 0;
|
writer->version_ctx.change_count = 0;
|
||||||
|
|
||||||
binlog_writer_set_next_version(writer, next_version);
|
binlog_writer_set_next_version(writer, next_version);
|
||||||
return sf_binlog_writer_init_normal(writer, subdir_name, buffer_size);
|
return sf_binlog_writer_init_normal(writer,
|
||||||
|
data_path, subdir_name, buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sf_binlog_writer_init_thread_ex(SFBinlogWriterThread *thread,
|
int sf_binlog_writer_init_thread_ex(SFBinlogWriterThread *thread,
|
||||||
|
|
|
||||||
|
|
@ -96,14 +96,14 @@ typedef struct sf_binlog_writer_context {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern char *g_sf_binlog_data_path;
|
|
||||||
|
|
||||||
int sf_binlog_writer_init_normal(SFBinlogWriterInfo *writer,
|
int sf_binlog_writer_init_normal(SFBinlogWriterInfo *writer,
|
||||||
const char *subdir_name, const int buffer_size);
|
const char *data_path, const char *subdir_name,
|
||||||
|
const int buffer_size);
|
||||||
|
|
||||||
int sf_binlog_writer_init_by_version(SFBinlogWriterInfo *writer,
|
int sf_binlog_writer_init_by_version(SFBinlogWriterInfo *writer,
|
||||||
const char *subdir_name, const uint64_t next_version,
|
const char *data_path, const char *subdir_name,
|
||||||
const int buffer_size, const int ring_size);
|
const uint64_t next_version, const int buffer_size,
|
||||||
|
const int ring_size);
|
||||||
|
|
||||||
int sf_binlog_writer_init_thread_ex(SFBinlogWriterThread *thread,
|
int sf_binlog_writer_init_thread_ex(SFBinlogWriterThread *thread,
|
||||||
const char *name, SFBinlogWriterInfo *writer, const short order_mode,
|
const char *name, SFBinlogWriterInfo *writer, const short order_mode,
|
||||||
|
|
@ -117,12 +117,12 @@ int sf_binlog_writer_init_thread_ex(SFBinlogWriterThread *thread,
|
||||||
order_by, max_record_size, 1, true)
|
order_by, max_record_size, 1, true)
|
||||||
|
|
||||||
static inline int sf_binlog_writer_init(SFBinlogWriterContext *context,
|
static inline int sf_binlog_writer_init(SFBinlogWriterContext *context,
|
||||||
const char *subdir_name, const int buffer_size,
|
const char *data_path, const char *subdir_name,
|
||||||
const int max_record_size)
|
const int buffer_size, const int max_record_size)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
if ((result=sf_binlog_writer_init_normal(&context->writer,
|
if ((result=sf_binlog_writer_init_normal(&context->writer,
|
||||||
subdir_name, buffer_size)) != 0)
|
data_path, subdir_name, buffer_size)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -139,18 +139,18 @@ int sf_binlog_writer_change_next_version(SFBinlogWriterInfo *writer,
|
||||||
const int64_t next_version);
|
const int64_t next_version);
|
||||||
|
|
||||||
#define sf_binlog_writer_set_flags(writer, flags) \
|
#define sf_binlog_writer_set_flags(writer, flags) \
|
||||||
sf_file_writer_set_flags(&writer->fw, flags)
|
sf_file_writer_set_flags(&(writer)->fw, flags)
|
||||||
|
|
||||||
#define sf_binlog_writer_get_last_version(writer) \
|
#define sf_binlog_writer_get_last_version(writer) \
|
||||||
sf_file_writer_get_last_version(&writer->fw)
|
sf_file_writer_get_last_version(&(writer)->fw)
|
||||||
|
|
||||||
void sf_binlog_writer_finish(SFBinlogWriterInfo *writer);
|
void sf_binlog_writer_finish(SFBinlogWriterInfo *writer);
|
||||||
|
|
||||||
#define sf_binlog_get_current_write_index(writer) \
|
#define sf_binlog_get_current_write_index(writer) \
|
||||||
sf_file_writer_get_current_index(&writer->fw)
|
sf_file_writer_get_current_index(&(writer)->fw)
|
||||||
|
|
||||||
#define sf_binlog_get_current_write_position(writer, position) \
|
#define sf_binlog_get_current_write_position(writer, position) \
|
||||||
sf_file_writer_get_current_position(&writer->fw, position)
|
sf_file_writer_get_current_position(&(writer)->fw, position)
|
||||||
|
|
||||||
static inline SFBinlogWriterBuffer *sf_binlog_writer_alloc_buffer(
|
static inline SFBinlogWriterBuffer *sf_binlog_writer_alloc_buffer(
|
||||||
SFBinlogWriterThread *thread)
|
SFBinlogWriterThread *thread)
|
||||||
|
|
@ -183,17 +183,16 @@ static inline SFBinlogWriterBuffer *sf_binlog_writer_alloc_versioned_buffer_ex(
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define sf_binlog_writer_get_filepath(subdir_name, filename, size) \
|
#define sf_binlog_writer_get_filepath(data_path, subdir_name, filename, size) \
|
||||||
sf_file_writer_get_filepath(g_sf_binlog_data_path, \
|
sf_file_writer_get_filepath(data_path, subdir_name, filename, size)
|
||||||
subdir_name, filename, size)
|
|
||||||
|
|
||||||
#define sf_binlog_writer_get_filename(subdir_name, \
|
#define sf_binlog_writer_get_filename(data_path, \
|
||||||
binlog_index, filename, size) \
|
subdir_name, binlog_index, filename, size) \
|
||||||
sf_file_writer_get_filename(g_sf_binlog_data_path, \
|
sf_file_writer_get_filename(data_path, subdir_name, \
|
||||||
subdir_name, binlog_index, filename, size)
|
binlog_index, filename, size)
|
||||||
|
|
||||||
#define sf_binlog_writer_set_binlog_index(writer, binlog_index) \
|
#define sf_binlog_writer_set_binlog_index(writer, binlog_index) \
|
||||||
sf_file_writer_set_binlog_index(writer, binlog_index)
|
sf_file_writer_set_binlog_index(&(writer)->fw, binlog_index)
|
||||||
|
|
||||||
#define sf_push_to_binlog_thread_queue(thread, buffer) \
|
#define sf_push_to_binlog_thread_queue(thread, buffer) \
|
||||||
fc_queue_push(&(thread)->queue, buffer)
|
fc_queue_push(&(thread)->queue, buffer)
|
||||||
|
|
@ -205,9 +204,9 @@ static inline void sf_push_to_binlog_write_queue(SFBinlogWriterInfo *writer,
|
||||||
fc_queue_push(&writer->thread->queue, buffer);
|
fc_queue_push(&writer->thread->queue, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define sf_binlog_writer_get_last_lines(subdir_name, current_write_index, \
|
#define sf_binlog_writer_get_last_lines(data_path, subdir_name, \
|
||||||
buff, buff_size, count, length) \
|
current_write_index, buff, buff_size, count, length) \
|
||||||
sf_file_writer_get_last_lines(g_sf_binlog_data_path, subdir_name, \
|
sf_file_writer_get_last_lines(data_path, subdir_name, \
|
||||||
current_write_index, buff, buff_size, count, length)
|
current_write_index, buff, buff_size, count, length)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue