sf_file_writer_get_indexes impl.
parent
c611b9b30c
commit
c717646593
|
|
@ -175,8 +175,17 @@ int sf_binlog_writer_notify_exit(SFBinlogWriterInfo *writer);
|
|||
#define sf_binlog_writer_get_last_version(writer) \
|
||||
sf_file_writer_get_last_version(&(writer)->fw)
|
||||
|
||||
#define sf_binlog_get_indexes(writer, start_index, last_index) \
|
||||
sf_file_writer_get_indexes(&(writer)->fw, start_index, last_index)
|
||||
|
||||
#define sf_binlog_get_start_index(writer) \
|
||||
sf_file_writer_get_start_index(&(writer)->fw)
|
||||
|
||||
#define sf_binlog_get_last_index(writer) \
|
||||
sf_file_writer_get_last_index(&(writer)->fw)
|
||||
|
||||
#define sf_binlog_get_current_write_index(writer) \
|
||||
sf_file_writer_get_current_index(&(writer)->fw)
|
||||
sf_file_writer_get_current_write_index(&(writer)->fw)
|
||||
|
||||
#define sf_binlog_get_current_write_position(writer, position) \
|
||||
sf_file_writer_get_current_position(&(writer)->fw, position)
|
||||
|
|
@ -225,13 +234,15 @@ static inline SFBinlogWriterBuffer *sf_binlog_writer_alloc_versioned_buffer_ex(
|
|||
sf_file_writer_get_index_filename(data_path, \
|
||||
subdir_name, filename, size)
|
||||
|
||||
#define sf_binlog_writer_get_binlog_index(data_path, \
|
||||
subdir_name, write_index) \
|
||||
sf_file_writer_get_binlog_index(data_path, \
|
||||
subdir_name, write_index)
|
||||
#define sf_binlog_writer_get_binlog_start_index(data_path, \
|
||||
subdir_name, start_index) \
|
||||
sf_file_writer_get_binlog_start_index(data_path, \
|
||||
subdir_name, start_index)
|
||||
|
||||
#define sf_binlog_writer_set_binlog_index(writer, binlog_index) \
|
||||
sf_file_writer_set_binlog_last_index(&(writer)->fw, binlog_index)
|
||||
#define sf_binlog_writer_get_binlog_last_index(data_path, \
|
||||
subdir_name, last_index) \
|
||||
sf_file_writer_get_binlog_last_index(data_path, \
|
||||
subdir_name, last_index)
|
||||
|
||||
#define sf_binlog_writer_set_binlog_start_index(writer, start_index) \
|
||||
sf_file_writer_set_binlog_start_index(&(writer)->fw, start_index)
|
||||
|
|
|
|||
|
|
@ -271,17 +271,26 @@ int sf_file_writer_flush(SFFileWriterInfo *writer)
|
|||
return result;
|
||||
}
|
||||
|
||||
int sf_file_writer_get_current_index(SFFileWriterInfo *writer)
|
||||
int sf_file_writer_get_indexes(SFFileWriterInfo *writer,
|
||||
int *start_index, int *last_index)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (writer == NULL) { //for data recovery
|
||||
*start_index = *last_index = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (writer->binlog.last_index < 0) {
|
||||
get_binlog_index_from_file(writer);
|
||||
if ((result=get_binlog_index_from_file(writer)) != 0) {
|
||||
*start_index = *last_index = -1;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return writer->binlog.last_index;
|
||||
*start_index = writer->binlog.start_index;
|
||||
*last_index = writer->binlog.last_index;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sf_file_writer_deal_versioned_buffer(SFFileWriterInfo *writer,
|
||||
|
|
|
|||
|
|
@ -100,15 +100,47 @@ static inline int64_t sf_file_writer_get_last_version(
|
|||
int sf_file_writer_get_binlog_indexes(const char *data_path,
|
||||
const char *subdir_name, int *start_index, int *last_index);
|
||||
|
||||
static inline int sf_file_writer_get_binlog_index(const char *data_path,
|
||||
const char *subdir_name, int *last_index)
|
||||
static inline int sf_file_writer_get_binlog_start_index(
|
||||
const char *data_path, const char *subdir_name,
|
||||
int *start_index)
|
||||
{
|
||||
int last_index;
|
||||
return sf_file_writer_get_binlog_indexes(data_path,
|
||||
subdir_name, start_index, &last_index);
|
||||
}
|
||||
|
||||
static inline int sf_file_writer_get_binlog_last_index(
|
||||
const char *data_path, const char *subdir_name,
|
||||
int *last_index)
|
||||
{
|
||||
int start_index;
|
||||
return sf_file_writer_get_binlog_indexes(data_path,
|
||||
subdir_name, &start_index, last_index);
|
||||
}
|
||||
|
||||
int sf_file_writer_get_current_index(SFFileWriterInfo *writer);
|
||||
int sf_file_writer_get_indexes(SFFileWriterInfo *writer,
|
||||
int *start_index, int *last_index);
|
||||
|
||||
static inline int sf_file_writer_get_start_index(SFFileWriterInfo *writer)
|
||||
{
|
||||
int start_index;
|
||||
int last_index;
|
||||
|
||||
sf_file_writer_get_indexes(writer, &start_index, &last_index);
|
||||
return start_index;
|
||||
}
|
||||
|
||||
static inline int sf_file_writer_get_last_index(SFFileWriterInfo *writer)
|
||||
{
|
||||
int start_index;
|
||||
int last_index;
|
||||
|
||||
sf_file_writer_get_indexes(writer, &start_index, &last_index);
|
||||
return last_index;
|
||||
}
|
||||
|
||||
#define sf_file_writer_get_current_write_index(writer) \
|
||||
sf_file_writer_get_last_index(writer)
|
||||
|
||||
static inline void sf_file_writer_get_current_position(
|
||||
SFFileWriterInfo *writer, SFBinlogFilePosition *position)
|
||||
|
|
|
|||
Loading…
Reference in New Issue