libfoedus-core
FOEDUS Core Library
masstree_record_location.cpp
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  */
19 
21 #include "foedus/xct/xct.hpp"
22 
23 namespace foedus {
24 namespace storage {
25 namespace masstree {
26 
28  xct::Xct* cur_xct,
29  MasstreeBorderPage* page,
30  SlotIndex index,
31  bool intended_for_write) {
32  page_ = page;
33  index_ = index;
34  readset_ = nullptr;
35 
36  // [Logical check]: Read XID in a finalized fashion. If we found it "moved",
37  // then we don't need to remember it as read-set.
39  intended_for_write,
40  page->get_owner_id(index),
41  &observed_,
42  &readset_,
43  true, // no_readset_if_moved. see below
44  true)); // no_readset_if_next_layer. see below
47 
49  // Once it becomes a next-layer or moved pointer, it never goes back to a normal record.
50  // so, there is no point to keep the read-set acquired in on_record_read().
51  // We thus give parameters above that tell on_record_read() to not take read-set in the case.
52  ASSERT_ND(readset_ == nullptr); // let's confirm it
53  }
54  return kErrorCodeOk;
55 }
56 
57 } // namespace masstree
58 } // namespace storage
59 } // namespace foedus
uint16_t SlotIndex
Index of a record in a (border) page.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
ErrorCode on_record_read(bool intended_for_write, RwLockableXctId *tid_address, XctId *observed_xid, ReadXctAccess **read_set_address, bool no_readset_if_moved=false, bool no_readset_if_next_layer=false)
The general logic invoked for every record read.
Definition: xct.cpp:258
Represents a user transaction.
Definition: xct.hpp:58
Represents one border page in Masstree Storage.
bool is_valid() const __attribute__((always_inline))
Definition: xct_id.hpp:973
0 means no-error.
Definition: error_code.hpp:87
xct::ReadXctAccess * readset_
If this method took a read-set on the returned record, points to the corresponding read-set...
bool is_next_layer() const __attribute__((always_inline))
Definition: xct_id.hpp:1042
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
SlotIndex index_
Index of the record in the page.
bool is_being_written() const __attribute__((always_inline))
Definition: xct_id.hpp:1038
xct::RwLockableXctId * get_owner_id(SlotIndex index) __attribute__((always_inline))
MasstreeBorderPage * page_
The border page containing the record.
bool is_moved() const __attribute__((always_inline))
Definition: xct_id.hpp:1041
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
xct::XctId observed_
TID as of locate_record() identifying the record.
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85
ErrorCode populate_logical(xct::Xct *cur_xct, MasstreeBorderPage *page, SlotIndex index, bool intended_for_write)
Populates the result with XID and possibly readset.