binary log improvements

This commit is contained in:
peri4
2021-10-21 18:48:01 +03:00
parent 1cb3d4ffe9
commit f781cc3846
3 changed files with 19 additions and 8 deletions

View File

@@ -581,6 +581,7 @@ void PIBinaryLog::parseLog(PIFile * f, PIBinaryLog::BinLogInfo * info, PIVector<
if (info) {
BinLogIndex bl_ind;
bl_ind.id = br.id;
bl_ind.data_size = br.size;
bl_ind.pos = f->pos() - br.size - hdr_size;
bl_ind.timestamp = br.timestamp;
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) {
// piCoutObj << "seekTo";
logmutex.lock();
@@ -688,13 +701,7 @@ void PIBinaryLog::seekTo(int rindex) {
bool PIBinaryLog::seek(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;
}
}
int ci = posForTime(time);
if (ci >= 0) {
seekTo(ci);
return true;