You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2014/09/23 00:07:35 UTC
svn commit: r1626912 [3/4] - in /avro/trunk: ./ lang/java/ lang/java/avro/
lang/java/ipc/src/test/java/org/apache/avro/ipc/ lang/java/mapred/
lang/java/mapred/src/test/java/org/apache/avro/hadoop/util/
lang/java/maven-plugin/ lang/java/maven-plugin/src...
Modified: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/E.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/E.java?rev=1626912&r1=1626911&r2=1626912&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/E.java (original)
+++ avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/E.java Mon Sep 22 22:07:34 2014
@@ -1,7 +1,8 @@
/**
- * Autogenerated by Thrift Compiler (0.7.0)
+ * Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
*/
package org.apache.avro.thrift.test;
Modified: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Error.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Error.java?rev=1626912&r1=1626911&r2=1626912&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Error.java (original)
+++ avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Error.java Mon Sep 22 22:07:34 2014
@@ -1,10 +1,22 @@
/**
- * Autogenerated by Thrift Compiler (0.7.0)
+ * Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
*/
package org.apache.avro.thrift.test;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
@@ -20,11 +32,17 @@ import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class Error extends Exception implements org.apache.thrift.TBase<Error, Error._Fields>, java.io.Serializable, Cloneable {
+public class Error extends TException implements org.apache.thrift.TBase<Error, Error._Fields>, java.io.Serializable, Cloneable, Comparable<Error> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Error");
private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new ErrorStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new ErrorTupleSchemeFactory());
+ }
+
private String message; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
@@ -86,7 +104,6 @@ public class Error extends Exception imp
}
// isset id assignments
-
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@@ -212,20 +229,20 @@ public class Error extends Exception imp
return 0;
}
+ @Override
public int compareTo(Error other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
- Error typedOther = (Error)other;
- lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
+ lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMessage()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, typedOther.message);
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
if (lastComparison != 0) {
return lastComparison;
}
@@ -238,42 +255,11 @@ public class Error extends Exception imp
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
- org.apache.thrift.protocol.TField field;
- iprot.readStructBegin();
- while (true)
- {
- field = iprot.readFieldBegin();
- if (field.type == org.apache.thrift.protocol.TType.STOP) {
- break;
- }
- switch (field.id) {
- case 1: // MESSAGE
- if (field.type == org.apache.thrift.protocol.TType.STRING) {
- this.message = iprot.readString();
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- break;
- default:
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
- validate();
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
- validate();
-
- oprot.writeStructBegin(STRUCT_DESC);
- if (this.message != null) {
- oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
- oprot.writeString(this.message);
- oprot.writeFieldEnd();
- }
- oprot.writeFieldStop();
- oprot.writeStructEnd();
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
@@ -294,6 +280,7 @@ public class Error extends Exception imp
public void validate() throws org.apache.thrift.TException {
// check for required fields
+ // check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -312,5 +299,87 @@ public class Error extends Exception imp
}
}
+ private static class ErrorStandardSchemeFactory implements SchemeFactory {
+ public ErrorStandardScheme getScheme() {
+ return new ErrorStandardScheme();
+ }
+ }
+
+ private static class ErrorStandardScheme extends StandardScheme<Error> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, Error struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // MESSAGE
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.message = iprot.readString();
+ struct.setMessageIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, Error struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.message != null) {
+ oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+ oprot.writeString(struct.message);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class ErrorTupleSchemeFactory implements SchemeFactory {
+ public ErrorTupleScheme getScheme() {
+ return new ErrorTupleScheme();
+ }
+ }
+
+ private static class ErrorTupleScheme extends TupleScheme<Error> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, Error struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetMessage()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetMessage()) {
+ oprot.writeString(struct.message);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, Error struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.message = iprot.readString();
+ struct.setMessageIsSet(true);
+ }
+ }
+ }
+
}
Modified: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Foo.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Foo.java?rev=1626912&r1=1626911&r2=1626912&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Foo.java (original)
+++ avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Foo.java Mon Sep 22 22:07:34 2014
@@ -1,10 +1,22 @@
/**
- * Autogenerated by Thrift Compiler (0.7.0)
+ * Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
*/
package org.apache.avro.thrift.test;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
@@ -34,11 +46,11 @@ public class Foo {
public interface AsyncIface {
- public void ping(org.apache.thrift.async.AsyncMethodCallback<AsyncClient.ping_call> resultHandler) throws org.apache.thrift.TException;
+ public void ping(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
- public void add(int num1, int num2, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.add_call> resultHandler) throws org.apache.thrift.TException;
+ public void add(int num1, int num2, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
- public void zip(org.apache.thrift.async.AsyncMethodCallback<AsyncClient.zip_call> resultHandler) throws org.apache.thrift.TException;
+ public void zip(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
}
@@ -134,7 +146,7 @@ public class Foo {
super(protocolFactory, clientManager, transport);
}
- public void ping(org.apache.thrift.async.AsyncMethodCallback<ping_call> resultHandler) throws org.apache.thrift.TException {
+ public void ping(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
ping_call method_call = new ping_call(resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
@@ -142,7 +154,7 @@ public class Foo {
}
public static class ping_call extends org.apache.thrift.async.TAsyncMethodCall {
- public ping_call(org.apache.thrift.async.AsyncMethodCallback<ping_call> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+ public ping_call(org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
super(client, protocolFactory, transport, resultHandler, false);
}
@@ -163,7 +175,7 @@ public class Foo {
}
}
- public void add(int num1, int num2, org.apache.thrift.async.AsyncMethodCallback<add_call> resultHandler) throws org.apache.thrift.TException {
+ public void add(int num1, int num2, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
add_call method_call = new add_call(num1, num2, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
@@ -173,7 +185,7 @@ public class Foo {
public static class add_call extends org.apache.thrift.async.TAsyncMethodCall {
private int num1;
private int num2;
- public add_call(int num1, int num2, org.apache.thrift.async.AsyncMethodCallback<add_call> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+ public add_call(int num1, int num2, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
super(client, protocolFactory, transport, resultHandler, false);
this.num1 = num1;
this.num2 = num2;
@@ -198,7 +210,7 @@ public class Foo {
}
}
- public void zip(org.apache.thrift.async.AsyncMethodCallback<zip_call> resultHandler) throws org.apache.thrift.TException {
+ public void zip(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
zip_call method_call = new zip_call(resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
@@ -206,7 +218,7 @@ public class Foo {
}
public static class zip_call extends org.apache.thrift.async.TAsyncMethodCall {
- public zip_call(org.apache.thrift.async.AsyncMethodCallback<zip_call> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+ public zip_call(org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
super(client, protocolFactory, transport, resultHandler, true);
}
@@ -228,7 +240,7 @@ public class Foo {
}
- public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor {
+ public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
public Processor(I iface) {
super(iface, getProcessMap(new HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
@@ -245,32 +257,40 @@ public class Foo {
return processMap;
}
- private static class ping<I extends Iface> extends org.apache.thrift.ProcessFunction<I, ping_args> {
+ public static class ping<I extends Iface> extends org.apache.thrift.ProcessFunction<I, ping_args> {
public ping() {
super("ping");
}
- protected ping_args getEmptyArgsInstance() {
+ public ping_args getEmptyArgsInstance() {
return new ping_args();
}
- protected ping_result getResult(I iface, ping_args args) throws org.apache.thrift.TException {
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public ping_result getResult(I iface, ping_args args) throws org.apache.thrift.TException {
ping_result result = new ping_result();
iface.ping();
return result;
}
}
- private static class add<I extends Iface> extends org.apache.thrift.ProcessFunction<I, add_args> {
+ public static class add<I extends Iface> extends org.apache.thrift.ProcessFunction<I, add_args> {
public add() {
super("add");
}
- protected add_args getEmptyArgsInstance() {
+ public add_args getEmptyArgsInstance() {
return new add_args();
}
- protected add_result getResult(I iface, add_args args) throws org.apache.thrift.TException {
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public add_result getResult(I iface, add_args args) throws org.apache.thrift.TException {
add_result result = new add_result();
result.success = iface.add(args.num1, args.num2);
result.setSuccessIsSet(true);
@@ -278,16 +298,20 @@ public class Foo {
}
}
- private static class zip<I extends Iface> extends org.apache.thrift.ProcessFunction<I, zip_args> {
+ public static class zip<I extends Iface> extends org.apache.thrift.ProcessFunction<I, zip_args> {
public zip() {
super("zip");
}
- protected zip_args getEmptyArgsInstance() {
+ public zip_args getEmptyArgsInstance() {
return new zip_args();
}
- protected org.apache.thrift.TBase getResult(I iface, zip_args args) throws org.apache.thrift.TException {
+ protected boolean isOneway() {
+ return true;
+ }
+
+ public org.apache.thrift.TBase getResult(I iface, zip_args args) throws org.apache.thrift.TException {
iface.zip();
return null;
}
@@ -295,10 +319,165 @@ public class Foo {
}
- public static class ping_args implements org.apache.thrift.TBase<ping_args, ping_args._Fields>, java.io.Serializable, Cloneable {
+ public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AsyncProcessor.class.getName());
+ public AsyncProcessor(I iface) {
+ super(iface, getProcessMap(new HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
+ }
+
+ protected AsyncProcessor(I iface, Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) {
+ super(iface, getProcessMap(processMap));
+ }
+
+ private static <I extends AsyncIface> Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase,?>> getProcessMap(Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) {
+ processMap.put("ping", new ping());
+ processMap.put("add", new add());
+ processMap.put("zip", new zip());
+ return processMap;
+ }
+
+ public static class ping<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, ping_args, Void> {
+ public ping() {
+ super("ping");
+ }
+
+ public ping_args getEmptyArgsInstance() {
+ return new ping_args();
+ }
+
+ public AsyncMethodCallback<Void> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
+ final org.apache.thrift.AsyncProcessFunction fcall = this;
+ return new AsyncMethodCallback<Void>() {
+ public void onComplete(Void o) {
+ ping_result result = new ping_result();
+ try {
+ fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+ return;
+ } catch (Exception e) {
+ LOGGER.error("Exception writing to internal frame buffer", e);
+ }
+ fb.close();
+ }
+ public void onError(Exception e) {
+ byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+ org.apache.thrift.TBase msg;
+ ping_result result = new ping_result();
+ {
+ msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+ msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+ }
+ try {
+ fcall.sendResponse(fb,msg,msgType,seqid);
+ return;
+ } catch (Exception ex) {
+ LOGGER.error("Exception writing to internal frame buffer", ex);
+ }
+ fb.close();
+ }
+ };
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public void start(I iface, ping_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws TException {
+ iface.ping(resultHandler);
+ }
+ }
+
+ public static class add<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, add_args, Integer> {
+ public add() {
+ super("add");
+ }
+
+ public add_args getEmptyArgsInstance() {
+ return new add_args();
+ }
+
+ public AsyncMethodCallback<Integer> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
+ final org.apache.thrift.AsyncProcessFunction fcall = this;
+ return new AsyncMethodCallback<Integer>() {
+ public void onComplete(Integer o) {
+ add_result result = new add_result();
+ result.success = o;
+ result.setSuccessIsSet(true);
+ try {
+ fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+ return;
+ } catch (Exception e) {
+ LOGGER.error("Exception writing to internal frame buffer", e);
+ }
+ fb.close();
+ }
+ public void onError(Exception e) {
+ byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+ org.apache.thrift.TBase msg;
+ add_result result = new add_result();
+ {
+ msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+ msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+ }
+ try {
+ fcall.sendResponse(fb,msg,msgType,seqid);
+ return;
+ } catch (Exception ex) {
+ LOGGER.error("Exception writing to internal frame buffer", ex);
+ }
+ fb.close();
+ }
+ };
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public void start(I iface, add_args args, org.apache.thrift.async.AsyncMethodCallback<Integer> resultHandler) throws TException {
+ iface.add(args.num1, args.num2,resultHandler);
+ }
+ }
+
+ public static class zip<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, zip_args, Void> {
+ public zip() {
+ super("zip");
+ }
+
+ public zip_args getEmptyArgsInstance() {
+ return new zip_args();
+ }
+
+ public AsyncMethodCallback<Void> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
+ final org.apache.thrift.AsyncProcessFunction fcall = this;
+ return new AsyncMethodCallback<Void>() {
+ public void onComplete(Void o) {
+ }
+ public void onError(Exception e) {
+ }
+ };
+ }
+
+ protected boolean isOneway() {
+ return true;
+ }
+
+ public void start(I iface, zip_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws TException {
+ iface.zip(resultHandler);
+ }
+ }
+
+ }
+
+ public static class ping_args implements org.apache.thrift.TBase<ping_args, ping_args._Fields>, java.io.Serializable, Cloneable, Comparable<ping_args> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ping_args");
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new ping_argsStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new ping_argsTupleSchemeFactory());
+ }
+
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -422,13 +601,13 @@ public class Foo {
return 0;
}
+ @Override
public int compareTo(ping_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
- ping_args typedOther = (ping_args)other;
return 0;
}
@@ -438,30 +617,11 @@ public class Foo {
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
- org.apache.thrift.protocol.TField field;
- iprot.readStructBegin();
- while (true)
- {
- field = iprot.readFieldBegin();
- if (field.type == org.apache.thrift.protocol.TType.STOP) {
- break;
- }
- switch (field.id) {
- default:
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
- validate();
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
- validate();
-
- oprot.writeStructBegin(STRUCT_DESC);
- oprot.writeFieldStop();
- oprot.writeStructEnd();
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
@@ -475,6 +635,7 @@ public class Foo {
public void validate() throws org.apache.thrift.TException {
// check for required fields
+ // check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -493,12 +654,74 @@ public class Foo {
}
}
+ private static class ping_argsStandardSchemeFactory implements SchemeFactory {
+ public ping_argsStandardScheme getScheme() {
+ return new ping_argsStandardScheme();
+ }
+ }
+
+ private static class ping_argsStandardScheme extends StandardScheme<ping_args> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, ping_args struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, ping_args struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class ping_argsTupleSchemeFactory implements SchemeFactory {
+ public ping_argsTupleScheme getScheme() {
+ return new ping_argsTupleScheme();
+ }
+ }
+
+ private static class ping_argsTupleScheme extends TupleScheme<ping_args> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, ping_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, ping_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ }
+ }
+
}
- public static class ping_result implements org.apache.thrift.TBase<ping_result, ping_result._Fields>, java.io.Serializable, Cloneable {
+ public static class ping_result implements org.apache.thrift.TBase<ping_result, ping_result._Fields>, java.io.Serializable, Cloneable, Comparable<ping_result> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ping_result");
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new ping_resultStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new ping_resultTupleSchemeFactory());
+ }
+
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -622,13 +845,13 @@ public class Foo {
return 0;
}
+ @Override
public int compareTo(ping_result other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
- ping_result typedOther = (ping_result)other;
return 0;
}
@@ -638,30 +861,12 @@ public class Foo {
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
- org.apache.thrift.protocol.TField field;
- iprot.readStructBegin();
- while (true)
- {
- field = iprot.readFieldBegin();
- if (field.type == org.apache.thrift.protocol.TType.STOP) {
- break;
- }
- switch (field.id) {
- default:
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
- validate();
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
- oprot.writeStructBegin(STRUCT_DESC);
-
- oprot.writeFieldStop();
- oprot.writeStructEnd();
- }
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
@Override
public String toString() {
@@ -674,6 +879,7 @@ public class Foo {
public void validate() throws org.apache.thrift.TException {
// check for required fields
+ // check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -692,14 +898,76 @@ public class Foo {
}
}
+ private static class ping_resultStandardSchemeFactory implements SchemeFactory {
+ public ping_resultStandardScheme getScheme() {
+ return new ping_resultStandardScheme();
+ }
+ }
+
+ private static class ping_resultStandardScheme extends StandardScheme<ping_result> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, ping_result struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, ping_result struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class ping_resultTupleSchemeFactory implements SchemeFactory {
+ public ping_resultTupleScheme getScheme() {
+ return new ping_resultTupleScheme();
+ }
+ }
+
+ private static class ping_resultTupleScheme extends TupleScheme<ping_result> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, ping_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, ping_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ }
+ }
+
}
- public static class add_args implements org.apache.thrift.TBase<add_args, add_args._Fields>, java.io.Serializable, Cloneable {
+ public static class add_args implements org.apache.thrift.TBase<add_args, add_args._Fields>, java.io.Serializable, Cloneable, Comparable<add_args> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("add_args");
private static final org.apache.thrift.protocol.TField NUM1_FIELD_DESC = new org.apache.thrift.protocol.TField("num1", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField NUM2_FIELD_DESC = new org.apache.thrift.protocol.TField("num2", org.apache.thrift.protocol.TType.I32, (short)2);
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new add_argsStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new add_argsTupleSchemeFactory());
+ }
+
private int num1; // required
private int num2; // required
@@ -767,8 +1035,7 @@ public class Foo {
// isset id assignments
private static final int __NUM1_ISSET_ID = 0;
private static final int __NUM2_ISSET_ID = 1;
- private BitSet __isset_bit_vector = new BitSet(2);
-
+ private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@@ -798,8 +1065,7 @@ public class Foo {
* Performs a deep copy on <i>other</i>.
*/
public add_args(add_args other) {
- __isset_bit_vector.clear();
- __isset_bit_vector.or(other.__isset_bit_vector);
+ __isset_bitfield = other.__isset_bitfield;
this.num1 = other.num1;
this.num2 = other.num2;
}
@@ -826,16 +1092,16 @@ public class Foo {
}
public void unsetNum1() {
- __isset_bit_vector.clear(__NUM1_ISSET_ID);
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __NUM1_ISSET_ID);
}
/** Returns true if field num1 is set (has been assigned a value) and false otherwise */
public boolean isSetNum1() {
- return __isset_bit_vector.get(__NUM1_ISSET_ID);
+ return EncodingUtils.testBit(__isset_bitfield, __NUM1_ISSET_ID);
}
public void setNum1IsSet(boolean value) {
- __isset_bit_vector.set(__NUM1_ISSET_ID, value);
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __NUM1_ISSET_ID, value);
}
public int getNum2() {
@@ -848,16 +1114,16 @@ public class Foo {
}
public void unsetNum2() {
- __isset_bit_vector.clear(__NUM2_ISSET_ID);
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __NUM2_ISSET_ID);
}
/** Returns true if field num2 is set (has been assigned a value) and false otherwise */
public boolean isSetNum2() {
- return __isset_bit_vector.get(__NUM2_ISSET_ID);
+ return EncodingUtils.testBit(__isset_bitfield, __NUM2_ISSET_ID);
}
public void setNum2IsSet(boolean value) {
- __isset_bit_vector.set(__NUM2_ISSET_ID, value);
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __NUM2_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
@@ -947,30 +1213,30 @@ public class Foo {
return 0;
}
+ @Override
public int compareTo(add_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
- add_args typedOther = (add_args)other;
- lastComparison = Boolean.valueOf(isSetNum1()).compareTo(typedOther.isSetNum1());
+ lastComparison = Boolean.valueOf(isSetNum1()).compareTo(other.isSetNum1());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetNum1()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num1, typedOther.num1);
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num1, other.num1);
if (lastComparison != 0) {
return lastComparison;
}
}
- lastComparison = Boolean.valueOf(isSetNum2()).compareTo(typedOther.isSetNum2());
+ lastComparison = Boolean.valueOf(isSetNum2()).compareTo(other.isSetNum2());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetNum2()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num2, typedOther.num2);
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num2, other.num2);
if (lastComparison != 0) {
return lastComparison;
}
@@ -983,52 +1249,11 @@ public class Foo {
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
- org.apache.thrift.protocol.TField field;
- iprot.readStructBegin();
- while (true)
- {
- field = iprot.readFieldBegin();
- if (field.type == org.apache.thrift.protocol.TType.STOP) {
- break;
- }
- switch (field.id) {
- case 1: // NUM1
- if (field.type == org.apache.thrift.protocol.TType.I32) {
- this.num1 = iprot.readI32();
- setNum1IsSet(true);
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- break;
- case 2: // NUM2
- if (field.type == org.apache.thrift.protocol.TType.I32) {
- this.num2 = iprot.readI32();
- setNum2IsSet(true);
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- break;
- default:
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
- validate();
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
- validate();
-
- oprot.writeStructBegin(STRUCT_DESC);
- oprot.writeFieldBegin(NUM1_FIELD_DESC);
- oprot.writeI32(this.num1);
- oprot.writeFieldEnd();
- oprot.writeFieldBegin(NUM2_FIELD_DESC);
- oprot.writeI32(this.num2);
- oprot.writeFieldEnd();
- oprot.writeFieldStop();
- oprot.writeStructEnd();
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
@@ -1049,6 +1274,7 @@ public class Foo {
public void validate() throws org.apache.thrift.TException {
// check for required fields
+ // check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -1062,20 +1288,127 @@ public class Foo {
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
- __isset_bit_vector = new BitSet(1);
+ __isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
+ private static class add_argsStandardSchemeFactory implements SchemeFactory {
+ public add_argsStandardScheme getScheme() {
+ return new add_argsStandardScheme();
+ }
+ }
+
+ private static class add_argsStandardScheme extends StandardScheme<add_args> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, add_args struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // NUM1
+ if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+ struct.num1 = iprot.readI32();
+ struct.setNum1IsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 2: // NUM2
+ if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+ struct.num2 = iprot.readI32();
+ struct.setNum2IsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, add_args struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldBegin(NUM1_FIELD_DESC);
+ oprot.writeI32(struct.num1);
+ oprot.writeFieldEnd();
+ oprot.writeFieldBegin(NUM2_FIELD_DESC);
+ oprot.writeI32(struct.num2);
+ oprot.writeFieldEnd();
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class add_argsTupleSchemeFactory implements SchemeFactory {
+ public add_argsTupleScheme getScheme() {
+ return new add_argsTupleScheme();
+ }
+ }
+
+ private static class add_argsTupleScheme extends TupleScheme<add_args> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, add_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetNum1()) {
+ optionals.set(0);
+ }
+ if (struct.isSetNum2()) {
+ optionals.set(1);
+ }
+ oprot.writeBitSet(optionals, 2);
+ if (struct.isSetNum1()) {
+ oprot.writeI32(struct.num1);
+ }
+ if (struct.isSetNum2()) {
+ oprot.writeI32(struct.num2);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, add_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(2);
+ if (incoming.get(0)) {
+ struct.num1 = iprot.readI32();
+ struct.setNum1IsSet(true);
+ }
+ if (incoming.get(1)) {
+ struct.num2 = iprot.readI32();
+ struct.setNum2IsSet(true);
+ }
+ }
+ }
+
}
- public static class add_result implements org.apache.thrift.TBase<add_result, add_result._Fields>, java.io.Serializable, Cloneable {
+ public static class add_result implements org.apache.thrift.TBase<add_result, add_result._Fields>, java.io.Serializable, Cloneable, Comparable<add_result> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("add_result");
private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.I32, (short)0);
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new add_resultStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new add_resultTupleSchemeFactory());
+ }
+
private int success; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
@@ -1138,8 +1471,7 @@ public class Foo {
// isset id assignments
private static final int __SUCCESS_ISSET_ID = 0;
- private BitSet __isset_bit_vector = new BitSet(1);
-
+ private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@@ -1164,8 +1496,7 @@ public class Foo {
* Performs a deep copy on <i>other</i>.
*/
public add_result(add_result other) {
- __isset_bit_vector.clear();
- __isset_bit_vector.or(other.__isset_bit_vector);
+ __isset_bitfield = other.__isset_bitfield;
this.success = other.success;
}
@@ -1189,16 +1520,16 @@ public class Foo {
}
public void unsetSuccess() {
- __isset_bit_vector.clear(__SUCCESS_ISSET_ID);
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID);
}
/** Returns true if field success is set (has been assigned a value) and false otherwise */
public boolean isSetSuccess() {
- return __isset_bit_vector.get(__SUCCESS_ISSET_ID);
+ return EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID);
}
public void setSuccessIsSet(boolean value) {
- __isset_bit_vector.set(__SUCCESS_ISSET_ID, value);
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
@@ -1266,20 +1597,20 @@ public class Foo {
return 0;
}
+ @Override
public int compareTo(add_result other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
- add_result typedOther = (add_result)other;
- lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSuccess()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success);
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
if (lastComparison != 0) {
return lastComparison;
}
@@ -1292,43 +1623,12 @@ public class Foo {
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
- org.apache.thrift.protocol.TField field;
- iprot.readStructBegin();
- while (true)
- {
- field = iprot.readFieldBegin();
- if (field.type == org.apache.thrift.protocol.TType.STOP) {
- break;
- }
- switch (field.id) {
- case 0: // SUCCESS
- if (field.type == org.apache.thrift.protocol.TType.I32) {
- this.success = iprot.readI32();
- setSuccessIsSet(true);
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- break;
- default:
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
- validate();
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
- oprot.writeStructBegin(STRUCT_DESC);
-
- if (this.isSetSuccess()) {
- oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
- oprot.writeI32(this.success);
- oprot.writeFieldEnd();
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
- oprot.writeFieldStop();
- oprot.writeStructEnd();
- }
@Override
public String toString() {
@@ -1344,6 +1644,7 @@ public class Foo {
public void validate() throws org.apache.thrift.TException {
// check for required fields
+ // check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -1356,18 +1657,108 @@ public class Foo {
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
+ // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+ __isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
+ private static class add_resultStandardSchemeFactory implements SchemeFactory {
+ public add_resultStandardScheme getScheme() {
+ return new add_resultStandardScheme();
+ }
+ }
+
+ private static class add_resultStandardScheme extends StandardScheme<add_result> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, add_result struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 0: // SUCCESS
+ if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+ struct.success = iprot.readI32();
+ struct.setSuccessIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, add_result struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeI32(struct.success);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class add_resultTupleSchemeFactory implements SchemeFactory {
+ public add_resultTupleScheme getScheme() {
+ return new add_resultTupleScheme();
+ }
+ }
+
+ private static class add_resultTupleScheme extends TupleScheme<add_result> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, add_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetSuccess()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetSuccess()) {
+ oprot.writeI32(struct.success);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, add_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.success = iprot.readI32();
+ struct.setSuccessIsSet(true);
+ }
+ }
+ }
+
}
- public static class zip_args implements org.apache.thrift.TBase<zip_args, zip_args._Fields>, java.io.Serializable, Cloneable {
+ public static class zip_args implements org.apache.thrift.TBase<zip_args, zip_args._Fields>, java.io.Serializable, Cloneable, Comparable<zip_args> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("zip_args");
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new zip_argsStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new zip_argsTupleSchemeFactory());
+ }
+
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -1491,13 +1882,13 @@ public class Foo {
return 0;
}
+ @Override
public int compareTo(zip_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
- zip_args typedOther = (zip_args)other;
return 0;
}
@@ -1507,30 +1898,11 @@ public class Foo {
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
- org.apache.thrift.protocol.TField field;
- iprot.readStructBegin();
- while (true)
- {
- field = iprot.readFieldBegin();
- if (field.type == org.apache.thrift.protocol.TType.STOP) {
- break;
- }
- switch (field.id) {
- default:
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
- validate();
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
- validate();
-
- oprot.writeStructBegin(STRUCT_DESC);
- oprot.writeFieldStop();
- oprot.writeStructEnd();
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
@@ -1544,6 +1916,7 @@ public class Foo {
public void validate() throws org.apache.thrift.TException {
// check for required fields
+ // check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -1562,6 +1935,62 @@ public class Foo {
}
}
+ private static class zip_argsStandardSchemeFactory implements SchemeFactory {
+ public zip_argsStandardScheme getScheme() {
+ return new zip_argsStandardScheme();
+ }
+ }
+
+ private static class zip_argsStandardScheme extends StandardScheme<zip_args> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, zip_args struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, zip_args struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class zip_argsTupleSchemeFactory implements SchemeFactory {
+ public zip_argsTupleScheme getScheme() {
+ return new zip_argsTupleScheme();
+ }
+ }
+
+ private static class zip_argsTupleScheme extends TupleScheme<zip_args> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, zip_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, zip_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ }
+ }
+
}
}
Modified: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java?rev=1626912&r1=1626911&r2=1626912&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java (original)
+++ avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/FooOrBar.java Mon Sep 22 22:07:34 2014
@@ -1,10 +1,22 @@
/**
- * Autogenerated by Thrift Compiler (0.7.0)
+ * Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
*/
package org.apache.avro.thrift.test;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
@@ -144,7 +156,7 @@ public class FooOrBar extends org.apache
}
@Override
- protected Object readValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {
+ protected Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {
_Fields setField = _Fields.findByThriftId(field.id);
if (setField != null) {
switch (setField) {
@@ -176,7 +188,44 @@ public class FooOrBar extends org.apache
}
@Override
- protected void writeValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ switch (setField_) {
+ case FOO:
+ String foo = (String)value_;
+ oprot.writeString(foo);
+ return;
+ case BAR:
+ String bar = (String)value_;
+ oprot.writeString(bar);
+ return;
+ default:
+ throw new IllegalStateException("Cannot write union with unknown field " + setField_);
+ }
+ }
+
+ @Override
+ protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
+ _Fields setField = _Fields.findByThriftId(fieldID);
+ if (setField != null) {
+ switch (setField) {
+ case FOO:
+ String foo;
+ foo = iprot.readString();
+ return foo;
+ case BAR:
+ String bar;
+ bar = iprot.readString();
+ return bar;
+ default:
+ throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
+ }
+ } else {
+ throw new TProtocolException("Couldn't find a field with field id " + fieldID);
+ }
+ }
+
+ @Override
+ protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
switch (setField_) {
case FOO:
String foo = (String)value_;
Modified: avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Nested.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Nested.java?rev=1626912&r1=1626911&r2=1626912&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Nested.java (original)
+++ avro/trunk/lang/java/thrift/src/test/java/org/apache/avro/thrift/test/Nested.java Mon Sep 22 22:07:34 2014
@@ -1,10 +1,22 @@
/**
- * Autogenerated by Thrift Compiler (0.7.0)
+ * Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
*/
package org.apache.avro.thrift.test;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
@@ -20,11 +32,17 @@ import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class Nested implements org.apache.thrift.TBase<Nested, Nested._Fields>, java.io.Serializable, Cloneable {
+public class Nested implements org.apache.thrift.TBase<Nested, Nested._Fields>, java.io.Serializable, Cloneable, Comparable<Nested> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Nested");
private static final org.apache.thrift.protocol.TField X_FIELD_DESC = new org.apache.thrift.protocol.TField("x", org.apache.thrift.protocol.TType.I32, (short)1);
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new NestedStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new NestedTupleSchemeFactory());
+ }
+
private int x; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
@@ -87,8 +105,7 @@ public class Nested implements org.apach
// isset id assignments
private static final int __X_ISSET_ID = 0;
- private BitSet __isset_bit_vector = new BitSet(1);
-
+ private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@@ -113,8 +130,7 @@ public class Nested implements org.apach
* Performs a deep copy on <i>other</i>.
*/
public Nested(Nested other) {
- __isset_bit_vector.clear();
- __isset_bit_vector.or(other.__isset_bit_vector);
+ __isset_bitfield = other.__isset_bitfield;
this.x = other.x;
}
@@ -138,16 +154,16 @@ public class Nested implements org.apach
}
public void unsetX() {
- __isset_bit_vector.clear(__X_ISSET_ID);
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __X_ISSET_ID);
}
/** Returns true if field x is set (has been assigned a value) and false otherwise */
public boolean isSetX() {
- return __isset_bit_vector.get(__X_ISSET_ID);
+ return EncodingUtils.testBit(__isset_bitfield, __X_ISSET_ID);
}
public void setXIsSet(boolean value) {
- __isset_bit_vector.set(__X_ISSET_ID, value);
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __X_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
@@ -215,20 +231,20 @@ public class Nested implements org.apach
return 0;
}
+ @Override
public int compareTo(Nested other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
- Nested typedOther = (Nested)other;
- lastComparison = Boolean.valueOf(isSetX()).compareTo(typedOther.isSetX());
+ lastComparison = Boolean.valueOf(isSetX()).compareTo(other.isSetX());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetX()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.x, typedOther.x);
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.x, other.x);
if (lastComparison != 0) {
return lastComparison;
}
@@ -241,41 +257,11 @@ public class Nested implements org.apach
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
- org.apache.thrift.protocol.TField field;
- iprot.readStructBegin();
- while (true)
- {
- field = iprot.readFieldBegin();
- if (field.type == org.apache.thrift.protocol.TType.STOP) {
- break;
- }
- switch (field.id) {
- case 1: // X
- if (field.type == org.apache.thrift.protocol.TType.I32) {
- this.x = iprot.readI32();
- setXIsSet(true);
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- break;
- default:
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
- validate();
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
- validate();
-
- oprot.writeStructBegin(STRUCT_DESC);
- oprot.writeFieldBegin(X_FIELD_DESC);
- oprot.writeI32(this.x);
- oprot.writeFieldEnd();
- oprot.writeFieldStop();
- oprot.writeStructEnd();
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
@@ -292,6 +278,7 @@ public class Nested implements org.apach
public void validate() throws org.apache.thrift.TException {
// check for required fields
+ // check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -305,12 +292,92 @@ public class Nested implements org.apach
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
- __isset_bit_vector = new BitSet(1);
+ __isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
+ private static class NestedStandardSchemeFactory implements SchemeFactory {
+ public NestedStandardScheme getScheme() {
+ return new NestedStandardScheme();
+ }
+ }
+
+ private static class NestedStandardScheme extends StandardScheme<Nested> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, Nested struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // X
+ if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+ struct.x = iprot.readI32();
+ struct.setXIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, Nested struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldBegin(X_FIELD_DESC);
+ oprot.writeI32(struct.x);
+ oprot.writeFieldEnd();
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class NestedTupleSchemeFactory implements SchemeFactory {
+ public NestedTupleScheme getScheme() {
+ return new NestedTupleScheme();
+ }
+ }
+
+ private static class NestedTupleScheme extends TupleScheme<Nested> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, Nested struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetX()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetX()) {
+ oprot.writeI32(struct.x);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, Nested struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.x = iprot.readI32();
+ struct.setXIsSet(true);
+ }
+ }
+ }
+
}