Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C048D200B84 for ; Tue, 6 Sep 2016 07:18:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BE95A160AD1; Tue, 6 Sep 2016 05:18:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 67386160ACC for ; Tue, 6 Sep 2016 07:18:04 +0200 (CEST) Received: (qmail 11698 invoked by uid 500); 6 Sep 2016 05:18:03 -0000 Mailing-List: contact commits-help@hawq.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hawq.incubator.apache.org Delivered-To: mailing list commits@hawq.incubator.apache.org Received: (qmail 11689 invoked by uid 99); 6 Sep 2016 05:18:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2016 05:18:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id C6A31C0115 for ; Tue, 6 Sep 2016 05:18:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id RprFgzOCW5xj for ; Tue, 6 Sep 2016 05:17:50 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id B44B85FD0A for ; Tue, 6 Sep 2016 05:17:49 +0000 (UTC) Received: (qmail 11150 invoked by uid 99); 6 Sep 2016 05:17:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2016 05:17:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F0701DF99D; Tue, 6 Sep 2016 05:17:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rlei@apache.org To: commits@hawq.incubator.apache.org Date: Tue, 06 Sep 2016 05:17:49 -0000 Message-Id: <3212ad6790af47d498ee700114c98e9d@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [02/51] [partial] incubator-hawq git commit: HAWQ-959. revert thrift build commands. archived-at: Tue, 06 Sep 2016 05:18:06 -0000 http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/TimerManager.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/TimerManager.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/TimerManager.h deleted file mode 100644 index 3946827..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/TimerManager.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 _THRIFT_CONCURRENCY_TIMERMANAGER_H_ -#define _THRIFT_CONCURRENCY_TIMERMANAGER_H_ 1 - -#include -#include -#include - -#include -#include -#include - -namespace apache { -namespace thrift { -namespace concurrency { - -/** - * Timer Manager - * - * This class dispatches timer tasks when they fall due. - * - * @version $Id:$ - */ -class TimerManager { - -public: - TimerManager(); - - virtual ~TimerManager(); - - virtual boost::shared_ptr threadFactory() const; - - virtual void threadFactory(boost::shared_ptr value); - - /** - * Starts the timer manager service - * - * @throws IllegalArgumentException Missing thread factory attribute - */ - virtual void start(); - - /** - * Stops the timer manager service - */ - virtual void stop(); - - virtual size_t taskCount() const; - - /** - * Adds a task to be executed at some time in the future by a worker thread. - * - * @param task The task to execute - * @param timeout Time in milliseconds to delay before executing task - */ - virtual void add(boost::shared_ptr task, int64_t timeout); - - /** - * Adds a task to be executed at some time in the future by a worker thread. - * - * @param task The task to execute - * @param timeout Absolute time in the future to execute task. - */ - virtual void add(boost::shared_ptr task, const struct THRIFT_TIMESPEC& timeout); - - /** - * Adds a task to be executed at some time in the future by a worker thread. - * - * @param task The task to execute - * @param timeout Absolute time in the future to execute task. - */ - virtual void add(boost::shared_ptr task, const struct timeval& timeout); - - /** - * Removes a pending task - * - * @throws NoSuchTaskException Specified task doesn't exist. It was either - * processed already or this call was made for a - * task that was never added to this timer - * - * @throws UncancellableTaskException Specified task is already being - * executed or has completed execution. - */ - virtual void remove(boost::shared_ptr task); - - enum STATE { UNINITIALIZED, STARTING, STARTED, STOPPING, STOPPED }; - - virtual STATE state() const; - -private: - boost::shared_ptr threadFactory_; - class Task; - friend class Task; - std::multimap > taskMap_; - size_t taskCount_; - Monitor monitor_; - STATE state_; - class Dispatcher; - friend class Dispatcher; - boost::shared_ptr dispatcher_; - boost::shared_ptr dispatcherThread_; - typedef std::multimap >::iterator task_iterator; - typedef std::pair task_range; -}; -} -} -} // apache::thrift::concurrency - -#endif // #ifndef _THRIFT_CONCURRENCY_TIMERMANAGER_H_ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/Util.cpp ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/Util.cpp b/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/Util.cpp deleted file mode 100644 index dd6d19f..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/Util.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -#include - -#include -#include - -#if defined(HAVE_SYS_TIME_H) -#include -#endif - -namespace apache { -namespace thrift { -namespace concurrency { - -int64_t Util::currentTimeTicks(int64_t ticksPerSec) { - int64_t result; - struct timeval now; - int ret = THRIFT_GETTIMEOFDAY(&now, NULL); - assert(ret == 0); - THRIFT_UNUSED_VARIABLE(ret); // squelching "unused variable" warning - toTicks(result, now, ticksPerSec); - return result; -} -} -} -} // apache::thrift::concurrency http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/Util.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/Util.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/Util.h deleted file mode 100644 index ba070b6..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/concurrency/Util.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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 _THRIFT_CONCURRENCY_UTIL_H_ -#define _THRIFT_CONCURRENCY_UTIL_H_ 1 - -#include -#include -#include -#include - -#ifdef HAVE_SYS_TIME_H -#include -#endif - -#include - -namespace apache { -namespace thrift { -namespace concurrency { - -/** - * Utility methods - * - * This class contains basic utility methods for converting time formats, - * and other common platform-dependent concurrency operations. - * It should not be included in API headers for other concurrency library - * headers, since it will, by definition, pull in all sorts of horrid - * platform dependent stuff. Rather it should be inluded directly in - * concurrency library implementation source. - * - * @version $Id:$ - */ -class Util { - - static const int64_t NS_PER_S = 1000000000LL; - static const int64_t US_PER_S = 1000000LL; - static const int64_t MS_PER_S = 1000LL; - - static const int64_t NS_PER_MS = NS_PER_S / MS_PER_S; - static const int64_t NS_PER_US = NS_PER_S / US_PER_S; - static const int64_t US_PER_MS = US_PER_S / MS_PER_S; - -public: - /** - * Converts millisecond timestamp into a THRIFT_TIMESPEC struct - * - * @param struct THRIFT_TIMESPEC& result - * @param time or duration in milliseconds - */ - static void toTimespec(struct THRIFT_TIMESPEC& result, int64_t value) { - result.tv_sec = value / MS_PER_S; // ms to s - result.tv_nsec = (value % MS_PER_S) * NS_PER_MS; // ms to ns - } - - static void toTimeval(struct timeval& result, int64_t value) { - result.tv_sec = static_cast(value / MS_PER_S); // ms to s - result.tv_usec = static_cast((value % MS_PER_S) * US_PER_MS); // ms to us - } - - static void toTicks(int64_t& result, - int64_t secs, - int64_t oldTicks, - int64_t oldTicksPerSec, - int64_t newTicksPerSec) { - result = secs * newTicksPerSec; - result += oldTicks * newTicksPerSec / oldTicksPerSec; - - int64_t oldPerNew = oldTicksPerSec / newTicksPerSec; - if (oldPerNew && ((oldTicks % oldPerNew) >= (oldPerNew / 2))) { - ++result; - } - } - /** - * Converts struct THRIFT_TIMESPEC to arbitrary-sized ticks since epoch - */ - static void toTicks(int64_t& result, const struct THRIFT_TIMESPEC& value, int64_t ticksPerSec) { - return toTicks(result, value.tv_sec, value.tv_nsec, NS_PER_S, ticksPerSec); - } - - /** - * Converts struct timeval to arbitrary-sized ticks since epoch - */ - static void toTicks(int64_t& result, const struct timeval& value, int64_t ticksPerSec) { - return toTicks(result, value.tv_sec, value.tv_usec, US_PER_S, ticksPerSec); - } - - /** - * Converts struct THRIFT_TIMESPEC to milliseconds - */ - static void toMilliseconds(int64_t& result, const struct THRIFT_TIMESPEC& value) { - return toTicks(result, value, MS_PER_S); - } - - /** - * Converts struct timeval to milliseconds - */ - static void toMilliseconds(int64_t& result, const struct timeval& value) { - return toTicks(result, value, MS_PER_S); - } - - /** - * Converts struct THRIFT_TIMESPEC to microseconds - */ - static void toUsec(int64_t& result, const struct THRIFT_TIMESPEC& value) { - return toTicks(result, value, US_PER_S); - } - - /** - * Converts struct timeval to microseconds - */ - static void toUsec(int64_t& result, const struct timeval& value) { - return toTicks(result, value, US_PER_S); - } - - /** - * Get current time as a number of arbitrary-size ticks from epoch - */ - static int64_t currentTimeTicks(int64_t ticksPerSec); - - /** - * Get current time as milliseconds from epoch - */ - static int64_t currentTime() { return currentTimeTicks(MS_PER_S); } - - /** - * Get current time as micros from epoch - */ - static int64_t currentTimeUsec() { return currentTimeTicks(US_PER_S); } -}; -} -} -} // apache::thrift::concurrency - -#endif // #ifndef _THRIFT_CONCURRENCY_UTIL_H_ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/cxxfunctional.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/cxxfunctional.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/cxxfunctional.h deleted file mode 100644 index dadaac3..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/cxxfunctional.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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 _THRIFT_CXXFUNCTIONAL_H_ -#define _THRIFT_CXXFUNCTIONAL_H_ 1 - -// clang-format off - -/** - * Loads from the 'right' location, depending - * on compiler and whether or not it's using C++03 with TR1 - * or C++11. - */ - -/* - * MSVC 10 and 11 have the stuff at . - * In MSVC 10 all of the implementations live in std::tr1. - * In MSVC 11 all of the implementations live in std, with aliases - * in std::tr1 to point to the ones in std. - */ -#ifdef _WIN32 - #define _THRIFT_USING_MICROSOFT_STDLIB 1 -#endif - -#ifdef __clang__ - /* Clang has two options, depending on standard library: - * - no -stdlib or -stdlib=libstdc++ set; uses GNU libstdc++. - * - * - -stdlib=libc++; uses LLVM libc++. - * , no 'std::tr1'. - * - * The compiler itself doesn't define anything differently - * depending on the value of -stdlib, but the library headers - * will set different preprocessor options. In order to check, - * though, we have to pull in some library header. - */ - #include - - /* With LLVM libc++, utility pulls in __config, which sets - _LIBCPP_VERSION. */ - #if defined(_LIBCPP_VERSION) - #define _THRIFT_USING_CLANG_LIBCXX 1 - - /* With GNU libstdc++, utility pulls in bits/c++config.h, - which sets __GLIBCXX__. */ - #elif defined(__GLIBCXX__) - #define _THRIFT_USING_GNU_LIBSTDCXX 1 - - /* No idea. */ - #else - #error Unable to detect which C++ standard library is in use. - #endif -#elif __GNUC__ - #define _THRIFT_USING_GNU_LIBSTDCXX 1 -#endif - -#if _THRIFT_USING_MICROSOFT_STDLIB - #include - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::tr1::function; - using ::std::tr1::bind; - - namespace placeholders { - using ::std::tr1::placeholders::_1; - using ::std::tr1::placeholders::_2; - using ::std::tr1::placeholders::_3; - using ::std::tr1::placeholders::_4; - using ::std::tr1::placeholders::_5; - using ::std::tr1::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx - -#elif _THRIFT_USING_CLANG_LIBCXX - #include - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::function; - using ::std::bind; - - namespace placeholders { - using ::std::placeholders::_1; - using ::std::placeholders::_2; - using ::std::placeholders::_3; - using ::std::placeholders::_4; - using ::std::placeholders::_5; - using ::std::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx - -#elif _THRIFT_USING_GNU_LIBSTDCXX - #include - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::tr1::function; - using ::std::tr1::bind; - - namespace placeholders { - using ::std::tr1::placeholders::_1; - using ::std::tr1::placeholders::_2; - using ::std::tr1::placeholders::_3; - using ::std::tr1::placeholders::_4; - using ::std::tr1::placeholders::_5; - using ::std::tr1::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx -#endif - - // Alias for thrift c++ compatibility namespace - namespace tcxx = apache::thrift::stdcxx; - -#endif // #ifndef _THRIFT_CXXFUNCTIONAL_H_ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/PeekProcessor.cpp ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/PeekProcessor.cpp b/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/PeekProcessor.cpp deleted file mode 100644 index 8c9a463..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/PeekProcessor.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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. - */ - -#include - -using namespace apache::thrift::transport; -using namespace apache::thrift::protocol; -using namespace apache::thrift; - -namespace apache { -namespace thrift { -namespace processor { - -PeekProcessor::PeekProcessor() { - memoryBuffer_.reset(new TMemoryBuffer()); - targetTransport_ = memoryBuffer_; -} -PeekProcessor::~PeekProcessor() { -} - -void PeekProcessor::initialize(boost::shared_ptr actualProcessor, - boost::shared_ptr protocolFactory, - boost::shared_ptr transportFactory) { - actualProcessor_ = actualProcessor; - pipedProtocol_ = protocolFactory->getProtocol(targetTransport_); - transportFactory_ = transportFactory; - transportFactory_->initializeTargetTransport(targetTransport_); -} - -boost::shared_ptr PeekProcessor::getPipedTransport(boost::shared_ptr in) { - return transportFactory_->getTransport(in); -} - -void PeekProcessor::setTargetTransport(boost::shared_ptr targetTransport) { - targetTransport_ = targetTransport; - if (boost::dynamic_pointer_cast(targetTransport_)) { - memoryBuffer_ = boost::dynamic_pointer_cast(targetTransport); - } else if (boost::dynamic_pointer_cast(targetTransport_)) { - memoryBuffer_ = boost::dynamic_pointer_cast( - boost::dynamic_pointer_cast(targetTransport_)->getTargetTransport()); - } - - if (!memoryBuffer_) { - throw TException( - "Target transport must be a TMemoryBuffer or a TPipedTransport with TMemoryBuffer"); - } -} - -bool PeekProcessor::process(boost::shared_ptr in, - boost::shared_ptr out, - void* connectionContext) { - - std::string fname; - TMessageType mtype; - int32_t seqid; - in->readMessageBegin(fname, mtype, seqid); - - if (mtype != T_CALL && mtype != T_ONEWAY) { - throw TException("Unexpected message type"); - } - - // Peek at the name - peekName(fname); - - TType ftype; - int16_t fid; - while (true) { - in->readFieldBegin(fname, ftype, fid); - if (ftype == T_STOP) { - break; - } - - // Peek at the variable - peek(in, ftype, fid); - in->readFieldEnd(); - } - in->readMessageEnd(); - in->getTransport()->readEnd(); - - // - // All the data is now in memoryBuffer_ and ready to be processed - // - - // Let's first take a peek at the full data in memory - uint8_t* buffer; - uint32_t size; - memoryBuffer_->getBuffer(&buffer, &size); - peekBuffer(buffer, size); - - // Done peeking at variables - peekEnd(); - - bool ret = actualProcessor_->process(pipedProtocol_, out, connectionContext); - memoryBuffer_->resetBuffer(); - return ret; -} - -void PeekProcessor::peekName(const std::string& fname) { - (void)fname; -} - -void PeekProcessor::peekBuffer(uint8_t* buffer, uint32_t size) { - (void)buffer; - (void)size; -} - -void PeekProcessor::peek(boost::shared_ptr in, TType ftype, int16_t fid) { - (void)fid; - in->skip(ftype); -} - -void PeekProcessor::peekEnd() { -} -} -} -} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/PeekProcessor.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/PeekProcessor.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/PeekProcessor.h deleted file mode 100644 index 21c5999..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/PeekProcessor.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 PEEKPROCESSOR_H -#define PEEKPROCESSOR_H - -#include -#include -#include -#include -#include -#include - -namespace apache { -namespace thrift { -namespace processor { - -/* - * Class for peeking at the raw data that is being processed by another processor - * and gives the derived class a chance to change behavior accordingly - * - */ -class PeekProcessor : public apache::thrift::TProcessor { - -public: - PeekProcessor(); - virtual ~PeekProcessor(); - - // Input here: actualProcessor - the underlying processor - // protocolFactory - the protocol factory used to wrap the memory buffer - // transportFactory - this TPipedTransportFactory is used to wrap the source transport - // via a call to getPipedTransport - void initialize( - boost::shared_ptr actualProcessor, - boost::shared_ptr protocolFactory, - boost::shared_ptr transportFactory); - - boost::shared_ptr getPipedTransport( - boost::shared_ptr in); - - void setTargetTransport(boost::shared_ptr targetTransport); - - virtual bool process(boost::shared_ptr in, - boost::shared_ptr out, - void* connectionContext); - - // The following three functions can be overloaded by child classes to - // achieve desired peeking behavior - virtual void peekName(const std::string& fname); - virtual void peekBuffer(uint8_t* buffer, uint32_t size); - virtual void peek(boost::shared_ptr in, - apache::thrift::protocol::TType ftype, - int16_t fid); - virtual void peekEnd(); - -private: - boost::shared_ptr actualProcessor_; - boost::shared_ptr pipedProtocol_; - boost::shared_ptr transportFactory_; - boost::shared_ptr memoryBuffer_; - boost::shared_ptr targetTransport_; -}; -} -} -} // apache::thrift::processor - -#endif http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/StatsProcessor.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/StatsProcessor.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/StatsProcessor.h deleted file mode 100644 index e8ca067..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/StatsProcessor.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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 STATSPROCESSOR_H -#define STATSPROCESSOR_H - -#include -#include -#include -#include - -namespace apache { -namespace thrift { -namespace processor { - -/* - * Class for keeping track of function call statistics and printing them if desired - * - */ -class StatsProcessor : public apache::thrift::TProcessor { -public: - StatsProcessor(bool print, bool frequency) : print_(print), frequency_(frequency) {} - virtual ~StatsProcessor(){}; - - virtual bool process(boost::shared_ptr piprot, - boost::shared_ptr poprot, - void* serverContext) { - - piprot_ = piprot; - - std::string fname; - apache::thrift::protocol::TMessageType mtype; - int32_t seqid; - - piprot_->readMessageBegin(fname, mtype, seqid); - if (mtype != apache::thrift::protocol::T_CALL && mtype != apache::thrift::protocol::T_ONEWAY) { - if (print_) { - printf("Unknown message type\n"); - } - throw apache::thrift::TException("Unexpected message type"); - } - if (print_) { - printf("%s (", fname.c_str()); - } - if (frequency_) { - if (frequency_map_.find(fname) != frequency_map_.end()) { - frequency_map_[fname]++; - } else { - frequency_map_[fname] = 1; - } - } - - apache::thrift::protocol::TType ftype; - int16_t fid; - - while (true) { - piprot_->readFieldBegin(fname, ftype, fid); - if (ftype == apache::thrift::protocol::T_STOP) { - break; - } - - printAndPassToBuffer(ftype); - if (print_) { - printf(", "); - } - } - - if (print_) { - printf("\b\b)\n"); - } - return true; - } - - const std::map& get_frequency_map() { return frequency_map_; } - -protected: - void printAndPassToBuffer(apache::thrift::protocol::TType ftype) { - switch (ftype) { - case apache::thrift::protocol::T_BOOL: { - bool boolv; - piprot_->readBool(boolv); - if (print_) { - printf("%d", boolv); - } - } break; - case apache::thrift::protocol::T_BYTE: { - int8_t bytev; - piprot_->readByte(bytev); - if (print_) { - printf("%d", bytev); - } - } break; - case apache::thrift::protocol::T_I16: { - int16_t i16; - piprot_->readI16(i16); - if (print_) { - printf("%d", i16); - } - } break; - case apache::thrift::protocol::T_I32: { - int32_t i32; - piprot_->readI32(i32); - if (print_) { - printf("%d", i32); - } - } break; - case apache::thrift::protocol::T_I64: { - int64_t i64; - piprot_->readI64(i64); - if (print_) { - printf("%ld", i64); - } - } break; - case apache::thrift::protocol::T_DOUBLE: { - double dub; - piprot_->readDouble(dub); - if (print_) { - printf("%f", dub); - } - } break; - case apache::thrift::protocol::T_STRING: { - std::string str; - piprot_->readString(str); - if (print_) { - printf("%s", str.c_str()); - } - } break; - case apache::thrift::protocol::T_STRUCT: { - std::string name; - int16_t fid; - apache::thrift::protocol::TType ftype; - piprot_->readStructBegin(name); - if (print_) { - printf("<"); - } - while (true) { - piprot_->readFieldBegin(name, ftype, fid); - if (ftype == apache::thrift::protocol::T_STOP) { - break; - } - printAndPassToBuffer(ftype); - if (print_) { - printf(","); - } - piprot_->readFieldEnd(); - } - piprot_->readStructEnd(); - if (print_) { - printf("\b>"); - } - } break; - case apache::thrift::protocol::T_MAP: { - apache::thrift::protocol::TType keyType; - apache::thrift::protocol::TType valType; - uint32_t i, size; - piprot_->readMapBegin(keyType, valType, size); - if (print_) { - printf("{"); - } - for (i = 0; i < size; i++) { - printAndPassToBuffer(keyType); - if (print_) { - printf("=>"); - } - printAndPassToBuffer(valType); - if (print_) { - printf(","); - } - } - piprot_->readMapEnd(); - if (print_) { - printf("\b}"); - } - } break; - case apache::thrift::protocol::T_SET: { - apache::thrift::protocol::TType elemType; - uint32_t i, size; - piprot_->readSetBegin(elemType, size); - if (print_) { - printf("{"); - } - for (i = 0; i < size; i++) { - printAndPassToBuffer(elemType); - if (print_) { - printf(","); - } - } - piprot_->readSetEnd(); - if (print_) { - printf("\b}"); - } - } break; - case apache::thrift::protocol::T_LIST: { - apache::thrift::protocol::TType elemType; - uint32_t i, size; - piprot_->readListBegin(elemType, size); - if (print_) { - printf("["); - } - for (i = 0; i < size; i++) { - printAndPassToBuffer(elemType); - if (print_) { - printf(","); - } - } - piprot_->readListEnd(); - if (print_) { - printf("\b]"); - } - } break; - default: - break; - } - } - - boost::shared_ptr piprot_; - std::map frequency_map_; - - bool print_; - bool frequency_; -}; -} -} -} // apache::thrift::processor - -#endif http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h deleted file mode 100644 index 0ef7261..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * 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 THRIFT_TMULTIPLEXEDPROCESSOR_H_ -#define THRIFT_TMULTIPLEXEDPROCESSOR_H_ 1 - -#include -#include -#include -#include - -namespace apache { -namespace thrift { -using boost::shared_ptr; - -namespace protocol { - -/** - * To be able to work with any protocol, we needed - * to allow them to call readMessageBegin() and get a TMessage in exactly - * the standard format, without the service name prepended to TMessage.name. - */ -class StoredMessageProtocol : public TProtocolDecorator { -public: - StoredMessageProtocol(shared_ptr _protocol, - const std::string& _name, - const TMessageType _type, - const int32_t _seqid) - : TProtocolDecorator(_protocol), name(_name), type(_type), seqid(_seqid) {} - - uint32_t readMessageBegin_virt(std::string& _name, TMessageType& _type, int32_t& _seqid) { - - _name = name; - _type = type; - _seqid = seqid; - - return 0; // (Normal TProtocol read functions return number of bytes read) - } - - std::string name; - TMessageType type; - int32_t seqid; -}; -} // namespace protocol - -/** - * TMultiplexedProcessor is a TProcessor allowing - * a single TServer to provide multiple services. - * - *

