diff options
author | Parth Chandra <pchandra@maprtech.com> | 2014-05-20 09:42:10 -0700 |
---|---|---|
committer | Jacques Nadeau <jacques@apache.org> | 2014-05-29 15:32:29 -0700 |
commit | e1e5ea0eddd9199672ab01c5ae31f7a3c0a57249 (patch) | |
tree | 92e1761f396dbc02762dd57f4dd1cf66a8b37fc5 /contrib/native/client/src/include | |
parent | b1d91c8187d197991306b4d054db135121ceca85 (diff) |
DRILL-423: C++ Client. Initial implementation (reviewed)
Diffstat (limited to 'contrib/native/client/src/include')
7 files changed, 3630 insertions, 0 deletions
diff --git a/contrib/native/client/src/include/drill/common.hpp b/contrib/native/client/src/include/drill/common.hpp new file mode 100644 index 000000000..436805861 --- /dev/null +++ b/contrib/native/client/src/include/drill/common.hpp @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#include <stdint.h> +#include <string> +#include <vector> + +#define LENGTH_PREFIX_MAX_LENGTH 5 +#define LEN_PREFIX_BUFLEN LENGTH_PREFIX_MAX_LENGTH + +#ifdef _DEBUG +#define EXTRA_DEBUGGING +#define CODER_DEBUGGING +#endif + +namespace Drill { + +typedef std::vector<uint8_t> DataBuf; + +typedef uint8_t Byte_t; +typedef Byte_t * ByteBuf_t; + +typedef enum{ + QRY_SUCCESS=0, + QRY_FAILURE=1, + QRY_SUCCESS_WITH_INFO=2, + QRY_NO_MORE_DATA=3, + QRY_CANCEL=4, + QRY_OUT_OF_BOUNDS=5, + QRY_CLIENT_OUTOFMEM=6, + QRY_INTERNAL_ERROR=7, + QRY_COMM_ERROR=8 +} status_t; + +typedef enum{ + CONN_SUCCESS=0, + CONN_FAILURE=1, + CONN_HANDSHAKE_FAILED=2, + CONN_INVALID_INPUT=3, + CONN_ZOOKEEPER_ERROR=4 +} connectionStatus_t; + +typedef enum{ + LOG_TRACE=0, + LOG_DEBUG=1, + LOG_INFO=2, + LOG_WARNING=3, + LOG_ERROR=4, + LOG_FATAL=5 +} logLevel_t; + +typedef enum{ + CAT_CONN=0, + CAT_QUERY=1 +} errCategory_t; + +typedef enum{ + RET_SUCCESS=0, + RET_FAILURE=1 +} ret_t; + +} // namespace Drill + +#endif + diff --git a/contrib/native/client/src/include/drill/decimalUtils.hpp b/contrib/native/client/src/include/drill/decimalUtils.hpp new file mode 100644 index 000000000..5f56e4d46 --- /dev/null +++ b/contrib/native/client/src/include/drill/decimalUtils.hpp @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _DECIMAL_UTILS_H +#define _DECIMAL_UTILS_H + +#include <boost/multiprecision/cpp_int.hpp> + +namespace Drill { + +class SlicedByteBuf; + +struct DecimalValue +{ + DecimalValue() : + m_unscaledValue(0), + m_scale(0) + { + ; + } + + DecimalValue(int32_t val, int32_t scale) : m_unscaledValue(val), m_scale(scale){ } + DecimalValue(int64_t val, int32_t scale) : m_unscaledValue(val), m_scale(scale){ } + boost::multiprecision::cpp_int m_unscaledValue; + int32_t m_scale; +}; + +// These functions need not be exported. They are used by the templates that return the DecimalValue class. +DecimalValue getDecimalValueFromByteBuf(SlicedByteBuf& data, size_t startIndex, int nDecimalDigits, int scale, bool truncateScale); +DecimalValue getDecimalValueFromDense(SlicedByteBuf& data, size_t startIndex, int nDecimalDigits, int scale, int maxPrecision, int width); + +inline DecimalValue getDecimalValueFromIntermediate(SlicedByteBuf& data, size_t startIndex, int nDecimalDigits, int scale) +{ + // In the intermediate representation, we don't pad the scale with zeros. Set truncate to false. + return getDecimalValueFromByteBuf(data, startIndex, nDecimalDigits, scale, false); +} + +inline DecimalValue getDecimalValueFromSparse(SlicedByteBuf& data, size_t startIndex, int nDecimalDigits, int scale) +{ + // In the sparse representation, we pad the scale with zeroes for ease of arithmetic. Set truncate to true. + return getDecimalValueFromByteBuf(data, startIndex, nDecimalDigits, scale, true); +} + +} // namespace Drill +#endif diff --git a/contrib/native/client/src/include/drill/drillClient.hpp b/contrib/native/client/src/include/drill/drillClient.hpp new file mode 100644 index 000000000..0e85dcc93 --- /dev/null +++ b/contrib/native/client/src/include/drill/drillClient.hpp @@ -0,0 +1,230 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef DRILL_CLIENT_H +#define DRILL_CLIENT_H + +#include <vector> +#include <boost/log/core.hpp> +#include <boost/log/trivial.hpp> +#include <boost/thread.hpp> +#include "drill/common.hpp" +#include "drill/protobuf/User.pb.h" + + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef DRILL_CLIENT_EXPORTS + #define DECLSPEC_DRILL_CLIENT __declspec(dllexport) + #else + #ifdef USE_STATIC_LIBDRILL + #define DECLSPEC_DRILL_CLIENT + #else + #define DECLSPEC_DRILL_CLIENT __declspec(dllimport) + #endif + #endif +#else + #if __GNUC__ >= 4 + #define DECLSPEC_DRILL_CLIENT __attribute__ ((visibility ("default"))) + #else + #define DECLSPEC_DRILL_CLIENT + #endif +#endif + +namespace Drill { + +//struct UserServerEndPoint; +class DrillClientImpl; +class DrillClientQueryResult; +class FieldMetadata; +class RecordBatch; +class SchemaDef; + +class DECLSPEC_DRILL_CLIENT DrillClientError{ + public: + static const uint32_t CONN_ERROR_START = 100; + static const uint32_t QRY_ERROR_START = 200; + + DrillClientError(uint32_t s, uint32_t e, char* m){status=s; errnum=e; msg=m;}; + DrillClientError(uint32_t s, uint32_t e, std::string m){status=s; errnum=e; msg=m;}; + + static DrillClientError* getErrorObject(const exec::shared::DrillPBError& e); + + // To get the error number we add a error range start number to + // the status code returned (either status_t or connectionStatus_t) + uint32_t status; // could be either status_t or connectionStatus_t + uint32_t errnum; + std::string msg; +}; + +// Only one instance of this class exists. A static member of DrillClientImpl; +class DECLSPEC_DRILL_CLIENT DrillClientInitializer{ + public: + DrillClientInitializer(); + ~DrillClientInitializer(); +}; + +// Only one instance of this class exists. A static member of DrillClientImpl; +class DECLSPEC_DRILL_CLIENT DrillClientConfig{ + public: + DrillClientConfig(); + static void initLogging(const char* path); + static void setLogLevel(logLevel_t l); + static void setBufferLimit(uint64_t l); + static uint64_t getBufferLimit(); + static logLevel_t getLogLevel(); + private: + // The logging level + static logLevel_t s_logLevel; + // The total amount of memory to be allocated by an instance of DrillClient. + // For future use. Currently, not enforced. + static uint64_t s_bufferLimit; + static boost::mutex s_mutex; +}; + + +/* + * Handle to the Query submitted for execution. + * */ +typedef void* QueryHandle_t; + +/* + * Query Results listener callback. This function is called for every record batch after it has + * been received and decoded. The listener function should return a status. + * If the listener returns failure, the query will be canceled. + * + * DrillClientQueryResult will hold a listener & listener contxt for the call back function + */ +typedef status_t (*pfnQueryResultsListener)(QueryHandle_t ctx, RecordBatch* b, DrillClientError* err); + +/* + * The schema change listener callback. This function is called if the record batch detects a + * change in the schema. The client application can call getColDefs in the RecordIterator or + * get the field information from the RecordBatch itself and handle the change appropriately. + */ +typedef uint32_t (*pfnSchemaListener)(void* ctx, SchemaDef* s, DrillClientError* err); + +/* + * A Record Iterator instance is returned by the SubmitQuery class. Calls block until some data + * is available, or until all data has been returned. + */ + +class DECLSPEC_DRILL_CLIENT RecordIterator{ + friend class DrillClient; + public: + + ~RecordIterator(); + /* + * Returns a vector of column(i.e. field) definitions. The returned reference is guaranteed to be valid till the + * end of the query or until a schema change event is received. If a schema change event is received by the + * application, the application should discard the reference it currently holds and call this function again. + */ + std::vector<Drill::FieldMetadata*>& getColDefs(); + + /* Move the current pointer to the next record. */ + status_t next(); + + /* Gets the ith column in the current record. */ + status_t getCol(size_t i, void** b, size_t* sz); + + /* true if ith column in the current record is NULL */ + bool isNull(size_t i); + + /* Cancels the query. */ + status_t cancel(); + + void registerSchemaChangeListener(pfnSchemaListener* l); + + /* + * Returns the last error message + */ + std::string& getError(); + + private: + RecordIterator(DrillClientQueryResult* pResult){ + this->m_currentRecord=-1; + this->m_pCurrentRecordBatch=NULL; + this->m_pQueryResult=pResult; + m_pColDefs=NULL; + } + + DrillClientQueryResult* m_pQueryResult; + size_t m_currentRecord; + RecordBatch* m_pCurrentRecordBatch; + boost::mutex m_recordBatchMutex; + std::vector<Drill::FieldMetadata*>* m_pColDefs; // Copy of the latest column defs made from the + // first record batch with this definition +}; + +class DECLSPEC_DRILL_CLIENT DrillClient{ + public: + DrillClient(); + ~DrillClient(); + + // change the logging level + static void initLogging(const char* path, logLevel_t l); + + /* connects the client to a Drillbit UserServer. */ + connectionStatus_t connect(const char* connectStr); + + /* test whether the client is active */ + bool isActive(); + + /* close the connection. cancel any pending requests. */ + void close() ; + + /* + * Submit a query asynchronously and wait for results to be returned thru a callback. A query context handle is passed + * back. The listener callback will return the handle in the ctx parameter. + */ + status_t submitQuery(exec::user::QueryType t, const std::string& plan, pfnQueryResultsListener listener, void* listenerCtx, QueryHandle_t* qHandle); + + /* + * Submit a query asynchronously and wait for results to be returned thru an iterator that returns + * results synchronously. The client app needs to call delete on the iterator when done. + */ + RecordIterator* submitQuery(exec::user::QueryType t, const std::string& plan, DrillClientError* err); + + /* + * The client application should call this function to wait for results if it has registered a + * listener. + */ + void waitForResults(); + + /* + * Returns the last error message + */ + std::string& getError(); + + /* + * Applications using the async query submit method should call freeQueryResources to free up resources + * once the query is no longer being processed. + * */ + void freeQueryResources(QueryHandle_t* handle); + void freeQueryIterator(RecordIterator** pIter){ delete *pIter; *pIter=NULL;}; + + private: + static DrillClientInitializer s_init; + static DrillClientConfig s_config; + + DrillClientImpl * m_pImpl; +}; + +} // namespace Drill + +#endif diff --git a/contrib/native/client/src/include/drill/drillc.hpp b/contrib/native/client/src/include/drill/drillc.hpp new file mode 100644 index 000000000..e5a0d33de --- /dev/null +++ b/contrib/native/client/src/include/drill/drillc.hpp @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DRILL_CLIENT__ALL_H +#define DRILL_CLIENT_ALL_H + +#include "drill/common.hpp" +#include "drill/drillClient.hpp" +#include "drill/recordBatch.hpp" +#include "Types.pb.h" +#include "User.pb.h" + +#endif + diff --git a/contrib/native/client/src/include/drill/protobuf/Types.pb.h b/contrib/native/client/src/include/drill/protobuf/Types.pb.h new file mode 100644 index 000000000..853415317 --- /dev/null +++ b/contrib/native/client/src/include/drill/protobuf/Types.pb.h @@ -0,0 +1,409 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Types.proto + +#ifndef PROTOBUF_Types_2eproto__INCLUDED +#define PROTOBUF_Types_2eproto__INCLUDED + +#include <string> + +#include <google/protobuf/stubs/common.h> + +#if GOOGLE_PROTOBUF_VERSION < 2005000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/message.h> +#include <google/protobuf/repeated_field.h> +#include <google/protobuf/extension_set.h> +#include <google/protobuf/generated_enum_reflection.h> +#include <google/protobuf/unknown_field_set.h> +// @@protoc_insertion_point(includes) + +namespace common { + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_Types_2eproto(); +void protobuf_AssignDesc_Types_2eproto(); +void protobuf_ShutdownFile_Types_2eproto(); + +class MajorType; + +enum MinorType { + LATE = 0, + MAP = 1, + TINYINT = 3, + SMALLINT = 4, + INT = 5, + BIGINT = 6, + DECIMAL9 = 7, + DECIMAL18 = 8, + DECIMAL28SPARSE = 9, + DECIMAL38SPARSE = 10, + MONEY = 11, + DATE = 12, + TIME = 13, + TIMETZ = 14, + TIMESTAMPTZ = 15, + TIMESTAMP = 16, + INTERVAL = 17, + FLOAT4 = 18, + FLOAT8 = 19, + BIT = 20, + FIXEDCHAR = 21, + FIXED16CHAR = 22, + FIXEDBINARY = 23, + VARCHAR = 24, + VAR16CHAR = 25, + VARBINARY = 26, + UINT1 = 29, + UINT2 = 30, + UINT4 = 31, + UINT8 = 32, + DECIMAL28DENSE = 33, + DECIMAL38DENSE = 34, + DM_UNKNOWN = 37, + INTERVALYEAR = 38, + INTERVALDAY = 39, + LIST = 40 +}; +bool MinorType_IsValid(int value); +const MinorType MinorType_MIN = LATE; +const MinorType MinorType_MAX = LIST; +const int MinorType_ARRAYSIZE = MinorType_MAX + 1; + +const ::google::protobuf::EnumDescriptor* MinorType_descriptor(); +inline const ::std::string& MinorType_Name(MinorType value) { + return ::google::protobuf::internal::NameOfEnum( + MinorType_descriptor(), value); +} +inline bool MinorType_Parse( + const ::std::string& name, MinorType* value) { + return ::google::protobuf::internal::ParseNamedEnum<MinorType>( + MinorType_descriptor(), name, value); +} +enum DataMode { + DM_OPTIONAL = 0, + DM_REQUIRED = 1, + DM_REPEATED = 2 +}; +bool DataMode_IsValid(int value); +const DataMode DataMode_MIN = DM_OPTIONAL; +const DataMode DataMode_MAX = DM_REPEATED; +const int DataMode_ARRAYSIZE = DataMode_MAX + 1; + +const ::google::protobuf::EnumDescriptor* DataMode_descriptor(); +inline const ::std::string& DataMode_Name(DataMode value) { + return ::google::protobuf::internal::NameOfEnum( + DataMode_descriptor(), value); +} +inline bool DataMode_Parse( + const ::std::string& name, DataMode* value) { + return ::google::protobuf::internal::ParseNamedEnum<DataMode>( + DataMode_descriptor(), name, value); +} +// =================================================================== + +class MajorType : public ::google::protobuf::Message { + public: + MajorType(); + virtual ~MajorType(); + + MajorType(const MajorType& from); + + inline MajorType& operator=(const MajorType& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const MajorType& default_instance(); + + void Swap(MajorType* other); + + // implements Message ---------------------------------------------- + + MajorType* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const MajorType& from); + void MergeFrom(const MajorType& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional .common.MinorType minor_type = 1; + inline bool has_minor_type() const; + inline void clear_minor_type(); + static const int kMinorTypeFieldNumber = 1; + inline ::common::MinorType minor_type() const; + inline void set_minor_type(::common::MinorType value); + + // optional .common.DataMode mode = 2; + inline bool has_mode() const; + inline void clear_mode(); + static const int kModeFieldNumber = 2; + inline ::common::DataMode mode() const; + inline void set_mode(::common::DataMode value); + + // optional int32 width = 3; + inline bool has_width() const; + inline void clear_width(); + static const int kWidthFieldNumber = 3; + inline ::google::protobuf::int32 width() const; + inline void set_width(::google::protobuf::int32 value); + + // optional int32 precision = 4; + inline bool has_precision() const; + inline void clear_precision(); + static const int kPrecisionFieldNumber = 4; + inline ::google::protobuf::int32 precision() const; + inline void set_precision(::google::protobuf::int32 value); + + // optional int32 scale = 5; + inline bool has_scale() const; + inline void clear_scale(); + static const int kScaleFieldNumber = 5; + inline ::google::protobuf::int32 scale() const; + inline void set_scale(::google::protobuf::int32 value); + + // optional int32 timeZone = 6; + inline bool has_timezone() const; + inline void clear_timezone(); + static const int kTimeZoneFieldNumber = 6; + inline ::google::protobuf::int32 timezone() const; + inline void set_timezone(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:common.MajorType) + private: + inline void set_has_minor_type(); + inline void clear_has_minor_type(); + inline void set_has_mode(); + inline void clear_has_mode(); + inline void set_has_width(); + inline void clear_has_width(); + inline void set_has_precision(); + inline void clear_has_precision(); + inline void set_has_scale(); + inline void clear_has_scale(); + inline void set_has_timezone(); + inline void clear_has_timezone(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + int minor_type_; + int mode_; + ::google::protobuf::int32 width_; + ::google::protobuf::int32 precision_; + ::google::protobuf::int32 scale_; + ::google::protobuf::int32 timezone_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; + + friend void protobuf_AddDesc_Types_2eproto(); + friend void protobuf_AssignDesc_Types_2eproto(); + friend void protobuf_ShutdownFile_Types_2eproto(); + + void InitAsDefaultInstance(); + static MajorType* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +// MajorType + +// optional .common.MinorType minor_type = 1; +inline bool MajorType::has_minor_type() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void MajorType::set_has_minor_type() { + _has_bits_[0] |= 0x00000001u; +} +inline void MajorType::clear_has_minor_type() { + _has_bits_[0] &= ~0x00000001u; +} +inline void MajorType::clear_minor_type() { + minor_type_ = 0; + clear_has_minor_type(); +} +inline ::common::MinorType MajorType::minor_type() const { + return static_cast< ::common::MinorType >(minor_type_); +} +inline void MajorType::set_minor_type(::common::MinorType value) { + assert(::common::MinorType_IsValid(value)); + set_has_minor_type(); + minor_type_ = value; +} + +// optional .common.DataMode mode = 2; +inline bool MajorType::has_mode() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void MajorType::set_has_mode() { + _has_bits_[0] |= 0x00000002u; +} +inline void MajorType::clear_has_mode() { + _has_bits_[0] &= ~0x00000002u; +} +inline void MajorType::clear_mode() { + mode_ = 0; + clear_has_mode(); +} +inline ::common::DataMode MajorType::mode() const { + return static_cast< ::common::DataMode >(mode_); +} +inline void MajorType::set_mode(::common::DataMode value) { + assert(::common::DataMode_IsValid(value)); + set_has_mode(); + mode_ = value; +} + +// optional int32 width = 3; +inline bool MajorType::has_width() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void MajorType::set_has_width() { + _has_bits_[0] |= 0x00000004u; +} +inline void MajorType::clear_has_width() { + _has_bits_[0] &= ~0x00000004u; +} +inline void MajorType::clear_width() { + width_ = 0; + clear_has_width(); +} +inline ::google::protobuf::int32 MajorType::width() const { + return width_; +} +inline void MajorType::set_width(::google::protobuf::int32 value) { + set_has_width(); + width_ = value; +} + +// optional int32 precision = 4; +inline bool MajorType::has_precision() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void MajorType::set_has_precision() { + _has_bits_[0] |= 0x00000008u; +} +inline void MajorType::clear_has_precision() { + _has_bits_[0] &= ~0x00000008u; +} +inline void MajorType::clear_precision() { + precision_ = 0; + clear_has_precision(); +} +inline ::google::protobuf::int32 MajorType::precision() const { + return precision_; +} +inline void MajorType::set_precision(::google::protobuf::int32 value) { + set_has_precision(); + precision_ = value; +} + +// optional int32 scale = 5; +inline bool MajorType::has_scale() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +inline void MajorType::set_has_scale() { + _has_bits_[0] |= 0x00000010u; +} +inline void MajorType::clear_has_scale() { + _has_bits_[0] &= ~0x00000010u; +} +inline void MajorType::clear_scale() { + scale_ = 0; + clear_has_scale(); +} +inline ::google::protobuf::int32 MajorType::scale() const { + return scale_; +} +inline void MajorType::set_scale(::google::protobuf::int32 value) { + set_has_scale(); + scale_ = value; +} + +// optional int32 timeZone = 6; +inline bool MajorType::has_timezone() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void MajorType::set_has_timezone() { + _has_bits_[0] |= 0x00000020u; +} +inline void MajorType::clear_has_timezone() { + _has_bits_[0] &= ~0x00000020u; +} +inline void MajorType::clear_timezone() { + timezone_ = 0; + clear_has_timezone(); +} +inline ::google::protobuf::int32 MajorType::timezone() const { + return timezone_; +} +inline void MajorType::set_timezone(::google::protobuf::int32 value) { + set_has_timezone(); + timezone_ = value; +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace common + +#ifndef SWIG +namespace google { +namespace protobuf { + +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::common::MinorType>() { + return ::common::MinorType_descriptor(); +} +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::common::DataMode>() { + return ::common::DataMode_descriptor(); +} + +} // namespace google +} // namespace protobuf +#endif // SWIG + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_Types_2eproto__INCLUDED diff --git a/contrib/native/client/src/include/drill/protobuf/User.pb.h b/contrib/native/client/src/include/drill/protobuf/User.pb.h new file mode 100644 index 000000000..3ed024963 --- /dev/null +++ b/contrib/native/client/src/include/drill/protobuf/User.pb.h @@ -0,0 +1,1944 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: User.proto + +#ifndef PROTOBUF_User_2eproto__INCLUDED +#define PROTOBUF_User_2eproto__INCLUDED + +#include <string> + +#include <google/protobuf/stubs/common.h> + +#if GOOGLE_PROTOBUF_VERSION < 2005000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/message.h> +#include <google/protobuf/repeated_field.h> +#include <google/protobuf/extension_set.h> +#include <google/protobuf/generated_enum_reflection.h> +#include <google/protobuf/unknown_field_set.h> +#include "SchemaDef.pb.h" +#include "UserBitShared.pb.h" +// @@protoc_insertion_point(includes) + +namespace exec { +namespace user { + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_User_2eproto(); +void protobuf_AssignDesc_User_2eproto(); +void protobuf_ShutdownFile_User_2eproto(); + +class Property; +class UserProperties; +class UserToBitHandshake; +class RequestResults; +class RunQuery; +class BitToUserHandshake; +class NodeStatus; +class QueryResult; + +enum QueryResult_QueryState { + QueryResult_QueryState_PENDING = 0, + QueryResult_QueryState_RUNNING = 1, + QueryResult_QueryState_COMPLETED = 2, + QueryResult_QueryState_CANCELED = 3, + QueryResult_QueryState_FAILED = 4, + QueryResult_QueryState_UNKNOWN_QUERY = 5 +}; +bool QueryResult_QueryState_IsValid(int value); +const QueryResult_QueryState QueryResult_QueryState_QueryState_MIN = QueryResult_QueryState_PENDING; +const QueryResult_QueryState QueryResult_QueryState_QueryState_MAX = QueryResult_QueryState_UNKNOWN_QUERY; +const int QueryResult_QueryState_QueryState_ARRAYSIZE = QueryResult_QueryState_QueryState_MAX + 1; + +const ::google::protobuf::EnumDescriptor* QueryResult_QueryState_descriptor(); +inline const ::std::string& QueryResult_QueryState_Name(QueryResult_QueryState value) { + return ::google::protobuf::internal::NameOfEnum( + QueryResult_QueryState_descriptor(), value); +} +inline bool QueryResult_QueryState_Parse( + const ::std::string& name, QueryResult_QueryState* value) { + return ::google::protobuf::internal::ParseNamedEnum<QueryResult_QueryState>( + QueryResult_QueryState_descriptor(), name, value); +} +enum RpcType { + HANDSHAKE = 0, + ACK = 1, + GOODBYE = 2, + RUN_QUERY = 3, + CANCEL_QUERY = 4, + REQUEST_RESULTS = 5, + QUERY_RESULT = 6, + QUERY_HANDLE = 7, + REQ_META_FUNCTIONS = 8, + RESP_FUNCTION_LIST = 9 +}; +bool RpcType_IsValid(int value); +const RpcType RpcType_MIN = HANDSHAKE; +const RpcType RpcType_MAX = RESP_FUNCTION_LIST; +const int RpcType_ARRAYSIZE = RpcType_MAX + 1; + +const ::google::protobuf::EnumDescriptor* RpcType_descriptor(); +inline const ::std::string& RpcType_Name(RpcType value) { + return ::google::protobuf::internal::NameOfEnum( + RpcType_descriptor(), value); +} +inline bool RpcType_Parse( + const ::std::string& name, RpcType* value) { + return ::google::protobuf::internal::ParseNamedEnum<RpcType>( + RpcType_descriptor(), name, value); +} +enum QueryType { + SQL = 1, + LOGICAL = 2, + PHYSICAL = 3 +}; +bool QueryType_IsValid(int value); +const QueryType QueryType_MIN = SQL; +const QueryType QueryType_MAX = PHYSICAL; +const int QueryType_ARRAYSIZE = QueryType_MAX + 1; + +const ::google::protobuf::EnumDescriptor* QueryType_descriptor(); +inline const ::std::string& QueryType_Name(QueryType value) { + return ::google::protobuf::internal::NameOfEnum( + QueryType_descriptor(), value); +} +inline bool QueryType_Parse( + const ::std::string& name, QueryType* value) { + return ::google::protobuf::internal::ParseNamedEnum<QueryType>( + QueryType_descriptor(), name, value); +} +enum QueryResultsMode { + STREAM_FULL = 1 +}; +bool QueryResultsMode_IsValid(int value); +const QueryResultsMode QueryResultsMode_MIN = STREAM_FULL; +const QueryResultsMode QueryResultsMode_MAX = STREAM_FULL; +const int QueryResultsMode_ARRAYSIZE = QueryResultsMode_MAX + 1; + +const ::google::protobuf::EnumDescriptor* QueryResultsMode_descriptor(); +inline const ::std::string& QueryResultsMode_Name(QueryResultsMode value) { + return ::google::protobuf::internal::NameOfEnum( + QueryResultsMode_descriptor(), value); +} +inline bool QueryResultsMode_Parse( + const ::std::string& name, QueryResultsMode* value) { + return ::google::protobuf::internal::ParseNamedEnum<QueryResultsMode>( + QueryResultsMode_descriptor(), name, value); +} +// =================================================================== + +class Property : public ::google::protobuf::Message { + public: + Property(); + virtual ~Property(); + + Property(const Property& from); + + inline Property& operator=(const Property& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Property& default_instance(); + + void Swap(Property* other); + + // implements Message ---------------------------------------------- + + Property* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const Property& from); + void MergeFrom(const Property& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // required string key = 1; + inline bool has_key() const; + inline void clear_key(); + static const int kKeyFieldNumber = 1; + inline const ::std::string& key() const; + inline void set_key(const ::std::string& value); + inline void set_key(const char* value); + inline void set_key(const char* value, size_t size); + inline ::std::string* mutable_key(); + inline ::std::string* release_key(); + inline void set_allocated_key(::std::string* key); + + // required string value = 2; + inline bool has_value() const; + inline void clear_value(); + static const int kValueFieldNumber = 2; + inline const ::std::string& value() const; + inline void set_value(const ::std::string& value); + inline void set_value(const char* value); + inline void set_value(const char* value, size_t size); + inline ::std::string* mutable_value(); + inline ::std::string* release_value(); + inline void set_allocated_value(::std::string* value); + + // @@protoc_insertion_point(class_scope:exec.user.Property) + private: + inline void set_has_key(); + inline void clear_has_key(); + inline void set_has_value(); + inline void clear_has_value(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::std::string* key_; + ::std::string* value_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; + + friend void protobuf_AddDesc_User_2eproto(); + friend void protobuf_AssignDesc_User_2eproto(); + friend void protobuf_ShutdownFile_User_2eproto(); + + void InitAsDefaultInstance(); + static Property* default_instance_; +}; +// ------------------------------------------------------------------- + +class UserProperties : public ::google::protobuf::Message { + public: + UserProperties(); + virtual ~UserProperties(); + + UserProperties(const UserProperties& from); + + inline UserProperties& operator=(const UserProperties& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const UserProperties& default_instance(); + + void Swap(UserProperties* other); + + // implements Message ---------------------------------------------- + + UserProperties* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const UserProperties& from); + void MergeFrom(const UserProperties& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // repeated .exec.user.Property properties = 1; + inline int properties_size() const; + inline void clear_properties(); + static const int kPropertiesFieldNumber = 1; + inline const ::exec::user::Property& properties(int index) const; + inline ::exec::user::Property* mutable_properties(int index); + inline ::exec::user::Property* add_properties(); + inline const ::google::protobuf::RepeatedPtrField< ::exec::user::Property >& + properties() const; + inline ::google::protobuf::RepeatedPtrField< ::exec::user::Property >* + mutable_properties(); + + // @@protoc_insertion_point(class_scope:exec.user.UserProperties) + private: + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::google::protobuf::RepeatedPtrField< ::exec::user::Property > properties_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; + + friend void protobuf_AddDesc_User_2eproto(); + friend void protobuf_AssignDesc_User_2eproto(); + friend void protobuf_ShutdownFile_User_2eproto(); + + void InitAsDefaultInstance(); + static UserProperties* default_instance_; +}; +// ------------------------------------------------------------------- + +class UserToBitHandshake : public ::google::protobuf::Message { + public: + UserToBitHandshake(); + virtual ~UserToBitHandshake(); + + UserToBitHandshake(const UserToBitHandshake& from); + + inline UserToBitHandshake& operator=(const UserToBitHandshake& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const UserToBitHandshake& default_instance(); + + void Swap(UserToBitHandshake* other); + + // implements Message ---------------------------------------------- + + UserToBitHandshake* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const UserToBitHandshake& from); + void MergeFrom(const UserToBitHandshake& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional .exec.shared.RpcChannel channel = 1 [default = USER]; + inline bool has_channel() const; + inline void clear_channel(); + static const int kChannelFieldNumber = 1; + inline ::exec::shared::RpcChannel channel() const; + inline void set_channel(::exec::shared::RpcChannel value); + + // optional bool support_listening = 2; + inline bool has_support_listening() const; + inline void clear_support_listening(); + static const int kSupportListeningFieldNumber = 2; + inline bool support_listening() const; + inline void set_support_listening(bool value); + + // optional int32 rpc_version = 3; + inline bool has_rpc_version() const; + inline void clear_rpc_version(); + static const int kRpcVersionFieldNumber = 3; + inline ::google::protobuf::int32 rpc_version() const; + inline void set_rpc_version(::google::protobuf::int32 value); + + // optional .exec.shared.UserCredentials credentials = 4; + inline bool has_credentials() const; + inline void clear_credentials(); + static const int kCredentialsFieldNumber = 4; + inline const ::exec::shared::UserCredentials& credentials() const; + inline ::exec::shared::UserCredentials* mutable_credentials(); + inline ::exec::shared::UserCredentials* release_credentials(); + inline void set_allocated_credentials(::exec::shared::UserCredentials* credentials); + + // optional .exec.user.UserProperties properties = 5; + inline bool has_properties() const; + inline void clear_properties(); + static const int kPropertiesFieldNumber = 5; + inline const ::exec::user::UserProperties& properties() const; + inline ::exec::user::UserProperties* mutable_properties(); + inline ::exec::user::UserProperties* release_properties(); + inline void set_allocated_properties(::exec::user::UserProperties* properties); + + // @@protoc_insertion_point(class_scope:exec.user.UserToBitHandshake) + private: + inline void set_has_channel(); + inline void clear_has_channel(); + inline void set_has_support_listening(); + inline void clear_has_support_listening(); + inline void set_has_rpc_version(); + inline void clear_has_rpc_version(); + inline void set_has_credentials(); + inline void clear_has_credentials(); + inline void set_has_properties(); + inline void clear_has_properties(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + int channel_; + bool support_listening_; + ::exec::shared::UserCredentials* credentials_; + ::exec::user::UserProperties* properties_; + ::google::protobuf::int32 rpc_version_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; + + friend void protobuf_AddDesc_User_2eproto(); + friend void protobuf_AssignDesc_User_2eproto(); + friend void protobuf_ShutdownFile_User_2eproto(); + + void InitAsDefaultInstance(); + static UserToBitHandshake* default_instance_; +}; +// ------------------------------------------------------------------- + +class RequestResults : public ::google::protobuf::Message { + public: + RequestResults(); + virtual ~RequestResults(); + + RequestResults(const RequestResults& from); + + inline RequestResults& operator=(const RequestResults& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const RequestResults& default_instance(); + + void Swap(RequestResults* other); + + // implements Message ---------------------------------------------- + + RequestResults* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const RequestResults& from); + void MergeFrom(const RequestResults& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional .exec.shared.QueryId query_id = 1; + inline bool has_query_id() const; + inline void clear_query_id(); + static const int kQueryIdFieldNumber = 1; + inline const ::exec::shared::QueryId& query_id() const; + inline ::exec::shared::QueryId* mutable_query_id(); + inline ::exec::shared::QueryId* release_query_id(); + inline void set_allocated_query_id(::exec::shared::QueryId* query_id); + + // optional int32 maximum_responses = 2; + inline bool has_maximum_responses() const; + inline void clear_maximum_responses(); + static const int kMaximumResponsesFieldNumber = 2; + inline ::google::protobuf::int32 maximum_responses() const; + inline void set_maximum_responses(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:exec.user.RequestResults) + private: + inline void set_has_query_id(); + inline void clear_has_query_id(); + inline void set_has_maximum_responses(); + inline void clear_has_maximum_responses(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::exec::shared::QueryId* query_id_; + ::google::protobuf::int32 maximum_responses_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; + + friend void protobuf_AddDesc_User_2eproto(); + friend void protobuf_AssignDesc_User_2eproto(); + friend void protobuf_ShutdownFile_User_2eproto(); + + void InitAsDefaultInstance(); + static RequestResults* default_instance_; +}; +// ------------------------------------------------------------------- + +class RunQuery : public ::google::protobuf::Message { + public: + RunQuery(); + virtual ~RunQuery(); + + RunQuery(const RunQuery& from); + + inline RunQuery& operator=(const RunQuery& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const RunQuery& default_instance(); + + void Swap(RunQuery* other); + + // implements Message ---------------------------------------------- + + RunQuery* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const RunQuery& from); + void MergeFrom(const RunQuery& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional .exec.user.QueryResultsMode results_mode = 1; + inline bool has_results_mode() const; + inline void clear_results_mode(); + static const int kResultsModeFieldNumber = 1; + inline ::exec::user::QueryResultsMode results_mode() const; + inline void set_results_mode(::exec::user::QueryResultsMode value); + + // optional .exec.user.QueryType type = 2; + inline bool has_type() const; + inline void clear_type(); + static const int kTypeFieldNumber = 2; + inline ::exec::user::QueryType type() const; + inline void set_type(::exec::user::QueryType value); + + // optional string plan = 3; + inline bool has_plan() const; + inline void clear_plan(); + static const int kPlanFieldNumber = 3; + inline const ::std::string& plan() const; + inline void set_plan(const ::std::string& value); + inline void set_plan(const char* value); + inline void set_plan(const char* value, size_t size); + inline ::std::string* mutable_plan(); + inline ::std::string* release_plan(); + inline void set_allocated_plan(::std::string* plan); + + // @@protoc_insertion_point(class_scope:exec.user.RunQuery) + private: + inline void set_has_results_mode(); + inline void clear_has_results_mode(); + inline void set_has_type(); + inline void clear_has_type(); + inline void set_has_plan(); + inline void clear_has_plan(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + int results_mode_; + int type_; + ::std::string* plan_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; + + friend void protobuf_AddDesc_User_2eproto(); + friend void protobuf_AssignDesc_User_2eproto(); + friend void protobuf_ShutdownFile_User_2eproto(); + + void InitAsDefaultInstance(); + static RunQuery* default_instance_; +}; +// ------------------------------------------------------------------- + +class BitToUserHandshake : public ::google::protobuf::Message { + public: + BitToUserHandshake(); + virtual ~BitToUserHandshake(); + + BitToUserHandshake(const BitToUserHandshake& from); + + inline BitToUserHandshake& operator=(const BitToUserHandshake& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const BitToUserHandshake& default_instance(); + + void Swap(BitToUserHandshake* other); + + // implements Message ---------------------------------------------- + + BitToUserHandshake* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const BitToUserHandshake& from); + void MergeFrom(const BitToUserHandshake& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional int32 rpc_version = 2; + inline bool has_rpc_version() const; + inline void clear_rpc_version(); + static const int kRpcVersionFieldNumber = 2; + inline ::google::protobuf::int32 rpc_version() const; + inline void set_rpc_version(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:exec.user.BitToUserHandshake) + private: + inline void set_has_rpc_version(); + inline void clear_has_rpc_version(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::google::protobuf::int32 rpc_version_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; + + friend void protobuf_AddDesc_User_2eproto(); + friend void protobuf_AssignDesc_User_2eproto(); + friend void protobuf_ShutdownFile_User_2eproto(); + + void InitAsDefaultInstance(); + static BitToUserHandshake* default_instance_; +}; +// ------------------------------------------------------------------- + +class NodeStatus : public ::google::protobuf::Message { + public: + NodeStatus(); + virtual ~NodeStatus(); + + NodeStatus(const NodeStatus& from); + + inline NodeStatus& operator=(const NodeStatus& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const NodeStatus& default_instance(); + + void Swap(NodeStatus* other); + + // implements Message ---------------------------------------------- + + NodeStatus* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const NodeStatus& from); + void MergeFrom(const NodeStatus& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional int32 node_id = 1; + inline bool has_node_id() const; + inline void clear_node_id(); + static const int kNodeIdFieldNumber = 1; + inline ::google::protobuf::int32 node_id() const; + inline void set_node_id(::google::protobuf::int32 value); + + // optional int64 memory_footprint = 2; + inline bool has_memory_footprint() const; + inline void clear_memory_footprint(); + static const int kMemoryFootprintFieldNumber = 2; + inline ::google::protobuf::int64 memory_footprint() const; + inline void set_memory_footprint(::google::protobuf::int64 value); + + // @@protoc_insertion_point(class_scope:exec.user.NodeStatus) + private: + inline void set_has_node_id(); + inline void clear_has_node_id(); + inline void set_has_memory_footprint(); + inline void clear_has_memory_footprint(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::google::protobuf::int64 memory_footprint_; + ::google::protobuf::int32 node_id_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; + + friend void protobuf_AddDesc_User_2eproto(); + friend void protobuf_AssignDesc_User_2eproto(); + friend void protobuf_ShutdownFile_User_2eproto(); + + void InitAsDefaultInstance(); + static NodeStatus* default_instance_; +}; +// ------------------------------------------------------------------- + +class QueryResult : public ::google::protobuf::Message { + public: + QueryResult(); + virtual ~QueryResult(); + + QueryResult(const QueryResult& from); + + inline QueryResult& operator=(const QueryResult& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const QueryResult& default_instance(); + + void Swap(QueryResult* other); + + // implements Message ---------------------------------------------- + + QueryResult* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const QueryResult& from); + void MergeFrom(const QueryResult& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + typedef QueryResult_QueryState QueryState; + static const QueryState PENDING = QueryResult_QueryState_PENDING; + static const QueryState RUNNING = QueryResult_QueryState_RUNNING; + static const QueryState COMPLETED = QueryResult_QueryState_COMPLETED; + static const QueryState CANCELED = QueryResult_QueryState_CANCELED; + static const QueryState FAILED = QueryResult_QueryState_FAILED; + static const QueryState UNKNOWN_QUERY = QueryResult_QueryState_UNKNOWN_QUERY; + static inline bool QueryState_IsValid(int value) { + return QueryResult_QueryState_IsValid(value); + } + static const QueryState QueryState_MIN = + QueryResult_QueryState_QueryState_MIN; + static const QueryState QueryState_MAX = + QueryResult_QueryState_QueryState_MAX; + static const int QueryState_ARRAYSIZE = + QueryResult_QueryState_QueryState_ARRAYSIZE; + static inline const ::google::protobuf::EnumDescriptor* + QueryState_descriptor() { + return QueryResult_QueryState_descriptor(); + } + static inline const ::std::string& QueryState_Name(QueryState value) { + return QueryResult_QueryState_Name(value); + } + static inline bool QueryState_Parse(const ::std::string& name, + QueryState* value) { + return QueryResult_QueryState_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + // optional .exec.user.QueryResult.QueryState query_state = 1; + inline bool has_query_state() const; + inline void clear_query_state(); + static const int kQueryStateFieldNumber = 1; + inline ::exec::user::QueryResult_QueryState query_state() const; + inline void set_query_state(::exec::user::QueryResult_QueryState value); + + // optional .exec.shared.QueryId query_id = 2; + inline bool has_query_id() const; + inline void clear_query_id(); + static const int kQueryIdFieldNumber = 2; + inline const ::exec::shared::QueryId& query_id() const; + inline ::exec::shared::QueryId* mutable_query_id(); + inline ::exec::shared::QueryId* release_query_id(); + inline void set_allocated_query_id(::exec::shared::QueryId* query_id); + + // optional bool is_last_chunk = 3; + inline bool has_is_last_chunk() const; + inline void clear_is_last_chunk(); + static const int kIsLastChunkFieldNumber = 3; + inline bool is_last_chunk() const; + inline void set_is_last_chunk(bool value); + + // optional int32 row_count = 4; + inline bool has_row_count() const; + inline void clear_row_count(); + static const int kRowCountFieldNumber = 4; + inline ::google::protobuf::int32 row_count() const; + inline void set_row_count(::google::protobuf::int32 value); + + // optional int64 records_scan = 5; + inline bool has_records_scan() const; + inline void clear_records_scan(); + static const int kRecordsScanFieldNumber = 5; + inline ::google::protobuf::int64 records_scan() const; + inline void set_records_scan(::google::protobuf::int64 value); + + // optional int64 records_error = 6; + inline bool has_records_error() const; + inline void clear_records_error(); + static const int kRecordsErrorFieldNumber = 6; + inline ::google::protobuf::int64 records_error() const; + inline void set_records_error(::google::protobuf::int64 value); + + // optional int64 submission_time = 7; + inline bool has_submission_time() const; + inline void clear_submission_time(); + static const int kSubmissionTimeFieldNumber = 7; + inline ::google::protobuf::int64 submission_time() const; + inline void set_submission_time(::google::protobuf::int64 value); + + // repeated .exec.user.NodeStatus node_status = 8; + inline int node_status_size() const; + inline void clear_node_status(); + static const int kNodeStatusFieldNumber = 8; + inline const ::exec::user::NodeStatus& node_status(int index) const; + inline ::exec::user::NodeStatus* mutable_node_status(int index); + inline ::exec::user::NodeStatus* add_node_status(); + inline const ::google::protobuf::RepeatedPtrField< ::exec::user::NodeStatus >& + node_status() const; + inline ::google::protobuf::RepeatedPtrField< ::exec::user::NodeStatus >* + mutable_node_status(); + + // repeated .exec.shared.DrillPBError error = 9; + inline int error_size() const; + inline void clear_error(); + static const int kErrorFieldNumber = 9; + inline const ::exec::shared::DrillPBError& error(int index) const; + inline ::exec::shared::DrillPBError* mutable_error(int index); + inline ::exec::shared::DrillPBError* add_error(); + inline const ::google::protobuf::RepeatedPtrField< ::exec::shared::DrillPBError >& + error() const; + inline ::google::protobuf::RepeatedPtrField< ::exec::shared::DrillPBError >* + mutable_error(); + + // optional .exec.shared.RecordBatchDef def = 10; + inline bool has_def() const; + inline void clear_def(); + static const int kDefFieldNumber = 10; + inline const ::exec::shared::RecordBatchDef& def() const; + inline ::exec::shared::RecordBatchDef* mutable_def(); + inline ::exec::shared::RecordBatchDef* release_def(); + inline void set_allocated_def(::exec::shared::RecordBatchDef* def); + + // optional bool schema_changed = 11; + inline bool has_schema_changed() const; + inline void clear_schema_changed(); + static const int kSchemaChangedFieldNumber = 11; + inline bool schema_changed() const; + inline void set_schema_changed(bool value); + + // @@protoc_insertion_point(class_scope:exec.user.QueryResult) + private: + inline void set_has_query_state(); + inline void clear_has_query_state(); + inline void set_has_query_id(); + inline void clear_has_query_id(); + inline void set_has_is_last_chunk(); + inline void clear_has_is_last_chunk(); + inline void set_has_row_count(); + inline void clear_has_row_count(); + inline void set_has_records_scan(); + inline void clear_has_records_scan(); + inline void set_has_records_error(); + inline void clear_has_records_error(); + inline void set_has_submission_time(); + inline void clear_has_submission_time(); + inline void set_has_def(); + inline void clear_has_def(); + inline void set_has_schema_changed(); + inline void clear_has_schema_changed(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::exec::shared::QueryId* query_id_; + int query_state_; + ::google::protobuf::int32 row_count_; + ::google::protobuf::int64 records_scan_; + ::google::protobuf::int64 records_error_; + ::google::protobuf::int64 submission_time_; + ::google::protobuf::RepeatedPtrField< ::exec::user::NodeStatus > node_status_; + ::google::protobuf::RepeatedPtrField< ::exec::shared::DrillPBError > error_; + ::exec::shared::RecordBatchDef* def_; + bool is_last_chunk_; + bool schema_changed_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(11 + 31) / 32]; + + friend void protobuf_AddDesc_User_2eproto(); + friend void protobuf_AssignDesc_User_2eproto(); + friend void protobuf_ShutdownFile_User_2eproto(); + + void InitAsDefaultInstance(); + static QueryResult* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +// Property + +// required string key = 1; +inline bool Property::has_key() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Property::set_has_key() { + _has_bits_[0] |= 0x00000001u; +} +inline void Property::clear_has_key() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Property::clear_key() { + if (key_ != &::google::protobuf::internal::kEmptyString) { + key_->clear(); + } + clear_has_key(); +} +inline const ::std::string& Property::key() const { + return *key_; +} +inline void Property::set_key(const ::std::string& value) { + set_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + key_ = new ::std::string; + } + key_->assign(value); +} +inline void Property::set_key(const char* value) { + set_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + key_ = new ::std::string; + } + key_->assign(value); +} +inline void Property::set_key(const char* value, size_t size) { + set_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + key_ = new ::std::string; + } + key_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* Property::mutable_key() { + set_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + key_ = new ::std::string; + } + return key_; +} +inline ::std::string* Property::release_key() { + clear_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = key_; + key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void Property::set_allocated_key(::std::string* key) { + if (key_ != &::google::protobuf::internal::kEmptyString) { + delete key_; + } + if (key) { + set_has_key(); + key_ = key; + } else { + clear_has_key(); + key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string value = 2; +inline bool Property::has_value() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void Property::set_has_value() { + _has_bits_[0] |= 0x00000002u; +} +inline void Property::clear_has_value() { + _has_bits_[0] &= ~0x00000002u; +} +inline void Property::clear_value() { + if (value_ != &::google::protobuf::internal::kEmptyString) { + value_->clear(); + } + clear_has_value(); +} +inline const ::std::string& Property::value() const { + return *value_; +} +inline void Property::set_value(const ::std::string& value) { + set_has_value(); + if (value_ == &::google::protobuf::internal::kEmptyString) { + value_ = new ::std::string; + } + value_->assign(value); +} +inline void Property::set_value(const char* value) { + set_has_value(); + if (value_ == &::google::protobuf::internal::kEmptyString) { + value_ = new ::std::string; + } + value_->assign(value); +} +inline void Property::set_value(const char* value, size_t size) { + set_has_value(); + if (value_ == &::google::protobuf::internal::kEmptyString) { + value_ = new ::std::string; + } + value_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* Property::mutable_value() { + set_has_value(); + if (value_ == &::google::protobuf::internal::kEmptyString) { + value_ = new ::std::string; + } + return value_; +} +inline ::std::string* Property::release_value() { + clear_has_value(); + if (value_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = value_; + value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void Property::set_allocated_value(::std::string* value) { + if (value_ != &::google::protobuf::internal::kEmptyString) { + delete value_; + } + if (value) { + set_has_value(); + value_ = value; + } else { + clear_has_value(); + value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// ------------------------------------------------------------------- + +// UserProperties + +// repeated .exec.user.Property properties = 1; +inline int UserProperties::properties_size() const { + return properties_.size(); +} +inline void UserProperties::clear_properties() { + properties_.Clear(); +} +inline const ::exec::user::Property& UserProperties::properties(int index) const { + return properties_.Get(index); +} +inline ::exec::user::Property* UserProperties::mutable_properties(int index) { + return properties_.Mutable(index); +} +inline ::exec::user::Property* UserProperties::add_properties() { + return properties_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::exec::user::Property >& +UserProperties::properties() const { + return properties_; +} +inline ::google::protobuf::RepeatedPtrField< ::exec::user::Property >* +UserProperties::mutable_properties() { + return &properties_; +} + +// ------------------------------------------------------------------- + +// UserToBitHandshake + +// optional .exec.shared.RpcChannel channel = 1 [default = USER]; +inline bool UserToBitHandshake::has_channel() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void UserToBitHandshake::set_has_channel() { + _has_bits_[0] |= 0x00000001u; +} +inline void UserToBitHandshake::clear_has_channel() { + _has_bits_[0] &= ~0x00000001u; +} +inline void UserToBitHandshake::clear_channel() { + channel_ = 2; + clear_has_channel(); +} +inline ::exec::shared::RpcChannel UserToBitHandshake::channel() const { + return static_cast< ::exec::shared::RpcChannel >(channel_); +} +inline void UserToBitHandshake::set_channel(::exec::shared::RpcChannel value) { + assert(::exec::shared::RpcChannel_IsValid(value)); + set_has_channel(); + channel_ = value; +} + +// optional bool support_listening = 2; +inline bool UserToBitHandshake::has_support_listening() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void UserToBitHandshake::set_has_support_listening() { + _has_bits_[0] |= 0x00000002u; +} +inline void UserToBitHandshake::clear_has_support_listening() { + _has_bits_[0] &= ~0x00000002u; +} +inline void UserToBitHandshake::clear_support_listening() { + support_listening_ = false; + clear_has_support_listening(); +} +inline bool UserToBitHandshake::support_listening() const { + return support_listening_; +} +inline void UserToBitHandshake::set_support_listening(bool value) { + set_has_support_listening(); + support_listening_ = value; +} + +// optional int32 rpc_version = 3; +inline bool UserToBitHandshake::has_rpc_version() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void UserToBitHandshake::set_has_rpc_version() { + _has_bits_[0] |= 0x00000004u; +} +inline void UserToBitHandshake::clear_has_rpc_version() { + _has_bits_[0] &= ~0x00000004u; +} +inline void UserToBitHandshake::clear_rpc_version() { + rpc_version_ = 0; + clear_has_rpc_version(); +} +inline ::google::protobuf::int32 UserToBitHandshake::rpc_version() const { + return rpc_version_; +} +inline void UserToBitHandshake::set_rpc_version(::google::protobuf::int32 value) { + set_has_rpc_version(); + rpc_version_ = value; +} + +// optional .exec.shared.UserCredentials credentials = 4; +inline bool UserToBitHandshake::has_credentials() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void UserToBitHandshake::set_has_credentials() { + _has_bits_[0] |= 0x00000008u; +} +inline void UserToBitHandshake::clear_has_credentials() { + _has_bits_[0] &= ~0x00000008u; +} +inline void UserToBitHandshake::clear_credentials() { + if (credentials_ != NULL) credentials_->::exec::shared::UserCredentials::Clear(); + clear_has_credentials(); +} +inline const ::exec::shared::UserCredentials& UserToBitHandshake::credentials() const { + return credentials_ != NULL ? *credentials_ : *default_instance_->credentials_; +} +inline ::exec::shared::UserCredentials* UserToBitHandshake::mutable_credentials() { + set_has_credentials(); + if (credentials_ == NULL) credentials_ = new ::exec::shared::UserCredentials; + return credentials_; +} +inline ::exec::shared::UserCredentials* UserToBitHandshake::release_credentials() { + clear_has_credentials(); + ::exec::shared::UserCredentials* temp = credentials_; + credentials_ = NULL; + return temp; +} +inline void UserToBitHandshake::set_allocated_credentials(::exec::shared::UserCredentials* credentials) { + delete credentials_; + credentials_ = credentials; + if (credentials) { + set_has_credentials(); + } else { + clear_has_credentials(); + } +} + +// optional .exec.user.UserProperties properties = 5; +inline bool UserToBitHandshake::has_properties() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +inline void UserToBitHandshake::set_has_properties() { + _has_bits_[0] |= 0x00000010u; +} +inline void UserToBitHandshake::clear_has_properties() { + _has_bits_[0] &= ~0x00000010u; +} +inline void UserToBitHandshake::clear_properties() { + if (properties_ != NULL) properties_->::exec::user::UserProperties::Clear(); + clear_has_properties(); +} +inline const ::exec::user::UserProperties& UserToBitHandshake::properties() const { + return properties_ != NULL ? *properties_ : *default_instance_->properties_; +} +inline ::exec::user::UserProperties* UserToBitHandshake::mutable_properties() { + set_has_properties(); + if (properties_ == NULL) properties_ = new ::exec::user::UserProperties; + return properties_; +} +inline ::exec::user::UserProperties* UserToBitHandshake::release_properties() { + clear_has_properties(); + ::exec::user::UserProperties* temp = properties_; + properties_ = NULL; + return temp; +} +inline void UserToBitHandshake::set_allocated_properties(::exec::user::UserProperties* properties) { + delete properties_; + properties_ = properties; + if (properties) { + set_has_properties(); + } else { + clear_has_properties(); + } +} + +// ------------------------------------------------------------------- + +// RequestResults + +// optional .exec.shared.QueryId query_id = 1; +inline bool RequestResults::has_query_id() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void RequestResults::set_has_query_id() { + _has_bits_[0] |= 0x00000001u; +} +inline void RequestResults::clear_has_query_id() { + _has_bits_[0] &= ~0x00000001u; +} +inline void RequestResults::clear_query_id() { + if (query_id_ != NULL) query_id_->::exec::shared::QueryId::Clear(); + clear_has_query_id(); +} +inline const ::exec::shared::QueryId& RequestResults::query_id() const { + return query_id_ != NULL ? *query_id_ : *default_instance_->query_id_; +} +inline ::exec::shared::QueryId* RequestResults::mutable_query_id() { + set_has_query_id(); + if (query_id_ == NULL) query_id_ = new ::exec::shared::QueryId; + return query_id_; +} +inline ::exec::shared::QueryId* RequestResults::release_query_id() { + clear_has_query_id(); + ::exec::shared::QueryId* temp = query_id_; + query_id_ = NULL; + return temp; +} +inline void RequestResults::set_allocated_query_id(::exec::shared::QueryId* query_id) { + delete query_id_; + query_id_ = query_id; + if (query_id) { + set_has_query_id(); + } else { + clear_has_query_id(); + } +} + +// optional int32 maximum_responses = 2; +inline bool RequestResults::has_maximum_responses() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void RequestResults::set_has_maximum_responses() { + _has_bits_[0] |= 0x00000002u; +} +inline void RequestResults::clear_has_maximum_responses() { + _has_bits_[0] &= ~0x00000002u; +} +inline void RequestResults::clear_maximum_responses() { + maximum_responses_ = 0; + clear_has_maximum_responses(); +} +inline ::google::protobuf::int32 RequestResults::maximum_responses() const { + return maximum_responses_; +} +inline void RequestResults::set_maximum_responses(::google::protobuf::int32 value) { + set_has_maximum_responses(); + maximum_responses_ = value; +} + +// ------------------------------------------------------------------- + +// RunQuery + +// optional .exec.user.QueryResultsMode results_mode = 1; +inline bool RunQuery::has_results_mode() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void RunQuery::set_has_results_mode() { + _has_bits_[0] |= 0x00000001u; +} +inline void RunQuery::clear_has_results_mode() { + _has_bits_[0] &= ~0x00000001u; +} +inline void RunQuery::clear_results_mode() { + results_mode_ = 1; + clear_has_results_mode(); +} +inline ::exec::user::QueryResultsMode RunQuery::results_mode() const { + return static_cast< ::exec::user::QueryResultsMode >(results_mode_); +} +inline void RunQuery::set_results_mode(::exec::user::QueryResultsMode value) { + assert(::exec::user::QueryResultsMode_IsValid(value)); + set_has_results_mode(); + results_mode_ = value; +} + +// optional .exec.user.QueryType type = 2; +inline bool RunQuery::has_type() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void RunQuery::set_has_type() { + _has_bits_[0] |= 0x00000002u; +} +inline void RunQuery::clear_has_type() { + _has_bits_[0] &= ~0x00000002u; +} +inline void RunQuery::clear_type() { + type_ = 1; + clear_has_type(); +} +inline ::exec::user::QueryType RunQuery::type() const { + return static_cast< ::exec::user::QueryType >(type_); +} +inline void RunQuery::set_type(::exec::user::QueryType value) { + assert(::exec::user::QueryType_IsValid(value)); + set_has_type(); + type_ = value; +} + +// optional string plan = 3; +inline bool RunQuery::has_plan() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void RunQuery::set_has_plan() { + _has_bits_[0] |= 0x00000004u; +} +inline void RunQuery::clear_has_plan() { + _has_bits_[0] &= ~0x00000004u; +} +inline void RunQuery::clear_plan() { + if (plan_ != &::google::protobuf::internal::kEmptyString) { + plan_->clear(); + } + clear_has_plan(); +} +inline const ::std::string& RunQuery::plan() const { + return *plan_; +} +inline void RunQuery::set_plan(const ::std::string& value) { + set_has_plan(); + if (plan_ == &::google::protobuf::internal::kEmptyString) { + plan_ = new ::std::string; + } + plan_->assign(value); +} +inline void RunQuery::set_plan(const char* value) { + set_has_plan(); + if (plan_ == &::google::protobuf::internal::kEmptyString) { + plan_ = new ::std::string; + } + plan_->assign(value); +} +inline void RunQuery::set_plan(const char* value, size_t size) { + set_has_plan(); + if (plan_ == &::google::protobuf::internal::kEmptyString) { + plan_ = new ::std::string; + } + plan_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* RunQuery::mutable_plan() { + set_has_plan(); + if (plan_ == &::google::protobuf::internal::kEmptyString) { + plan_ = new ::std::string; + } + return plan_; +} +inline ::std::string* RunQuery::release_plan() { + clear_has_plan(); + if (plan_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = plan_; + plan_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void RunQuery::set_allocated_plan(::std::string* plan) { + if (plan_ != &::google::protobuf::internal::kEmptyString) { + delete plan_; + } + if (plan) { + set_has_plan(); + plan_ = plan; + } else { + clear_has_plan(); + plan_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// ------------------------------------------------------------------- + +// BitToUserHandshake + +// optional int32 rpc_version = 2; +inline bool BitToUserHandshake::has_rpc_version() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void BitToUserHandshake::set_has_rpc_version() { + _has_bits_[0] |= 0x00000001u; +} +inline void BitToUserHandshake::clear_has_rpc_version() { + _has_bits_[0] &= ~0x00000001u; +} +inline void BitToUserHandshake::clear_rpc_version() { + rpc_version_ = 0; + clear_has_rpc_version(); +} +inline ::google::protobuf::int32 BitToUserHandshake::rpc_version() const { + return rpc_version_; +} +inline void BitToUserHandshake::set_rpc_version(::google::protobuf::int32 value) { + set_has_rpc_version(); + rpc_version_ = value; +} + +// ------------------------------------------------------------------- + +// NodeStatus + +// optional int32 node_id = 1; +inline bool NodeStatus::has_node_id() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void NodeStatus::set_has_node_id() { + _has_bits_[0] |= 0x00000001u; +} +inline void NodeStatus::clear_has_node_id() { + _has_bits_[0] &= ~0x00000001u; +} +inline void NodeStatus::clear_node_id() { + node_id_ = 0; + clear_has_node_id(); +} +inline ::google::protobuf::int32 NodeStatus::node_id() const { + return node_id_; +} +inline void NodeStatus::set_node_id(::google::protobuf::int32 value) { + set_has_node_id(); + node_id_ = value; +} + +// optional int64 memory_footprint = 2; +inline bool NodeStatus::has_memory_footprint() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void NodeStatus::set_has_memory_footprint() { + _has_bits_[0] |= 0x00000002u; +} +inline void NodeStatus::clear_has_memory_footprint() { + _has_bits_[0] &= ~0x00000002u; +} +inline void NodeStatus::clear_memory_footprint() { + memory_footprint_ = GOOGLE_LONGLONG(0); + clear_has_memory_footprint(); +} +inline ::google::protobuf::int64 NodeStatus::memory_footprint() const { + return memory_footprint_; +} +inline void NodeStatus::set_memory_footprint(::google::protobuf::int64 value) { + set_has_memory_footprint(); + memory_footprint_ = value; +} + +// ------------------------------------------------------------------- + +// QueryResult + +// optional .exec.user.QueryResult.QueryState query_state = 1; +inline bool QueryResult::has_query_state() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void QueryResult::set_has_query_state() { + _has_bits_[0] |= 0x00000001u; +} +inline void QueryResult::clear_has_query_state() { + _has_bits_[0] &= ~0x00000001u; +} +inline void QueryResult::clear_query_state() { + query_state_ = 0; + clear_has_query_state(); +} +inline ::exec::user::QueryResult_QueryState QueryResult::query_state() const { + return static_cast< ::exec::user::QueryResult_QueryState >(query_state_); +} +inline void QueryResult::set_query_state(::exec::user::QueryResult_QueryState value) { + assert(::exec::user::QueryResult_QueryState_IsValid(value)); + set_has_query_state(); + query_state_ = value; +} + +// optional .exec.shared.QueryId query_id = 2; +inline bool QueryResult::has_query_id() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void QueryResult::set_has_query_id() { + _has_bits_[0] |= 0x00000002u; +} +inline void QueryResult::clear_has_query_id() { + _has_bits_[0] &= ~0x00000002u; +} +inline void QueryResult::clear_query_id() { + if (query_id_ != NULL) query_id_->::exec::shared::QueryId::Clear(); + clear_has_query_id(); +} +inline const ::exec::shared::QueryId& QueryResult::query_id() const { + return query_id_ != NULL ? *query_id_ : *default_instance_->query_id_; +} +inline ::exec::shared::QueryId* QueryResult::mutable_query_id() { + set_has_query_id(); + if (query_id_ == NULL) query_id_ = new ::exec::shared::QueryId; + return query_id_; +} +inline ::exec::shared::QueryId* QueryResult::release_query_id() { + clear_has_query_id(); + ::exec::shared::QueryId* temp = query_id_; + query_id_ = NULL; + return temp; +} +inline void QueryResult::set_allocated_query_id(::exec::shared::QueryId* query_id) { + delete query_id_; + query_id_ = query_id; + if (query_id) { + set_has_query_id(); + } else { + clear_has_query_id(); + } +} + +// optional bool is_last_chunk = 3; +inline bool QueryResult::has_is_last_chunk() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void QueryResult::set_has_is_last_chunk() { + _has_bits_[0] |= 0x00000004u; +} +inline void QueryResult::clear_has_is_last_chunk() { + _has_bits_[0] &= ~0x00000004u; +} +inline void QueryResult::clear_is_last_chunk() { + is_last_chunk_ = false; + clear_has_is_last_chunk(); +} +inline bool QueryResult::is_last_chunk() const { + return is_last_chunk_; +} +inline void QueryResult::set_is_last_chunk(bool value) { + set_has_is_last_chunk(); + is_last_chunk_ = value; +} + +// optional int32 row_count = 4; +inline bool QueryResult::has_row_count() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void QueryResult::set_has_row_count() { + _has_bits_[0] |= 0x00000008u; +} +inline void QueryResult::clear_has_row_count() { + _has_bits_[0] &= ~0x00000008u; +} +inline void QueryResult::clear_row_count() { + row_count_ = 0; + clear_has_row_count(); +} +inline ::google::protobuf::int32 QueryResult::row_count() const { + return row_count_; +} +inline void QueryResult::set_row_count(::google::protobuf::int32 value) { + set_has_row_count(); + row_count_ = value; +} + +// optional int64 records_scan = 5; +inline bool QueryResult::has_records_scan() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +inline void QueryResult::set_has_records_scan() { + _has_bits_[0] |= 0x00000010u; +} +inline void QueryResult::clear_has_records_scan() { + _has_bits_[0] &= ~0x00000010u; +} +inline void QueryResult::clear_records_scan() { + records_scan_ = GOOGLE_LONGLONG(0); + clear_has_records_scan(); +} +inline ::google::protobuf::int64 QueryResult::records_scan() const { + return records_scan_; +} +inline void QueryResult::set_records_scan(::google::protobuf::int64 value) { + set_has_records_scan(); + records_scan_ = value; +} + +// optional int64 records_error = 6; +inline bool QueryResult::has_records_error() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void QueryResult::set_has_records_error() { + _has_bits_[0] |= 0x00000020u; +} +inline void QueryResult::clear_has_records_error() { + _has_bits_[0] &= ~0x00000020u; +} +inline void QueryResult::clear_records_error() { + records_error_ = GOOGLE_LONGLONG(0); + clear_has_records_error(); +} +inline ::google::protobuf::int64 QueryResult::records_error() const { + return records_error_; +} +inline void QueryResult::set_records_error(::google::protobuf::int64 value) { + set_has_records_error(); + records_error_ = value; +} + +// optional int64 submission_time = 7; +inline bool QueryResult::has_submission_time() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +inline void QueryResult::set_has_submission_time() { + _has_bits_[0] |= 0x00000040u; +} +inline void QueryResult::clear_has_submission_time() { + _has_bits_[0] &= ~0x00000040u; +} +inline void QueryResult::clear_submission_time() { + submission_time_ = GOOGLE_LONGLONG(0); + clear_has_submission_time(); +} +inline ::google::protobuf::int64 QueryResult::submission_time() const { + return submission_time_; +} +inline void QueryResult::set_submission_time(::google::protobuf::int64 value) { + set_has_submission_time(); + submission_time_ = value; +} + +// repeated .exec.user.NodeStatus node_status = 8; +inline int QueryResult::node_status_size() const { + return node_status_.size(); +} +inline void QueryResult::clear_node_status() { + node_status_.Clear(); +} +inline const ::exec::user::NodeStatus& QueryResult::node_status(int index) const { + return node_status_.Get(index); +} +inline ::exec::user::NodeStatus* QueryResult::mutable_node_status(int index) { + return node_status_.Mutable(index); +} +inline ::exec::user::NodeStatus* QueryResult::add_node_status() { + return node_status_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::exec::user::NodeStatus >& +QueryResult::node_status() const { + return node_status_; +} +inline ::google::protobuf::RepeatedPtrField< ::exec::user::NodeStatus >* +QueryResult::mutable_node_status() { + return &node_status_; +} + +// repeated .exec.shared.DrillPBError error = 9; +inline int QueryResult::error_size() const { + return error_.size(); +} +inline void QueryResult::clear_error() { + error_.Clear(); +} +inline const ::exec::shared::DrillPBError& QueryResult::error(int index) const { + return error_.Get(index); +} +inline ::exec::shared::DrillPBError* QueryResult::mutable_error(int index) { + return error_.Mutable(index); +} +inline ::exec::shared::DrillPBError* QueryResult::add_error() { + return error_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::exec::shared::DrillPBError >& +QueryResult::error() const { + return error_; +} +inline ::google::protobuf::RepeatedPtrField< ::exec::shared::DrillPBError >* +QueryResult::mutable_error() { + return &error_; +} + +// optional .exec.shared.RecordBatchDef def = 10; +inline bool QueryResult::has_def() const { + return (_has_bits_[0] & 0x00000200u) != 0; +} +inline void QueryResult::set_has_def() { + _has_bits_[0] |= 0x00000200u; +} +inline void QueryResult::clear_has_def() { + _has_bits_[0] &= ~0x00000200u; +} +inline void QueryResult::clear_def() { + if (def_ != NULL) def_->::exec::shared::RecordBatchDef::Clear(); + clear_has_def(); +} +inline const ::exec::shared::RecordBatchDef& QueryResult::def() const { + return def_ != NULL ? *def_ : *default_instance_->def_; +} +inline ::exec::shared::RecordBatchDef* QueryResult::mutable_def() { + set_has_def(); + if (def_ == NULL) def_ = new ::exec::shared::RecordBatchDef; + return def_; +} +inline ::exec::shared::RecordBatchDef* QueryResult::release_def() { + clear_has_def(); + ::exec::shared::RecordBatchDef* temp = def_; + def_ = NULL; + return temp; +} +inline void QueryResult::set_allocated_def(::exec::shared::RecordBatchDef* def) { + delete def_; + def_ = def; + if (def) { + set_has_def(); + } else { + clear_has_def(); + } +} + +// optional bool schema_changed = 11; +inline bool QueryResult::has_schema_changed() const { + return (_has_bits_[0] & 0x00000400u) != 0; +} +inline void QueryResult::set_has_schema_changed() { + _has_bits_[0] |= 0x00000400u; +} +inline void QueryResult::clear_has_schema_changed() { + _has_bits_[0] &= ~0x00000400u; +} +inline void QueryResult::clear_schema_changed() { + schema_changed_ = false; + clear_has_schema_changed(); +} +inline bool QueryResult::schema_changed() const { + return schema_changed_; +} +inline void QueryResult::set_schema_changed(bool value) { + set_has_schema_changed(); + schema_changed_ = value; +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace user +} // namespace exec + +#ifndef SWIG +namespace google { +namespace protobuf { + +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::exec::user::QueryResult_QueryState>() { + return ::exec::user::QueryResult_QueryState_descriptor(); +} +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::exec::user::RpcType>() { + return ::exec::user::RpcType_descriptor(); +} +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::exec::user::QueryType>() { + return ::exec::user::QueryType_descriptor(); +} +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::exec::user::QueryResultsMode>() { + return ::exec::user::QueryResultsMode_descriptor(); +} + +} // namespace google +} // namespace protobuf +#endif // SWIG + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_User_2eproto__INCLUDED diff --git a/contrib/native/client/src/include/drill/recordBatch.hpp b/contrib/native/client/src/include/drill/recordBatch.hpp new file mode 100644 index 000000000..c40327bfd --- /dev/null +++ b/contrib/native/client/src/include/drill/recordBatch.hpp @@ -0,0 +1,873 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef RECORDBATCH_H +#define RECORDBATCH_H + + +#include <assert.h> +#include <stdint.h> +#include <stdio.h> +#include <ostream> +#include <sstream> +#include <vector> +#include <boost/lexical_cast.hpp> +#include "drill/common.hpp" +#include "drill/decimalUtils.hpp" +#include "drill/protobuf/User.pb.h" + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef DRILL_CLIENT_EXPORTS + #define DECLSPEC_DRILL_CLIENT __declspec(dllexport) + #else + #ifdef USE_STATIC_LIBDRILL + #define DECLSPEC_DRILL_CLIENT + #else + #define DECLSPEC_DRILL_CLIENT __declspec(dllimport) + #endif + #endif +#else + #if __GNUC__ >= 4 + #define DECLSPEC_DRILL_CLIENT __attribute__ ((visibility ("default"))) + #else + #define DECLSPEC_DRILL_CLIENT + #endif +#endif + + +namespace Drill { + +class FieldBatch; +class ValueVectorBase; + +//TODO: The base classes for value vectors should have abstract functions instead of implementations +//that return 'NOT IMPLEMENTED YET' + +// A Read Only Sliced byte buffer +class SlicedByteBuf{ + public: + //TODO: check the size and offset parameters. What is the largest they can be? + SlicedByteBuf(const ByteBuf_t b, size_t offset, size_t length){ + this->m_buffer=b; + this->m_start=offset; + this->m_end=offset+length-1; + this->m_length=length; + } + + // Carve a sliced buffer out of another sliced buffer + SlicedByteBuf(const SlicedByteBuf& sb, size_t offset, size_t length){ + this->m_buffer=sb.m_buffer; + this->m_start=sb.m_start+offset; + this->m_end=sb.m_start+offset+length; + this->m_length=length; + } + + //Copy ctor + SlicedByteBuf(const SlicedByteBuf& other ){ + if(this!=&other){ + this->m_buffer=other.m_buffer; + this->m_start=other.m_start; + this->m_end=other.m_end; + this->m_length=other.m_length; + } + } + + SlicedByteBuf& operator=( const SlicedByteBuf& rhs ){ + if(this!=&rhs){ + this->m_buffer=rhs.m_buffer; + this->m_start=rhs.m_start; + this->m_end=rhs.m_end; + this->m_length=rhs.m_length; + } + return *this; + } + + size_t getStart(){ + return this->m_start; + } + size_t getEnd(){ + return this->m_end; + } + size_t getLength(){ + return this->m_length; + } + + // ByteBuf_t getBuffer(){ return m_buffer;} + ByteBuf_t getSliceStart(){ return this->m_buffer+this->m_start;} + + // accessor functions + // + // TYPE getTYPE(size_t index){ + // if(index>=m_length) return 0; + // return (TYPE) m_buffer[offset+index]; + // } + + + template <typename T> T readAt(size_t index) const { + // Type T can only be an integer type + // Type T cannot be a struct of fixed size + // Because struct alignment is compiler dependent + // we can end up with a struct size that is larger + // than the buffer in the sliced buf. + assert((index + sizeof(T) <= this->m_length)); + if(index + sizeof(T) <= this->m_length) + return *((T*)(this->m_buffer+this->m_start+index)); + return 0; + + } + + uint8_t getByte(size_t index){ + return readAt<uint8_t>(index); + } + + uint32_t getUint32(size_t index){ + return readAt<uint32_t>(index); + } + + uint64_t getUint64(size_t index){ + return readAt<uint64_t>(index); + } + + ByteBuf_t getAt(size_t index){ + return this->m_buffer+m_start+index; + } + + bool getBit(size_t index){ + // refer to BitVector.java http://bit.ly/Py1jof + return ((this->m_buffer[m_start+index/8] & ( 1 << (index % 8) )) !=0); + } + private: + ByteBuf_t m_buffer; // the backing store + size_t m_start; //offset within the backing store where this slice begins + size_t m_end; //offset within the backing store where this slice ends + size_t m_length; //length +}; + +class DECLSPEC_DRILL_CLIENT ValueVectorBase{ + public: + ValueVectorBase(SlicedByteBuf *b, size_t rowCount){ + m_pBuffer=b; + m_rowCount=rowCount; + } + + virtual ~ValueVectorBase(){ + } + + // test whether the value is null in the position index + virtual bool isNull(size_t index) const { + return false; + } + + + const char* get(size_t index) const { return 0;} + virtual void getValueAt(size_t index, char* buf, size_t nChars) const =0; + + virtual const ByteBuf_t getRaw(size_t index) const { + return (ByteBuf_t)m_pBuffer->getSliceStart() ; + } + + virtual uint32_t getSize(size_t index) const=0; + //virtual uint32_t getSize(size_t index) const { + // return 0; + //} + + protected: + SlicedByteBuf* m_pBuffer; + size_t m_rowCount; +}; + +class DECLSPEC_DRILL_CLIENT ValueVectorUnimplemented:public ValueVectorBase{ + public: + ValueVectorUnimplemented(SlicedByteBuf *b, size_t rowCount):ValueVectorBase(b,rowCount){ + } + + virtual ~ValueVectorUnimplemented(){ + } + + const char* get(size_t index) const { return 0;}; + virtual void getValueAt(size_t index, char* buf, size_t nChars) const{ + *buf=0; return; + } + + virtual uint32_t getSize(size_t index) const{ return 0;}; + + protected: + SlicedByteBuf* m_pBuffer; + size_t m_rowCount; +}; + +class DECLSPEC_DRILL_CLIENT ValueVectorFixedWidth:public ValueVectorBase{ + public: + ValueVectorFixedWidth(SlicedByteBuf *b, size_t rowCount):ValueVectorBase(b, rowCount){ + } + + void getValueAt(size_t index, char* buf, size_t nChars) const { + strncpy(buf, "NOT IMPLEMENTED YET", nChars); + return; + } + + const ByteBuf_t getRaw(size_t index) const { + return this->m_pBuffer->getSliceStart()+index*this->getSize(index); + } + + uint32_t getSize(size_t index) const { + return 0; + } +}; + +template <typename VALUE_TYPE> + class ValueVectorFixed : public ValueVectorFixedWidth { + public: + ValueVectorFixed(SlicedByteBuf *b, size_t rowCount) : + ValueVectorFixedWidth(b, rowCount) {} + + VALUE_TYPE get(size_t index) const { + return m_pBuffer->readAt<VALUE_TYPE>(index * sizeof(VALUE_TYPE)); + } + + void getValueAt(size_t index, char* buf, size_t nChars) const { + std::stringstream sstr; + VALUE_TYPE value = this->get(index); + sstr << value; + strncpy(buf, sstr.str().c_str(), nChars); + } + + uint32_t getSize(size_t index) const { + return sizeof(VALUE_TYPE); + } + }; + + +class DECLSPEC_DRILL_CLIENT ValueVectorBit:public ValueVectorFixedWidth{ + public: + ValueVectorBit(SlicedByteBuf *b, size_t rowCount):ValueVectorFixedWidth(b, rowCount){ + } + bool get(size_t index) const { + #ifdef DEBUG + uint8_t b = m_pBuffer->getByte((index)/8); + uint8_t bitOffset = index%8; + uint8_t setBit = (1<<bitOffset); // sets the Nth bit. + uint8_t isSet = (b&setBit); + return isSet; + #else + return (bool)((m_pBuffer->getByte((index)/8)) & (1<< (index%8) )); + #endif + + } + void getValueAt(size_t index, char* buf, size_t nChars) const { + char str[64]; // Can't have more than 64 digits of precision + //could use itoa instead of sprintf which is slow, but it is not portable + sprintf(str, "%s", this->get(index)?"true":"false"); + strncpy(buf, str, nChars); + return; + } + uint32_t getSize(size_t index) const { + return sizeof(uint8_t); + } +}; + +template <int DECIMAL_DIGITS, int WIDTH_IN_BYTES, bool IS_SPARSE, int MAX_PRECISION = 0 > + class ValueVectorDecimal: public ValueVectorFixedWidth { + public: + ValueVectorDecimal(SlicedByteBuf* b, size_t rowCount, int32_t scale): + ValueVectorFixedWidth(b, rowCount), + m_scale(scale) + { + ; // Do nothing + } + + DecimalValue get(size_t index) const { + if (IS_SPARSE) + { + return getDecimalValueFromSparse(*m_pBuffer, index * WIDTH_IN_BYTES, DECIMAL_DIGITS, m_scale); + } + return getDecimalValueFromDense(*m_pBuffer, index * WIDTH_IN_BYTES, DECIMAL_DIGITS, m_scale, MAX_PRECISION, WIDTH_IN_BYTES); + } + + void getValueAt(size_t index, char* buf, size_t nChars) const { + const DecimalValue& val = this->get(index); + const std::string& str = boost::lexical_cast<std::string>(val.m_unscaledValue); + size_t idxDecimalMark = str.length() - m_scale; + const std::string& decStr= str.substr(0, idxDecimalMark) + "." + str.substr(idxDecimalMark, m_scale); + strncpy(buf, decStr.c_str(), nChars); + return; + } + + uint32_t getSize(size_t index) const { + return WIDTH_IN_BYTES; + } + + private: + int32_t m_scale; + }; + +template<typename VALUE_TYPE> + class ValueVectorDecimalTrivial: public ValueVectorFixedWidth { + public: + ValueVectorDecimalTrivial(SlicedByteBuf* b, size_t rowCount, int32_t scale): + ValueVectorFixedWidth(b, rowCount), + m_scale(scale) + { + ; // Do nothing + } + + DecimalValue get(size_t index) const { + return DecimalValue( + m_pBuffer->readAt<VALUE_TYPE>(index * sizeof(VALUE_TYPE)), + m_scale); + } + + void getValueAt(size_t index, char* buf, size_t nChars) const { + VALUE_TYPE value = m_pBuffer->readAt<VALUE_TYPE>(index * sizeof(VALUE_TYPE)); + const std::string& str = boost::lexical_cast<std::string>(value); + size_t idxDecimalMark = str.length() - m_scale; + const std::string& decStr= str.substr(0, idxDecimalMark) + "." + str.substr(idxDecimalMark, m_scale); + strncpy(buf, decStr.c_str(), nChars); + return; + } + + uint32_t getSize(size_t index) const { + return sizeof(VALUE_TYPE); + } + + private: + int32_t m_scale; + }; + + +template <typename VALUE_TYPE> + class NullableValueVectorFixed : public ValueVectorBase +{ + public: + NullableValueVectorFixed(SlicedByteBuf *b, size_t rowCount):ValueVectorBase(b, rowCount){ + size_t offsetEnd = rowCount/8 + 1; + this->m_pBitmap= new SlicedByteBuf(*b, 0, offsetEnd); + this->m_pData= new SlicedByteBuf(*b, offsetEnd, b->getLength()); + // TODO: testing boundary case(null columns) + } + + ~NullableValueVectorFixed(){ + delete this->m_pBitmap; + delete this->m_pData; + } + + // test whether the value is null in the position index + bool isNull(size_t index) const { + return (m_pBitmap->getBit(index)==0); + } + + VALUE_TYPE get(size_t index) const { + // it should not be called if the value is null + assert( "value is null" && !isNull(index)); + return m_pData->readAt<VALUE_TYPE>(index * sizeof(VALUE_TYPE)); + } + + void getValueAt(size_t index, char* buf, size_t nChars) const { + assert( "value is null" && !isNull(index)); + std::stringstream sstr; + VALUE_TYPE value = this->get(index); + sstr << value; + strncpy(buf, sstr.str().c_str(), nChars); + } + + uint32_t getSize(size_t index) const { + assert("value is null" && !isNull(index)); + return sizeof(VALUE_TYPE); + } + private: + SlicedByteBuf* m_pBitmap; + SlicedByteBuf* m_pData; +}; + +// The 'holder' classes are (by contract) simple structs with primitive members and no dynamic allocations. +// The template classes create an instance of the class and return it to the caller in the 'get' routines. +// The compiler will create a copy and return it to the caller. If the object is more complex than a struct of +// primitives, the class _must_ provide a copy constructor. +// We don't really need a destructor here, but we declare a virtual dtor in the base class in case we ever get +// more complex and start doing dynamic allocations in these classes. + +struct DateTimeBase{ + DateTimeBase(){m_datetime=0;} + virtual ~DateTimeBase(){} + uint64_t m_datetime; + virtual void load() =0; + virtual std::string toString()=0; +}; + +struct DateHolder: public virtual DateTimeBase{ + DateHolder(){}; + DateHolder(uint64_t d){m_datetime=d; load();} + uint32_t m_year; + uint32_t m_month; + uint32_t m_day; + void load(); + std::string toString(); +}; + +struct TimeHolder: public virtual DateTimeBase{ + TimeHolder(){}; + TimeHolder(uint32_t d){m_datetime=d; load();} + uint32_t m_hr; + uint32_t m_min; + uint32_t m_sec; + uint32_t m_msec; + void load(); + std::string toString(); +}; + +struct DateTimeHolder: public DateHolder, public TimeHolder{ + DateTimeHolder(){}; + DateTimeHolder(uint64_t d){m_datetime=d; load();} + void load(); + std::string toString(); +}; + +struct DateTimeTZHolder: public DateTimeHolder{ + DateTimeTZHolder(ByteBuf_t b){ + m_datetime=*(uint64_t*)b; + m_tzIndex=*(uint32_t*)(b+sizeof(uint64_t)); + load(); + } + void load(); + std::string toString(); + int32_t m_tzIndex; + static uint32_t size(){ return sizeof(uint64_t)+sizeof(uint32_t); } + +}; + +struct IntervalYearHolder{ + IntervalYearHolder(ByteBuf_t b){ + m_month=*(uint32_t*)b; + load(); + } + void load(){}; + std::string toString(); + uint32_t m_month; + static uint32_t size(){ return sizeof(uint32_t); } +}; + +struct IntervalDayHolder{ + IntervalDayHolder(ByteBuf_t b){ + m_day=*(uint32_t*)(b); + m_ms=*(uint32_t*)(b+sizeof(uint32_t)); + load(); + } + void load(){}; + std::string toString(); + uint32_t m_day; + uint32_t m_ms; + static uint32_t size(){ return 2*sizeof(uint32_t)+4; } +}; + +struct IntervalHolder{ + IntervalHolder(ByteBuf_t b){ + m_month=*(uint32_t*)b; + m_day=*(uint32_t*)(b+sizeof(uint32_t)); + m_ms=*(uint32_t*)(b+2*sizeof(uint32_t)); + load(); + } + void load(){}; + std::string toString(); + uint32_t m_month; + uint32_t m_day; + uint32_t m_ms; + static uint32_t size(){ return 3*sizeof(uint32_t)+4; } +}; + +/* + * VALUEHOLDER_CLASS_TYPE is a struct with a constructor that takes a parameter of type VALUE_VECTOR_TYPE + * (a primitive type) + * VALUEHOLDER_CLASS_TYPE implements a toString function + * Note that VALUEHOLDER_CLASS_TYPE is created on the stack and the copy returned in the get function. + * So the class needs to have the appropriate copy constructor or the default bitwise copy should work + * correctly. + */ +template <class VALUEHOLDER_CLASS_TYPE, typename VALUE_TYPE> + class ValueVectorTyped:public ValueVectorFixedWidth{ + public: + ValueVectorTyped(SlicedByteBuf *b, size_t rowCount) : + ValueVectorFixedWidth(b, rowCount) {} + + + VALUEHOLDER_CLASS_TYPE get(size_t index) const { + VALUE_TYPE v= m_pBuffer->readAt<VALUE_TYPE>(index * sizeof(VALUE_TYPE)); + VALUEHOLDER_CLASS_TYPE r(v); + return r; + } + + void getValueAt(size_t index, char* buf, size_t nChars) const { + std::stringstream sstr; + VALUEHOLDER_CLASS_TYPE value = this->get(index); + sstr << value.toString(); + strncpy(buf, sstr.str().c_str(), nChars); + } + + uint32_t getSize(size_t index) const { + return sizeof(VALUE_TYPE); + } + }; + +template <class VALUEHOLDER_CLASS_TYPE> + class ValueVectorTypedComposite:public ValueVectorFixedWidth{ + public: + ValueVectorTypedComposite(SlicedByteBuf *b, size_t rowCount) : + ValueVectorFixedWidth(b, rowCount) {} + + + VALUEHOLDER_CLASS_TYPE get(size_t index) const { + ByteBuf_t b= m_pBuffer->getAt(index * getSize(index)); + VALUEHOLDER_CLASS_TYPE r(b); + return r; + } + + void getValueAt(size_t index, char* buf, size_t nChars) const { + std::stringstream sstr; + VALUEHOLDER_CLASS_TYPE value = this->get(index); + sstr << value.toString(); + strncpy(buf, sstr.str().c_str(), nChars); + } + + uint32_t getSize(size_t index) const { + return VALUEHOLDER_CLASS_TYPE::size(); + } + }; + +template <class VALUEHOLDER_CLASS_TYPE, class VALUE_VECTOR_TYPE> + class NullableValueVectorTyped : public ValueVectorBase { + public: + + NullableValueVectorTyped(SlicedByteBuf *b, size_t rowCount):ValueVectorBase(b, rowCount){ + size_t offsetEnd = rowCount/8 + 1; + this->m_pBitmap= new SlicedByteBuf(*b, 0, offsetEnd); + this->m_pData= new SlicedByteBuf(*b, offsetEnd, b->getLength()-offsetEnd); + this->m_pVector= new VALUE_VECTOR_TYPE(m_pData, rowCount); + } + + ~NullableValueVectorTyped(){ + delete this->m_pBitmap; + delete this->m_pData; + delete this->m_pVector; + } + + bool isNull(size_t index) const{ + return (m_pBitmap->getBit(index)==0); + } + + VALUEHOLDER_CLASS_TYPE get(size_t index) const { + assert(!isNull(index)); + return m_pVector->get(index); + } + + void getValueAt(size_t index, char* buf, size_t nChars) const{ + std::stringstream sstr; + if(this->isNull(index)){ + sstr<<"NULL"; + strncpy(buf, sstr.str().c_str(), nChars); + }else{ + return m_pVector->getValueAt(index, buf, nChars); + } + } + + uint32_t getSize(size_t index) const { + assert(!isNull(index)); + return this->m_pVector->getSize(index); + } + + private: + SlicedByteBuf* m_pBitmap; + SlicedByteBuf* m_pData; + VALUE_VECTOR_TYPE* m_pVector; + }; + +class DECLSPEC_DRILL_CLIENT VarWidthHolder{ + public: + ByteBuf_t data; + size_t size; +}; + +class DECLSPEC_DRILL_CLIENT ValueVectorVarWidth:public ValueVectorBase{ + public: + ValueVectorVarWidth(SlicedByteBuf *b, size_t rowCount):ValueVectorBase(b, rowCount){ + size_t offsetEnd = (rowCount+1)*sizeof(uint32_t); + this->m_pOffsetArray= new SlicedByteBuf(*b, 0, offsetEnd); + this->m_pData= new SlicedByteBuf(*b, offsetEnd, b->getLength()); + } + ~ValueVectorVarWidth(){ + delete this->m_pOffsetArray; + delete this->m_pData; + } + + VarWidthHolder get(size_t index) const { + size_t startIdx = this->m_pOffsetArray->getUint32(index*sizeof(uint32_t)); + size_t endIdx = this->m_pOffsetArray->getUint32((index+1)*sizeof(uint32_t)); + size_t length = endIdx - startIdx; + assert(length >= 0); + // Return an object created on the stack. The compiler will return a + // copy and destroy the stack object. The optimizer will hopefully + // elide this so we can return an object with no extra memory allocation + // and no copies.(SEE: http://en.wikipedia.org/wiki/Return_value_optimization) + VarWidthHolder dst; + dst.data=this->m_pData->getSliceStart()+startIdx; + dst.size=length; + return dst; + } + + void getValueAt(size_t index, char* buf, size_t nChars) const { + size_t startIdx = this->m_pOffsetArray->getUint32(index*sizeof(uint32_t)); + size_t endIdx = this->m_pOffsetArray->getUint32((index+1)*sizeof(uint32_t)); + size_t length = endIdx - startIdx; + size_t copyChars=0; + assert(length >= 0); + copyChars=nChars<=length?nChars:length; + memcpy(buf, this->m_pData->getSliceStart()+startIdx, copyChars); + return; + } + + const ByteBuf_t getRaw(size_t index) const { + size_t startIdx = this->m_pOffsetArray->getUint32(index*sizeof(uint32_t)); + size_t endIdx = this->m_pOffsetArray->getUint32((index+1)*sizeof(uint32_t)); + size_t length = endIdx - startIdx; + assert(length >= 0); + return this->m_pData->getSliceStart()+startIdx; + } + + uint32_t getSize(size_t index) const { + size_t startIdx = this->m_pOffsetArray->getUint32(index*sizeof(uint32_t)); + size_t endIdx = this->m_pOffsetArray->getUint32((index+1)*sizeof(uint32_t)); + size_t length = endIdx - startIdx; + assert(length >= 0); + return length; + } + private: + SlicedByteBuf* m_pOffsetArray; + SlicedByteBuf* m_pData; +}; + +class DECLSPEC_DRILL_CLIENT ValueVectorVarChar:public ValueVectorVarWidth{ + public: + ValueVectorVarChar(SlicedByteBuf *b, size_t rowCount):ValueVectorVarWidth(b, rowCount){ + } + VarWidthHolder get(size_t index) const { + return ValueVectorVarWidth::get(index); + } +}; + +class DECLSPEC_DRILL_CLIENT ValueVectorVarBinary:public ValueVectorVarWidth{ + public: + ValueVectorVarBinary(SlicedByteBuf *b, size_t rowCount):ValueVectorVarWidth(b, rowCount){ + } +}; +// +//TODO: For windows, we have to export instantiations of the template class. +//see: http://msdn.microsoft.com/en-us/library/twa2aw10.aspx +//for example: +//template class __declspec(dllexport) B<int>; +//class __declspec(dllexport) D : public B<int> { } +// +// -------------------------------------------------------------------------------------- +// TODO: alias for all value vector types +// -------------------------------------------------------------------------------------- +typedef NullableValueVectorTyped<int, ValueVectorBit > NullableValueVectorBit; +// Aliases for Decimal Types: +// The definitions for decimal digits, width, max precision are defined in +// /exec/java-exec/src/main/codegen/data/ValueVectorTypes.tdd +// +// Decimal9 and Decimal18 could be optimized, maybe write seperate classes? +typedef ValueVectorDecimalTrivial<int32_t> ValueVectorDecimal9; +typedef ValueVectorDecimalTrivial<int64_t> ValueVectorDecimal18; +typedef ValueVectorDecimal<3, 12, false, 28> ValueVectorDecimal28Dense; +typedef ValueVectorDecimal<4, 16, false, 38> ValueVectorDecimal38Dense; +typedef ValueVectorDecimal<5, 20, true, 28> ValueVectorDecimal28Sparse; +typedef ValueVectorDecimal<6, 24, true, 38> ValueVectorDecimal38Sparse; + +typedef NullableValueVectorTyped<int32_t, ValueVectorDecimal9> NullableValueVectorDecimal9; +typedef NullableValueVectorTyped<int64_t, ValueVectorDecimal18> NullableValueVectorDecimal18; +typedef NullableValueVectorTyped<DecimalValue , ValueVectorDecimal28Dense> NullableValueVectorDecimal28Dense; +typedef NullableValueVectorTyped<DecimalValue , ValueVectorDecimal38Dense> NullableValueVectorDecimal38Dense; +typedef NullableValueVectorTyped<DecimalValue , ValueVectorDecimal28Sparse> NullableValueVectorDecimal28Sparse; +typedef NullableValueVectorTyped<DecimalValue , ValueVectorDecimal38Sparse> NullableValueVectorDecimal38Sparse; + +typedef ValueVectorTyped<DateHolder, uint64_t> ValueVectorDate; +typedef ValueVectorTyped<DateTimeHolder, uint64_t> ValueVectorTimestamp; +typedef ValueVectorTyped<TimeHolder, uint32_t> ValueVectorTime; +typedef ValueVectorTypedComposite<DateTimeTZHolder> ValueVectorTimestampTZ; +typedef ValueVectorTypedComposite<IntervalHolder> ValueVectorInterval; +typedef ValueVectorTypedComposite<IntervalDayHolder> ValueVectorIntervalDay; +typedef ValueVectorTypedComposite<IntervalYearHolder> ValueVectorIntervalYear; + +typedef NullableValueVectorTyped<DateHolder, ValueVectorDate> NullableValueVectorDate; +typedef NullableValueVectorTyped<DateTimeHolder, ValueVectorTimestamp> NullableValueVectorTimestamp; +typedef NullableValueVectorTyped<TimeHolder, ValueVectorTime> NullableValueVectorTime; +typedef NullableValueVectorTyped<DateTimeTZHolder, ValueVectorTimestampTZ> NullableValueVectorTimestampTZ; +typedef NullableValueVectorTyped<IntervalHolder, ValueVectorInterval> NullableValueVectorInterval; +typedef NullableValueVectorTyped<IntervalDayHolder, ValueVectorIntervalDay> NullableValueVectorIntervalDay; +typedef NullableValueVectorTyped<IntervalYearHolder, ValueVectorIntervalYear> NullableValueVectorIntervalYear; + +class DECLSPEC_DRILL_CLIENT FieldMetadata{ + public: + FieldMetadata(){}; + void set(const exec::shared::SerializedField& f){ + m_name=f.name_part().name(); + m_minorType=f.major_type().minor_type(); + m_dataMode=f.major_type().mode(); + m_valueCount=f.value_count(); + m_scale=f.major_type().scale(); + m_precision=f.major_type().precision(); + m_bufferLength=f.buffer_length(); + } + const std::string& getName(){ return m_name;} + common::MinorType getMinorType() const{ return m_minorType;} + common::DataMode getDataMode() const{return m_dataMode;} + uint32_t getValueCount() const{return m_valueCount;} + uint32_t getScale() const{return m_scale;} + uint32_t getBufferLength() const{return m_bufferLength;} + void copy(Drill::FieldMetadata& f){ + m_name=f.m_name; + m_minorType=f.m_minorType; + m_dataMode=f.m_dataMode; + m_valueCount=f.m_valueCount; + m_scale=f.m_scale; + m_precision=f.m_precision; + m_bufferLength=f.m_bufferLength; + } + + private: + //exec::shared::FieldMetadata* m_pFieldMetadata; + std::string m_name; + common::MinorType m_minorType; + common::DataMode m_dataMode; + uint32_t m_valueCount; + uint32_t m_scale; + uint32_t m_precision; + uint32_t m_bufferLength; +}; + +class FieldBatch{ + public: + FieldBatch(const Drill::FieldMetadata& fmd, const ByteBuf_t data, size_t start, size_t length): + m_fieldMetadata(fmd){ + m_pValueVector=NULL; + m_pFieldData=new SlicedByteBuf(data, start, length); + } + + ~FieldBatch(){ + if(m_pFieldData!=NULL){ + delete m_pFieldData; m_pFieldData=NULL; + } + if(m_pValueVector!=NULL){ + delete m_pValueVector; m_pValueVector=NULL; + } + } + + // Loads the data into a Value Vector ofappropriate type + ret_t load(); + + const ValueVectorBase * getVector(){ + return m_pValueVector; + } + + private: + const Drill::FieldMetadata& m_fieldMetadata; + ValueVectorBase * m_pValueVector; + SlicedByteBuf * m_pFieldData; + +}; + +class ValueVectorFactory{ + public: + static ValueVectorBase* allocateValueVector(const Drill::FieldMetadata & fmd, SlicedByteBuf *b); +}; + +class DECLSPEC_DRILL_CLIENT RecordBatch{ + public: + RecordBatch(exec::user::QueryResult* pResult, ByteBuf_t b){ + m_pQueryResult=pResult; + m_pRecordBatchDef=&pResult->def(); + m_numRecords=pResult->row_count(); + m_buffer=b; + m_numFields=pResult->def().field_size(); + m_bHasSchemaChanged=false; + } + + ~RecordBatch(){ + m_buffer=NULL; + //free memory allocated for FieldBatch objects saved in m_fields; + for(std::vector<FieldBatch*>::iterator it = m_fields.begin(); it != m_fields.end(); ++it){ + delete *it; + } + m_fields.clear(); + for(std::vector<Drill::FieldMetadata*>::iterator it = m_fieldDefs.begin(); it != m_fieldDefs.end(); ++it){ + delete *it; + } + m_fieldDefs.clear(); + delete m_pQueryResult; + } + + // get the ith field metadata + const Drill::FieldMetadata& getFieldMetadata(size_t index){ + //return this->m_pRecordBatchDef->field(index); + return *(m_fieldDefs[index]); + } + + size_t getNumRecords(){ return m_numRecords;} + std::vector<FieldBatch*>& getFields(){ return m_fields;} + size_t getNumFields() { return m_pRecordBatchDef->field_size(); } + bool isLastChunk() { return m_pQueryResult->is_last_chunk(); } + + std::vector<Drill::FieldMetadata*>& getColumnDefs(){ return m_fieldDefs;} + + // + // build the record batch: i.e. fill up the value vectors from the buffer. + // On fetching the data from the server, the caller creates a RecordBatch + // object then calls build() to build the value vectors.The caller saves the + // Record Batch and is responsible for freeing both the RecordBatch and the + // raw buffer memory + // + ret_t build(); + + void print(std::ostream& s, size_t num); + + const ValueVectorBase * getVector(size_t index){ + return m_fields[index]->getVector(); + } + + void schemaChanged(bool b){ + this->m_bHasSchemaChanged=b; + } + + bool hasSchemaChanged(){ return m_bHasSchemaChanged;} + + #ifdef DEBUG + const exec::user::QueryResult* getQueryResult(){ return this->m_pQueryResult;} + #endif + private: + const exec::user::QueryResult* m_pQueryResult; + const exec::shared::RecordBatchDef* m_pRecordBatchDef; + ByteBuf_t m_buffer; + //build the current schema out of the field metadata + std::vector<Drill::FieldMetadata*> m_fieldDefs; + std::vector<FieldBatch*> m_fields; + size_t m_numFields; + size_t m_numRecords; + bool m_bHasSchemaChanged; + +}; // RecordBatch + +} // namespace + +#endif |