You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2015/10/29 01:46:21 UTC
[3/6] calcite git commit: [CALCITE-903] Enable Avatica client to
recover from missing server-side state (Josh Elser)
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java b/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java
index 15a9a2e..e098322 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java
@@ -10369,6 +10369,758 @@ package org.apache.calcite.avatica.proto;
}
+ public interface SyncResultsRequestOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:SyncResultsRequest)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ java.lang.String getConnectionId();
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ com.google.protobuf.ByteString
+ getConnectionIdBytes();
+
+ /**
+ * <code>optional uint32 statement_id = 2;</code>
+ */
+ int getStatementId();
+
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ boolean hasState();
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ org.apache.calcite.avatica.proto.Common.QueryState getState();
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ org.apache.calcite.avatica.proto.Common.QueryStateOrBuilder getStateOrBuilder();
+
+ /**
+ * <code>optional uint64 offset = 4;</code>
+ */
+ long getOffset();
+ }
+ /**
+ * Protobuf type {@code SyncResultsRequest}
+ */
+ public static final class SyncResultsRequest extends
+ com.google.protobuf.GeneratedMessage implements
+ // @@protoc_insertion_point(message_implements:SyncResultsRequest)
+ SyncResultsRequestOrBuilder {
+ // Use SyncResultsRequest.newBuilder() to construct.
+ private SyncResultsRequest(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ super(builder);
+ }
+ private SyncResultsRequest() {
+ connectionId_ = "";
+ statementId_ = 0;
+ offset_ = 0L;
+ }
+
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
+ }
+ private SyncResultsRequest(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry) {
+ this();
+ int mutable_bitField0_ = 0;
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!input.skipField(tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ String s = input.readStringRequireUtf8();
+
+ connectionId_ = s;
+ break;
+ }
+ case 16: {
+
+ statementId_ = input.readUInt32();
+ break;
+ }
+ case 26: {
+ org.apache.calcite.avatica.proto.Common.QueryState.Builder subBuilder = null;
+ if (state_ != null) {
+ subBuilder = state_.toBuilder();
+ }
+ state_ = input.readMessage(org.apache.calcite.avatica.proto.Common.QueryState.parser(), extensionRegistry);
+ if (subBuilder != null) {
+ subBuilder.mergeFrom(state_);
+ state_ = subBuilder.buildPartial();
+ }
+
+ break;
+ }
+ case 32: {
+
+ offset_ = input.readUInt64();
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw new RuntimeException(e.setUnfinishedMessage(this));
+ } catch (java.io.IOException e) {
+ throw new RuntimeException(
+ new com.google.protobuf.InvalidProtocolBufferException(
+ e.getMessage()).setUnfinishedMessage(this));
+ } finally {
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.calcite.avatica.proto.Requests.internal_static_SyncResultsRequest_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.calcite.avatica.proto.Requests.internal_static_SyncResultsRequest_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.calcite.avatica.proto.Requests.SyncResultsRequest.class, org.apache.calcite.avatica.proto.Requests.SyncResultsRequest.Builder.class);
+ }
+
+ public static final int CONNECTION_ID_FIELD_NUMBER = 1;
+ private volatile java.lang.Object connectionId_;
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ public java.lang.String getConnectionId() {
+ java.lang.Object ref = connectionId_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ connectionId_ = s;
+ return s;
+ }
+ }
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ public com.google.protobuf.ByteString
+ getConnectionIdBytes() {
+ java.lang.Object ref = connectionId_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ connectionId_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int STATEMENT_ID_FIELD_NUMBER = 2;
+ private int statementId_;
+ /**
+ * <code>optional uint32 statement_id = 2;</code>
+ */
+ public int getStatementId() {
+ return statementId_;
+ }
+
+ public static final int STATE_FIELD_NUMBER = 3;
+ private org.apache.calcite.avatica.proto.Common.QueryState state_;
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public boolean hasState() {
+ return state_ != null;
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public org.apache.calcite.avatica.proto.Common.QueryState getState() {
+ return state_ == null ? org.apache.calcite.avatica.proto.Common.QueryState.getDefaultInstance() : state_;
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public org.apache.calcite.avatica.proto.Common.QueryStateOrBuilder getStateOrBuilder() {
+ return getState();
+ }
+
+ public static final int OFFSET_FIELD_NUMBER = 4;
+ private long offset_;
+ /**
+ * <code>optional uint64 offset = 4;</code>
+ */
+ public long getOffset() {
+ return offset_;
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (!getConnectionIdBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessage.writeString(output, 1, connectionId_);
+ }
+ if (statementId_ != 0) {
+ output.writeUInt32(2, statementId_);
+ }
+ if (state_ != null) {
+ output.writeMessage(3, getState());
+ }
+ if (offset_ != 0L) {
+ output.writeUInt64(4, offset_);
+ }
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (!getConnectionIdBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessage.computeStringSize(1, connectionId_);
+ }
+ if (statementId_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeUInt32Size(2, statementId_);
+ }
+ if (state_ != null) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(3, getState());
+ }
+ if (offset_ != 0L) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeUInt64Size(4, offset_);
+ }
+ memoizedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input, extensionRegistry);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(org.apache.calcite.avatica.proto.Requests.SyncResultsRequest prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code SyncResultsRequest}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder> implements
+ // @@protoc_insertion_point(builder_implements:SyncResultsRequest)
+ org.apache.calcite.avatica.proto.Requests.SyncResultsRequestOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.calcite.avatica.proto.Requests.internal_static_SyncResultsRequest_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.calcite.avatica.proto.Requests.internal_static_SyncResultsRequest_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.calcite.avatica.proto.Requests.SyncResultsRequest.class, org.apache.calcite.avatica.proto.Requests.SyncResultsRequest.Builder.class);
+ }
+
+ // Construct using org.apache.calcite.avatica.proto.Requests.SyncResultsRequest.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ connectionId_ = "";
+
+ statementId_ = 0;
+
+ if (stateBuilder_ == null) {
+ state_ = null;
+ } else {
+ state_ = null;
+ stateBuilder_ = null;
+ }
+ offset_ = 0L;
+
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return org.apache.calcite.avatica.proto.Requests.internal_static_SyncResultsRequest_descriptor;
+ }
+
+ public org.apache.calcite.avatica.proto.Requests.SyncResultsRequest getDefaultInstanceForType() {
+ return org.apache.calcite.avatica.proto.Requests.SyncResultsRequest.getDefaultInstance();
+ }
+
+ public org.apache.calcite.avatica.proto.Requests.SyncResultsRequest build() {
+ org.apache.calcite.avatica.proto.Requests.SyncResultsRequest result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public org.apache.calcite.avatica.proto.Requests.SyncResultsRequest buildPartial() {
+ org.apache.calcite.avatica.proto.Requests.SyncResultsRequest result = new org.apache.calcite.avatica.proto.Requests.SyncResultsRequest(this);
+ result.connectionId_ = connectionId_;
+ result.statementId_ = statementId_;
+ if (stateBuilder_ == null) {
+ result.state_ = state_;
+ } else {
+ result.state_ = stateBuilder_.build();
+ }
+ result.offset_ = offset_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.apache.calcite.avatica.proto.Requests.SyncResultsRequest) {
+ return mergeFrom((org.apache.calcite.avatica.proto.Requests.SyncResultsRequest)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.apache.calcite.avatica.proto.Requests.SyncResultsRequest other) {
+ if (other == org.apache.calcite.avatica.proto.Requests.SyncResultsRequest.getDefaultInstance()) return this;
+ if (!other.getConnectionId().isEmpty()) {
+ connectionId_ = other.connectionId_;
+ onChanged();
+ }
+ if (other.getStatementId() != 0) {
+ setStatementId(other.getStatementId());
+ }
+ if (other.hasState()) {
+ mergeState(other.getState());
+ }
+ if (other.getOffset() != 0L) {
+ setOffset(other.getOffset());
+ }
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ org.apache.calcite.avatica.proto.Requests.SyncResultsRequest parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (org.apache.calcite.avatica.proto.Requests.SyncResultsRequest) e.getUnfinishedMessage();
+ throw e;
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+
+ private java.lang.Object connectionId_ = "";
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ public java.lang.String getConnectionId() {
+ java.lang.Object ref = connectionId_;
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ connectionId_ = s;
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ public com.google.protobuf.ByteString
+ getConnectionIdBytes() {
+ java.lang.Object ref = connectionId_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ connectionId_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ public Builder setConnectionId(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ connectionId_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ public Builder clearConnectionId() {
+
+ connectionId_ = getDefaultInstance().getConnectionId();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string connection_id = 1;</code>
+ */
+ public Builder setConnectionIdBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ connectionId_ = value;
+ onChanged();
+ return this;
+ }
+
+ private int statementId_ ;
+ /**
+ * <code>optional uint32 statement_id = 2;</code>
+ */
+ public int getStatementId() {
+ return statementId_;
+ }
+ /**
+ * <code>optional uint32 statement_id = 2;</code>
+ */
+ public Builder setStatementId(int value) {
+
+ statementId_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional uint32 statement_id = 2;</code>
+ */
+ public Builder clearStatementId() {
+
+ statementId_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private org.apache.calcite.avatica.proto.Common.QueryState state_ = null;
+ private com.google.protobuf.SingleFieldBuilder<
+ org.apache.calcite.avatica.proto.Common.QueryState, org.apache.calcite.avatica.proto.Common.QueryState.Builder, org.apache.calcite.avatica.proto.Common.QueryStateOrBuilder> stateBuilder_;
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public boolean hasState() {
+ return stateBuilder_ != null || state_ != null;
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public org.apache.calcite.avatica.proto.Common.QueryState getState() {
+ if (stateBuilder_ == null) {
+ return state_ == null ? org.apache.calcite.avatica.proto.Common.QueryState.getDefaultInstance() : state_;
+ } else {
+ return stateBuilder_.getMessage();
+ }
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public Builder setState(org.apache.calcite.avatica.proto.Common.QueryState value) {
+ if (stateBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ state_ = value;
+ onChanged();
+ } else {
+ stateBuilder_.setMessage(value);
+ }
+
+ return this;
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public Builder setState(
+ org.apache.calcite.avatica.proto.Common.QueryState.Builder builderForValue) {
+ if (stateBuilder_ == null) {
+ state_ = builderForValue.build();
+ onChanged();
+ } else {
+ stateBuilder_.setMessage(builderForValue.build());
+ }
+
+ return this;
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public Builder mergeState(org.apache.calcite.avatica.proto.Common.QueryState value) {
+ if (stateBuilder_ == null) {
+ if (state_ != null) {
+ state_ =
+ org.apache.calcite.avatica.proto.Common.QueryState.newBuilder(state_).mergeFrom(value).buildPartial();
+ } else {
+ state_ = value;
+ }
+ onChanged();
+ } else {
+ stateBuilder_.mergeFrom(value);
+ }
+
+ return this;
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public Builder clearState() {
+ if (stateBuilder_ == null) {
+ state_ = null;
+ onChanged();
+ } else {
+ state_ = null;
+ stateBuilder_ = null;
+ }
+
+ return this;
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public org.apache.calcite.avatica.proto.Common.QueryState.Builder getStateBuilder() {
+
+ onChanged();
+ return getStateFieldBuilder().getBuilder();
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ public org.apache.calcite.avatica.proto.Common.QueryStateOrBuilder getStateOrBuilder() {
+ if (stateBuilder_ != null) {
+ return stateBuilder_.getMessageOrBuilder();
+ } else {
+ return state_ == null ?
+ org.apache.calcite.avatica.proto.Common.QueryState.getDefaultInstance() : state_;
+ }
+ }
+ /**
+ * <code>optional .QueryState state = 3;</code>
+ */
+ private com.google.protobuf.SingleFieldBuilder<
+ org.apache.calcite.avatica.proto.Common.QueryState, org.apache.calcite.avatica.proto.Common.QueryState.Builder, org.apache.calcite.avatica.proto.Common.QueryStateOrBuilder>
+ getStateFieldBuilder() {
+ if (stateBuilder_ == null) {
+ stateBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+ org.apache.calcite.avatica.proto.Common.QueryState, org.apache.calcite.avatica.proto.Common.QueryState.Builder, org.apache.calcite.avatica.proto.Common.QueryStateOrBuilder>(
+ getState(),
+ getParentForChildren(),
+ isClean());
+ state_ = null;
+ }
+ return stateBuilder_;
+ }
+
+ private long offset_ ;
+ /**
+ * <code>optional uint64 offset = 4;</code>
+ */
+ public long getOffset() {
+ return offset_;
+ }
+ /**
+ * <code>optional uint64 offset = 4;</code>
+ */
+ public Builder setOffset(long value) {
+
+ offset_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional uint64 offset = 4;</code>
+ */
+ public Builder clearOffset() {
+
+ offset_ = 0L;
+ onChanged();
+ return this;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return this;
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return this;
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:SyncResultsRequest)
+ }
+
+ // @@protoc_insertion_point(class_scope:SyncResultsRequest)
+ private static final org.apache.calcite.avatica.proto.Requests.SyncResultsRequest DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new org.apache.calcite.avatica.proto.Requests.SyncResultsRequest();
+ }
+
+ public static org.apache.calcite.avatica.proto.Requests.SyncResultsRequest getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser<SyncResultsRequest>
+ PARSER = new com.google.protobuf.AbstractParser<SyncResultsRequest>() {
+ public SyncResultsRequest parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ try {
+ return new SyncResultsRequest(input, extensionRegistry);
+ } catch (RuntimeException e) {
+ if (e.getCause() instanceof
+ com.google.protobuf.InvalidProtocolBufferException) {
+ throw (com.google.protobuf.InvalidProtocolBufferException)
+ e.getCause();
+ }
+ throw e;
+ }
+ }
+ };
+
+ public static com.google.protobuf.Parser<SyncResultsRequest> parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<SyncResultsRequest> getParserForType() {
+ return PARSER;
+ }
+
+ public org.apache.calcite.avatica.proto.Requests.SyncResultsRequest getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
private static com.google.protobuf.Descriptors.Descriptor
internal_static_CatalogsRequest_descriptor;
private static
@@ -10454,6 +11206,11 @@ package org.apache.calcite.avatica.proto;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_ExecuteRequest_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_SyncResultsRequest_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_SyncResultsRequest_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
@@ -10498,8 +11255,11 @@ package org.apache.calcite.avatica.proto;
"ExecuteRequest\022)\n\017statementHandle\030\001 \001(\0132" +
"\020.StatementHandle\022%\n\020parameter_values\030\002 " +
"\003(\0132\013.TypedValue\022\025\n\rmax_row_count\030\003 \001(\004\022" +
- "\034\n\024has_parameter_values\030\004 \001(\010B\"\n org.apa" +
- "che.calcite.avatica.protob\006proto3"
+ "\034\n\024has_parameter_values\030\004 \001(\010\"m\n\022SyncRes" +
+ "ultsRequest\022\025\n\rconnection_id\030\001 \001(\t\022\024\n\014st" +
+ "atement_id\030\002 \001(\r\022\032\n\005state\030\003 \001(\0132\013.QueryS" +
+ "tate\022\016\n\006offset\030\004 \001(\004B\"\n org.apache.calci" +
+ "te.avatica.protob\006proto3"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -10616,6 +11376,12 @@ package org.apache.calcite.avatica.proto;
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_ExecuteRequest_descriptor,
new java.lang.String[] { "StatementHandle", "ParameterValues", "MaxRowCount", "HasParameterValues", });
+ internal_static_SyncResultsRequest_descriptor =
+ getDescriptor().getMessageTypes().get(16);
+ internal_static_SyncResultsRequest_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_SyncResultsRequest_descriptor,
+ new java.lang.String[] { "ConnectionId", "StatementId", "State", "Offset", });
org.apache.calcite.avatica.proto.Common.getDescriptor();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java b/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java
index 82cc88e..9392326 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java
@@ -1075,6 +1075,15 @@ package org.apache.calcite.avatica.proto;
*/
org.apache.calcite.avatica.proto.Responses.ResultSetResponseOrBuilder getResultsOrBuilder(
int index);
+
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ boolean getMissingStatement();
}
/**
* Protobuf type {@code ExecuteResponse}
@@ -1093,6 +1102,7 @@ package org.apache.calcite.avatica.proto;
}
private ExecuteResponse() {
results_ = java.util.Collections.emptyList();
+ missingStatement_ = false;
}
@java.lang.Override
@@ -1127,6 +1137,11 @@ package org.apache.calcite.avatica.proto;
results_.add(input.readMessage(org.apache.calcite.avatica.proto.Responses.ResultSetResponse.parser(), extensionRegistry));
break;
}
+ case 16: {
+
+ missingStatement_ = input.readBool();
+ break;
+ }
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -1154,6 +1169,7 @@ package org.apache.calcite.avatica.proto;
org.apache.calcite.avatica.proto.Responses.ExecuteResponse.class, org.apache.calcite.avatica.proto.Responses.ExecuteResponse.Builder.class);
}
+ private int bitField0_;
public static final int RESULTS_FIELD_NUMBER = 1;
private java.util.List<org.apache.calcite.avatica.proto.Responses.ResultSetResponse> results_;
/**
@@ -1189,6 +1205,19 @@ package org.apache.calcite.avatica.proto;
return results_.get(index);
}
+ public static final int MISSING_STATEMENT_FIELD_NUMBER = 2;
+ private boolean missingStatement_;
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ public boolean getMissingStatement() {
+ return missingStatement_;
+ }
+
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
@@ -1204,6 +1233,9 @@ package org.apache.calcite.avatica.proto;
for (int i = 0; i < results_.size(); i++) {
output.writeMessage(1, results_.get(i));
}
+ if (missingStatement_ != false) {
+ output.writeBool(2, missingStatement_);
+ }
}
public int getSerializedSize() {
@@ -1215,6 +1247,10 @@ package org.apache.calcite.avatica.proto;
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(1, results_.get(i));
}
+ if (missingStatement_ != false) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBoolSize(2, missingStatement_);
+ }
memoizedSize = size;
return size;
}
@@ -1337,6 +1373,8 @@ package org.apache.calcite.avatica.proto;
} else {
resultsBuilder_.clear();
}
+ missingStatement_ = false;
+
return this;
}
@@ -1360,6 +1398,7 @@ package org.apache.calcite.avatica.proto;
public org.apache.calcite.avatica.proto.Responses.ExecuteResponse buildPartial() {
org.apache.calcite.avatica.proto.Responses.ExecuteResponse result = new org.apache.calcite.avatica.proto.Responses.ExecuteResponse(this);
int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
if (resultsBuilder_ == null) {
if (((bitField0_ & 0x00000001) == 0x00000001)) {
results_ = java.util.Collections.unmodifiableList(results_);
@@ -1369,6 +1408,8 @@ package org.apache.calcite.avatica.proto;
} else {
result.results_ = resultsBuilder_.build();
}
+ result.missingStatement_ = missingStatement_;
+ result.bitField0_ = to_bitField0_;
onBuilt();
return result;
}
@@ -1410,6 +1451,9 @@ package org.apache.calcite.avatica.proto;
}
}
}
+ if (other.getMissingStatement() != false) {
+ setMissingStatement(other.getMissingStatement());
+ }
onChanged();
return this;
}
@@ -1676,6 +1720,44 @@ package org.apache.calcite.avatica.proto;
}
return resultsBuilder_;
}
+
+ private boolean missingStatement_ ;
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ public boolean getMissingStatement() {
+ return missingStatement_;
+ }
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ public Builder setMissingStatement(boolean value) {
+
+ missingStatement_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ public Builder clearMissingStatement() {
+
+ missingStatement_ = false;
+ onChanged();
+ return this;
+ }
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
@@ -2259,6 +2341,24 @@ package org.apache.calcite.avatica.proto;
* <code>optional .Frame frame = 1;</code>
*/
org.apache.calcite.avatica.proto.Common.FrameOrBuilder getFrameOrBuilder();
+
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ boolean getMissingStatement();
+
+ /**
+ * <code>optional bool missing_results = 3;</code>
+ *
+ * <pre>
+ * Did the request fail because of a cached-statement w/o ResultSet
+ * </pre>
+ */
+ boolean getMissingResults();
}
/**
* Protobuf type {@code FetchResponse}
@@ -2276,6 +2376,8 @@ package org.apache.calcite.avatica.proto;
super(builder);
}
private FetchResponse() {
+ missingStatement_ = false;
+ missingResults_ = false;
}
@java.lang.Override
@@ -2315,6 +2417,16 @@ package org.apache.calcite.avatica.proto;
break;
}
+ case 16: {
+
+ missingStatement_ = input.readBool();
+ break;
+ }
+ case 24: {
+
+ missingResults_ = input.readBool();
+ break;
+ }
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -2360,6 +2472,32 @@ package org.apache.calcite.avatica.proto;
return getFrame();
}
+ public static final int MISSING_STATEMENT_FIELD_NUMBER = 2;
+ private boolean missingStatement_;
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ public boolean getMissingStatement() {
+ return missingStatement_;
+ }
+
+ public static final int MISSING_RESULTS_FIELD_NUMBER = 3;
+ private boolean missingResults_;
+ /**
+ * <code>optional bool missing_results = 3;</code>
+ *
+ * <pre>
+ * Did the request fail because of a cached-statement w/o ResultSet
+ * </pre>
+ */
+ public boolean getMissingResults() {
+ return missingResults_;
+ }
+
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
@@ -2375,6 +2513,12 @@ package org.apache.calcite.avatica.proto;
if (frame_ != null) {
output.writeMessage(1, getFrame());
}
+ if (missingStatement_ != false) {
+ output.writeBool(2, missingStatement_);
+ }
+ if (missingResults_ != false) {
+ output.writeBool(3, missingResults_);
+ }
}
public int getSerializedSize() {
@@ -2386,6 +2530,14 @@ package org.apache.calcite.avatica.proto;
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(1, getFrame());
}
+ if (missingStatement_ != false) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBoolSize(2, missingStatement_);
+ }
+ if (missingResults_ != false) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBoolSize(3, missingResults_);
+ }
memoizedSize = size;
return size;
}
@@ -2507,6 +2659,10 @@ package org.apache.calcite.avatica.proto;
frame_ = null;
frameBuilder_ = null;
}
+ missingStatement_ = false;
+
+ missingResults_ = false;
+
return this;
}
@@ -2534,6 +2690,8 @@ package org.apache.calcite.avatica.proto;
} else {
result.frame_ = frameBuilder_.build();
}
+ result.missingStatement_ = missingStatement_;
+ result.missingResults_ = missingResults_;
onBuilt();
return result;
}
@@ -2552,6 +2710,12 @@ package org.apache.calcite.avatica.proto;
if (other.hasFrame()) {
mergeFrame(other.getFrame());
}
+ if (other.getMissingStatement() != false) {
+ setMissingStatement(other.getMissingStatement());
+ }
+ if (other.getMissingResults() != false) {
+ setMissingResults(other.getMissingResults());
+ }
onChanged();
return this;
}
@@ -2694,6 +2858,82 @@ package org.apache.calcite.avatica.proto;
}
return frameBuilder_;
}
+
+ private boolean missingStatement_ ;
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ public boolean getMissingStatement() {
+ return missingStatement_;
+ }
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ public Builder setMissingStatement(boolean value) {
+
+ missingStatement_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bool missing_statement = 2;</code>
+ *
+ * <pre>
+ * Did the request fail because of no-cached statement
+ * </pre>
+ */
+ public Builder clearMissingStatement() {
+
+ missingStatement_ = false;
+ onChanged();
+ return this;
+ }
+
+ private boolean missingResults_ ;
+ /**
+ * <code>optional bool missing_results = 3;</code>
+ *
+ * <pre>
+ * Did the request fail because of a cached-statement w/o ResultSet
+ * </pre>
+ */
+ public boolean getMissingResults() {
+ return missingResults_;
+ }
+ /**
+ * <code>optional bool missing_results = 3;</code>
+ *
+ * <pre>
+ * Did the request fail because of a cached-statement w/o ResultSet
+ * </pre>
+ */
+ public Builder setMissingResults(boolean value) {
+
+ missingResults_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bool missing_results = 3;</code>
+ *
+ * <pre>
+ * Did the request fail because of a cached-statement w/o ResultSet
+ * </pre>
+ */
+ public Builder clearMissingResults() {
+
+ missingResults_ = false;
+ onChanged();
+ return this;
+ }
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
@@ -7204,6 +7444,480 @@ package org.apache.calcite.avatica.proto;
}
+ public interface SyncResultsResponseOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:SyncResultsResponse)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * <code>optional bool missing_statement = 1;</code>
+ *
+ * <pre>
+ * Server doesn't have the statement with the ID from the request
+ * </pre>
+ */
+ boolean getMissingStatement();
+
+ /**
+ * <code>optional bool more_results = 2;</code>
+ *
+ * <pre>
+ * Should the client fetch() to get more results
+ * </pre>
+ */
+ boolean getMoreResults();
+ }
+ /**
+ * Protobuf type {@code SyncResultsResponse}
+ */
+ public static final class SyncResultsResponse extends
+ com.google.protobuf.GeneratedMessage implements
+ // @@protoc_insertion_point(message_implements:SyncResultsResponse)
+ SyncResultsResponseOrBuilder {
+ // Use SyncResultsResponse.newBuilder() to construct.
+ private SyncResultsResponse(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ super(builder);
+ }
+ private SyncResultsResponse() {
+ missingStatement_ = false;
+ moreResults_ = false;
+ }
+
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
+ }
+ private SyncResultsResponse(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry) {
+ this();
+ int mutable_bitField0_ = 0;
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!input.skipField(tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 8: {
+
+ missingStatement_ = input.readBool();
+ break;
+ }
+ case 16: {
+
+ moreResults_ = input.readBool();
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw new RuntimeException(e.setUnfinishedMessage(this));
+ } catch (java.io.IOException e) {
+ throw new RuntimeException(
+ new com.google.protobuf.InvalidProtocolBufferException(
+ e.getMessage()).setUnfinishedMessage(this));
+ } finally {
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.calcite.avatica.proto.Responses.internal_static_SyncResultsResponse_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.calcite.avatica.proto.Responses.internal_static_SyncResultsResponse_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.calcite.avatica.proto.Responses.SyncResultsResponse.class, org.apache.calcite.avatica.proto.Responses.SyncResultsResponse.Builder.class);
+ }
+
+ public static final int MISSING_STATEMENT_FIELD_NUMBER = 1;
+ private boolean missingStatement_;
+ /**
+ * <code>optional bool missing_statement = 1;</code>
+ *
+ * <pre>
+ * Server doesn't have the statement with the ID from the request
+ * </pre>
+ */
+ public boolean getMissingStatement() {
+ return missingStatement_;
+ }
+
+ public static final int MORE_RESULTS_FIELD_NUMBER = 2;
+ private boolean moreResults_;
+ /**
+ * <code>optional bool more_results = 2;</code>
+ *
+ * <pre>
+ * Should the client fetch() to get more results
+ * </pre>
+ */
+ public boolean getMoreResults() {
+ return moreResults_;
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (missingStatement_ != false) {
+ output.writeBool(1, missingStatement_);
+ }
+ if (moreResults_ != false) {
+ output.writeBool(2, moreResults_);
+ }
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (missingStatement_ != false) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBoolSize(1, missingStatement_);
+ }
+ if (moreResults_ != false) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBoolSize(2, moreResults_);
+ }
+ memoizedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input, extensionRegistry);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(org.apache.calcite.avatica.proto.Responses.SyncResultsResponse prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code SyncResultsResponse}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder> implements
+ // @@protoc_insertion_point(builder_implements:SyncResultsResponse)
+ org.apache.calcite.avatica.proto.Responses.SyncResultsResponseOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.calcite.avatica.proto.Responses.internal_static_SyncResultsResponse_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.calcite.avatica.proto.Responses.internal_static_SyncResultsResponse_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.calcite.avatica.proto.Responses.SyncResultsResponse.class, org.apache.calcite.avatica.proto.Responses.SyncResultsResponse.Builder.class);
+ }
+
+ // Construct using org.apache.calcite.avatica.proto.Responses.SyncResultsResponse.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ missingStatement_ = false;
+
+ moreResults_ = false;
+
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return org.apache.calcite.avatica.proto.Responses.internal_static_SyncResultsResponse_descriptor;
+ }
+
+ public org.apache.calcite.avatica.proto.Responses.SyncResultsResponse getDefaultInstanceForType() {
+ return org.apache.calcite.avatica.proto.Responses.SyncResultsResponse.getDefaultInstance();
+ }
+
+ public org.apache.calcite.avatica.proto.Responses.SyncResultsResponse build() {
+ org.apache.calcite.avatica.proto.Responses.SyncResultsResponse result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public org.apache.calcite.avatica.proto.Responses.SyncResultsResponse buildPartial() {
+ org.apache.calcite.avatica.proto.Responses.SyncResultsResponse result = new org.apache.calcite.avatica.proto.Responses.SyncResultsResponse(this);
+ result.missingStatement_ = missingStatement_;
+ result.moreResults_ = moreResults_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.apache.calcite.avatica.proto.Responses.SyncResultsResponse) {
+ return mergeFrom((org.apache.calcite.avatica.proto.Responses.SyncResultsResponse)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.apache.calcite.avatica.proto.Responses.SyncResultsResponse other) {
+ if (other == org.apache.calcite.avatica.proto.Responses.SyncResultsResponse.getDefaultInstance()) return this;
+ if (other.getMissingStatement() != false) {
+ setMissingStatement(other.getMissingStatement());
+ }
+ if (other.getMoreResults() != false) {
+ setMoreResults(other.getMoreResults());
+ }
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ org.apache.calcite.avatica.proto.Responses.SyncResultsResponse parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (org.apache.calcite.avatica.proto.Responses.SyncResultsResponse) e.getUnfinishedMessage();
+ throw e;
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+
+ private boolean missingStatement_ ;
+ /**
+ * <code>optional bool missing_statement = 1;</code>
+ *
+ * <pre>
+ * Server doesn't have the statement with the ID from the request
+ * </pre>
+ */
+ public boolean getMissingStatement() {
+ return missingStatement_;
+ }
+ /**
+ * <code>optional bool missing_statement = 1;</code>
+ *
+ * <pre>
+ * Server doesn't have the statement with the ID from the request
+ * </pre>
+ */
+ public Builder setMissingStatement(boolean value) {
+
+ missingStatement_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bool missing_statement = 1;</code>
+ *
+ * <pre>
+ * Server doesn't have the statement with the ID from the request
+ * </pre>
+ */
+ public Builder clearMissingStatement() {
+
+ missingStatement_ = false;
+ onChanged();
+ return this;
+ }
+
+ private boolean moreResults_ ;
+ /**
+ * <code>optional bool more_results = 2;</code>
+ *
+ * <pre>
+ * Should the client fetch() to get more results
+ * </pre>
+ */
+ public boolean getMoreResults() {
+ return moreResults_;
+ }
+ /**
+ * <code>optional bool more_results = 2;</code>
+ *
+ * <pre>
+ * Should the client fetch() to get more results
+ * </pre>
+ */
+ public Builder setMoreResults(boolean value) {
+
+ moreResults_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bool more_results = 2;</code>
+ *
+ * <pre>
+ * Should the client fetch() to get more results
+ * </pre>
+ */
+ public Builder clearMoreResults() {
+
+ moreResults_ = false;
+ onChanged();
+ return this;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return this;
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return this;
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:SyncResultsResponse)
+ }
+
+ // @@protoc_insertion_point(class_scope:SyncResultsResponse)
+ private static final org.apache.calcite.avatica.proto.Responses.SyncResultsResponse DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new org.apache.calcite.avatica.proto.Responses.SyncResultsResponse();
+ }
+
+ public static org.apache.calcite.avatica.proto.Responses.SyncResultsResponse getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser<SyncResultsResponse>
+ PARSER = new com.google.protobuf.AbstractParser<SyncResultsResponse>() {
+ public SyncResultsResponse parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ try {
+ return new SyncResultsResponse(input, extensionRegistry);
+ } catch (RuntimeException e) {
+ if (e.getCause() instanceof
+ com.google.protobuf.InvalidProtocolBufferException) {
+ throw (com.google.protobuf.InvalidProtocolBufferException)
+ e.getCause();
+ }
+ throw e;
+ }
+ }
+ };
+
+ public static com.google.protobuf.Parser<SyncResultsResponse> parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<SyncResultsResponse> getParserForType() {
+ return PARSER;
+ }
+
+ public org.apache.calcite.avatica.proto.Responses.SyncResultsResponse getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
private static com.google.protobuf.Descriptors.Descriptor
internal_static_ResultSetResponse_descriptor;
private static
@@ -7264,6 +7978,11 @@ package org.apache.calcite.avatica.proto;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_ErrorResponse_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_SyncResultsResponse_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_SyncResultsResponse_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
@@ -7278,24 +7997,28 @@ package org.apache.calcite.avatica.proto;
"statement_id\030\002 \001(\r\022\025\n\rown_statement\030\003 \001(" +
"\010\022\035\n\tsignature\030\004 \001(\0132\n.Signature\022\033\n\013firs" +
"t_frame\030\005 \001(\0132\006.Frame\022\024\n\014update_count\030\006 " +
- "\001(\004\"6\n\017ExecuteResponse\022#\n\007results\030\001 \003(\0132" +
- "\022.ResultSetResponse\"6\n\017PrepareResponse\022#" +
- "\n\tstatement\030\001 \001(\0132\020.StatementHandle\"&\n\rF" +
- "etchResponse\022\025\n\005frame\030\001 \001(\0132\006.Frame\"F\n\027C" +
- "reateStatementResponse\022\025\n\rconnection_id\030",
- "\001 \001(\t\022\024\n\014statement_id\030\002 \001(\r\"\030\n\026CloseStat" +
- "ementResponse\"\030\n\026OpenConnectionResponse\"" +
- "\031\n\027CloseConnectionResponse\"C\n\026Connection" +
- "SyncResponse\022)\n\nconn_props\030\001 \001(\0132\025.Conne" +
- "ctionProperties\"U\n\027DatabasePropertyEleme" +
- "nt\022\036\n\003key\030\001 \001(\0132\021.DatabaseProperty\022\032\n\005va" +
- "lue\030\002 \001(\0132\013.TypedValue\"C\n\030DatabaseProper" +
- "tyResponse\022\'\n\005props\030\001 \003(\0132\030.DatabaseProp" +
- "ertyElement\"~\n\rErrorResponse\022\022\n\nexceptio" +
- "ns\030\001 \003(\t\022\025\n\rerror_message\030\002 \001(\t\022\033\n\010sever",
- "ity\030\003 \001(\0162\t.Severity\022\022\n\nerror_code\030\004 \001(\r" +
- "\022\021\n\tsql_state\030\005 \001(\tB\"\n org.apache.calcit" +
- "e.avatica.protob\006proto3"
+ "\001(\004\"Q\n\017ExecuteResponse\022#\n\007results\030\001 \003(\0132" +
+ "\022.ResultSetResponse\022\031\n\021missing_statement" +
+ "\030\002 \001(\010\"6\n\017PrepareResponse\022#\n\tstatement\030\001" +
+ " \001(\0132\020.StatementHandle\"Z\n\rFetchResponse\022" +
+ "\025\n\005frame\030\001 \001(\0132\006.Frame\022\031\n\021missing_statem",
+ "ent\030\002 \001(\010\022\027\n\017missing_results\030\003 \001(\010\"F\n\027Cr" +
+ "eateStatementResponse\022\025\n\rconnection_id\030\001" +
+ " \001(\t\022\024\n\014statement_id\030\002 \001(\r\"\030\n\026CloseState" +
+ "mentResponse\"\030\n\026OpenConnectionResponse\"\031" +
+ "\n\027CloseConnectionResponse\"C\n\026ConnectionS" +
+ "yncResponse\022)\n\nconn_props\030\001 \001(\0132\025.Connec" +
+ "tionProperties\"U\n\027DatabasePropertyElemen" +
+ "t\022\036\n\003key\030\001 \001(\0132\021.DatabaseProperty\022\032\n\005val" +
+ "ue\030\002 \001(\0132\013.TypedValue\"C\n\030DatabasePropert" +
+ "yResponse\022\'\n\005props\030\001 \003(\0132\030.DatabasePrope",
+ "rtyElement\"~\n\rErrorResponse\022\022\n\nexception" +
+ "s\030\001 \003(\t\022\025\n\rerror_message\030\002 \001(\t\022\033\n\010severi" +
+ "ty\030\003 \001(\0162\t.Severity\022\022\n\nerror_code\030\004 \001(\r\022" +
+ "\021\n\tsql_state\030\005 \001(\t\"F\n\023SyncResultsRespons" +
+ "e\022\031\n\021missing_statement\030\001 \001(\010\022\024\n\014more_res" +
+ "ults\030\002 \001(\010B\"\n org.apache.calcite.avatica" +
+ ".protob\006proto3"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -7321,7 +8044,7 @@ package org.apache.calcite.avatica.proto;
internal_static_ExecuteResponse_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_ExecuteResponse_descriptor,
- new java.lang.String[] { "Results", });
+ new java.lang.String[] { "Results", "MissingStatement", });
internal_static_PrepareResponse_descriptor =
getDescriptor().getMessageTypes().get(2);
internal_static_PrepareResponse_fieldAccessorTable = new
@@ -7333,7 +8056,7 @@ package org.apache.calcite.avatica.proto;
internal_static_FetchResponse_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_FetchResponse_descriptor,
- new java.lang.String[] { "Frame", });
+ new java.lang.String[] { "Frame", "MissingStatement", "MissingResults", });
internal_static_CreateStatementResponse_descriptor =
getDescriptor().getMessageTypes().get(4);
internal_static_CreateStatementResponse_fieldAccessorTable = new
@@ -7382,6 +8105,12 @@ package org.apache.calcite.avatica.proto;
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_ErrorResponse_descriptor,
new java.lang.String[] { "Exceptions", "ErrorMessage", "Severity", "ErrorCode", "SqlState", });
+ internal_static_SyncResultsResponse_descriptor =
+ getDescriptor().getMessageTypes().get(12);
+ internal_static_SyncResultsResponse_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_SyncResultsResponse_descriptor,
+ new java.lang.String[] { "MissingStatement", "MoreResults", });
org.apache.calcite.avatica.proto.Common.getDescriptor();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractHandler.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractHandler.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractHandler.java
index 9d3bf66..503790f 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractHandler.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractHandler.java
@@ -17,6 +17,7 @@
package org.apache.calcite.avatica.remote;
import org.apache.calcite.avatica.AvaticaSeverity;
+import org.apache.calcite.avatica.NoSuchConnectionException;
import org.apache.calcite.avatica.remote.Service.ErrorResponse;
import org.apache.calcite.avatica.remote.Service.Request;
import org.apache.calcite.avatica.remote.Service.Response;
@@ -68,6 +69,10 @@ public abstract class AbstractHandler<T> implements Handler<T> {
sqlState = rte.getSqlState();
severity = rte.getSeverity();
errorMsg = rte.getErrorMessage();
+ } else if (e instanceof NoSuchConnectionException) {
+ errorCode = ErrorResponse.MISSING_CONNECTION_ERROR_CODE;
+ severity = AvaticaSeverity.ERROR;
+ errorMsg = e.getMessage();
} else {
// Try to construct a meaningful error message when the server impl doesn't provide one.
errorMsg = getCausalChain(e);
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractService.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractService.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractService.java
index 93ad3ef..f15e0e7 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractService.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/AbstractService.java
@@ -130,6 +130,9 @@ public abstract class AbstractService implements Service {
}
ExecuteResponse finagle(ExecuteResponse r) {
+ if (r.missingStatement) {
+ return r;
+ }
final List<ResultSetResponse> results = new ArrayList<>();
int changeCount = 0;
for (ResultSetResponse result : r.results) {
@@ -142,7 +145,7 @@ public abstract class AbstractService implements Service {
if (changeCount == 0) {
return r;
}
- return new ExecuteResponse(results);
+ return new ExecuteResponse(results, r.missingStatement);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClient.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClient.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClient.java
new file mode 100644
index 0000000..eac1b74
--- /dev/null
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClient.java
@@ -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.
+ */
+package org.apache.calcite.avatica.remote;
+
+/**
+ * An interface which defines how requests are sent to the Avatica server.
+ */
+public interface AvaticaHttpClient {
+
+ /**
+ * Sends a serialized request to the Avatica server.
+ *
+ * @param request The serialized request.
+ * @return The serialized response.
+ */
+ byte[] send(byte[] request);
+
+}
+
+// End AvaticaHttpClient.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClientImpl.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClientImpl.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClientImpl.java
new file mode 100644
index 0000000..c100eec
--- /dev/null
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClientImpl.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+package org.apache.calcite.avatica.remote;
+
+import org.apache.calcite.avatica.AvaticaUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * A common class to invoke HTTP requests against the Avatica server agnostic of the data being
+ * sent and received across the wire.
+ */
+public class AvaticaHttpClientImpl implements AvaticaHttpClient {
+ protected final URL url;
+
+ public AvaticaHttpClientImpl(URL url) {
+ this.url = url;
+ }
+
+ public byte[] send(byte[] request) {
+ // TODO back-off policy?
+ while (true) {
+ try {
+ final HttpURLConnection connection = openConnection();
+ connection.setRequestMethod("POST");
+ connection.setDoInput(true);
+ connection.setDoOutput(true);
+ try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
+ wr.write(request);
+ wr.flush();
+ wr.close();
+ }
+ final int responseCode = connection.getResponseCode();
+ final InputStream inputStream;
+ if (responseCode == HttpURLConnection.HTTP_UNAVAILABLE) {
+ // Could be sitting behind a load-balancer, try again.
+ continue;
+ } else if (responseCode != HttpURLConnection.HTTP_OK) {
+ inputStream = connection.getErrorStream();
+ } else {
+ inputStream = connection.getInputStream();
+ }
+ return AvaticaUtils.readFullyToBytes(inputStream);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ HttpURLConnection openConnection() throws IOException {
+ return (HttpURLConnection) url.openConnection();
+ }
+}
+
+// End AvaticaHttpClientImpl.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/remote/Driver.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/Driver.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/Driver.java
index 0ab90b1..707a163 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/remote/Driver.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/Driver.java
@@ -31,9 +31,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
/**
@@ -85,27 +83,28 @@ public class Driver extends UnregisteredDriver {
return new RemoteMeta(connection, service);
}
- private Service createService(AvaticaConnection connection, ConnectionConfig config) {
+ /**
+ * Creates a {@link Service} with the given {@link AvaticaConnection} and configuration.
+ *
+ * @param connection The {@link AvaticaConnection} to use.
+ * @param config Configuration properties
+ * @return A Service implementation.
+ */
+ Service createService(AvaticaConnection connection, ConnectionConfig config) {
final Service.Factory metaFactory = config.factory();
final Service service;
if (metaFactory != null) {
service = metaFactory.create(connection);
} else if (config.url() != null) {
- final URL url;
- try {
- url = new URL(config.url());
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
-
- Serialization serializationType = getSerialization(config);
+ final AvaticaHttpClient httpClient = getHttpClient(connection, config);
+ final Serialization serializationType = getSerialization(config);
switch (serializationType) {
case JSON:
- service = new RemoteService(url);
+ service = new RemoteService(httpClient);
break;
case PROTOBUF:
- service = new RemoteProtobufService(url, new ProtobufTranslationImpl());
+ service = new RemoteProtobufService(httpClient, new ProtobufTranslationImpl());
break;
default:
throw new IllegalArgumentException("Unhandled serialization type: " + serializationType);
@@ -116,6 +115,24 @@ public class Driver extends UnregisteredDriver {
return service;
}
+ /**
+ * Creates the HTTP client that communicates with the Avatica server.
+ *
+ * @param connection The {@link AvaticaConnection}.
+ * @param config The configuration.
+ * @return An {@link AvaticaHttpClient} implementation.
+ */
+ AvaticaHttpClient getHttpClient(AvaticaConnection connection, ConnectionConfig config) {
+ URL url;
+ try {
+ url = new URL(config.url());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+
+ return new AvaticaHttpClientImpl(url);
+ }
+
@Override public Connection connect(String url, Properties info)
throws SQLException {
AvaticaConnection conn = (AvaticaConnection) super.connect(url, info);
@@ -128,28 +145,14 @@ public class Driver extends UnregisteredDriver {
ConnectionConfig config = conn.config();
Service service = createService(conn, config);
- Map<String, String> infoAsString = new HashMap<>();
- for (Map.Entry<Object, Object> entry : info.entrySet()) {
- // Determine if this is a property we want to forward to the server
- boolean localProperty = false;
- for (BuiltInConnectionProperty prop : BuiltInConnectionProperty.values()) {
- if (prop.camelName().equals(entry.getKey())) {
- localProperty = true;
- break;
- }
- }
-
- if (!localProperty) {
- infoAsString.put(entry.getKey().toString(), entry.getValue().toString());
- }
- }
-
- service.apply(new Service.OpenConnectionRequest(conn.id, infoAsString));
+ service.apply(
+ new Service.OpenConnectionRequest(conn.id,
+ Service.OpenConnectionRequest.serializeProperties(info)));
return conn;
}
- private Serialization getSerialization(ConnectionConfig config) {
+ Serialization getSerialization(ConnectionConfig config) {
final String serializationStr = config.serialization();
Serialization serializationType = Serialization.JSON;
if (null != serializationStr) {
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/remote/Handler.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/Handler.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/Handler.java
index f0e8a93..f2cfeb6 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/remote/Handler.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/Handler.java
@@ -46,6 +46,10 @@ public interface Handler<T> {
public int getStatusCode() {
return statusCode;
}
+
+ @Override public String toString() {
+ return "Response: " + response + ", Status:" + statusCode;
+ }
}
HandlerResponse<T> apply(T request);
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/remote/JsonService.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/JsonService.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/JsonService.java
index a223069..99cf79b 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/remote/JsonService.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/JsonService.java
@@ -198,6 +198,14 @@ public abstract class JsonService extends AbstractService {
throw handle(e);
}
}
+
+ public SyncResultsResponse apply(SyncResultsRequest request) {
+ try {
+ return decode(apply(encode(request)), SyncResultsResponse.class);
+ } catch (IOException e) {
+ throw handle(e);
+ }
+ }
}
// End JsonService.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/97df1acb/avatica/src/main/java/org/apache/calcite/avatica/remote/LocalService.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/LocalService.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/LocalService.java
index 1a5a554..ff75af5 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/remote/LocalService.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/LocalService.java
@@ -18,6 +18,8 @@ package org.apache.calcite.avatica.remote;
import org.apache.calcite.avatica.Meta;
import org.apache.calcite.avatica.MetaImpl;
+import org.apache.calcite.avatica.MissingResultsException;
+import org.apache.calcite.avatica.NoSuchStatementException;
import java.util.ArrayList;
import java.util.Collections;
@@ -103,7 +105,7 @@ public class LocalService implements Service {
final Meta.StatementHandle h = new Meta.StatementHandle(
resultSet.connectionId, resultSet.statementId, null);
final List<TypedValue> parameterValues = Collections.emptyList();
- final Iterable<Object> iterable = meta.createIterable(h,
+ final Iterable<Object> iterable = meta.createIterable(h, null,
resultSet.signature, parameterValues, resultSet.firstFrame);
final List<List<Object>> list = new ArrayList<>();
return MetaImpl.collect(resultSet.signature.cursorFactory, iterable, list);
@@ -173,49 +175,65 @@ public class LocalService implements Service {
public ExecuteResponse apply(PrepareAndExecuteRequest request) {
final Meta.StatementHandle sh =
new Meta.StatementHandle(request.connectionId, request.statementId, null);
- final Meta.ExecuteResult executeResult =
- meta.prepareAndExecute(sh, request.sql, request.maxRowCount,
- new Meta.PrepareCallback() {
- @Override public Object getMonitor() {
- return LocalService.class;
- }
-
- @Override public void clear() {
- }
-
- @Override public void assign(Meta.Signature signature,
- Meta.Frame firstFrame, long updateCount) {
- }
-
- @Override public void execute() {
- }
- });
- final List<ResultSetResponse> results = new ArrayList<>();
- for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) {
- results.add(toResponse(metaResultSet));
+ try {
+ final Meta.ExecuteResult executeResult =
+ meta.prepareAndExecute(sh, request.sql, request.maxRowCount,
+ new Meta.PrepareCallback() {
+ @Override public Object getMonitor() {
+ return LocalService.class;
+ }
+
+ @Override public void clear() {
+ }
+
+ @Override public void assign(Meta.Signature signature,
+ Meta.Frame firstFrame, long updateCount) {
+ }
+
+ @Override public void execute() {
+ }
+ });
+ final List<ResultSetResponse> results = new ArrayList<>();
+ for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) {
+ results.add(toResponse(metaResultSet));
+ }
+ return new ExecuteResponse(results, false);
+ } catch (NoSuchStatementException e) {
+ // The Statement doesn't exist anymore, bubble up this information
+ return new ExecuteResponse(null, true);
}
- return new ExecuteResponse(results);
}
public FetchResponse apply(FetchRequest request) {
final Meta.StatementHandle h = new Meta.StatementHandle(
request.connectionId, request.statementId, null);
- final Meta.Frame frame =
- meta.fetch(h,
- request.offset,
- request.fetchMaxRowCount);
- return new FetchResponse(frame);
+ try {
+ final Meta.Frame frame =
+ meta.fetch(h,
+ request.offset,
+ request.fetchMaxRowCount);
+ return new FetchResponse(frame, false, false);
+ } catch (NullPointerException | NoSuchStatementException e) {
+ // The Statement doesn't exist anymore, bubble up this information
+ return new FetchResponse(null, true, true);
+ } catch (MissingResultsException e) {
+ return new FetchResponse(null, false, true);
+ }
}
public ExecuteResponse apply(ExecuteRequest request) {
- final Meta.ExecuteResult executeResult = meta.execute(request.statementHandle,
- request.parameterValues, request.maxRowCount);
+ try {
+ final Meta.ExecuteResult executeResult = meta.execute(request.statementHandle,
+ request.parameterValues, request.maxRowCount);
- final List<ResultSetResponse> results = new ArrayList<>();
- for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) {
- results.add(toResponse(metaResultSet));
+ final List<ResultSetResponse> results = new ArrayList<>();
+ for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) {
+ results.add(toResponse(metaResultSet));
+ }
+ return new ExecuteResponse(results, false);
+ } catch (NoSuchStatementException e) {
+ return new ExecuteResponse(null, true);
}
- return new ExecuteResponse(results);
}
public CreateStatementResponse apply(CreateStatementRequest request) {
@@ -259,6 +277,21 @@ public class LocalService implements Service {
new Meta.ConnectionHandle(request.connectionId);
return new DatabasePropertyResponse(meta.getDatabaseProperties(ch));
}
+
+ public SyncResultsResponse apply(SyncResultsRequest request) {
+ final Meta.StatementHandle h = new Meta.StatementHandle(
+ request.connectionId, request.statementId, null);
+ SyncResultsResponse response;
+ try {
+ // Set success on the cached statement
+ response = new SyncResultsResponse(meta.syncResults(h, request.state, request.offset), false);
+ } catch (NoSuchStatementException e) {
+ // Tried to sync results on a statement which wasn't cached
+ response = new SyncResultsResponse(false, true);
+ }
+
+ return response;
+ }
}
// End LocalService.java