libfoedus-core
FOEDUS Core Library
hash_reserve_impl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
18 #ifndef FOEDUS_STORAGE_HASH_HASH_RESERVE_IMPL_HPP_
19 #define FOEDUS_STORAGE_HASH_HASH_RESERVE_IMPL_HPP_
20 
21 #include "foedus/error_code.hpp"
25 #include "foedus/thread/fwd.hpp"
27 
28 namespace foedus {
29 namespace storage {
30 namespace hash {
31 
73 struct ReserveRecords final : public xct::SysxctFunctor {
97  const void* const key_;
125 
141 
143  thread::Thread* context,
144  HashDataPage* target,
145  const void* key,
146  KeyLength key_length,
147  const HashCombo& combo,
148  PayloadLength payload_count,
149  PayloadLength aggressive_payload_count_hint,
150  DataPageSlotIndex hint_check_from)
151  : xct::SysxctFunctor(),
152  context_(context),
153  target_(target),
154  key_(key),
155  combo_(combo),
156  key_length_(key_length),
157  payload_count_(payload_count),
158  aggressive_payload_count_hint_(aggressive_payload_count_hint),
159  hint_check_from_(hint_check_from),
160  out_slot_(kSlotNotFound),
161  out_page_(nullptr) {
162  }
163  virtual ErrorCode run(xct::SysxctWorkspace* sysxct_workspace) override;
164 
169  xct::SysxctWorkspace* sysxct_workspace,
170  HashDataPage* page,
171  DataPageSlotIndex examined_records);
172 
174  xct::SysxctWorkspace* sysxct_workspace,
175  HashDataPage* page,
176  DataPageSlotIndex index);
177 
179  xct::SysxctWorkspace* sysxct_workspace,
180  HashDataPage* from_page,
181  HashDataPage** tail);
182 
188 
190  HashDataPage* cur_tail,
191  HashDataPage** new_tail);
192 
194  const HashDataPage* page,
195  DataPageSlotIndex key_count,
196  DataPageSlotIndex examined_records) const;
203 };
204 
205 } // namespace hash
206 } // namespace storage
207 } // namespace foedus
208 #endif // FOEDUS_STORAGE_HASH_HASH_RESERVE_IMPL_HPP_
HashDataPage *const target_
The data page to install a new physical record.
ErrorCode find_and_lock_spacious_tail(xct::SysxctWorkspace *sysxct_workspace, HashDataPage *from_page, HashDataPage **tail)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Represents one thread running on one NUMA core.
Definition: thread.hpp:48
DataPageSlotIndex out_slot_
[Out] The slot of the record that is found or created.
const PayloadLength payload_count_
Minimal required length of the payload.
const DataPageSlotIndex kSlotNotFound
Definition: hash_id.hpp:197
Persistent status part of Transaction ID.
Definition: xct_id.hpp:955
ErrorCode find_or_create_or_expand(xct::SysxctWorkspace *sysxct_workspace, HashDataPage *page, DataPageSlotIndex examined_records)
The main loop (well, recursion actually).
uint16_t PayloadLength
Represents a byte-length of a payload in this package.
Definition: hash_id.hpp:209
HashDataPage * out_page_
[Out] The page that contains the found/created record.
const void *const key_
The key of the new record.
const KeyLength key_length_
Byte length of the key.
A functor representing the logic in a system transaction via virtual-function.
ErrorCode create_new_tail_page(HashDataPage *cur_tail, HashDataPage **new_tail)
ErrorCode create_new_record_in_tail_page(HashDataPage *tail)
Installs it as a fresh-new physical record, assuming the given page is the tail and already locked...
virtual ErrorCode run(xct::SysxctWorkspace *sysxct_workspace) override
Execute the system transaction.
A system transaction to reserve a physical record(s) in a hash data page.
uint16_t DataPageSlotIndex
Definition: hash_id.hpp:196
const DataPageSlotIndex hint_check_from_
The in-page location from which this sysxct will look for matching records.
A set of information that are used in many places, extracted from the given key.
Definition: hash_combo.hpp:48
ReserveRecords(thread::Thread *context, HashDataPage *target, const void *key, KeyLength key_length, const HashCombo &combo, PayloadLength payload_count, PayloadLength aggressive_payload_count_hint, DataPageSlotIndex hint_check_from)
thread::Thread *const context_
Thread context.
ErrorCode expand_record(xct::SysxctWorkspace *sysxct_workspace, HashDataPage *page, DataPageSlotIndex index)
Represents an individual data page in Hashtable Storage.
const PayloadLength aggressive_payload_count_hint_
When we expand the record or allocate a new record, we might allocate a larger-than-necessary space g...
uint16_t KeyLength
Represents a byte-length of a key in this package.
Definition: hash_id.hpp:203
DataPageSlotIndex append_record_to_page(HashDataPage *page, xct::XctId initial_xid) const
Appends a new physical record to the page.
DataPageSlotIndex search_within_page(const HashDataPage *page, DataPageSlotIndex key_count, DataPageSlotIndex examined_records) const
Definitions of IDs in this package and a few related constant values.
Forward declarations of classes in thread package.
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85
Per-thread reused work memory for system transactions.
Forward declarations of classes in hash storage package.
const HashCombo & combo_
Hash info of the key.