forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpika_binlog_reader.h
48 lines (38 loc) · 1.46 KB
/
pika_binlog_reader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef PIKA_BINLOG_READER_H_
#define PIKA_BINLOG_READER_H_
#include <string>
#include <memory>
#include "slash/include/slash_status.h"
#include "slash/include/env.h"
#include "slash/include/slash_slice.h"
#include "include/pika_binlog.h"
using slash::Status;
using slash::Slice;
class PikaBinlogReader {
public:
PikaBinlogReader(uint32_t cur_filenum, uint64_t cur_offset);
PikaBinlogReader();
~PikaBinlogReader();
Status Get(std::string* scratch, uint32_t* filenum, uint64_t* offset);
int Seek(std::shared_ptr<Binlog> logger, uint32_t filenum, uint64_t offset);
bool ReadToTheEnd();
void GetReaderStatus(uint32_t* cur_filenum, uint64_t* cur_offset);
private:
bool GetNext(uint64_t* size);
unsigned int ReadPhysicalRecord(slash::Slice *redult, uint32_t* filenum, uint64_t* offset);
// Returns scratch binflog and corresponding offset
Status Consume(std::string* scratch, uint32_t* filenum, uint64_t* offset);
pthread_rwlock_t rwlock_;
uint32_t cur_filenum_;
uint64_t cur_offset_;
uint64_t last_record_offset_;
std::shared_ptr<Binlog> logger_;
slash::SequentialFile *queue_;
char* const backing_store_;
Slice buffer_;
};
#endif // PIKA_BINLOG_READER_H_