libfoedus-core
FOEDUS Core Library
proc_id.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_PROC_PROC_ID_HPP_
19 #define FOEDUS_PROC_PROC_ID_HPP_
20 
21 #include <stdint.h>
22 
23 #include <utility>
24 
25 #include "foedus/error_stack.hpp"
26 #include "foedus/fwd.hpp"
28 #include "foedus/thread/fwd.hpp"
29 
35 namespace foedus {
36 namespace proc {
37 
45 
56 typedef uint32_t LocalProcId;
57 
58 const LocalProcId kLocalProcInvalid = -1;
59 
65 typedef uint64_t GlobalProcId;
66 
67 inline GlobalProcId combined_global_proc_id(uint16_t node, LocalProcId local_id) {
68  return static_cast<GlobalProcId>(node) << 32 | local_id;
69 }
70 inline uint16_t extract_numa_node_from_global_proc_id(GlobalProcId id) {
71  return static_cast<uint16_t>(id >> 32);
72 }
73 inline LocalProcId extract_local_id_from_global_proc_id(GlobalProcId id) {
74  return static_cast<LocalProcId>(id);
75 }
76 
81 struct ProcArguments {
87  const void* input_buffer_;
89  uint32_t input_len_;
95  uint32_t* output_used_;
96 };
97 
113 typedef ErrorStack (*Proc)(const ProcArguments& args);
114 
119 typedef std::pair<ProcName, Proc> ProcAndName;
120 
121 } // namespace proc
122 } // namespace foedus
123 #endif // FOEDUS_PROC_PROC_ID_HPP_
const void * input_buffer_
[IN] Arbitrary user input given to the procedure
Definition: proc_id.hpp:87
uint32_t output_buffer_size_
[IN] Byte length of output_buffer_ capacity
Definition: proc_id.hpp:93
uint32_t input_len_
[IN] Byte length of input_buffer_
Definition: proc_id.hpp:89
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
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Engine * engine_
[IN] Database Engine
Definition: proc_id.hpp:83
thread::Thread * context_
[IN] Thread on which the procedure is running
Definition: proc_id.hpp:85
uint64_t GlobalProcId
A globally unique ID of a procedure.
Definition: proc_id.hpp:65
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
std::pair< ProcName, Proc > ProcAndName
Just a std::pair.
Definition: proc_id.hpp:119
const LocalProcId kLocalProcInvalid
Definition: proc_id.hpp:58
uint32_t * output_used_
[OUT] Byte length of output_buffer_ actually written
Definition: proc_id.hpp:95
void * output_buffer_
[OUT] Arbitrary user output buffer given to the procedure
Definition: proc_id.hpp:91
assorted::FixedString< 60 > ProcName
Represents a unique name of a procedure.
Definition: proc_id.hpp:44
GlobalProcId combined_global_proc_id(uint16_t node, LocalProcId local_id)
Definition: proc_id.hpp:67
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
Definition: proc_id.hpp:56
ErrorStack(* Proc)(const ProcArguments &args)
A function pointer of a user/system stored procedure.
Definition: proc_id.hpp:113
Set of arguments, both inputs and outputs, given to each procedure.
Definition: proc_id.hpp:81
Forward declarations of classes in thread package.
LocalProcId extract_local_id_from_global_proc_id(GlobalProcId id)
Definition: proc_id.hpp:73
uint16_t extract_numa_node_from_global_proc_id(GlobalProcId id)
Definition: proc_id.hpp:70