binary log improvements
This commit is contained in:
@@ -581,6 +581,7 @@ void PIBinaryLog::parseLog(PIFile * f, PIBinaryLog::BinLogInfo * info, PIVector<
|
|||||||
if (info) {
|
if (info) {
|
||||||
BinLogIndex bl_ind;
|
BinLogIndex bl_ind;
|
||||||
bl_ind.id = br.id;
|
bl_ind.id = br.id;
|
||||||
|
bl_ind.data_size = br.size;
|
||||||
bl_ind.pos = f->pos() - br.size - hdr_size;
|
bl_ind.pos = f->pos() - br.size - hdr_size;
|
||||||
bl_ind.timestamp = br.timestamp;
|
bl_ind.timestamp = br.timestamp;
|
||||||
index->append(bl_ind);
|
index->append(bl_ind);
|
||||||
@@ -667,6 +668,18 @@ bool PIBinaryLog::createIndex() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PIBinaryLog::posForTime(const PISystemTime & time) {
|
||||||
|
int ci = -1;
|
||||||
|
for (uint i = 0; i < index.size(); i++) {
|
||||||
|
if (time <= index[i].timestamp && (filterID.contains(index[i].id) || filterID.isEmpty())) {
|
||||||
|
ci = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ci;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIBinaryLog::seekTo(int rindex) {
|
void PIBinaryLog::seekTo(int rindex) {
|
||||||
// piCoutObj << "seekTo";
|
// piCoutObj << "seekTo";
|
||||||
logmutex.lock();
|
logmutex.lock();
|
||||||
@@ -688,13 +701,7 @@ void PIBinaryLog::seekTo(int rindex) {
|
|||||||
|
|
||||||
|
|
||||||
bool PIBinaryLog::seek(const PISystemTime & time) {
|
bool PIBinaryLog::seek(const PISystemTime & time) {
|
||||||
int ci = -1;
|
int ci = posForTime(time);
|
||||||
for (uint i=0; i<index.size(); i++) {
|
|
||||||
if (time <= index[i].timestamp && (filterID.contains(index[i].id) || filterID.isEmpty())) {
|
|
||||||
ci = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ci >= 0) {
|
if (ci >= 0) {
|
||||||
seekTo(ci);
|
seekTo(ci);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public:
|
|||||||
//! @brief Struct contains position, ID and timestamp of record in file
|
//! @brief Struct contains position, ID and timestamp of record in file
|
||||||
struct PIP_EXPORT BinLogIndex {
|
struct PIP_EXPORT BinLogIndex {
|
||||||
int id;
|
int id;
|
||||||
|
int data_size;
|
||||||
llong pos;
|
llong pos;
|
||||||
PISystemTime timestamp;
|
PISystemTime timestamp;
|
||||||
};
|
};
|
||||||
@@ -236,6 +237,9 @@ public:
|
|||||||
//! Return if current binlog file is indexed
|
//! Return if current binlog file is indexed
|
||||||
bool isIndexed() {return is_indexed;}
|
bool isIndexed() {return is_indexed;}
|
||||||
|
|
||||||
|
//! Find nearest record of time \"time\". Returns -1 if not indexed or time less than first record
|
||||||
|
int posForTime(const PISystemTime & time);
|
||||||
|
|
||||||
//! Go to record #index
|
//! Go to record #index
|
||||||
void seekTo(int rindex);
|
void seekTo(int rindex);
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ bool stopThread(PIThread * t, bool hard) {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
t->stop();
|
t->stop();
|
||||||
if (t->waitForFinish(10000)) {
|
if (!t->waitForFinish(10000)) {
|
||||||
t->terminate();
|
t->terminate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user