Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala-server.inline.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_SERVICE_IMPALA_SERVER_INLINE_H
17 #define IMPALA_SERVICE_IMPALA_SERVER_INLINE_H
18 
19 #include "service/impala-server.h"
20 
21 namespace impala {
22 
24  const apache::hive::service::cli::thrift::THandleIdentifier& handle,
25  TUniqueId* unique_id, TUniqueId* secret) {
26  if (handle.guid.length() != 16 || handle.secret.length() != 16) {
27  std::stringstream ss;
28  ss << "Malformed THandleIdentifier (guid size: " << handle.guid.length()
29  << ", expected 16, secret size: " << handle.secret.length() << ", expected 16)";
30  return Status(ss.str());
31  }
32  memcpy(&(unique_id->hi), handle.guid.c_str(), 8);
33  memcpy(&(unique_id->lo), handle.guid.c_str() + 8, 8);
34  memcpy(&(secret->hi), handle.secret.c_str(), 8);
35  memcpy(&(secret->lo), handle.secret.c_str() + 8, 8);
36 
37  return Status::OK;
38 }
39 
41  const TUniqueId& unique_id, const TUniqueId& secret,
42  apache::hive::service::cli::thrift::THandleIdentifier* handle) {
43  char uuid[16];
44  memcpy((void*)uuid, &unique_id.hi, 8);
45  memcpy((void*)(uuid + 8), &unique_id.lo, 8);
46  handle->guid.assign(uuid, 16);
47  memcpy((void*)uuid, &secret.hi, 8);
48  memcpy((void*)(uuid + 8), &secret.lo, 8);
49  handle->secret.assign(uuid, 16);
50 }
51 
52 }
53 
54 #endif
static void TUniqueIdToTHandleIdentifier(const TUniqueId &unique_id, const TUniqueId &secret, apache::hive::service::cli::thrift::THandleIdentifier *handle)
static Status THandleIdentifierToTUniqueId(const apache::hive::service::cli::thrift::THandleIdentifier &handle, TUniqueId *unique_id, TUniqueId *secret)
Helper functions to translate between HiveServer2 and Impala structs.
static const Status OK
Definition: status.h:87