CUBRID Engine  latest
log_postpone_cache.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * log_postpone_cache.hpp - log postpone cache module
21  */
22 
23 #ifndef _LOG_POSTPONE_CACHE_HPP_
24 #define _LOG_POSTPONE_CACHE_HPP_
25 
26 #include "log_lsa.hpp"
27 #include "log_record.hpp"
28 #include "mem_block.hpp"
29 #include "storage_common.h"
30 
31 #include <array>
32 
33 // forward declarations
34 struct log_tdes;
35 struct log_prior_node;
36 
37 namespace cubthread
38 {
39  class entry;
40 }
41 
47 {
48  public:
50  : m_redo_data_buf ()
51  , m_redo_data_offset (0)
52  , m_is_redo_data_buf_full (false)
53  , m_cursor (0)
54  , m_cache_entries ()
55  {
56  }
57 
58  log_postpone_cache (log_postpone_cache &&other) = delete;
59  log_postpone_cache (const log_postpone_cache &other) = delete;
60 
61  log_postpone_cache &operator= (log_postpone_cache &&other) = delete;
62  log_postpone_cache &operator= (const log_postpone_cache &other) = delete;
63 
64  ~log_postpone_cache () = default;
65 
66  void reset ();
67 
68  void add_redo_data (const log_prior_node &node);
69  void add_lsa (const log_lsa &lsa);
70  bool do_postpone (cubthread::entry &thread_ref, const log_lsa &start_postpone_lsa);
71 
72  private:
73  static const std::size_t MAX_CACHE_ENTRIES = 512;
74  static const std::size_t REDO_DATA_MAX_SIZE = 100 * 1024; // 100k
75  static const std::size_t BUFFER_RESET_SIZE = 1024;
76 
78  {
79  public:
81  : m_lsa ()
82  , m_offset (0)
83  {
84  m_lsa.set_null ();
85  }
86 
88  std::size_t m_offset;
89  };
90 
92  std::size_t m_redo_data_offset;
94 
95  std::size_t m_cursor;
96  std::array<cache_entry, MAX_CACHE_ENTRIES> m_cache_entries;
97 
98  bool is_full () const;
99 };
100 
101 #endif /* _LOG_POSTPONE_CACHE_HPP_ */
std::size_t m_redo_data_offset
cache_entry()
std::array< cache_entry, MAX_CACHE_ENTRIES > m_cache_entries
log_lsa m_lsa
std::size_t m_offset
cubmem::extensible_block m_redo_data_buf