You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by rl...@apache.org on 2016/05/18 02:50:21 UTC
[08/51] [abbrv] [partial] incubator-hawq git commit: HAWQ-735. Import
thrift-0.9.3 into depends/thirdparty/thrift folder
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/thrift_c_glib.pc.in
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/thrift_c_glib.pc.in b/depends/thirdparty/thrift/lib/c_glib/thrift_c_glib.pc.in
new file mode 100644
index 0000000..568c7a2
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/thrift_c_glib.pc.in
@@ -0,0 +1,30 @@
+#
+# 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.
+#
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Thrift
+Description: Thrift C API
+Version: @VERSION@
+Requires: glib-2.0 gobject-2.0
+Libs: -L${libdir} -lthrift_c_glib
+Cflags: -I${includedir}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/README.md
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/README.md b/depends/thirdparty/thrift/lib/cocoa/README.md
new file mode 100644
index 0000000..bbe3c93
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/README.md
@@ -0,0 +1,21 @@
+Thrift Cocoa Software Library
+
+License
+=======
+
+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.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/coding_standards.md
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/coding_standards.md b/depends/thirdparty/thrift/lib/cocoa/coding_standards.md
new file mode 100644
index 0000000..fa0390b
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/coding_standards.md
@@ -0,0 +1 @@
+Please follow [General Coding Standards](/doc/coding_standards.md)
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TApplicationException.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TApplicationException.h b/depends/thirdparty/thrift/lib/cocoa/src/TApplicationException.h
new file mode 100644
index 0000000..7b027d6
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TApplicationException.h
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+#import "TException.h"
+#import "TProtocol.h"
+
+enum {
+ TApplicationException_UNKNOWN = 0,
+ TApplicationException_UNKNOWN_METHOD = 1,
+ TApplicationException_INVALID_MESSAGE_TYPE = 2,
+ TApplicationException_WRONG_METHOD_NAME = 3,
+ TApplicationException_BAD_SEQUENCE_ID = 4,
+ TApplicationException_MISSING_RESULT = 5,
+ TApplicationException_INTERNAL_ERROR = 6,
+ TApplicationException_PROTOCOL_ERROR = 7,
+ TApplicationException_INVALID_TRANSFORM = 8,
+ TApplicationException_INVALID_PROTOCOL = 9,
+ TApplicationException_UNSUPPORTED_CLIENT_TYPE = 10
+};
+
+// FIXME
+@interface TApplicationException : TException {
+ int mType;
+}
+
++ (TApplicationException *) read: (id <TProtocol>) protocol;
+
+- (void) write: (id <TProtocol>) protocol;
+
++ (TApplicationException *) exceptionWithType: (int) type
+ reason: (NSString *) message;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TApplicationException.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TApplicationException.m b/depends/thirdparty/thrift/lib/cocoa/src/TApplicationException.m
new file mode 100644
index 0000000..974dfc5
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TApplicationException.m
@@ -0,0 +1,146 @@
+/*
+ * 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.
+ */
+
+#import "TApplicationException.h"
+#import "TProtocolUtil.h"
+#import "TObjective-C.h"
+
+@implementation TApplicationException
+
+- (id) initWithType: (int) type
+ reason: (NSString *) reason
+{
+ mType = type;
+
+ NSString * name;
+ switch (type) {
+ case TApplicationException_UNKNOWN_METHOD:
+ name = @"Unknown method";
+ break;
+ case TApplicationException_INVALID_MESSAGE_TYPE:
+ name = @"Invalid message type";
+ break;
+ case TApplicationException_WRONG_METHOD_NAME:
+ name = @"Wrong method name";
+ break;
+ case TApplicationException_BAD_SEQUENCE_ID:
+ name = @"Bad sequence ID";
+ break;
+ case TApplicationException_MISSING_RESULT:
+ name = @"Missing result";
+ break;
+ case TApplicationException_INTERNAL_ERROR:
+ name = @"Internal error";
+ break;
+ case TApplicationException_PROTOCOL_ERROR:
+ name = @"Protocol error";
+ break;
+ case TApplicationException_INVALID_TRANSFORM:
+ name = @"Invalid transform";
+ break;
+ case TApplicationException_INVALID_PROTOCOL:
+ name = @"Invalid protocol";
+ break;
+ case TApplicationException_UNSUPPORTED_CLIENT_TYPE:
+ name = @"Unsupported client type";
+ break;
+ default:
+ name = @"Unknown";
+ break;
+ }
+
+ self = [super initWithName: name reason: reason userInfo: nil];
+ return self;
+}
+
+
++ (TApplicationException *) read: (id <TProtocol>) protocol
+{
+ NSString * reason = nil;
+ int type = TApplicationException_UNKNOWN;
+ int fieldType;
+ int fieldID;
+
+ [protocol readStructBeginReturningName: NULL];
+
+ while (true) {
+ [protocol readFieldBeginReturningName: NULL
+ type: &fieldType
+ fieldID: &fieldID];
+ if (fieldType == TType_STOP) {
+ break;
+ }
+ switch (fieldID) {
+ case 1:
+ if (fieldType == TType_STRING) {
+ reason = [protocol readString];
+ } else {
+ [TProtocolUtil skipType: fieldType onProtocol: protocol];
+ }
+ break;
+ case 2:
+ if (fieldType == TType_I32) {
+ type = [protocol readI32];
+ } else {
+ [TProtocolUtil skipType: fieldType onProtocol: protocol];
+ }
+ break;
+ default:
+ [TProtocolUtil skipType: fieldType onProtocol: protocol];
+ break;
+ }
+ [protocol readFieldEnd];
+ }
+ [protocol readStructEnd];
+
+ return [TApplicationException exceptionWithType: type reason: reason];
+}
+
+
+- (void) write: (id <TProtocol>) protocol
+{
+ [protocol writeStructBeginWithName: @"TApplicationException"];
+
+ if ([self reason] != nil) {
+ [protocol writeFieldBeginWithName: @"message"
+ type: TType_STRING
+ fieldID: 1];
+ [protocol writeString: [self reason]];
+ [protocol writeFieldEnd];
+ }
+
+ [protocol writeFieldBeginWithName: @"type"
+ type: TType_I32
+ fieldID: 2];
+ [protocol writeI32: mType];
+ [protocol writeFieldEnd];
+
+ [protocol writeFieldStop];
+ [protocol writeStructEnd];
+}
+
+
++ (TApplicationException *) exceptionWithType: (int) type
+ reason: (NSString *) reason
+{
+ return [[[TApplicationException alloc] initWithType: type
+ reason: reason] autorelease_stub];
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TBaseClient.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TBaseClient.h b/depends/thirdparty/thrift/lib/cocoa/src/TBaseClient.h
new file mode 100644
index 0000000..12944b1
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TBaseClient.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#import "TProtocol.h"
+#import "TApplicationException.h"
+
+@interface TBaseClient : NSObject {
+ id <TProtocol> inProtocol;
+ id <TProtocol> outProtocol;
+}
+
+- (TApplicationException *)checkIncomingMessageException;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TBaseClient.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TBaseClient.m b/depends/thirdparty/thrift/lib/cocoa/src/TBaseClient.m
new file mode 100644
index 0000000..d15f9d3
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TBaseClient.m
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+#import "TBaseClient.h"
+#import "TApplicationException.h"
+#import "TObjective-C.h"
+
+@implementation TBaseClient
+
+- (void) dealloc
+{
+ [inProtocol release_stub];
+ [outProtocol release_stub];
+ [super dealloc_stub];
+}
+
+- (TApplicationException *)checkIncomingMessageException
+{
+ int msgType = 0;
+ [inProtocol readMessageBeginReturningName: nil type: &msgType sequenceID: NULL];
+ if (msgType == TMessageType_EXCEPTION) {
+ TApplicationException * x = [TApplicationException read: inProtocol];
+ [inProtocol readMessageEnd];
+ return x;
+ }
+
+ return nil;
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TException.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TException.h b/depends/thirdparty/thrift/lib/cocoa/src/TException.h
new file mode 100644
index 0000000..e56f4fa
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TException.h
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+@interface TException : NSException {
+}
+
++ (id) exceptionWithName: (NSString *) name;
+
++ (id) exceptionWithName: (NSString *) name
+ reason: (NSString *) reason;
+
++ (id) exceptionWithName: (NSString *) name
+ reason: (NSString *) reason
+ error: (NSError *) error;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TException.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TException.m b/depends/thirdparty/thrift/lib/cocoa/src/TException.m
new file mode 100644
index 0000000..0160e3b
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TException.m
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#import "TException.h"
+#import "TObjective-C.h"
+
+@implementation TException
+
++ (id) exceptionWithName: (NSString *) name
+{
+ return [self exceptionWithName: name reason: @"unknown" error: nil];
+}
+
+
++ (id) exceptionWithName: (NSString *) name
+ reason: (NSString *) reason
+{
+ return [self exceptionWithName: name reason: reason error: nil];
+}
+
+
++ (id) exceptionWithName: (NSString *) name
+ reason: (NSString *) reason
+ error: (NSError *) error
+{
+ NSDictionary * userInfo = nil;
+ if (error != nil) {
+ userInfo = [NSDictionary dictionaryWithObject: error forKey: @"error"];
+ }
+
+ return [super exceptionWithName: name
+ reason: reason
+ userInfo: userInfo];
+}
+
+
+- (NSString *) description
+{
+ NSMutableString * result = [NSMutableString stringWithString: [self name]];
+ [result appendFormat: @": %@", [self reason]];
+ if ([self userInfo] != nil) {
+ [result appendFormat: @"\n userInfo = %@", [self userInfo]];
+ }
+
+ return result;
+}
+
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TObjective-C.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TObjective-C.h b/depends/thirdparty/thrift/lib/cocoa/src/TObjective-C.h
new file mode 100644
index 0000000..9c0831d
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TObjective-C.h
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+/*
+ * TObjective-C.h is for supporting coexistence of both the ARC (Automatic
+ * Reference Counting) mode and the Non-ARC mode of Objective-C
+ * in the same source code.
+ *
+ * 2011/11/14 HIRANO Satoshi (AIST, Japan)
+ *
+ * Before:
+ *
+ * var = [aObject retain];
+ * [aObject release];
+ * [aObject autorelease];
+ * [super dealloc];
+ * CFFunction(obj);
+ *
+ * ARC and Non-ARC compatible:
+ *
+ * #import "TObjective-C.h"
+ * var = [aObject retain_stub];
+ * [aObject release_stub];
+ * [aObject autorelease_stub];
+ * [super dealloc_stub];
+ * CFFunction(bridge_stub obj);
+ *
+ * Don't use retain_stub for @property(retain).
+ * Use NSAutoreleasePool like this:
+ * #if __has_feature(objc_arc)
+ * @autoreleasepool {
+ * // code
+ * }
+ * #else
+ * NSAutoReleasePool *pool = [[NSAutoReleasePool alloc] init...
+ * // code
+ * [pool release];
+ * #endif
+ */
+
+
+#if !defined(retain_stub)
+#if __has_feature(objc_arc)
+#define retain_stub self
+#define autorelease_stub self
+#define release_stub self
+#define dealloc_stub self
+#define bridge_stub __bridge
+#else
+#define retain_stub retain
+#define autorelease_stub autorelease
+#define release_stub release
+#define dealloc_stub dealloc
+#define bridge_stub
+#endif
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TProcessor.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TProcessor.h b/depends/thirdparty/thrift/lib/cocoa/src/TProcessor.h
new file mode 100644
index 0000000..980be94
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TProcessor.h
@@ -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.
+ */
+
+#import <Foundation/Foundation.h>
+#import "TProtocol.h"
+
+
+@protocol TProcessor <NSObject>
+
+- (BOOL) processOnInputProtocol: (id <TProtocol>) inProtocol
+ outputProtocol: (id <TProtocol>) outProtocol;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TProcessorFactory.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TProcessorFactory.h b/depends/thirdparty/thrift/lib/cocoa/src/TProcessorFactory.h
new file mode 100644
index 0000000..29d12b3
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TProcessorFactory.h
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import "TProcessor.h"
+
+@protocol TProcessorFactory <NSObject>
+
+- (id<TProcessor>) processorForTransport: (id<TTransport>) transport;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TSharedProcessorFactory.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TSharedProcessorFactory.h b/depends/thirdparty/thrift/lib/cocoa/src/TSharedProcessorFactory.h
new file mode 100644
index 0000000..cf4a462
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TSharedProcessorFactory.h
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import "TProcessorFactory.h"
+
+@interface TSharedProcessorFactory : NSObject <TProcessorFactory> {
+ id<TProcessor> mSharedProcessor;
+}
+- (id) initWithSharedProcessor: (id<TProcessor>) sharedProcessor;
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/TSharedProcessorFactory.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/TSharedProcessorFactory.m b/depends/thirdparty/thrift/lib/cocoa/src/TSharedProcessorFactory.m
new file mode 100644
index 0000000..a0007c0
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/TSharedProcessorFactory.m
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+
+#import "TSharedProcessorFactory.h"
+#import "TObjective-C.h"
+
+
+@implementation TSharedProcessorFactory
+
+
+- (id) initWithSharedProcessor: (id<TProcessor>) sharedProcessor
+{
+ self = [super init];
+ if (!self) {
+ return nil;
+ }
+
+ mSharedProcessor = [sharedProcessor retain_stub];
+ return self;
+}
+
+
+- (void) dealloc
+{
+ [mSharedProcessor release_stub];
+ [super dealloc_stub];
+}
+
+
+- (id<TProcessor>) processorForTransport: (id<TTransport>) transport
+{
+ return [[mSharedProcessor retain_stub] autorelease_stub];
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/Thrift.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/Thrift.h b/depends/thirdparty/thrift/lib/cocoa/src/Thrift.h
new file mode 100644
index 0000000..9cedb66
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/Thrift.h
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+#define ThriftVersion @"0.9.3"
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBase.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBase.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBase.h
new file mode 100644
index 0000000..33037ef
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBase.h
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "TProtocol.h"
+
+@protocol TBase <NSObject>
+
+/**
+ * De-serialize object from the given input protocol
+ *
+ * @param input protocol used for reading
+ */
+- (void) read: (id <TProtocol>) inProtocol;
+
+/**
+ * Serialize object to the given protocol
+ *
+ * @param buf output protocol used for writing
+ */
+- (void) write: (id <TProtocol>) outProtocol;
+
+@end
+
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBinaryProtocol.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBinaryProtocol.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBinaryProtocol.h
new file mode 100644
index 0000000..9a73730
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBinaryProtocol.h
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#import "TProtocol.h"
+#import "TTransport.h"
+#import "TProtocolFactory.h"
+
+
+@interface TBinaryProtocol : NSObject <TProtocol> {
+ id <TTransport> mTransport;
+ BOOL mStrictRead;
+ BOOL mStrictWrite;
+ int32_t mMessageSizeLimit;
+}
+
+- (id) initWithTransport: (id <TTransport>) transport;
+
+- (id) initWithTransport: (id <TTransport>) transport
+ strictRead: (BOOL) strictRead
+ strictWrite: (BOOL) strictWrite;
+
+- (int32_t) messageSizeLimit;
+- (void) setMessageSizeLimit: (int32_t) sizeLimit;
+
+@end
+
+
+@interface TBinaryProtocolFactory : NSObject <TProtocolFactory> {
+}
+
++ (TBinaryProtocolFactory *) sharedFactory;
+
+- (TBinaryProtocol *) newProtocolOnTransport: (id <TTransport>) transport;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBinaryProtocol.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBinaryProtocol.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBinaryProtocol.m
new file mode 100644
index 0000000..847c723
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TBinaryProtocol.m
@@ -0,0 +1,530 @@
+/*
+ * 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.
+ */
+
+#import "TBinaryProtocol.h"
+#import "TProtocolException.h"
+#import "TObjective-C.h"
+
+/* In the modern protocol, version is stored in the high half of an int32.
+ * The low half contains type info. */
+static const uint16_t VERSION_1 = 0x8001;
+
+NS_INLINE size_t
+CheckedCastInt32ToSizeT(int32_t size)
+{
+ if (size < 0) {
+ NSString *reason = [NSString stringWithFormat:
+ @"%s: refusing to read data with negative size: %"PRId32,
+ __func__, size];
+ @throw [TProtocolException
+ exceptionWithName: @"TProtocolException"
+ reason: reason];
+ }
+ size_t checkedSize = (size_t)size;
+ return checkedSize;
+}
+
+NS_INLINE int32_t
+CheckedCastSizeTToInt32(size_t size)
+{
+ if (size > INT32_MAX) {
+ NSString *reason = [NSString stringWithFormat:
+ @"%s: data size exceeds values representable by a 32-bit signed integer: %zu",
+ __func__, size];
+ @throw [TProtocolException
+ exceptionWithName: @"TProtocolException"
+ reason: reason];
+ }
+ int32_t checkedSize = (int32_t)size;
+ return checkedSize;
+}
+
+NS_INLINE uint8_t
+CheckedCastIntToUInt8(int size)
+{
+ if (size > UINT8_MAX) {
+ NSString *reason = [NSString stringWithFormat:
+ @"%s: data size exceeds values representable by a 8-bit unsigned integer: %d",
+ __func__, size];
+ @throw [TProtocolException
+ exceptionWithName: @"TProtocolException"
+ reason: reason];
+ }
+ uint8_t checkedSize = (uint8_t)size;
+ return checkedSize;
+}
+
+static TBinaryProtocolFactory * gSharedFactory = nil;
+
+@implementation TBinaryProtocolFactory
+
++ (TBinaryProtocolFactory *) sharedFactory {
+ if (gSharedFactory == nil) {
+ gSharedFactory = [[TBinaryProtocolFactory alloc] init];
+ }
+
+ return gSharedFactory;
+}
+
+- (TBinaryProtocol *) newProtocolOnTransport: (id <TTransport>) transport {
+ return [[TBinaryProtocol alloc] initWithTransport: transport];
+}
+
+@end
+
+
+
+@implementation TBinaryProtocol
+
+- (id) initWithTransport: (id <TTransport>) transport
+{
+ return [self initWithTransport: transport strictRead: NO strictWrite: YES];
+}
+
+- (id) initWithTransport: (id <TTransport>) transport
+ strictRead: (BOOL) strictRead
+ strictWrite: (BOOL) strictWrite
+{
+ self = [super init];
+ mTransport = [transport retain_stub];
+ mStrictRead = strictRead;
+ mStrictWrite = strictWrite;
+ return self;
+}
+
+
+- (int32_t) messageSizeLimit
+{
+ return mMessageSizeLimit;
+}
+
+
+- (void) setMessageSizeLimit: (int32_t) sizeLimit
+{
+ mMessageSizeLimit = sizeLimit;
+}
+
+
+- (void) dealloc
+{
+ [mTransport release_stub];
+ [super dealloc_stub];
+}
+
+
+- (id <TTransport>) transport
+{
+ return mTransport;
+}
+
+
+- (NSString *) readStringBody: (int) rawSize
+{
+ size_t size = CheckedCastInt32ToSizeT(rawSize);
+ char * buffer = malloc(size+1);
+ if (!buffer) {
+ @throw [TProtocolException exceptionWithName: @"TProtocolException"
+ reason: [NSString stringWithFormat: @"Unable to allocate memory in %s, size: %zu",
+ __PRETTY_FUNCTION__,
+ size]];;
+ }
+ [mTransport readAll: (uint8_t *) buffer offset: 0 length: size];
+ buffer[size] = 0;
+ NSString * result = [NSString stringWithUTF8String: buffer];
+ free(buffer);
+ return result;
+}
+
+
+- (void) readMessageBeginReturningName: (NSString **) name
+ type: (int *) type
+ sequenceID: (int *) sequenceID
+{
+ int32_t size = [self readI32];
+ if (size < 0) {
+ /* Version (unsigned) is stored in the high halfword. */
+ uint16_t version = (size >> 16) & 0xFFFF;
+ if (version != VERSION_1) {
+ NSString *reason = [NSString stringWithFormat:
+ @"%s: Expected version %"PRIu16", instead found: %"PRIu16,
+ __func__, VERSION_1, version];
+ @throw [TProtocolException exceptionWithName: @"TProtocolException"
+ reason: reason];
+ }
+ if (type != NULL) {
+ *type = size & 0x00FF;
+ }
+ NSString * messageName = [self readString];
+ if (name != NULL) {
+ *name = messageName;
+ }
+ int seqID = [self readI32];
+ if (sequenceID != NULL) {
+ *sequenceID = seqID;
+ }
+ } else {
+ if (mStrictRead) {
+ @throw [TProtocolException exceptionWithName: @"TProtocolException"
+ reason: @"Missing version in readMessageBegin, old client?"];
+ }
+ if ([self messageSizeLimit] > 0 && size > [self messageSizeLimit]) {
+ @throw [TProtocolException exceptionWithName: @"TProtocolException"
+ reason: [NSString stringWithFormat: @"Message too big. Size limit is: %d Message size is: %d",
+ mMessageSizeLimit,
+ size]];
+ }
+ NSString * messageName = [self readStringBody: size];
+ if (name != NULL) {
+ *name = messageName;
+ }
+ int messageType = [self readByte];
+ if (type != NULL) {
+ *type = messageType;
+ }
+ int seqID = [self readI32];
+ if (sequenceID != NULL) {
+ *sequenceID = seqID;
+ }
+ }
+}
+
+
+- (void) readMessageEnd {}
+
+
+- (void) readStructBeginReturningName: (NSString **) name
+{
+ if (name != NULL) {
+ *name = nil;
+ }
+}
+
+
+- (void) readStructEnd {}
+
+
+- (void) readFieldBeginReturningName: (NSString **) name
+ type: (int *) fieldType
+ fieldID: (int *) fieldID
+{
+ if (name != NULL) {
+ *name = nil;
+ }
+ int ft = [self readByte];
+ if (fieldType != NULL) {
+ *fieldType = ft;
+ }
+ if (ft != TType_STOP) {
+ int fid = [self readI16];
+ if (fieldID != NULL) {
+ *fieldID = fid;
+ }
+ }
+}
+
+
+- (void) readFieldEnd {}
+
+
+- (int32_t) readI32
+{
+ uint8_t i32rd[4];
+ [mTransport readAll: i32rd offset: 0 length: 4];
+ return
+ ((i32rd[0] & 0xff) << 24) |
+ ((i32rd[1] & 0xff) << 16) |
+ ((i32rd[2] & 0xff) << 8) |
+ ((i32rd[3] & 0xff));
+}
+
+
+- (NSString *) readString
+{
+ int32_t size = [self readI32];
+ return [self readStringBody: size];
+}
+
+
+- (BOOL) readBool
+{
+ return [self readByte] == 1;
+}
+
+- (uint8_t) readByte
+{
+ uint8_t myByte;
+ [mTransport readAll: &myByte offset: 0 length: 1];
+ return myByte;
+}
+
+- (short) readI16
+{
+ uint8_t buff[2];
+ [mTransport readAll: buff offset: 0 length: 2];
+ return (short)
+ (((buff[0] & 0xff) << 8) |
+ ((buff[1] & 0xff)));
+}
+
+- (int64_t) readI64
+{
+ uint8_t i64rd[8];
+ [mTransport readAll: i64rd offset: 0 length: 8];
+ return
+ ((int64_t)(i64rd[0] & 0xff) << 56) |
+ ((int64_t)(i64rd[1] & 0xff) << 48) |
+ ((int64_t)(i64rd[2] & 0xff) << 40) |
+ ((int64_t)(i64rd[3] & 0xff) << 32) |
+ ((int64_t)(i64rd[4] & 0xff) << 24) |
+ ((int64_t)(i64rd[5] & 0xff) << 16) |
+ ((int64_t)(i64rd[6] & 0xff) << 8) |
+ ((int64_t)(i64rd[7] & 0xff));
+}
+
+- (double) readDouble
+{
+ // FIXME - will this get us into trouble on PowerPC?
+ int64_t ieee754 = [self readI64];
+ return *((double *) &ieee754);
+}
+
+
+- (NSData *) readBinary
+{
+ int32_t size = [self readI32];
+ size_t binarySize = CheckedCastInt32ToSizeT(size);
+ uint8_t * buff = malloc(binarySize);
+ if (buff == NULL) {
+ @throw [TProtocolException
+ exceptionWithName: @"TProtocolException"
+ reason: [NSString stringWithFormat: @"Out of memory. Unable to allocate %d bytes trying to read binary data.",
+ size]];
+ }
+ [mTransport readAll: buff offset: 0 length: binarySize];
+ return [NSData dataWithBytesNoCopy: buff length: binarySize];
+}
+
+
+- (void) readMapBeginReturningKeyType: (int *) keyType
+ valueType: (int *) valueType
+ size: (int *) size
+{
+ int kt = [self readByte];
+ int vt = [self readByte];
+ int s = [self readI32];
+ if (keyType != NULL) {
+ *keyType = kt;
+ }
+ if (valueType != NULL) {
+ *valueType = vt;
+ }
+ if (size != NULL) {
+ *size = s;
+ }
+}
+
+- (void) readMapEnd {}
+
+
+- (void) readSetBeginReturningElementType: (int *) elementType
+ size: (int *) size
+{
+ int et = [self readByte];
+ int s = [self readI32];
+ if (elementType != NULL) {
+ *elementType = et;
+ }
+ if (size != NULL) {
+ *size = s;
+ }
+}
+
+
+- (void) readSetEnd {}
+
+
+- (void) readListBeginReturningElementType: (int *) elementType
+ size: (int *) size
+{
+ int et = [self readByte];
+ int s = [self readI32];
+ if (elementType != NULL) {
+ *elementType = et;
+ }
+ if (size != NULL) {
+ *size = s;
+ }
+}
+
+
+- (void) readListEnd {}
+
+
+- (void) writeByte: (uint8_t) value
+{
+ [mTransport write: &value offset: 0 length: 1];
+}
+
+
+- (void) writeMessageBeginWithName: (NSString *) name
+ type: (int) messageType
+ sequenceID: (int) sequenceID
+{
+ if (mStrictWrite) {
+ int version = (VERSION_1 << 16) | messageType;
+ [self writeI32: version];
+ [self writeString: name];
+ [self writeI32: sequenceID];
+ } else {
+ [self writeString: name];
+ [self writeByte: CheckedCastIntToUInt8(messageType)];
+ [self writeI32: sequenceID];
+ }
+}
+
+
+- (void) writeMessageEnd {}
+
+
+- (void) writeStructBeginWithName: (NSString *) name {}
+
+
+- (void) writeStructEnd {}
+
+
+- (void) writeFieldBeginWithName: (NSString *) name
+ type: (int) fieldType
+ fieldID: (int) fieldID
+{
+ [self writeByte: CheckedCastIntToUInt8(fieldType)];
+ [self writeI16: CheckedCastIntToUInt8(fieldID)];
+}
+
+
+- (void) writeI32: (int32_t) value
+{
+ uint8_t buff[4];
+ buff[0] = 0xFF & (value >> 24);
+ buff[1] = 0xFF & (value >> 16);
+ buff[2] = 0xFF & (value >> 8);
+ buff[3] = 0xFF & value;
+ [mTransport write: buff offset: 0 length: 4];
+}
+
+- (void) writeI16: (short) value
+{
+ uint8_t buff[2];
+ buff[0] = 0xff & (value >> 8);
+ buff[1] = 0xff & value;
+ [mTransport write: buff offset: 0 length: 2];
+}
+
+
+- (void) writeI64: (int64_t) value
+{
+ uint8_t buff[8];
+ buff[0] = 0xFF & (value >> 56);
+ buff[1] = 0xFF & (value >> 48);
+ buff[2] = 0xFF & (value >> 40);
+ buff[3] = 0xFF & (value >> 32);
+ buff[4] = 0xFF & (value >> 24);
+ buff[5] = 0xFF & (value >> 16);
+ buff[6] = 0xFF & (value >> 8);
+ buff[7] = 0xFF & value;
+ [mTransport write: buff offset: 0 length: 8];
+}
+
+- (void) writeDouble: (double) value
+{
+ // spit out IEEE 754 bits - FIXME - will this get us in trouble on
+ // PowerPC?
+ [self writeI64: *((int64_t *) &value)];
+}
+
+
+- (void) writeString: (NSString *) value
+{
+ if (value != nil) {
+ const char * utf8Bytes = [value UTF8String];
+ size_t length = strlen(utf8Bytes);
+ int32_t size = CheckedCastSizeTToInt32(length);
+ [self writeI32: size];
+ [mTransport write: (uint8_t *) utf8Bytes offset: 0 length: length];
+ } else {
+ // instead of crashing when we get null, let's write out a zero
+ // length string
+ [self writeI32: 0];
+ }
+}
+
+
+- (void) writeBinary: (NSData *) data
+{
+ int32_t size = CheckedCastSizeTToInt32([data length]);
+ [self writeI32: size];
+ [mTransport write: [data bytes] offset: 0 length: [data length]];
+}
+
+- (void) writeFieldStop
+{
+ [self writeByte: TType_STOP];
+}
+
+
+- (void) writeFieldEnd {}
+
+
+- (void) writeMapBeginWithKeyType: (int) keyType
+ valueType: (int) valueType
+ size: (int) size
+{
+ [self writeByte: CheckedCastIntToUInt8(keyType)];
+ [self writeByte: CheckedCastIntToUInt8(valueType)];
+ [self writeI32: size];
+}
+
+- (void) writeMapEnd {}
+
+
+- (void) writeSetBeginWithElementType: (int) elementType
+ size: (int) size
+{
+ [self writeByte: CheckedCastIntToUInt8(elementType)];
+ [self writeI32: size];
+}
+
+- (void) writeSetEnd {}
+
+
+- (void) writeListBeginWithElementType: (int) elementType
+ size: (int) size
+{
+ [self writeByte: CheckedCastIntToUInt8(elementType)];
+ [self writeI32: size];
+}
+
+- (void) writeListEnd {}
+
+
+- (void) writeBool: (BOOL) value
+{
+ [self writeByte: (value ? 1 : 0)];
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.h
new file mode 100644
index 0000000..3c9195c
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.h
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#import "TProtocol.h"
+#import "TTransport.h"
+#import "TProtocolFactory.h"
+
+@interface TCompactProtocol : NSObject <TProtocol>
+
+- (id) initWithTransport: (id <TTransport>) transport;
+
+@end
+
+@interface TCompactProtocolFactory : NSObject <TProtocolFactory>
+
++ (TCompactProtocolFactory *) sharedFactory;
+
+- (TCompactProtocol *) newProtocolOnTransport: (id <TTransport>) transport;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.m
new file mode 100644
index 0000000..45b0ef3
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.m
@@ -0,0 +1,687 @@
+/*
+ * 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.
+ */
+
+#import "TCompactProtocol.h"
+#import "TObjective-C.h"
+#import "TProtocolException.h"
+
+static const uint8_t COMPACT_PROTOCOL_ID = 0x82;
+static const uint8_t COMPACT_VERSION = 1;
+static const uint8_t COMPACT_VERSION_MASK = 0x1F; // 0001 1111
+static const uint8_t COMPACT_TYPE_MASK = 0xE0; // 1110 0000
+static const uint8_t COMPACT_TYPE_BITS = 0x07; // 0000 0111
+static const int COMPACT_TYPE_SHIFT_AMOUNT = 5;
+
+enum {
+ TCType_STOP = 0x00,
+ TCType_BOOLEAN_TRUE = 0x01,
+ TCType_BOOLEAN_FALSE = 0x02,
+ TCType_BYTE = 0x03,
+ TCType_I16 = 0x04,
+ TCType_I32 = 0x05,
+ TCType_I64 = 0x06,
+ TCType_DOUBLE = 0x07,
+ TCType_BINARY = 0x08,
+ TCType_LIST = 0x09,
+ TCType_SET = 0x0A,
+ TCType_MAP = 0x0B,
+ TCType_STRUCT = 0x0C,
+};
+
+@implementation TCompactProtocolFactory
+
++ (TCompactProtocolFactory *) sharedFactory
+{
+ static TCompactProtocolFactory * gSharedFactory = nil;
+ if (gSharedFactory == nil) {
+ gSharedFactory = [[TCompactProtocolFactory alloc] init];
+ }
+
+ return gSharedFactory;
+}
+
+- (TCompactProtocol *) newProtocolOnTransport: (id <TTransport>) transport
+{
+ return [[TCompactProtocol alloc] initWithTransport: transport];
+}
+
+@end
+
+@implementation TCompactProtocol {
+ NSMutableArray * lastField;
+ short lastFieldId;
+ id <TTransport> mTransport;
+
+ NSString * boolFieldName;
+ NSNumber * boolFieldType;
+ NSNumber * boolFieldId;
+ NSNumber * booleanValue;
+}
+
+- (id) init
+{
+ self = [super init];
+
+ if (self != nil) {
+ lastField = [[NSMutableArray alloc] init];
+ }
+
+ return self;
+}
+
+- (id) initWithTransport: (id <TTransport>) transport
+{
+ self = [self init];
+
+ if (self != nil) {
+ mTransport = [transport retain_stub];
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [lastField release_stub];
+ [mTransport release_stub];
+ [boolFieldName release_stub];
+ [boolFieldType release_stub];
+ [boolFieldId release_stub];
+ [booleanValue release_stub];
+
+ [super dealloc_stub];
+}
+
+- (id <TTransport>) transport
+{
+ return mTransport;
+}
+
+- (void) writeByteDirect: (int8_t) n
+{
+ [mTransport write: (uint8_t *)&n offset: 0 length: 1];
+}
+
+- (void)writeVarint32: (uint32_t) n
+{
+ uint8_t i32buf[5] = {0};
+ uint32_t idx = 0;
+
+ while (true) {
+ if ((n & ~0x7F) == 0) {
+ i32buf[idx++] = (uint8_t)n;
+ break;
+ } else {
+ i32buf[idx++] = (uint8_t)((n & 0x7F) | 0x80);
+ n >>= 7;
+ }
+ }
+
+ [mTransport write: i32buf offset: 0 length: idx];
+}
+
+- (void) writeMessageBeginWithName: (NSString *) name
+ type: (int) messageType
+ sequenceID: (int) sequenceID
+{
+ [self writeByteDirect: COMPACT_PROTOCOL_ID];
+ [self writeByteDirect: (uint8_t)((COMPACT_VERSION & COMPACT_VERSION_MASK) |
+ ((((uint32_t)messageType) << COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_MASK))];
+ [self writeVarint32: (uint32_t)sequenceID];
+ [self writeString: name];
+}
+
+- (void) writeStructBeginWithName: (NSString *) name
+{
+ [lastField addObject: [NSNumber numberWithShort: lastFieldId]];
+ lastFieldId = 0;
+}
+
+- (void) writeStructEnd
+{
+ lastFieldId = [[lastField lastObject] shortValue];
+ [lastField removeLastObject];
+}
+
+- (void) writeFieldBeginWithName: (NSString *) name
+ type: (int) fieldType
+ fieldID: (int) fieldID
+{
+ if (fieldType == TType_BOOL) {
+ boolFieldName = [name copy];
+ boolFieldType = [[NSNumber numberWithInt: fieldType] retain_stub];
+ boolFieldId = [[NSNumber numberWithInt: fieldID] retain_stub];
+ } else {
+ [self writeFieldBeginInternalWithName: name
+ type: fieldType
+ fieldID: fieldID
+ typeOverride: 0xFF];
+ }
+}
+
+- (void) writeFieldBeginInternalWithName: (NSString *) name
+ type: (int) fieldType
+ fieldID: (int) fieldID
+ typeOverride: (uint8_t) typeOverride
+{
+ uint8_t typeToWrite = typeOverride == 0xFF ? [self compactTypeForTType: fieldType] : typeOverride;
+
+ // check if we can use delta encoding for the field id
+ if (fieldID > lastFieldId && fieldID - lastFieldId <= 15) {
+ // Write them together
+ [self writeByteDirect: (fieldID - lastFieldId) << 4 | typeToWrite];
+ } else {
+ // Write them separate
+ [self writeByteDirect: typeToWrite];
+ [self writeI16: fieldID];
+ }
+
+ lastFieldId = fieldID;
+}
+
+- (void) writeFieldStop
+{
+ [self writeByteDirect: TCType_STOP];
+}
+
+- (void) writeMapBeginWithKeyType: (int) keyType
+ valueType: (int) valueType
+ size: (int) size
+{
+ if (size == 0) {
+ [self writeByteDirect: 0];
+ } else {
+ [self writeVarint32: (uint32_t)size];
+ [self writeByteDirect: [self compactTypeForTType: keyType] << 4 | [self compactTypeForTType: valueType]];
+ }
+}
+
+- (void) writeListBeginWithElementType: (int) elementType
+ size: (int) size
+{
+ [self writeCollectionBeginWithElementType: elementType size: size];
+}
+
+- (void) writeSetBeginWithElementType: (int) elementType
+ size: (int) size
+{
+ [self writeCollectionBeginWithElementType: elementType size: size];
+}
+
+- (void) writeBool: (BOOL) b
+{
+ if (boolFieldId != nil && boolFieldName != nil && boolFieldType != nil) {
+ // we haven't written the field header yet
+ [self writeFieldBeginInternalWithName: boolFieldName
+ type: [boolFieldType intValue]
+ fieldID: [boolFieldId intValue]
+ typeOverride: b ? TCType_BOOLEAN_TRUE : TCType_BOOLEAN_FALSE];
+
+ [boolFieldId release_stub];
+ [boolFieldName release_stub];
+ [boolFieldType release_stub];
+
+ boolFieldId = nil;
+ boolFieldName = nil;
+ boolFieldType = nil;
+ } else {
+ // we're not part of a field, so just Write the value.
+ [self writeByteDirect: b ? TCType_BOOLEAN_TRUE : TCType_BOOLEAN_FALSE];
+ }
+}
+
+- (void) writeByte: (uint8_t) value
+{
+ [self writeByteDirect: value];
+}
+
+- (void) writeI16: (int16_t) value
+{
+ [self writeVarint32: [self i32ToZigZag: value]];
+}
+
+- (void) writeI32: (int32_t) value
+{
+ [self writeVarint32: [self i32ToZigZag: value]];
+}
+
+- (void) writeI64: (int64_t) value
+{
+ [self writeVarint64: [self i64ToZigZag: value]];
+}
+
+- (void) writeDouble: (double) value
+{
+ //Safe bit-casting double->uint64
+
+ uint64_t bits = 0;
+ memcpy(&bits, &value, 8);
+
+ bits = OSSwapHostToLittleInt64(bits);
+
+ [mTransport write: (uint8_t *)&bits offset: 0 length: 8];
+}
+
+- (void) writeString: (NSString *) value
+{
+ [self writeBinary: [value dataUsingEncoding: NSUTF8StringEncoding]];
+}
+
+- (void) writeBinary: (NSData *) data
+{
+ [self writeVarint32: (uint32_t)data.length];
+ [mTransport write: data.bytes offset: 0 length: data.length];
+}
+
+- (void) writeMessageEnd {}
+- (void) writeMapEnd {}
+- (void) writeListEnd {}
+- (void) writeSetEnd {}
+- (void) writeFieldEnd {}
+
+- (void) writeCollectionBeginWithElementType: (int) elementType
+ size: (int) size
+{
+ if (size <= 14) {
+ [self writeByteDirect: size << 4 | [self compactTypeForTType: elementType]];
+ } else {
+ [self writeByteDirect: 0xf0 | [self compactTypeForTType: elementType]];
+ [self writeVarint32: (uint32_t)size];
+ }
+}
+
+- (void) writeVarint64: (uint64_t) n
+{
+ uint8_t varint64out[10] = {0};
+ int idx = 0;
+
+ while (true) {
+ if ((n & ~0x7FL) == 0) {
+ varint64out[idx++] = (uint8_t)n;
+ break;
+ } else {
+ varint64out[idx++] = (uint8_t)((n & 0x7F) | 0x80);
+ n >>= 7;
+ }
+ }
+
+ [mTransport write: varint64out offset: 0 length: idx];
+}
+
+- (uint32_t) i32ToZigZag: (int32_t) n
+{
+ /*
+ ZigZag encoding maps signed integers to unsigned integers so that
+ numbers with a small absolute value (for instance, -1) have
+ a small varint encoded value too. It does this in a way that
+ "zig-zags" back and forth through the positive and negative integers,
+ so that -1 is encoded as 1, 1 is encoded as 2, -2 is encoded as 3, and so on
+ */
+ return (uint32_t)(n << 1) ^ (uint32_t)(n >> 31);
+}
+
+- (uint64_t) i64ToZigZag: (int64_t) n
+{
+ return (uint64_t)(n << 1) ^ (uint64_t)(n >> 63);
+}
+
+- (void) readMessageBeginReturningName: (NSString **) pname
+ type: (int *) ptype
+ sequenceID: (int *) psequenceID
+{
+ uint8_t protocolId = [self readByte];
+ if (protocolId != COMPACT_PROTOCOL_ID) {
+ @throw [TProtocolException exceptionWithName: @"TProtocolException"
+ reason: [NSString stringWithFormat: @"Expected protocol id %X but got %X", COMPACT_PROTOCOL_ID, protocolId]];
+ }
+
+ uint8_t versionAndType = [self readByte];
+ uint8_t version = versionAndType & COMPACT_VERSION_MASK;
+ if (version != COMPACT_VERSION) {
+ @throw [TProtocolException exceptionWithName: @"TProtocolException"
+ reason: [NSString stringWithFormat: @"Expected version %d but got %d", COMPACT_VERSION, version]];
+ }
+
+ int type = (versionAndType >> COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_BITS;
+ int sequenceID = (int)[self readVarint32];
+ NSString* name = [self readString];
+
+ if (ptype != NULL) {
+ *ptype = type;
+ }
+ if (psequenceID != NULL) {
+ *psequenceID = sequenceID;
+ }
+ if (pname != NULL) {
+ *pname = name;
+ }
+}
+
+- (void) readStructBeginReturningName: (NSString **) pname
+{
+ [lastField addObject: [NSNumber numberWithShort: lastFieldId]];
+ lastFieldId = 0;
+
+ if (pname != NULL) {
+ *pname = @"";
+ }
+}
+
+- (void) readStructEnd
+{
+ lastFieldId = [[lastField lastObject] shortValue];
+ [lastField removeLastObject];
+}
+
+- (void) readFieldBeginReturningName: (NSString **) pname
+ type: (int *) pfieldType
+ fieldID: (int *) pfieldID
+{
+ uint8_t byte = [self readByte];
+ uint8_t type = byte & 0x0f;
+
+ // if it's a stop, then we can return immediately, as the struct is over.
+ if (type == TCType_STOP) {
+ if (pname != NULL) {
+ *pname = @"";
+ }
+ if (pfieldType != NULL) {
+ *pfieldType = TType_STOP;
+ }
+ if (pfieldID != NULL) {
+ *pfieldID = 0;
+ }
+ return;
+ }
+
+ short fieldId = 0;
+
+ // mask off the 4 MSB of the type header. it could contain a field id delta.
+ short modifier = (byte & 0xf0) >> 4;
+ if (modifier == 0) {
+ // not a delta. look ahead for the zigzag varint field id.
+ fieldId = [self readI16];
+ } else {
+ // has a delta. add the delta to the last Read field id.
+ fieldId = lastFieldId + modifier;
+ }
+
+ int fieldType = [self ttypeForCompactType: type];
+
+ if (pname != NULL) {
+ *pname = @"";
+ }
+ if (pfieldType != NULL) {
+ *pfieldType = fieldType;
+ }
+ if (pfieldID != NULL) {
+ *pfieldID = fieldId;
+ }
+
+ // if this happens to be a boolean field, the value is encoded in the type
+ if (type == TCType_BOOLEAN_TRUE ||
+ type == TCType_BOOLEAN_FALSE) {
+ // save the boolean value in a special instance variable.
+ booleanValue = [[NSNumber numberWithBool: type == TCType_BOOLEAN_TRUE] retain_stub];
+ }
+
+ // push the new field onto the field stack so we can keep the deltas going.
+ lastFieldId = fieldId;
+}
+
+- (void) readMapBeginReturningKeyType: (int *) pkeyType
+ valueType: (int *) pvalueType
+ size: (int *) psize
+{
+ uint8_t keyAndValueType = 0;
+ int size = (int)[self readVarint32];
+ if (size != 0) {
+ keyAndValueType = [self readByte];
+ }
+
+ int keyType = [self ttypeForCompactType: keyAndValueType >> 4];
+ int valueType = [self ttypeForCompactType: keyAndValueType & 0xf];
+
+ if (pkeyType != NULL) {
+ *pkeyType = keyType;
+ }
+ if (pvalueType != NULL) {
+ *pvalueType = valueType;
+ }
+ if (psize != NULL) {
+ *psize = size;
+ }
+}
+
+- (void) readListBeginReturningElementType: (int *) pelementType
+ size: (int *) psize
+{
+ uint8_t size_and_type = [self readByte];
+ int size = (size_and_type >> 4) & 0x0f;
+ if (size == 15) {
+ size = (int)[self readVarint32];
+ }
+
+ int elementType = [self ttypeForCompactType: size_and_type & 0x0f];
+
+ if (pelementType != NULL) {
+ *pelementType = elementType;
+ }
+ if (psize != NULL) {
+ *psize = size;
+ }
+}
+
+- (void) readSetBeginReturningElementType: (int *) pelementType
+ size: (int *) psize
+{
+ [self readListBeginReturningElementType: pelementType size: psize];
+}
+
+- (BOOL) readBool
+{
+ if (booleanValue != nil) {
+ BOOL result = [booleanValue boolValue];
+ [booleanValue release_stub];
+ booleanValue = nil;
+ return result;
+ } else {
+ return [self readByte] == TCType_BOOLEAN_TRUE;
+ }
+}
+
+- (uint8_t) readByte
+{
+ uint8_t buf = 0;
+ [mTransport readAll: &buf offset: 0 length: 1];
+ return buf;
+}
+
+- (int16_t) readI16
+{
+ return (int16_t)[self zigZagToi32: [self readVarint32]];
+}
+
+- (int32_t) readI32
+{
+ return [self zigZagToi32: [self readVarint32]];
+}
+
+- (int64_t) readI64
+{
+ return [self zigZagToi64: [self readVarint64]];
+}
+
+- (double) readDouble
+{
+ uint64_t bits = 0;
+ [mTransport readAll: (uint8_t *)&bits offset: 0 length: 8];
+ bits = OSSwapLittleToHostInt64(bits);
+
+ double result = 0;
+ memcpy(&result, &bits, 8);
+
+ return result;
+}
+
+- (NSString *) readString
+{
+ int length = (int)[self readVarint32];
+ if (length == 0) {
+ return @"";
+ }
+
+ return [[[NSString alloc] initWithData: [self readBinary: length]
+ encoding: NSUTF8StringEncoding] autorelease_stub];
+}
+
+- (NSData *) readBinary
+{
+ return [self readBinary: (int)[self readVarint32]];
+}
+
+- (NSData *) readBinary: (int) length
+{
+ if (length == 0) {
+ return [NSData data];
+ }
+
+ NSMutableData* buf = [NSMutableData dataWithLength: length];
+ [mTransport readAll: buf.mutableBytes offset: 0 length: length];
+ return buf;
+}
+
+- (void) readMessageEnd {}
+- (void) readFieldEnd {}
+- (void) readMapEnd {}
+- (void) readListEnd {}
+- (void) readSetEnd {}
+
+- (uint32_t) readVarint32
+{
+ uint32_t result = 0;
+ int shift = 0;
+
+ while (true) {
+ uint8_t byte = [self readByte];
+ result |= (uint32_t)(byte & 0x7f) << shift;
+ if (!(byte & 0x80)) {
+ break;
+ }
+
+ shift += 7;
+ }
+ return result;
+}
+
+- (uint64_t) readVarint64
+{
+ int shift = 0;
+ uint64_t result = 0;
+
+ while (true) {
+ uint8_t byte = [self readByte];
+ result |= (uint64_t)(byte & 0x7f) << shift;
+ if (!(byte & 0x80)) {
+ break;
+ }
+
+ shift += 7;
+ }
+
+ return result;
+}
+
+- (int32_t) zigZagToi32: (uint32_t) n
+{
+ return (int32_t)(n >> 1) ^ (-(int32_t)(n & 1));
+}
+
+- (int64_t) zigZagToi64: (uint64_t) n
+{
+ return (int64_t)(n >> 1) ^ (-(int64_t)(n & 1));
+}
+
+- (uint8_t) ttypeForCompactType: (uint8_t) type
+{
+ switch (type & 0x0f) {
+ case TCType_STOP:
+ return TType_STOP;
+
+ case TCType_BOOLEAN_FALSE:
+ case TCType_BOOLEAN_TRUE:
+ return TType_BOOL;
+
+ case TCType_BYTE:
+ return TType_BYTE;
+
+ case TCType_I16:
+ return TType_I16;
+
+ case TCType_I32:
+ return TType_I32;
+
+ case TCType_I64:
+ return TType_I64;
+
+ case TCType_DOUBLE:
+ return TType_DOUBLE;
+
+ case TCType_BINARY:
+ return TType_STRING;
+
+ case TCType_LIST:
+ return TType_LIST;
+
+ case TCType_SET:
+ return TType_SET;
+
+ case TCType_MAP:
+ return TType_MAP;
+
+ case TCType_STRUCT:
+ return TType_STRUCT;
+
+ default:
+ @throw [TProtocolException exceptionWithName: @"TProtocolException"
+ reason: [NSString stringWithFormat: @"Don't know what type: %d", (uint8_t)(type & 0x0F)]];
+ }
+}
+
+- (uint8_t) compactTypeForTType: (uint8_t) ttype
+{
+ static uint8_t ttypeToCompactType[] = {
+ [TType_STOP] = TCType_STOP,
+ [TType_BOOL] = TCType_BOOLEAN_FALSE,
+ [TType_BYTE] = TCType_BYTE,
+ [TType_DOUBLE] = TCType_DOUBLE,
+ [TType_I16] = TCType_I16,
+ [TType_I32] = TCType_I32,
+ [TType_I64] = TCType_I64,
+ [TType_STRING] = TCType_BINARY,
+ [TType_STRUCT] = TCType_STRUCT,
+ [TType_MAP] = TCType_MAP,
+ [TType_SET] = TCType_SET,
+ [TType_LIST] = TCType_LIST
+ };
+
+ return ttypeToCompactType[ttype];
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.h
new file mode 100644
index 0000000..f298459
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "TProtocolDecorator.h"
+
+FOUNDATION_EXPORT NSString *const MULTIPLEXED_SERVICE_SEPERATOR;
+
+@interface TMultiplexedProtocol : TProtocolDecorator {
+ NSString * mServiceName;
+}
+
+- (id) initWithProtocol: (id <TProtocol>) protocol
+ serviceName: (NSString *) name;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.m
new file mode 100644
index 0000000..49095e3
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.m
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+#import "TMultiplexedProtocol.h"
+
+#import "TProtocol.h"
+#import "TObjective-C.h"
+
+NSString *const MULTIPLEXED_SERVICE_SEPERATOR = @":";
+
+@implementation TMultiplexedProtocol
+
+- (id) initWithProtocol: (id <TProtocol>) protocol
+ serviceName: (NSString *) name
+{
+ self = [super initWithProtocol:protocol];
+
+ if (self) {
+ mServiceName = [name retain_stub];
+ }
+ return self;
+}
+
+- (void) writeMessageBeginWithName: (NSString *) name
+ type: (int) messageType
+ sequenceID: (int) sequenceID
+{
+ switch (messageType) {
+ case TMessageType_CALL:
+ case TMessageType_ONEWAY:
+ {
+ NSMutableString * serviceFunction = [[NSMutableString alloc] initWithString:mServiceName];
+ [serviceFunction appendString:MULTIPLEXED_SERVICE_SEPERATOR];
+ [serviceFunction appendString:name];
+ [super writeMessageBeginWithName:serviceFunction type:messageType sequenceID:sequenceID];
+ [serviceFunction release_stub];
+ }
+ break;
+ default:
+ [super writeMessageBeginWithName:name type:messageType sequenceID:sequenceID];
+ break;
+ }
+}
+
+- (void) dealloc
+{
+ [mServiceName release_stub];
+ [super dealloc_stub];
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocol.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocol.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocol.h
new file mode 100644
index 0000000..281239d
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocol.h
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "TTransport.h"
+
+
+enum {
+ TMessageType_CALL = 1,
+ TMessageType_REPLY = 2,
+ TMessageType_EXCEPTION = 3,
+ TMessageType_ONEWAY = 4
+};
+
+enum {
+ TType_STOP = 0,
+ TType_VOID = 1,
+ TType_BOOL = 2,
+ TType_BYTE = 3,
+ TType_DOUBLE = 4,
+ TType_I16 = 6,
+ TType_I32 = 8,
+ TType_I64 = 10,
+ TType_STRING = 11,
+ TType_STRUCT = 12,
+ TType_MAP = 13,
+ TType_SET = 14,
+ TType_LIST = 15
+};
+
+
+@protocol TProtocol <NSObject>
+
+- (id <TTransport>) transport;
+
+- (void) readMessageBeginReturningName: (NSString **) name
+ type: (int *) type
+ sequenceID: (int *) sequenceID;
+- (void) readMessageEnd;
+
+- (void) readStructBeginReturningName: (NSString **) name;
+- (void) readStructEnd;
+
+- (void) readFieldBeginReturningName: (NSString **) name
+ type: (int *) fieldType
+ fieldID: (int *) fieldID;
+- (void) readFieldEnd;
+
+- (NSString *) readString;
+
+- (BOOL) readBool;
+
+- (unsigned char) readByte;
+
+- (short) readI16;
+
+- (int32_t) readI32;
+
+- (int64_t) readI64;
+
+- (double) readDouble;
+
+- (NSData *) readBinary;
+
+- (void) readMapBeginReturningKeyType: (int *) keyType
+ valueType: (int *) valueType
+ size: (int *) size;
+- (void) readMapEnd;
+
+
+- (void) readSetBeginReturningElementType: (int *) elementType
+ size: (int *) size;
+- (void) readSetEnd;
+
+
+- (void) readListBeginReturningElementType: (int *) elementType
+ size: (int *) size;
+- (void) readListEnd;
+
+
+- (void) writeMessageBeginWithName: (NSString *) name
+ type: (int) messageType
+ sequenceID: (int) sequenceID;
+- (void) writeMessageEnd;
+
+- (void) writeStructBeginWithName: (NSString *) name;
+- (void) writeStructEnd;
+
+- (void) writeFieldBeginWithName: (NSString *) name
+ type: (int) fieldType
+ fieldID: (int) fieldID;
+
+- (void) writeI32: (int32_t) value;
+
+- (void) writeI64: (int64_t) value;
+
+- (void) writeI16: (short) value;
+
+- (void) writeByte: (uint8_t) value;
+
+- (void) writeString: (NSString *) value;
+
+- (void) writeDouble: (double) value;
+
+- (void) writeBool: (BOOL) value;
+
+- (void) writeBinary: (NSData *) data;
+
+- (void) writeFieldStop;
+
+- (void) writeFieldEnd;
+
+- (void) writeMapBeginWithKeyType: (int) keyType
+ valueType: (int) valueType
+ size: (int) size;
+- (void) writeMapEnd;
+
+
+- (void) writeSetBeginWithElementType: (int) elementType
+ size: (int) size;
+- (void) writeSetEnd;
+
+
+- (void) writeListBeginWithElementType: (int) elementType
+ size: (int) size;
+
+- (void) writeListEnd;
+
+
+@end
+
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.h
new file mode 100644
index 0000000..829bed6
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "TProtocol.h"
+
+@interface TProtocolDecorator : NSObject <TProtocol> {
+ id<TProtocol> mConcreteProtocol;
+}
+
+- (id) initWithProtocol: (id <TProtocol>) protocol;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.m
new file mode 100644
index 0000000..e5acb6c
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.m
@@ -0,0 +1,274 @@
+/*
+ * 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.
+ */
+
+#import "TProtocolDecorator.h"
+#import "TObjective-C.h"
+
+@implementation TProtocolDecorator
+
+- (id) initWithProtocol: (id <TProtocol>) protocol
+{
+ self = [super init];
+ if (self) {
+ mConcreteProtocol = [protocol retain_stub];
+ }
+ return self;
+}
+
+- (id <TTransport>) transport
+{
+ return [mConcreteProtocol transport];
+}
+
+- (void) readMessageBeginReturningName: (NSString **) name
+ type: (int *) type
+ sequenceID: (int *) sequenceID
+{
+ [mConcreteProtocol readMessageBeginReturningName:name
+ type:type
+ sequenceID:sequenceID];
+}
+
+- (void) readMessageEnd
+{
+ [mConcreteProtocol readMessageEnd];
+}
+
+- (void) readStructBeginReturningName: (NSString **) name
+{
+ [mConcreteProtocol readStructBeginReturningName:name];
+}
+
+- (void) readStructEnd
+{
+ [mConcreteProtocol readStructEnd];
+}
+
+- (void) readFieldBeginReturningName: (NSString **) name
+ type: (int *) fieldType
+ fieldID: (int *) fieldID
+{
+ [mConcreteProtocol readFieldBeginReturningName:name
+ type:fieldType
+ fieldID:fieldID];
+}
+- (void) readFieldEnd
+{
+ [mConcreteProtocol readFieldEnd];
+}
+
+- (NSString *) readString
+{
+ return [mConcreteProtocol readString];
+}
+
+- (BOOL) readBool
+{
+ return [mConcreteProtocol readBool];
+}
+
+- (unsigned char) readByte
+{
+ return [mConcreteProtocol readByte];
+}
+
+- (short) readI16
+{
+ return [mConcreteProtocol readI16];
+}
+
+- (int32_t) readI32
+{
+ return [mConcreteProtocol readI32];
+}
+
+- (int64_t) readI64
+{
+ return [mConcreteProtocol readI64];
+}
+
+- (double) readDouble
+{
+ return [mConcreteProtocol readDouble];
+}
+
+- (NSData *) readBinary
+{
+ return [mConcreteProtocol readBinary];
+}
+
+- (void) readMapBeginReturningKeyType: (int *) keyType
+ valueType: (int *) valueType
+ size: (int *) size
+{
+ [mConcreteProtocol readMapBeginReturningKeyType:keyType
+ valueType:valueType
+ size:size];
+}
+- (void) readMapEnd
+{
+ [mConcreteProtocol readMapEnd];
+}
+
+
+- (void) readSetBeginReturningElementType: (int *) elementType
+ size: (int *) size
+{
+ [mConcreteProtocol readSetBeginReturningElementType:elementType
+ size:size];
+}
+- (void) readSetEnd
+{
+ [mConcreteProtocol readSetEnd];
+}
+
+- (void) readListBeginReturningElementType: (int *) elementType
+ size: (int *) size
+{
+ [mConcreteProtocol readListBeginReturningElementType:elementType
+ size:size];
+}
+- (void) readListEnd
+{
+ [mConcreteProtocol readListEnd];
+}
+
+- (void) writeMessageBeginWithName: (NSString *) name
+ type: (int) messageType
+ sequenceID: (int) sequenceID
+{
+ [mConcreteProtocol writeMessageBeginWithName:name
+ type:messageType
+ sequenceID:sequenceID];
+}
+- (void) writeMessageEnd
+{
+ [mConcreteProtocol writeMessageEnd];
+}
+
+- (void) writeStructBeginWithName: (NSString *) name
+{
+ [mConcreteProtocol writeStructBeginWithName:name];
+}
+- (void) writeStructEnd
+{
+ [mConcreteProtocol writeStructEnd];
+}
+
+- (void) writeFieldBeginWithName: (NSString *) name
+ type: (int) fieldType
+ fieldID: (int) fieldID
+{
+ [mConcreteProtocol writeFieldBeginWithName:name
+ type:fieldType
+ fieldID:fieldID];
+}
+
+- (void) writeI32: (int32_t) value
+{
+ [mConcreteProtocol writeI32:value];
+}
+
+- (void) writeI64: (int64_t) value
+{
+ [mConcreteProtocol writeI64:value];
+}
+
+- (void) writeI16: (short) value
+{
+ [mConcreteProtocol writeI16:value];
+}
+
+- (void) writeByte: (uint8_t) value
+{
+ [mConcreteProtocol writeByte:value];
+}
+
+- (void) writeString: (NSString *) value
+{
+ [mConcreteProtocol writeString:value];
+}
+
+- (void) writeDouble: (double) value
+{
+ [mConcreteProtocol writeDouble:value];
+}
+
+- (void) writeBool: (BOOL) value
+{
+ [mConcreteProtocol writeBool:value];
+}
+
+- (void) writeBinary: (NSData *) data
+{
+ [mConcreteProtocol writeBinary:data];
+}
+
+- (void) writeFieldStop
+{
+ [mConcreteProtocol writeFieldStop];
+}
+
+- (void) writeFieldEnd
+{
+ [mConcreteProtocol writeFieldEnd];
+}
+
+- (void) writeMapBeginWithKeyType: (int) keyType
+ valueType: (int) valueType
+ size: (int) size
+{
+ [mConcreteProtocol writeMapBeginWithKeyType:keyType
+ valueType:valueType
+ size:size];
+}
+- (void) writeMapEnd
+{
+ [mConcreteProtocol writeMapEnd];
+}
+
+- (void) writeSetBeginWithElementType: (int) elementType
+ size: (int) size
+{
+ [mConcreteProtocol writeSetBeginWithElementType:elementType size:size];
+}
+
+- (void) writeSetEnd
+{
+ [mConcreteProtocol writeSetEnd];
+}
+
+- (void) writeListBeginWithElementType: (int) elementType
+ size: (int) size
+{
+ [mConcreteProtocol writeListBeginWithElementType:elementType size:size];
+}
+
+- (void) writeListEnd
+{
+ [mConcreteProtocol writeListEnd];
+}
+
+- (void) dealloc
+{
+ [mConcreteProtocol release_stub];
+ [super dealloc_stub];
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.h
new file mode 100644
index 0000000..ad354fc
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.h
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+#import "TException.h"
+
+@interface TProtocolException : TException {
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.m
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.m
new file mode 100644
index 0000000..681487a
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.m
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+#import "TProtocolException.h"
+
+@implementation TProtocolException
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolFactory.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolFactory.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolFactory.h
new file mode 100644
index 0000000..f200a6d
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolFactory.h
@@ -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.
+ */
+
+#import <Foundation/Foundation.h>
+#import "TProtocol.h"
+#import "TTransport.h"
+
+
+@protocol TProtocolFactory <NSObject>
+
+- (id <TProtocol>) newProtocolOnTransport: (id <TTransport>) transport;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.h
new file mode 100644
index 0000000..757748a
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.h
@@ -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.
+ */
+
+#import "TProtocol.h"
+#import "TTransport.h"
+
+@interface TProtocolUtil : NSObject {
+
+}
+
++ (void) skipType: (int) type onProtocol: (id <TProtocol>) protocol;
+
+@end