libfoedus-core
FOEDUS Core Library
hash_record_location.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_RECORD_LOCATION_HPP_
19 #define FOEDUS_STORAGE_HASH_RECORD_LOCATION_HPP_
20 
21 #include "foedus/cxx11.hpp"
22 #include "foedus/error_code.hpp"
26 #include "foedus/xct/fwd.hpp"
27 #include "foedus/xct/xct_id.hpp"
28 
29 namespace foedus {
30 namespace storage {
31 namespace hash {
32 
88  uint16_t key_length_;
91 
93  char* record_;
101 
107 
108  bool is_found() const { return index_ != kSlotNotFound; }
109  inline uint16_t get_aligned_key_length() const { return assorted::align8(key_length_); }
110  inline uint16_t get_max_payload() const {
111  return physical_record_length_ - get_aligned_key_length();
112  }
113 
114  void clear() {
115  page_ = CXX11_NULLPTR;
116  index_ = kSlotNotFound;
117  cur_payload_length_ = 0;
118  key_length_ = 0;
119  physical_record_length_ = 0;
120  record_ = CXX11_NULLPTR;
121  observed_.data_ = 0;
122  readset_ = CXX11_NULLPTR;
123  }
124 
130  xct::Xct* cur_xct,
131  HashDataPage* page,
132  DataPageSlotIndex index,
133  bool intended_for_write);
134 
140 };
141 
142 } // namespace hash
143 } // namespace storage
144 } // namespace foedus
145 #endif // FOEDUS_STORAGE_HASH_RECORD_LOCATION_HPP_
uint16_t physical_record_length_
Byte count the record of the slot occupies, which is immutable.
T align8(T value)
8-alignment.
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Forward declarations of classes in transaction package.
const DataPageSlotIndex kSlotNotFound
Definition: hash_id.hpp:197
Represents a user transaction.
Definition: xct.hpp:58
Persistent status part of Transaction ID.
Definition: xct_id.hpp:955
Represents a record of read-access during a transaction.
Definition: xct_access.hpp:139
ErrorCode populate_logical(xct::Xct *cur_xct, HashDataPage *page, DataPageSlotIndex index, bool intended_for_write)
Populates the result with XID and possibly readset.
HashDataPage * page_
The data page (might not be bin-head) containing the record.
char * record_
Address of the record.
Definitions of IDs in this package and a few related constant values.
uint16_t key_length_
Key length of the slot, which is immutable.
uint16_t cur_payload_length_
Logical payload length as-of the observed XID.
uint16_t DataPageSlotIndex
Definition: hash_id.hpp:196
void populate_physical(HashDataPage *page, DataPageSlotIndex index)
Populates fields other than readset_.
Represents an individual data page in Hashtable Storage.
xct::XctId observed_
TID as of locate_record() identifying the record.
return value of locate_record().
xct::ReadXctAccess * readset_
If this method took a read-set on the returned record, points to the corresponding read-set...
Definitions of IDs in this package and a few related constant values.
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85
DataPageSlotIndex index_
Index of the record in the page.
Forward declarations of classes in hash storage package.