To do so, you instantiate the processor and then register additional - * processors with it, as shown in the following example:

- * - *
- * shared_ptr processor(new TMultiplexedProcessor()); - * - * processor->registerProcessor( - * "Calculator", - * shared_ptr( new CalculatorProcessor( - * shared_ptr( new CalculatorHandler())))); - * - * processor->registerProcessor( - * "WeatherReport", - * shared_ptr( new WeatherReportProcessor( - * shared_ptr( new WeatherReportHandler())))); - * - * shared_ptr transport(new TServerSocket(9090)); - * TSimpleServer server(processor, transport); - * - * server.serve(); - *
- */ -class TMultiplexedProcessor : public TProcessor { -public: - typedef std::map > services_t; - - /** - * 'Register' a service with this TMultiplexedProcessor. This - * allows us to broker requests to individual services by using the service - * name to select them at request time. - * - * \param [in] serviceName Name of a service, has to be identical to the name - * declared in the Thrift IDL, e.g. "WeatherReport". - * \param [in] processor Implementation of a service, usually referred to - * as "handlers", e.g. WeatherReportHandler, - * implementing WeatherReportIf interface. - */ - void registerProcessor(const std::string& serviceName, shared_ptr processor) { - services[serviceName] = processor; - } - - /** - * This implementation of process performs the following steps: - * - *
    - *
  1. Read the beginning of the message.
  2. - *
  3. Extract the service name from the message.
  4. - *
  5. Using the service name to locate the appropriate processor.
  6. - *
  7. Dispatch to the processor, with a decorated instance of TProtocol - * that allows readMessageBegin() to return the original TMessage.
  8. - *
- * - * \throws TException If the message type is not T_CALL or T_ONEWAY, if - * the service name was not found in the message, or if the service - * name was not found in the service map. - */ - bool process(shared_ptr in, - shared_ptr out, - void* connectionContext) { - std::string name; - protocol::TMessageType type; - int32_t seqid; - - // Use the actual underlying protocol (e.g. TBinaryProtocol) to read the - // message header. This pulls the message "off the wire", which we'll - // deal with at the end of this method. - in->readMessageBegin(name, type, seqid); - - if (type != protocol::T_CALL && type != protocol::T_ONEWAY) { - // Unexpected message type. - in->skip(::apache::thrift::protocol::T_STRUCT); - in->readMessageEnd(); - in->getTransport()->readEnd(); - const std::string msg("TMultiplexedProcessor: Unexpected message type"); - ::apache::thrift::TApplicationException - x(::apache::thrift::TApplicationException::PROTOCOL_ERROR, msg); - out->writeMessageBegin(name, ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(out.get()); - out->writeMessageEnd(); - out->getTransport()->writeEnd(); - out->getTransport()->flush(); - throw TException(msg); - } - - // Extract the service name - - boost::tokenizer > tok(name, boost::char_separator(":")); - - std::vector tokens; - std::copy(tok.begin(), tok.end(), std::back_inserter(tokens)); - - // A valid message should consist of two tokens: the service - // name and the name of the method to call. - if (tokens.size() == 2) { - // Search for a processor associated with this service name. - services_t::iterator it = services.find(tokens[0]); - - if (it != services.end()) { - shared_ptr processor = it->second; - // Let the processor registered for this service name - // process the message. - return processor - ->process(shared_ptr( - new protocol::StoredMessageProtocol(in, tokens[1], type, seqid)), - out, - connectionContext); - } else { - // Unknown service. - in->skip(::apache::thrift::protocol::T_STRUCT); - in->readMessageEnd(); - in->getTransport()->readEnd(); - - std::string msg("TMultiplexedProcessor: Unknown service: "); - msg += tokens[0]; - ::apache::thrift::TApplicationException - x(::apache::thrift::TApplicationException::PROTOCOL_ERROR, msg); - out->writeMessageBegin(name, ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(out.get()); - out->writeMessageEnd(); - out->getTransport()->writeEnd(); - out->getTransport()->flush(); - msg += ". Did you forget to call registerProcessor()?"; - throw TException(msg); - } - } - return false; - } - -private: - /** Map of service processor objects, indexed by service names. */ - services_t services; -}; -} -} - -#endif // THRIFT_TMULTIPLEXEDPROCESSOR_H_ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBase64Utils.cpp ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBase64Utils.cpp b/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBase64Utils.cpp deleted file mode 100644 index beb76eb..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBase64Utils.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/* - * 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. - */ - -#include - -#include - -using std::string; - -namespace apache { -namespace thrift { -namespace protocol { - -static const uint8_t* kBase64EncodeTable - = (const uint8_t*)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -void base64_encode(const uint8_t* in, uint32_t len, uint8_t* buf) { - buf[0] = kBase64EncodeTable[(in[0] >> 2) & 0x3f]; - if (len == 3) { - buf[1] = kBase64EncodeTable[((in[0] << 4) & 0x30) | ((in[1] >> 4) & 0x0f)]; - buf[2] = kBase64EncodeTable[((in[1] << 2) & 0x3c) | ((in[2] >> 6) & 0x03)]; - buf[3] = kBase64EncodeTable[in[2] & 0x3f]; - } else if (len == 2) { - buf[1] = kBase64EncodeTable[((in[0] << 4) & 0x30) | ((in[1] >> 4) & 0x0f)]; - buf[2] = kBase64EncodeTable[(in[1] << 2) & 0x3c]; - } else { // len == 1 - buf[1] = kBase64EncodeTable[(in[0] << 4) & 0x30]; - } -} - -static const uint8_t kBase64DecodeTable[256] = { - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0x3e, - 0xff, - 0xff, - 0xff, - 0x3f, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x3a, - 0x3b, - 0x3c, - 0x3d, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0x00, - 0x01, - 0x02, - 0x03, - 0x04, - 0x05, - 0x06, - 0x07, - 0x08, - 0x09, - 0x0a, - 0x0b, - 0x0c, - 0x0d, - 0x0e, - 0x0f, - 0x10, - 0x11, - 0x12, - 0x13, - 0x14, - 0x15, - 0x16, - 0x17, - 0x18, - 0x19, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0x1a, - 0x1b, - 0x1c, - 0x1d, - 0x1e, - 0x1f, - 0x20, - 0x21, - 0x22, - 0x23, - 0x24, - 0x25, - 0x26, - 0x27, - 0x28, - 0x29, - 0x2a, - 0x2b, - 0x2c, - 0x2d, - 0x2e, - 0x2f, - 0x30, - 0x31, - 0x32, - 0x33, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, -}; - -void base64_decode(uint8_t* buf, uint32_t len) { - buf[0] = (kBase64DecodeTable[buf[0]] << 2) | (kBase64DecodeTable[buf[1]] >> 4); - if (len > 2) { - buf[1] = ((kBase64DecodeTable[buf[1]] << 4) & 0xf0) | (kBase64DecodeTable[buf[2]] >> 2); - if (len > 3) { - buf[2] = ((kBase64DecodeTable[buf[2]] << 6) & 0xc0) | (kBase64DecodeTable[buf[3]]); - } - } -} -} -} -} // apache::thrift::protocol http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBase64Utils.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBase64Utils.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBase64Utils.h deleted file mode 100644 index 1ea6744..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBase64Utils.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 _THRIFT_PROTOCOL_TBASE64UTILS_H_ -#define _THRIFT_PROTOCOL_TBASE64UTILS_H_ - -#include -#include - -namespace apache { -namespace thrift { -namespace protocol { - -// in must be at least len bytes -// len must be 1, 2, or 3 -// buf must be a buffer of at least 4 bytes and may not overlap in -// the data is not padded with '='; the caller can do this if desired -void base64_encode(const uint8_t* in, uint32_t len, uint8_t* buf); - -// buf must be a buffer of at least 4 bytes and contain base64 encoded values -// buf will be changed to contain output bytes -// len is number of bytes to consume from input (must be 2, 3, or 4) -// no '=' padding should be included in the input -void base64_decode(uint8_t* buf, uint32_t len); -} -} -} // apache::thrift::protocol - -#endif // #define _THRIFT_PROTOCOL_TBASE64UTILS_H_ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBinaryProtocol.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBinaryProtocol.h deleted file mode 100644 index e0650cf..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBinaryProtocol.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - * 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 _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ -#define _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ 1 - -#include -#include - -#include - -namespace apache { -namespace thrift { -namespace protocol { - -/** - * The default binary protocol for thrift. Writes all data in a very basic - * binary format, essentially just spitting out the raw bytes. - * - */ -template -class TBinaryProtocolT : public TVirtualProtocol > { -protected: - static const int32_t VERSION_MASK = ((int32_t)0xffff0000); - static const int32_t VERSION_1 = ((int32_t)0x80010000); - // VERSION_2 (0x80020000) was taken by TDenseProtocol (which has since been removed) - -public: - TBinaryProtocolT(boost::shared_ptr trans) - : TVirtualProtocol >(trans), - trans_(trans.get()), - string_limit_(0), - container_limit_(0), - strict_read_(false), - strict_write_(true) {} - - TBinaryProtocolT(boost::shared_ptr trans, - int32_t string_limit, - int32_t container_limit, - bool strict_read, - bool strict_write) - : TVirtualProtocol >(trans), - trans_(trans.get()), - string_limit_(string_limit), - container_limit_(container_limit), - strict_read_(strict_read), - strict_write_(strict_write) {} - - void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; } - - void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; } - - void setStrict(bool strict_read, bool strict_write) { - strict_read_ = strict_read; - strict_write_ = strict_write; - } - - /** - * Writing functions. - */ - - /*ol*/ uint32_t writeMessageBegin(const std::string& name, - const TMessageType messageType, - const int32_t seqid); - - /*ol*/ uint32_t writeMessageEnd(); - - inline uint32_t writeStructBegin(const char* name); - - inline uint32_t writeStructEnd(); - - inline uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId); - - inline uint32_t writeFieldEnd(); - - inline uint32_t writeFieldStop(); - - inline uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size); - - inline uint32_t writeMapEnd(); - - inline uint32_t writeListBegin(const TType elemType, const uint32_t size); - - inline uint32_t writeListEnd(); - - inline uint32_t writeSetBegin(const TType elemType, const uint32_t size); - - inline uint32_t writeSetEnd(); - - inline uint32_t writeBool(const bool value); - - inline uint32_t writeByte(const int8_t byte); - - inline uint32_t writeI16(const int16_t i16); - - inline uint32_t writeI32(const int32_t i32); - - inline uint32_t writeI64(const int64_t i64); - - inline uint32_t writeDouble(const double dub); - - template - inline uint32_t writeString(const StrType& str); - - inline uint32_t writeBinary(const std::string& str); - - /** - * Reading functions - */ - - /*ol*/ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid); - - /*ol*/ uint32_t readMessageEnd(); - - inline uint32_t readStructBegin(std::string& name); - - inline uint32_t readStructEnd(); - - inline uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId); - - inline uint32_t readFieldEnd(); - - inline uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size); - - inline uint32_t readMapEnd(); - - inline uint32_t readListBegin(TType& elemType, uint32_t& size); - - inline uint32_t readListEnd(); - - inline uint32_t readSetBegin(TType& elemType, uint32_t& size); - - inline uint32_t readSetEnd(); - - inline uint32_t readBool(bool& value); - // Provide the default readBool() implementation for std::vector - using TVirtualProtocol >::readBool; - - inline uint32_t readByte(int8_t& byte); - - inline uint32_t readI16(int16_t& i16); - - inline uint32_t readI32(int32_t& i32); - - inline uint32_t readI64(int64_t& i64); - - inline uint32_t readDouble(double& dub); - - template - inline uint32_t readString(StrType& str); - - inline uint32_t readBinary(std::string& str); - -protected: - template - uint32_t readStringBody(StrType& str, int32_t sz); - - Transport_* trans_; - - int32_t string_limit_; - int32_t container_limit_; - - // Enforce presence of version identifier - bool strict_read_; - bool strict_write_; -}; - -typedef TBinaryProtocolT TBinaryProtocol; -typedef TBinaryProtocolT TLEBinaryProtocol; - -/** - * Constructs binary protocol handlers - */ -template -class TBinaryProtocolFactoryT : public TProtocolFactory { -public: - TBinaryProtocolFactoryT() - : string_limit_(0), container_limit_(0), strict_read_(false), strict_write_(true) {} - - TBinaryProtocolFactoryT(int32_t string_limit, - int32_t container_limit, - bool strict_read, - bool strict_write) - : string_limit_(string_limit), - container_limit_(container_limit), - strict_read_(strict_read), - strict_write_(strict_write) {} - - virtual ~TBinaryProtocolFactoryT() {} - - void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; } - - void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; } - - void setStrict(bool strict_read, bool strict_write) { - strict_read_ = strict_read; - strict_write_ = strict_write; - } - - boost::shared_ptr getProtocol(boost::shared_ptr trans) { - boost::shared_ptr specific_trans = boost::dynamic_pointer_cast(trans); - TProtocol* prot; - if (specific_trans) { - prot = new TBinaryProtocolT( - specific_trans, - string_limit_, - container_limit_, - strict_read_, - strict_write_); - } else { - prot = new TBinaryProtocolT( - trans, - string_limit_, - container_limit_, - strict_read_, - strict_write_); - } - - return boost::shared_ptr(prot); - } - -private: - int32_t string_limit_; - int32_t container_limit_; - bool strict_read_; - bool strict_write_; -}; - -typedef TBinaryProtocolFactoryT TBinaryProtocolFactory; -typedef TBinaryProtocolFactoryT TLEBinaryProtocolFactory; -} -} -} // apache::thrift::protocol - -#include - -#endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc b/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc deleted file mode 100644 index ae350df..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc +++ /dev/null @@ -1,452 +0,0 @@ -/* - * 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 _THRIFT_PROTOCOL_TBINARYPROTOCOL_TCC_ -#define _THRIFT_PROTOCOL_TBINARYPROTOCOL_TCC_ 1 - -#include - -#include - -namespace apache { -namespace thrift { -namespace protocol { - -template -uint32_t TBinaryProtocolT::writeMessageBegin(const std::string& name, - const TMessageType messageType, - const int32_t seqid) { - if (this->strict_write_) { - int32_t version = (VERSION_1) | ((int32_t)messageType); - uint32_t wsize = 0; - wsize += writeI32(version); - wsize += writeString(name); - wsize += writeI32(seqid); - return wsize; - } else { - uint32_t wsize = 0; - wsize += writeString(name); - wsize += writeByte((int8_t)messageType); - wsize += writeI32(seqid); - return wsize; - } -} - -template -uint32_t TBinaryProtocolT::writeMessageEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::writeStructBegin(const char* name) { - (void)name; - return 0; -} - -template -uint32_t TBinaryProtocolT::writeStructEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::writeFieldBegin(const char* name, - const TType fieldType, - const int16_t fieldId) { - (void)name; - uint32_t wsize = 0; - wsize += writeByte((int8_t)fieldType); - wsize += writeI16(fieldId); - return wsize; -} - -template -uint32_t TBinaryProtocolT::writeFieldEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::writeFieldStop() { - return writeByte((int8_t)T_STOP); -} - -template -uint32_t TBinaryProtocolT::writeMapBegin(const TType keyType, - const TType valType, - const uint32_t size) { - uint32_t wsize = 0; - wsize += writeByte((int8_t)keyType); - wsize += writeByte((int8_t)valType); - wsize += writeI32((int32_t)size); - return wsize; -} - -template -uint32_t TBinaryProtocolT::writeMapEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::writeListBegin(const TType elemType, const uint32_t size) { - uint32_t wsize = 0; - wsize += writeByte((int8_t)elemType); - wsize += writeI32((int32_t)size); - return wsize; -} - -template -uint32_t TBinaryProtocolT::writeListEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::writeSetBegin(const TType elemType, const uint32_t size) { - uint32_t wsize = 0; - wsize += writeByte((int8_t)elemType); - wsize += writeI32((int32_t)size); - return wsize; -} - -template -uint32_t TBinaryProtocolT::writeSetEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::writeBool(const bool value) { - uint8_t tmp = value ? 1 : 0; - this->trans_->write(&tmp, 1); - return 1; -} - -template -uint32_t TBinaryProtocolT::writeByte(const int8_t byte) { - this->trans_->write((uint8_t*)&byte, 1); - return 1; -} - -template -uint32_t TBinaryProtocolT::writeI16(const int16_t i16) { - int16_t net = (int16_t)ByteOrder_::toWire16(i16); - this->trans_->write((uint8_t*)&net, 2); - return 2; -} - -template -uint32_t TBinaryProtocolT::writeI32(const int32_t i32) { - int32_t net = (int32_t)ByteOrder_::toWire32(i32); - this->trans_->write((uint8_t*)&net, 4); - return 4; -} - -template -uint32_t TBinaryProtocolT::writeI64(const int64_t i64) { - int64_t net = (int64_t)ByteOrder_::toWire64(i64); - this->trans_->write((uint8_t*)&net, 8); - return 8; -} - -template -uint32_t TBinaryProtocolT::writeDouble(const double dub) { - BOOST_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t)); - BOOST_STATIC_ASSERT(std::numeric_limits::is_iec559); - - uint64_t bits = bitwise_cast(dub); - bits = ByteOrder_::toWire64(bits); - this->trans_->write((uint8_t*)&bits, 8); - return 8; -} - -template -template -uint32_t TBinaryProtocolT::writeString(const StrType& str) { - if (str.size() > static_cast((std::numeric_limits::max)())) - throw TProtocolException(TProtocolException::SIZE_LIMIT); - uint32_t size = static_cast(str.size()); - uint32_t result = writeI32((int32_t)size); - if (size > 0) { - this->trans_->write((uint8_t*)str.data(), size); - } - return result + size; -} - -template -uint32_t TBinaryProtocolT::writeBinary(const std::string& str) { - return TBinaryProtocolT::writeString(str); -} - -/** - * Reading functions - */ - -template -uint32_t TBinaryProtocolT::readMessageBegin(std::string& name, - TMessageType& messageType, - int32_t& seqid) { - uint32_t result = 0; - int32_t sz; - result += readI32(sz); - - if (sz < 0) { - // Check for correct version number - int32_t version = sz & VERSION_MASK; - if (version != VERSION_1) { - throw TProtocolException(TProtocolException::BAD_VERSION, "Bad version identifier"); - } - messageType = (TMessageType)(sz & 0x000000ff); - result += readString(name); - result += readI32(seqid); - } else { - if (this->strict_read_) { - throw TProtocolException(TProtocolException::BAD_VERSION, - "No version identifier... old protocol client in strict mode?"); - } else { - // Handle pre-versioned input - int8_t type; - result += readStringBody(name, sz); - result += readByte(type); - messageType = (TMessageType)type; - result += readI32(seqid); - } - } - return result; -} - -template -uint32_t TBinaryProtocolT::readMessageEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::readStructBegin(std::string& name) { - name = ""; - return 0; -} - -template -uint32_t TBinaryProtocolT::readStructEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::readFieldBegin(std::string& name, - TType& fieldType, - int16_t& fieldId) { - (void)name; - uint32_t result = 0; - int8_t type; - result += readByte(type); - fieldType = (TType)type; - if (fieldType == T_STOP) { - fieldId = 0; - return result; - } - result += readI16(fieldId); - return result; -} - -template -uint32_t TBinaryProtocolT::readFieldEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::readMapBegin(TType& keyType, - TType& valType, - uint32_t& size) { - int8_t k, v; - uint32_t result = 0; - int32_t sizei; - result += readByte(k); - keyType = (TType)k; - result += readByte(v); - valType = (TType)v; - result += readI32(sizei); - if (sizei < 0) { - throw TProtocolException(TProtocolException::NEGATIVE_SIZE); - } else if (this->container_limit_ && sizei > this->container_limit_) { - throw TProtocolException(TProtocolException::SIZE_LIMIT); - } - size = (uint32_t)sizei; - return result; -} - -template -uint32_t TBinaryProtocolT::readMapEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::readListBegin(TType& elemType, uint32_t& size) { - int8_t e; - uint32_t result = 0; - int32_t sizei; - result += readByte(e); - elemType = (TType)e; - result += readI32(sizei); - if (sizei < 0) { - throw TProtocolException(TProtocolException::NEGATIVE_SIZE); - } else if (this->container_limit_ && sizei > this->container_limit_) { - throw TProtocolException(TProtocolException::SIZE_LIMIT); - } - size = (uint32_t)sizei; - return result; -} - -template -uint32_t TBinaryProtocolT::readListEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::readSetBegin(TType& elemType, uint32_t& size) { - int8_t e; - uint32_t result = 0; - int32_t sizei; - result += readByte(e); - elemType = (TType)e; - result += readI32(sizei); - if (sizei < 0) { - throw TProtocolException(TProtocolException::NEGATIVE_SIZE); - } else if (this->container_limit_ && sizei > this->container_limit_) { - throw TProtocolException(TProtocolException::SIZE_LIMIT); - } - size = (uint32_t)sizei; - return result; -} - -template -uint32_t TBinaryProtocolT::readSetEnd() { - return 0; -} - -template -uint32_t TBinaryProtocolT::readBool(bool& value) { - uint8_t b[1]; - this->trans_->readAll(b, 1); - value = *(int8_t*)b != 0; - return 1; -} - -template -uint32_t TBinaryProtocolT::readByte(int8_t& byte) { - uint8_t b[1]; - this->trans_->readAll(b, 1); - byte = *(int8_t*)b; - return 1; -} - -template -uint32_t TBinaryProtocolT::readI16(int16_t& i16) { - union bytes { - uint8_t b[2]; - int16_t all; - } theBytes; - this->trans_->readAll(theBytes.b, 2); - i16 = (int16_t)ByteOrder_::fromWire16(theBytes.all); - return 2; -} - -template -uint32_t TBinaryProtocolT::readI32(int32_t& i32) { - union bytes { - uint8_t b[4]; - int32_t all; - } theBytes; - this->trans_->readAll(theBytes.b, 4); - i32 = (int32_t)ByteOrder_::fromWire32(theBytes.all); - return 4; -} - -template -uint32_t TBinaryProtocolT::readI64(int64_t& i64) { - union bytes { - uint8_t b[8]; - int64_t all; - } theBytes; - this->trans_->readAll(theBytes.b, 8); - i64 = (int64_t)ByteOrder_::fromWire64(theBytes.all); - return 8; -} - -template -uint32_t TBinaryProtocolT::readDouble(double& dub) { - BOOST_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t)); - BOOST_STATIC_ASSERT(std::numeric_limits::is_iec559); - - union bytes { - uint8_t b[8]; - uint64_t all; - } theBytes; - this->trans_->readAll(theBytes.b, 8); - theBytes.all = ByteOrder_::fromWire64(theBytes.all); - dub = bitwise_cast(theBytes.all); - return 8; -} - -template -template -uint32_t TBinaryProtocolT::readString(StrType& str) { - uint32_t result; - int32_t size; - result = readI32(size); - return result + readStringBody(str, size); -} - -template -uint32_t TBinaryProtocolT::readBinary(std::string& str) { - return TBinaryProtocolT::readString(str); -} - -template -template -uint32_t TBinaryProtocolT::readStringBody(StrType& str, int32_t size) { - uint32_t result = 0; - - // Catch error cases - if (size < 0) { - throw TProtocolException(TProtocolException::NEGATIVE_SIZE); - } - if (this->string_limit_ > 0 && size > this->string_limit_) { - throw TProtocolException(TProtocolException::SIZE_LIMIT); - } - - // Catch empty string case - if (size == 0) { - str.clear(); - return result; - } - - // Try to borrow first - const uint8_t* borrow_buf; - uint32_t got = size; - if ((borrow_buf = this->trans_->borrow(NULL, &got))) { - str.assign((const char*)borrow_buf, size); - this->trans_->consume(size); - return size; - } - - str.resize(size); - this->trans_->readAll(reinterpret_cast(&str[0]), size); - return (uint32_t)size; -} -} -} -} // apache::thrift::protocol - -#endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_TCC_ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TCompactProtocol.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TCompactProtocol.h deleted file mode 100644 index 5b7ade2..0000000 --- a/depends/thirdparty/thrift/lib/cpp/src/thrift/protocol/TCompactProtocol.h +++ /dev/null @@ -1,265 +0,0 @@ -/* - * 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 _THRIFT_PROTOCOL_TCOMPACTPROTOCOL_H_ -#define _THRIFT_PROTOCOL_TCOMPACTPROTOCOL_H_ 1 - -#include - -#include -#include - -namespace apache { -namespace thrift { -namespace protocol { - -/** - * C++ Implementation of the Compact Protocol as described in THRIFT-110 - */ -template -class TCompactProtocolT : public TVirtualProtocol > { - -protected: - static const int8_t PROTOCOL_ID = (int8_t)0x82u; - static const int8_t VERSION_N = 1; - static const int8_t VERSION_MASK = 0x1f; // 0001 1111 - static const int8_t TYPE_MASK = (int8_t)0xE0u; // 1110 0000 - static const int8_t TYPE_BITS = 0x07; // 0000 0111 - static const int32_t TYPE_SHIFT_AMOUNT = 5; - - Transport_* trans_; - - /** - * (Writing) If we encounter a boolean field begin, save the TField here - * so it can have the value incorporated. - */ - struct { - const char* name; - TType fieldType; - int16_t fieldId; - } booleanField_; - - /** - * (Reading) If we read a field header, and it's a boolean field, save - * the boolean value here so that readBool can use it. - */ - struct { - bool hasBoolValue; - bool boolValue; - } boolValue_; - - /** - * Used to keep track of the last field for the current and previous structs, - * so we can do the delta stuff. - */ - - std::stack lastField_; - int16_t lastFieldId_; - -public: - TCompactProtocolT(boost::shared_ptr trans) - : TVirtualProtocol >(trans), - trans_(trans.get()), - lastFieldId_(0), - string_limit_(0), - string_buf_(NULL), - string_buf_size_(0), - container_limit_(0) { - booleanField_.name = NULL; - boolValue_.hasBoolValue = false; - } - - TCompactProtocolT(boost::shared_ptr trans, - int32_t string_limit, - int32_t container_limit) - : TVirtualProtocol >(trans), - trans_(trans.get()), - lastFieldId_(0), - string_limit_(string_limit), - string_buf_(NULL), - string_buf_size_(0), - container_limit_(container_limit) { - booleanField_.name = NULL; - boolValue_.hasBoolValue = false; - } - - ~TCompactProtocolT() { free(string_buf_); } - - /** - * Writing functions - */ - - virtual uint32_t writeMessageBegin(const std::string& name, - const TMessageType messageType, - const int32_t seqid); - - uint32_t writeStructBegin(const char* name); - - uint32_t writeStructEnd(); - - uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId); - - uint32_t writeFieldStop(); - - uint32_t writeListBegin(const TType elemType, const uint32_t size); - - uint32_t writeSetBegin(const TType elemType, const uint32_t size); - - virtual uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size); - - uint32_t writeBool(const bool value); - - uint32_t writeByte(const int8_t byte); - - uint32_t writeI16(const int16_t i16); - - uint32_t writeI32(const int32_t i32); - - uint32_t writeI64(const int64_t i64); - - uint32_t writeDouble(const double dub); - - uint32_t writeString(const std::string& str); - - uint32_t writeBinary(const std::string& str); - - /** - * These methods are called by structs, but don't actually have any wired - * output or purpose - */ - virtual uint32_t writeMessageEnd() { return 0; } - uint32_t writeMapEnd() { return 0; } - uint32_t writeListEnd() { return 0; } - uint32_t writeSetEnd() { return 0; } - uint32_t writeFieldEnd() { return 0; } - -protected: - int32_t writeFieldBeginInternal(const char* name, - const TType fieldType, - const int16_t fieldId, - int8_t typeOverride); - uint32_t writeCollectionBegin(const TType elemType, int32_t size); - uint32_t writeVarint32(uint32_t n); - uint32_t writeVarint64(uint64_t n); - uint64_t i64ToZigzag(const int64_t l); - uint32_t i32ToZigzag(const int32_t n); - inline int8_t getCompactType(const TType ttype); - -public: - uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid); - - uint32_t readStructBegin(std::string& name); - - uint32_t readStructEnd(); - - uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId); - - uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size); - - uint32_t readListBegin(TType& elemType, uint32_t& size); - - uint32_t readSetBegin(TType& elemType, uint32_t& size); - - uint32_t readBool(bool& value); - // Provide the default readBool() implementation for std::vector - using TVirtualProtocol >::readBool; - - uint32_t readByte(int8_t& byte); - - uint32_t readI16(int16_t& i16); - - uint32_t readI32(int32_t& i32); - - uint32_t readI64(int64_t& i64); - - uint32_t readDouble(double& dub); - - uint32_t readString(std::string& str); - - uint32_t readBinary(std::string& str); - - /* - *These methods are here for the struct to call, but don't have any wire - * encoding. - */ - uint32_t readMessageEnd() { return 0; } - uint32_t readFieldEnd() { return 0; } - uint32_t readMapEnd() { return 0; } - uint32_t readListEnd() { return 0; } - uint32_t readSetEnd() { return 0; } - -protected: - uint32_t readVarint32(int32_t& i32); - uint32_t readVarint64(int64_t& i64); - int32_t zigzagToI32(uint32_t n); - int64_t zigzagToI64(uint64_t n); - TType getTType(int8_t type); - - // Buffer for reading strings, save for the lifetime of the protocol to - // avoid memory churn allocating memory on every string read - int32_t string_limit_; - uint8_t* string_buf_; - int32_t string_buf_size_; - int32_t container_limit_; -}; - -typedef TCompactProtocolT TCompactProtocol; - -/** - * Constructs compact protocol handlers - */ -template -class TCompactProtocolFactoryT : public TProtocolFactory { -public: - TCompactProtocolFactoryT() : string_limit_(0), container_limit_(0) {} - - TCompactProtocolFactoryT(int32_t string_limit, int32_t container_limit) - : string_limit_(string_limit), container_limit_(container_limit) {} - - virtual ~TCompactProtocolFactoryT() {} - - void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; } - - void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; } - - boost::shared_ptr getProtocol(boost::shared_ptr trans) { - boost::shared_ptr specific_trans = boost::dynamic_pointer_cast(trans); - TProtocol* prot; - if (specific_trans) { - prot = new TCompactProtocolT(specific_trans, string_limit_, container_limit_); - } else { - prot = new TCompactProtocol(trans, string_limit_, container_limit_); - } - - return boost::shared_ptr(prot); - } - -private: - int32_t string_limit_; - int32_t container_limit_; -}; - -typedef TCompactProtocolFactoryT TCompactProtocolFactory; -} -} -} // apache::thrift::protocol - -#include - -#endif