0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CommitLogReader.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef Hypertable_Lib_CommitLogReader_h
28 #define Hypertable_Lib_CommitLogReader_h
29 
34 #include <Hypertable/Lib/Key.h>
35 
36 #include <Common/Filesystem.h>
37 #include <Common/String.h>
38 
39 #include <boost/thread/mutex.hpp>
40 
41 #include <memory>
42 #include <stack>
43 #include <unordered_map>
44 #include <vector>
45 
46 namespace Hypertable {
47 
50 
52  class CommitLogReader : public CommitLogBase {
53 
54  public:
55  CommitLogReader(FilesystemPtr &fs, const std::string &log_dir);
56 
57  CommitLogReader(FilesystemPtr &fs, const std::string &log_dir,
58  const std::vector<int32_t> &fragment_filter);
59 
60  virtual ~CommitLogReader() { }
61 
62  void get_init_fragment_ids(std::vector<uint32_t> &ids);
63 
66  bool next(const uint8_t **blockp, size_t *lenp,
68 
69  void reset() {
74  m_error_map.clear();
75  }
76 
77  void get_linked_logs(StringSet &linked_logs) {
78  linked_logs.insert(m_linked_logs.begin(), m_linked_logs.end());
79  }
80 
81  const std::map<uint32_t, uint32_t> &get_error_map() { return m_error_map; }
82 
83  const std::string& last_fragment_fname() const { return m_last_fragment_fname; }
84 
85  int32_t last_fragment_id() { return m_last_fragment_id; }
86 
87  private:
88 
89  void load_fragments(String log_dir, CommitLogFileInfo *parent);
90  void load_compressor(uint16_t ztype);
91 
95  int64_t m_revision {};
96 
97  typedef std::unordered_map<uint16_t, BlockCompressionCodecPtr> CompressorMap;
98 
99  CompressorMap m_compressor_map;
100  uint16_t m_compressor_type {};
102  std::set<uint32_t> m_fragment_filter;
103  std::vector<int32_t> m_init_fragments;
104  std::map<uint32_t, uint32_t> m_error_map;
107  int32_t m_last_fragment_id {};
108  bool m_verbose {};
109  };
110 
112  typedef std::shared_ptr<CommitLogReader> CommitLogReaderPtr;
113 
115 }
116 
117 #endif // Hypertable_Lib_CommitLogReader_h
118 
std::set< String > StringSet
STL Set managing Strings.
Definition: StringExt.h:42
CommitLogReader(FilesystemPtr &fs, const std::string &log_dir)
Holds information about an individual block.
std::shared_ptr< BlockCompressionCodec > BlockCompressionCodecPtr
Smart pointer to BlockCompressionCodec.
Abstract base class for a filesystem.
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
bool next_raw_block(CommitLogBlockInfo *, BlockHeaderCommitLog *)
std::vector< int32_t > m_init_fragments
std::map< uint32_t, uint32_t > m_error_map
Declarations for BlockCompressionCodec.
A dynamic, resizable and reference counted memory buffer.
Definition: DynamicBuffer.h:42
static const int64_t TIMESTAMP_MIN
Definition: KeySpec.h:34
Declarations for CommitLogBlockStream.
std::shared_ptr< CommitLogReader > CommitLogReaderPtr
Smart pointer to CommitLogReader.
const std::map< uint32_t, uint32_t > & get_error_map()
void load_fragments(String log_dir, CommitLogFileInfo *parent)
void get_init_fragment_ids(std::vector< uint32_t > &ids)
Declarations for BlockHeaderCommitLog.
Provides sequential access to blocks in a commit log.
BlockCompressionCodecPtr m_compressor
Hypertable definitions
const std::string & last_fragment_fname() const
void clear()
Clears the buffer.
std::shared_ptr< Filesystem > FilesystemPtr
Smart pointer to Filesystem.
Definition: Filesystem.h:572
std::unordered_map< uint16_t, BlockCompressionCodecPtr > CompressorMap
A String class based on std::string.
std::set< uint32_t > m_fragment_filter
bool next(const uint8_t **blockp, size_t *lenp, BlockHeaderCommitLog *)
void load_compressor(uint16_t ztype)
void get_linked_logs(StringSet &linked_logs)