org.apache.calcite.avatica.remote.Service Maven / Gradle / Ivy
/*
* 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.AvaticaClientRuntimeException;
import org.apache.calcite.avatica.AvaticaConnection;
import org.apache.calcite.avatica.AvaticaSeverity;
import org.apache.calcite.avatica.BuiltInConnectionProperty;
import org.apache.calcite.avatica.ConnectionPropertiesImpl;
import org.apache.calcite.avatica.Meta;
import org.apache.calcite.avatica.QueryState;
import org.apache.calcite.avatica.proto.Common;
import org.apache.calcite.avatica.proto.Requests;
import org.apache.calcite.avatica.proto.Responses;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Message;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Properties;
/**
* API for request-response calls to an Avatica server.
*/
public interface Service {
ResultSetResponse apply(CatalogsRequest request);
ResultSetResponse apply(SchemasRequest request);
ResultSetResponse apply(TablesRequest request);
ResultSetResponse apply(TableTypesRequest request);
ResultSetResponse apply(TypeInfoRequest request);
ResultSetResponse apply(ColumnsRequest request);
PrepareResponse apply(PrepareRequest request);
ExecuteResponse apply(ExecuteRequest request);
ExecuteResponse apply(PrepareAndExecuteRequest request);
SyncResultsResponse apply(SyncResultsRequest request);
FetchResponse apply(FetchRequest request);
CreateStatementResponse apply(CreateStatementRequest request);
CloseStatementResponse apply(CloseStatementRequest request);
OpenConnectionResponse apply(OpenConnectionRequest request);
CloseConnectionResponse apply(CloseConnectionRequest request);
ConnectionSyncResponse apply(ConnectionSyncRequest request);
DatabasePropertyResponse apply(DatabasePropertyRequest request);
CommitResponse apply(CommitRequest request);
RollbackResponse apply(RollbackRequest request);
/**
* Sets server-level metadata for RPCs. This includes information that is static across all RPCs.
*
* @param metadata The server-level metadata.
*/
void setRpcMetadata(RpcMetadataResponse metadata);
/** Factory that creates a {@code Service}. */
interface Factory {
Service create(AvaticaConnection connection);
}
/** Base class for request and response. */
abstract class Base {
static final int PRIME = 31;
protected static int p(int result, Object o) {
return PRIME * result + ((o == null) ? 0 : o.hashCode());
}
protected static int p(int result, boolean v) {
return PRIME * result + (v ? 1231 : 1237);
}
protected static int p(int result, int v) {
return PRIME * result + v;
}
protected static int p(int result, long v) {
return PRIME * result + (int) (v ^ (v >>> 32));
}
}
/** Base class for all service request messages. */
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
property = "request",
defaultImpl = SchemasRequest.class)
@JsonSubTypes({
@JsonSubTypes.Type(value = CatalogsRequest.class, name = "getCatalogs"),
@JsonSubTypes.Type(value = SchemasRequest.class, name = "getSchemas"),
@JsonSubTypes.Type(value = TablesRequest.class, name = "getTables"),
@JsonSubTypes.Type(value = TableTypesRequest.class, name = "getTableTypes"),
@JsonSubTypes.Type(value = TypeInfoRequest.class, name = "getTypeInfo"),
@JsonSubTypes.Type(value = ColumnsRequest.class, name = "getColumns"),
@JsonSubTypes.Type(value = ExecuteRequest.class, name = "execute"),
@JsonSubTypes.Type(value = PrepareRequest.class, name = "prepare"),
@JsonSubTypes.Type(value = PrepareAndExecuteRequest.class,
name = "prepareAndExecute"),
@JsonSubTypes.Type(value = FetchRequest.class, name = "fetch"),
@JsonSubTypes.Type(value = CreateStatementRequest.class,
name = "createStatement"),
@JsonSubTypes.Type(value = CloseStatementRequest.class,
name = "closeStatement"),
@JsonSubTypes.Type(value = OpenConnectionRequest.class,
name = "openConnection"),
@JsonSubTypes.Type(value = CloseConnectionRequest.class,
name = "closeConnection"),
@JsonSubTypes.Type(value = ConnectionSyncRequest.class, name = "connectionSync"),
@JsonSubTypes.Type(value = DatabasePropertyRequest.class, name = "databaseProperties"),
@JsonSubTypes.Type(value = SyncResultsRequest.class, name = "syncResults"),
@JsonSubTypes.Type(value = CommitRequest.class, name = "commit"),
@JsonSubTypes.Type(value = RollbackRequest.class, name = "rollback") })
abstract class Request extends Base {
abstract Response accept(Service service);
abstract Request deserialize(Message genericMsg);
abstract Message serialize();
}
/** Base class for all service response messages. */
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
property = "response",
defaultImpl = ResultSetResponse.class)
@JsonSubTypes({
@JsonSubTypes.Type(value = OpenConnectionResponse.class, name = "openConnection"),
@JsonSubTypes.Type(value = ResultSetResponse.class, name = "resultSet"),
@JsonSubTypes.Type(value = PrepareResponse.class, name = "prepare"),
@JsonSubTypes.Type(value = FetchResponse.class, name = "fetch"),
@JsonSubTypes.Type(value = CreateStatementResponse.class,
name = "createStatement"),
@JsonSubTypes.Type(value = CloseStatementResponse.class,
name = "closeStatement"),
@JsonSubTypes.Type(value = CloseConnectionResponse.class,
name = "closeConnection"),
@JsonSubTypes.Type(value = ConnectionSyncResponse.class, name = "connectionSync"),
@JsonSubTypes.Type(value = DatabasePropertyResponse.class, name = "databaseProperties"),
@JsonSubTypes.Type(value = ExecuteResponse.class, name = "executeResults"),
@JsonSubTypes.Type(value = ErrorResponse.class, name = "error"),
@JsonSubTypes.Type(value = SyncResultsResponse.class, name = "syncResults"),
@JsonSubTypes.Type(value = RpcMetadataResponse.class, name = "rpcMetadata"),
@JsonSubTypes.Type(value = CommitResponse.class, name = "commit"),
@JsonSubTypes.Type(value = RollbackResponse.class, name = "rollback") })
abstract class Response extends Base {
abstract Response deserialize(Message genericMsg);
abstract Message serialize();
}
/** Request for
* {@link org.apache.calcite.avatica.Meta#getCatalogs(Meta.ConnectionHandle)}. */
class CatalogsRequest extends Request {
public final String connectionId;
public CatalogsRequest() {
connectionId = null;
}
@JsonCreator
public CatalogsRequest(@JsonProperty("connectionId") String connectionId) {
this.connectionId = connectionId;
}
ResultSetResponse accept(Service service) {
return service.apply(this);
}
@Override CatalogsRequest deserialize(Message genericMsg) {
final Requests.CatalogsRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.CatalogsRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Requests.CatalogsRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
return new CatalogsRequest(connectionId);
}
@Override Requests.CatalogsRequest serialize() {
Requests.CatalogsRequest.Builder builder = Requests.CatalogsRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof CatalogsRequest
&& Objects.equals(connectionId, ((CatalogsRequest) o).connectionId);
}
}
/** Request for
* {@link org.apache.calcite.avatica.Meta#getDatabaseProperties(Meta.ConnectionHandle)}. */
class DatabasePropertyRequest extends Request {
public final String connectionId;
public DatabasePropertyRequest() {
connectionId = null;
}
@JsonCreator
public DatabasePropertyRequest(@JsonProperty("connectionId") String connectionId) {
this.connectionId = connectionId;
}
DatabasePropertyResponse accept(Service service) {
return service.apply(this);
}
@Override DatabasePropertyRequest deserialize(Message genericMsg) {
final Requests.DatabasePropertyRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.DatabasePropertyRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Requests.DatabasePropertyRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
return new DatabasePropertyRequest(connectionId);
}
@Override Requests.DatabasePropertyRequest serialize() {
Requests.DatabasePropertyRequest.Builder builder =
Requests.DatabasePropertyRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof DatabasePropertyRequest
&& Objects.equals(connectionId, ((DatabasePropertyRequest) o).connectionId);
}
}
/** Request for
* {@link Meta#getSchemas(Meta.ConnectionHandle, String, Meta.Pat)}. */
class SchemasRequest extends Request {
public final String connectionId;
public final String catalog;
public final String schemaPattern;
SchemasRequest() {
connectionId = null;
catalog = null;
schemaPattern = null;
}
@JsonCreator
public SchemasRequest(@JsonProperty("connectionId") String connectionId,
@JsonProperty("catalog") String catalog,
@JsonProperty("schemaPattern") String schemaPattern) {
this.connectionId = connectionId;
this.catalog = catalog;
this.schemaPattern = schemaPattern;
}
ResultSetResponse accept(Service service) {
return service.apply(this);
}
@Override SchemasRequest deserialize(Message genericMsg) {
final Requests.SchemasRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.SchemasRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc, Requests.SchemasRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
String catalog = null;
if (ProtobufService.hasField(msg, desc, Requests.SchemasRequest.CATALOG_FIELD_NUMBER)) {
catalog = msg.getCatalog();
}
String schemaPattern = null;
if (ProtobufService.hasField(msg, desc,
Requests.SchemasRequest.SCHEMA_PATTERN_FIELD_NUMBER)) {
schemaPattern = msg.getSchemaPattern();
}
return new SchemasRequest(connectionId, catalog, schemaPattern);
}
@Override Requests.SchemasRequest serialize() {
Requests.SchemasRequest.Builder builder = Requests.SchemasRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
if (null != catalog) {
builder.setCatalog(catalog);
}
if (null != schemaPattern) {
builder.setSchemaPattern(schemaPattern);
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, catalog);
result = p(result, schemaPattern);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof SchemasRequest
&& Objects.equals(connectionId, ((SchemasRequest) o).connectionId)
&& Objects.equals(catalog, ((SchemasRequest) o).catalog)
&& Objects.equals(schemaPattern, ((SchemasRequest) o).schemaPattern);
}
}
/** Request for
* {@link Meta#getTables(Meta.ConnectionHandle, String, org.apache.calcite.avatica.Meta.Pat, org.apache.calcite.avatica.Meta.Pat, java.util.List)}
*/
class TablesRequest extends Request {
public final String connectionId;
public final String catalog;
public final String schemaPattern;
public final String tableNamePattern;
public final List typeList;
TablesRequest() {
connectionId = null;
catalog = null;
schemaPattern = null;
tableNamePattern = null;
typeList = null;
}
@JsonCreator
public TablesRequest(@JsonProperty("connectionId") String connectionId,
@JsonProperty("catalog") String catalog,
@JsonProperty("schemaPattern") String schemaPattern,
@JsonProperty("tableNamePattern") String tableNamePattern,
@JsonProperty("typeList") List typeList) {
this.connectionId = connectionId;
this.catalog = catalog;
this.schemaPattern = schemaPattern;
this.tableNamePattern = tableNamePattern;
this.typeList = typeList;
}
@Override Response accept(Service service) {
return service.apply(this);
}
@Override Request deserialize(Message genericMsg) {
final Requests.TablesRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.TablesRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc, Requests.TablesRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
String catalog = null;
if (ProtobufService.hasField(msg, desc, Requests.TablesRequest.CATALOG_FIELD_NUMBER)) {
catalog = msg.getCatalog();
}
String schemaPattern = null;
if (ProtobufService.hasField(msg, desc, Requests.TablesRequest.SCHEMA_PATTERN_FIELD_NUMBER)) {
schemaPattern = msg.getSchemaPattern();
}
String tableNamePattern = null;
if (ProtobufService.hasField(msg, desc,
Requests.TablesRequest.TABLE_NAME_PATTERN_FIELD_NUMBER)) {
tableNamePattern = msg.getTableNamePattern();
}
// Cannot determine if a value was set for a repeated field. Must use an extra boolean
// parameter to distinguish an empty and null typeList.
List typeList = null;
if (msg.getHasTypeList()) {
typeList = msg.getTypeListList();
}
return new TablesRequest(connectionId, catalog, schemaPattern, tableNamePattern, typeList);
}
@Override Requests.TablesRequest serialize() {
Requests.TablesRequest.Builder builder = Requests.TablesRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
if (null != catalog) {
builder.setCatalog(catalog);
}
if (null != schemaPattern) {
builder.setSchemaPattern(schemaPattern);
}
if (null != tableNamePattern) {
builder.setTableNamePattern(tableNamePattern);
}
if (null != typeList) {
builder.setHasTypeList(true);
builder.addAllTypeList(typeList);
} else {
builder.setHasTypeList(false);
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, catalog);
result = p(result, schemaPattern);
result = p(result, tableNamePattern);
result = p(result, typeList);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof TablesRequest
&& Objects.equals(connectionId, ((TablesRequest) o).connectionId)
&& Objects.equals(catalog, ((TablesRequest) o).catalog)
&& Objects.equals(schemaPattern, ((TablesRequest) o).schemaPattern)
&& Objects.equals(tableNamePattern, ((TablesRequest) o).tableNamePattern)
&& Objects.equals(typeList, ((TablesRequest) o).typeList);
}
}
/**
* Request for {@link Meta#getTableTypes(Meta.ConnectionHandle)}.
*/
class TableTypesRequest extends Request {
public final String connectionId;
public TableTypesRequest() {
this.connectionId = null;
}
@JsonCreator
public TableTypesRequest(@JsonProperty("connectionId") String connectionId) {
this.connectionId = connectionId;
}
@Override ResultSetResponse accept(Service service) {
return service.apply(this);
}
@Override TableTypesRequest deserialize(Message genericMsg) {
final Requests.TableTypesRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.TableTypesRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Requests.TableTypesRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
return new TableTypesRequest(connectionId);
}
@Override Requests.TableTypesRequest serialize() {
Requests.TableTypesRequest.Builder builder = Requests.TableTypesRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof TableTypesRequest
&& Objects.equals(connectionId, ((TableTypesRequest) o).connectionId);
}
}
/** Request for
* {@link Meta#getColumns(Meta.ConnectionHandle, String, org.apache.calcite.avatica.Meta.Pat, org.apache.calcite.avatica.Meta.Pat, org.apache.calcite.avatica.Meta.Pat)}.
*/
class ColumnsRequest extends Request {
public final String connectionId;
public final String catalog;
public final String schemaPattern;
public final String tableNamePattern;
public final String columnNamePattern;
ColumnsRequest() {
connectionId = null;
catalog = null;
schemaPattern = null;
tableNamePattern = null;
columnNamePattern = null;
}
@JsonCreator
public ColumnsRequest(@JsonProperty("connectionId") String connectionId,
@JsonProperty("catalog") String catalog,
@JsonProperty("schemaPattern") String schemaPattern,
@JsonProperty("tableNamePattern") String tableNamePattern,
@JsonProperty("columnNamePattern") String columnNamePattern) {
this.connectionId = connectionId;
this.catalog = catalog;
this.schemaPattern = schemaPattern;
this.tableNamePattern = tableNamePattern;
this.columnNamePattern = columnNamePattern;
}
ResultSetResponse accept(Service service) {
return service.apply(this);
}
@Override ColumnsRequest deserialize(Message genericMsg) {
final Requests.ColumnsRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.ColumnsRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc, Requests.ColumnsRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
String catalog = null;
if (ProtobufService.hasField(msg, desc, Requests.ColumnsRequest.CATALOG_FIELD_NUMBER)) {
catalog = msg.getCatalog();
}
String schemaPattern = null;
if (ProtobufService.hasField(msg, desc,
Requests.ColumnsRequest.SCHEMA_PATTERN_FIELD_NUMBER)) {
schemaPattern = msg.getSchemaPattern();
}
String tableNamePattern = null;
if (ProtobufService.hasField(msg, desc,
Requests.ColumnsRequest.TABLE_NAME_PATTERN_FIELD_NUMBER)) {
tableNamePattern = msg.getTableNamePattern();
}
String columnNamePattern = null;
if (ProtobufService.hasField(msg, desc,
Requests.ColumnsRequest.COLUMN_NAME_PATTERN_FIELD_NUMBER)) {
columnNamePattern = msg.getColumnNamePattern();
}
return new ColumnsRequest(connectionId, catalog, schemaPattern, tableNamePattern,
columnNamePattern);
}
@Override Requests.ColumnsRequest serialize() {
Requests.ColumnsRequest.Builder builder = Requests.ColumnsRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
if (null != catalog) {
builder.setCatalog(catalog);
}
if (null != schemaPattern) {
builder.setSchemaPattern(schemaPattern);
}
if (null != tableNamePattern) {
builder.setTableNamePattern(tableNamePattern);
}
if (null != columnNamePattern) {
builder.setColumnNamePattern(columnNamePattern);
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, catalog);
result = p(result, columnNamePattern);
result = p(result, schemaPattern);
result = p(result, tableNamePattern);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof ColumnsRequest
&& Objects.equals(connectionId, ((ColumnsRequest) o).connectionId)
&& Objects.equals(catalog, ((ColumnsRequest) o).catalog)
&& Objects.equals(schemaPattern, ((ColumnsRequest) o).schemaPattern)
&& Objects.equals(tableNamePattern, ((ColumnsRequest) o).tableNamePattern)
&& Objects.equals(columnNamePattern, ((ColumnsRequest) o).columnNamePattern);
}
}
/** Request for
* {@link Meta#getTypeInfo(Meta.ConnectionHandle)}. */
class TypeInfoRequest extends Request {
public final String connectionId;
public TypeInfoRequest() {
connectionId = null;
}
@JsonCreator
public TypeInfoRequest(@JsonProperty("connectionId") String connectionId) {
this.connectionId = connectionId;
}
@Override ResultSetResponse accept(Service service) {
return service.apply(this);
}
@Override TypeInfoRequest deserialize(Message genericMsg) {
final Requests.TypeInfoRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.TypeInfoRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Requests.TypeInfoRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
return new TypeInfoRequest(connectionId);
}
@Override Requests.TypeInfoRequest serialize() {
Requests.TypeInfoRequest.Builder builder = Requests.TypeInfoRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof TypeInfoRequest
&& Objects.equals(connectionId, ((TypeInfoRequest) o).connectionId);
}
}
/** Response that contains a result set.
*
* Regular result sets have {@code updateCount} -1;
* any other value means a dummy result set that is just a count, and has
* no signature and no other data.
*
*
Several types of request, including
* {@link org.apache.calcite.avatica.Meta#getCatalogs(Meta.ConnectionHandle)} and
* {@link org.apache.calcite.avatica.Meta#getSchemas(Meta.ConnectionHandle, String, org.apache.calcite.avatica.Meta.Pat)}
* {@link Meta#getTables(Meta.ConnectionHandle, String, Meta.Pat, Meta.Pat, List)}
* {@link Meta#getTableTypes(Meta.ConnectionHandle)}
* return this response. */
class ResultSetResponse extends Response {
public final String connectionId;
public final int statementId;
public final boolean ownStatement;
public final Meta.Signature signature;
public final Meta.Frame firstFrame;
public final long updateCount;
public final RpcMetadataResponse rpcMetadata;
ResultSetResponse() {
connectionId = null;
statementId = 0;
ownStatement = false;
signature = null;
firstFrame = null;
updateCount = 0;
rpcMetadata = null;
}
@JsonCreator
public ResultSetResponse(
@JsonProperty("connectionId") String connectionId,
@JsonProperty("statementId") int statementId,
@JsonProperty("ownStatement") boolean ownStatement,
@JsonProperty("signature") Meta.Signature signature,
@JsonProperty("firstFrame") Meta.Frame firstFrame,
@JsonProperty("updateCount") long updateCount,
@JsonProperty("rpcMetadata") RpcMetadataResponse rpcMetadata) {
this.connectionId = connectionId;
this.statementId = statementId;
this.ownStatement = ownStatement;
this.signature = signature;
this.firstFrame = firstFrame;
this.updateCount = updateCount;
this.rpcMetadata = rpcMetadata;
}
@Override ResultSetResponse deserialize(Message genericMsg) {
final Responses.ResultSetResponse msg = ProtobufService.castProtobufMessage(genericMsg,
Responses.ResultSetResponse.class);
return fromProto(msg);
}
static ResultSetResponse fromProto(Responses.ResultSetResponse msg) {
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Responses.ResultSetResponse.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
Meta.Signature signature = null;
if (ProtobufService.hasField(msg, desc, Responses.ResultSetResponse.SIGNATURE_FIELD_NUMBER)) {
signature = Meta.Signature.fromProto(msg.getSignature());
}
Meta.Frame frame = null;
if (ProtobufService.hasField(msg, desc,
Responses.ResultSetResponse.FIRST_FRAME_FIELD_NUMBER)) {
frame = Meta.Frame.fromProto(msg.getFirstFrame());
}
RpcMetadataResponse metadata = null;
if (ProtobufService.hasField(msg, desc, Responses.ResultSetResponse.METADATA_FIELD_NUMBER)) {
metadata = RpcMetadataResponse.fromProto(msg.getMetadata());
}
return new ResultSetResponse(connectionId, msg.getStatementId(), msg.getOwnStatement(),
signature, frame, msg.getUpdateCount(), metadata);
}
@Override Responses.ResultSetResponse serialize() {
Responses.ResultSetResponse.Builder builder = Responses.ResultSetResponse.newBuilder();
builder.setStatementId(statementId).setOwnStatement(ownStatement).setUpdateCount(updateCount);
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
if (null != signature) {
builder.setSignature(signature.toProto());
}
if (null != firstFrame) {
builder.setFirstFrame(firstFrame.toProto());
}
if (null != rpcMetadata) {
builder.setMetadata(rpcMetadata.serialize());
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, firstFrame);
result = p(result, ownStatement);
result = p(result, signature);
result = p(result, statementId);
result = p(result, updateCount);
result = p(result, rpcMetadata);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof ResultSetResponse
&& statementId == ((ResultSetResponse) o).statementId
&& ownStatement == ((ResultSetResponse) o).ownStatement
&& updateCount == ((ResultSetResponse) o).updateCount
&& Objects.equals(connectionId, ((ResultSetResponse) o).connectionId)
&& Objects.equals(firstFrame, ((ResultSetResponse) o).firstFrame)
&& Objects.equals(signature, ((ResultSetResponse) o).signature)
&& Objects.equals(rpcMetadata, ((ResultSetResponse) o).rpcMetadata);
}
}
/** Request for
* {@link Meta#prepareAndExecute(Meta.StatementHandle, String, long, Meta.PrepareCallback)}. */
class PrepareAndExecuteRequest extends Request {
public final String connectionId;
public final String sql;
public final long maxRowCount;
public final int statementId;
PrepareAndExecuteRequest() {
connectionId = null;
sql = null;
maxRowCount = 0;
statementId = 0;
}
@JsonCreator
public PrepareAndExecuteRequest(
@JsonProperty("connectionId") String connectionId,
@JsonProperty("statementId") int statementId,
@JsonProperty("sql") String sql,
@JsonProperty("maxRowCount") long maxRowCount) {
this.connectionId = connectionId;
this.statementId = statementId;
this.sql = sql;
this.maxRowCount = maxRowCount;
}
@Override ExecuteResponse accept(Service service) {
return service.apply(this);
}
@Override PrepareAndExecuteRequest deserialize(Message genericMsg) {
final Requests.PrepareAndExecuteRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.PrepareAndExecuteRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Requests.PrepareAndExecuteRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
String sql = null;
if (ProtobufService.hasField(msg, desc, Requests.PrepareAndExecuteRequest.SQL_FIELD_NUMBER)) {
sql = msg.getSql();
}
return new PrepareAndExecuteRequest(connectionId, msg.getStatementId(), sql,
msg.getMaxRowCount());
}
@Override Requests.PrepareAndExecuteRequest serialize() {
Requests.PrepareAndExecuteRequest.Builder builder = Requests.PrepareAndExecuteRequest
.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
if (null != sql) {
builder.setSql(sql);
}
builder.setStatementId(statementId);
builder.setMaxRowCount(maxRowCount);
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, maxRowCount);
result = p(result, sql);
result = p(result, statementId);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof PrepareAndExecuteRequest
&& statementId == ((PrepareAndExecuteRequest) o).statementId
&& maxRowCount == ((PrepareAndExecuteRequest) o).maxRowCount
&& Objects.equals(connectionId, ((PrepareAndExecuteRequest) o).connectionId)
&& Objects.equals(sql, ((PrepareAndExecuteRequest) o).sql);
}
}
/** Request for
* {@link org.apache.calcite.avatica.Meta#execute}. */
class ExecuteRequest extends Request {
public final Meta.StatementHandle statementHandle;
public final List parameterValues;
public final long maxRowCount;
ExecuteRequest() {
statementHandle = null;
parameterValues = null;
maxRowCount = 0;
}
@JsonCreator
public ExecuteRequest(
@JsonProperty("statementHandle") Meta.StatementHandle statementHandle,
@JsonProperty("parameterValues") List parameterValues,
@JsonProperty("maxRowCount") long maxRowCount) {
this.statementHandle = statementHandle;
this.parameterValues = parameterValues;
this.maxRowCount = maxRowCount;
}
@Override ExecuteResponse accept(Service service) {
return service.apply(this);
}
@Override ExecuteRequest deserialize(Message genericMsg) {
final Requests.ExecuteRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.ExecuteRequest.class);
final Descriptor desc = msg.getDescriptorForType();
Meta.StatementHandle statemetnHandle = null;
if (ProtobufService.hasField(msg, desc,
Requests.ExecuteRequest.STATEMENTHANDLE_FIELD_NUMBER)) {
statemetnHandle = Meta.StatementHandle.fromProto(msg.getStatementHandle());
}
List values = null;
if (msg.getHasParameterValues()) {
values = new ArrayList<>(msg.getParameterValuesCount());
for (Common.TypedValue valueProto : msg.getParameterValuesList()) {
values.add(TypedValue.fromProto(valueProto));
}
}
return new ExecuteRequest(statemetnHandle, values, msg.getMaxRowCount());
}
@Override Requests.ExecuteRequest serialize() {
Requests.ExecuteRequest.Builder builder = Requests.ExecuteRequest.newBuilder();
if (null != statementHandle) {
builder.setStatementHandle(statementHandle.toProto());
}
if (null != parameterValues) {
builder.setHasParameterValues(true);
for (TypedValue paramValue : parameterValues) {
if (paramValue == null) {
builder.addParameterValues(TypedValue.NULL.toProto());
} else {
builder.addParameterValues(paramValue.toProto());
}
}
} else {
builder.setHasParameterValues(false);
}
builder.setMaxRowCount(maxRowCount);
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, statementHandle);
result = p(result, parameterValues);
result = p(result, maxRowCount);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof ExecuteRequest
&& maxRowCount == ((ExecuteRequest) o).maxRowCount
&& Objects.equals(statementHandle, ((ExecuteRequest) o).statementHandle)
&& Objects.equals(parameterValues, ((ExecuteRequest) o).parameterValues);
}
}
/** Response to a
* {@link org.apache.calcite.avatica.remote.Service.PrepareAndExecuteRequest}. */
class ExecuteResponse extends Response {
public final List results;
public boolean missingStatement = false;
public final RpcMetadataResponse rpcMetadata;
ExecuteResponse() {
results = null;
rpcMetadata = null;
}
@JsonCreator
public ExecuteResponse(@JsonProperty("resultSets") List results,
@JsonProperty("missingStatement") boolean missingStatement,
@JsonProperty("rpcMetadata") RpcMetadataResponse rpcMetadata) {
this.results = results;
this.missingStatement = missingStatement;
this.rpcMetadata = rpcMetadata;
}
@Override ExecuteResponse deserialize(Message genericMsg) {
final Responses.ExecuteResponse msg = ProtobufService.castProtobufMessage(genericMsg,
Responses.ExecuteResponse.class);
final Descriptor desc = msg.getDescriptorForType();
List msgResults = msg.getResultsList();
List copiedResults = new ArrayList<>(msgResults.size());
for (Responses.ResultSetResponse msgResult : msgResults) {
copiedResults.add(ResultSetResponse.fromProto(msgResult));
}
RpcMetadataResponse metadata = null;
if (ProtobufService.hasField(msg, desc, Responses.ExecuteResponse.METADATA_FIELD_NUMBER)) {
metadata = RpcMetadataResponse.fromProto(msg.getMetadata());
}
return new ExecuteResponse(copiedResults, msg.getMissingStatement(), metadata);
}
@Override Responses.ExecuteResponse serialize() {
Responses.ExecuteResponse.Builder builder = Responses.ExecuteResponse.newBuilder();
if (null != results) {
for (ResultSetResponse result : results) {
builder.addResults(result.serialize());
}
}
if (null != rpcMetadata) {
builder.setMetadata(rpcMetadata.serialize());
}
return builder.setMissingStatement(missingStatement).build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, results);
result = p(result, rpcMetadata);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof ExecuteResponse
&& Objects.equals(results, ((ExecuteResponse) o).results)
&& Objects.equals(rpcMetadata, ((ExecuteResponse) o).rpcMetadata);
}
}
/** Request for
* {@link Meta#prepare(Meta.ConnectionHandle, String, long)}. */
class PrepareRequest extends Request {
public final String connectionId;
public final String sql;
public final long maxRowCount;
PrepareRequest() {
connectionId = null;
sql = null;
maxRowCount = 0;
}
@JsonCreator
public PrepareRequest(
@JsonProperty("connectionId") String connectionId,
@JsonProperty("sql") String sql,
@JsonProperty("maxRowCount") long maxRowCount) {
this.connectionId = connectionId;
this.sql = sql;
this.maxRowCount = maxRowCount;
}
@Override PrepareResponse accept(Service service) {
return service.apply(this);
}
@Override PrepareRequest deserialize(Message genericMsg) {
final Requests.PrepareRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.PrepareRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc, Requests.PrepareRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
String sql = null;
if (ProtobufService.hasField(msg, desc, Requests.PrepareRequest.SQL_FIELD_NUMBER)) {
sql = msg.getSql();
}
return new PrepareRequest(connectionId, sql, msg.getMaxRowCount());
}
@Override Requests.PrepareRequest serialize() {
Requests.PrepareRequest.Builder builder = Requests.PrepareRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
if (null != sql) {
builder.setSql(sql);
}
return builder.setMaxRowCount(maxRowCount).build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, maxRowCount);
result = p(result, sql);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof PrepareRequest
&& maxRowCount == ((PrepareRequest) o).maxRowCount
&& Objects.equals(connectionId, ((PrepareRequest) o).connectionId)
&& Objects.equals(sql, ((PrepareRequest) o).sql);
}
}
/** Response from
* {@link org.apache.calcite.avatica.remote.Service.PrepareRequest}. */
class PrepareResponse extends Response {
public final Meta.StatementHandle statement;
public final RpcMetadataResponse rpcMetadata;
PrepareResponse() {
statement = null;
rpcMetadata = null;
}
@JsonCreator
public PrepareResponse(
@JsonProperty("statement") Meta.StatementHandle statement,
@JsonProperty("rpcMetadata") RpcMetadataResponse rpcMetadata) {
this.statement = statement;
this.rpcMetadata = rpcMetadata;
}
@Override PrepareResponse deserialize(Message genericMsg) {
final Responses.PrepareResponse msg = ProtobufService.castProtobufMessage(genericMsg,
Responses.PrepareResponse.class);
final Descriptor desc = msg.getDescriptorForType();
RpcMetadataResponse metadata = null;
if (ProtobufService.hasField(msg, desc, Responses.PrepareResponse.METADATA_FIELD_NUMBER)) {
metadata = RpcMetadataResponse.fromProto(msg.getMetadata());
}
return new PrepareResponse(Meta.StatementHandle.fromProto(msg.getStatement()), metadata);
}
@Override Responses.PrepareResponse serialize() {
Responses.PrepareResponse.Builder builder = Responses.PrepareResponse.newBuilder();
if (null != statement) {
builder.setStatement(statement.toProto());
}
if (null != rpcMetadata) {
builder.setMetadata(rpcMetadata.serialize());
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, statement);
result = p(result, rpcMetadata);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof PrepareResponse
&& Objects.equals(statement, ((PrepareResponse) o).statement)
&& Objects.equals(rpcMetadata, ((PrepareResponse) o).rpcMetadata);
}
}
/** Request for
* {@link Meta#fetch}. */
class FetchRequest extends Request {
public final String connectionId;
public final int statementId;
public final long offset;
/** Maximum number of rows to be returned in the frame. Negative means no
* limit. */
public final int fetchMaxRowCount;
FetchRequest() {
connectionId = null;
statementId = 0;
offset = 0;
fetchMaxRowCount = 0;
}
@JsonCreator
public FetchRequest(
@JsonProperty("connectionId") String connectionId,
@JsonProperty("statementId") int statementId,
@JsonProperty("offset") long offset,
@JsonProperty("fetchMaxRowCount") int fetchMaxRowCount) {
this.connectionId = connectionId;
this.statementId = statementId;
this.offset = offset;
this.fetchMaxRowCount = fetchMaxRowCount;
}
@Override FetchResponse accept(Service service) {
return service.apply(this);
}
@Override FetchRequest deserialize(Message genericMsg) {
final Requests.FetchRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.FetchRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc, Requests.FetchRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
return new FetchRequest(connectionId, msg.getStatementId(), msg.getOffset(),
msg.getFetchMaxRowCount());
}
@Override Requests.FetchRequest serialize() {
Requests.FetchRequest.Builder builder = Requests.FetchRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
builder.setStatementId(statementId);
builder.setOffset(offset);
builder.setFetchMaxRowCount(fetchMaxRowCount);
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, fetchMaxRowCount);
result = p(result, offset);
result = p(result, statementId);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof FetchRequest
&& statementId == ((FetchRequest) o).statementId
&& offset == ((FetchRequest) o).offset
&& fetchMaxRowCount == ((FetchRequest) o).fetchMaxRowCount
&& Objects.equals(connectionId, ((FetchRequest) o).connectionId);
}
}
/** Response from
* {@link org.apache.calcite.avatica.remote.Service.FetchRequest}. */
class FetchResponse extends Response {
public final Meta.Frame frame;
public boolean missingStatement = false;
public boolean missingResults = false;
public final RpcMetadataResponse rpcMetadata;
FetchResponse() {
frame = null;
rpcMetadata = null;
}
@JsonCreator
public FetchResponse(@JsonProperty("frame") Meta.Frame frame,
@JsonProperty("missingStatement") boolean missingStatement,
@JsonProperty("missingResults") boolean missingResults,
@JsonProperty("rpcMetadata") RpcMetadataResponse rpcMetadata) {
this.frame = frame;
this.missingStatement = missingStatement;
this.missingResults = missingResults;
this.rpcMetadata = rpcMetadata;
}
@Override FetchResponse deserialize(Message genericMsg) {
final Responses.FetchResponse msg = ProtobufService.castProtobufMessage(genericMsg,
Responses.FetchResponse.class);
final Descriptor desc = msg.getDescriptorForType();
RpcMetadataResponse metadata = null;
if (ProtobufService.hasField(msg, desc, Responses.FetchResponse.METADATA_FIELD_NUMBER)) {
metadata = RpcMetadataResponse.fromProto(msg.getMetadata());
}
return new FetchResponse(Meta.Frame.fromProto(msg.getFrame()), msg.getMissingStatement(),
msg.getMissingResults(), metadata);
}
@Override Responses.FetchResponse serialize() {
Responses.FetchResponse.Builder builder = Responses.FetchResponse.newBuilder();
if (null != frame) {
builder.setFrame(frame.toProto());
}
if (null != rpcMetadata) {
builder.setMetadata(rpcMetadata.serialize());
}
return builder.setMissingStatement(missingStatement)
.setMissingResults(missingResults).build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, frame);
result = p(result, rpcMetadata);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof FetchResponse
&& Objects.equals(frame, ((FetchResponse) o).frame)
&& Objects.equals(rpcMetadata, ((FetchResponse) o).rpcMetadata)
&& missingStatement == ((FetchResponse) o).missingStatement;
}
}
/** Request for
* {@link org.apache.calcite.avatica.Meta#createStatement(org.apache.calcite.avatica.Meta.ConnectionHandle)}. */
class CreateStatementRequest extends Request {
public final String connectionId;
CreateStatementRequest() {
connectionId = null;
}
@JsonCreator
public CreateStatementRequest(
@JsonProperty("signature") String connectionId) {
this.connectionId = connectionId;
}
@Override CreateStatementResponse accept(Service service) {
return service.apply(this);
}
@Override CreateStatementRequest deserialize(Message genericMsg) {
final Requests.CreateStatementRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.CreateStatementRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Requests.CreateStatementRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
return new CreateStatementRequest(connectionId);
}
@Override Requests.CreateStatementRequest serialize() {
Requests.CreateStatementRequest.Builder builder = Requests.CreateStatementRequest
.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof CreateStatementRequest
&& Objects.equals(connectionId, ((CreateStatementRequest) o).connectionId);
}
}
/** Response from
* {@link org.apache.calcite.avatica.remote.Service.CreateStatementRequest}. */
class CreateStatementResponse extends Response {
public final String connectionId;
public final int statementId;
public final RpcMetadataResponse rpcMetadata;
CreateStatementResponse() {
connectionId = null;
statementId = 0;
rpcMetadata = null;
}
@JsonCreator
public CreateStatementResponse(
@JsonProperty("connectionId") String connectionId,
@JsonProperty("statementId") int statementId,
@JsonProperty("rpcMetadata") RpcMetadataResponse rpcMetadata) {
this.connectionId = connectionId;
this.statementId = statementId;
this.rpcMetadata = rpcMetadata;
}
@Override CreateStatementResponse deserialize(Message genericMsg) {
final Responses.CreateStatementResponse msg = ProtobufService.castProtobufMessage(genericMsg,
Responses.CreateStatementResponse.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Responses.CreateStatementResponse.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
RpcMetadataResponse metadata = null;
if (ProtobufService.hasField(msg, desc,
Responses.CreateStatementResponse.METADATA_FIELD_NUMBER)) {
metadata = RpcMetadataResponse.fromProto(msg.getMetadata());
}
return new CreateStatementResponse(connectionId, msg.getStatementId(), metadata);
}
@Override Responses.CreateStatementResponse serialize() {
Responses.CreateStatementResponse.Builder builder = Responses.CreateStatementResponse
.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
if (null != rpcMetadata) {
builder.setMetadata(rpcMetadata.serialize());
}
builder.setStatementId(statementId);
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, statementId);
result = p(result, rpcMetadata);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof CreateStatementResponse
&& statementId == ((CreateStatementResponse) o).statementId
&& Objects.equals(connectionId, ((CreateStatementResponse) o).connectionId)
&& Objects.equals(rpcMetadata, ((CreateStatementResponse) o).rpcMetadata);
}
}
/** Request for
* {@link org.apache.calcite.avatica.Meta#closeStatement(org.apache.calcite.avatica.Meta.StatementHandle)}. */
class CloseStatementRequest extends Request {
public final String connectionId;
public final int statementId;
CloseStatementRequest() {
connectionId = null;
statementId = 0;
}
@JsonCreator
public CloseStatementRequest(
@JsonProperty("connectionId") String connectionId,
@JsonProperty("statementId") int statementId) {
this.connectionId = connectionId;
this.statementId = statementId;
}
@Override CloseStatementResponse accept(Service service) {
return service.apply(this);
}
@Override CloseStatementRequest deserialize(Message genericMsg) {
final Requests.CloseStatementRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.CloseStatementRequest.class);
final Descriptor desc = msg.getDescriptorForType();
String connectionId = null;
if (ProtobufService.hasField(msg, desc,
Requests.CloseStatementRequest.CONNECTION_ID_FIELD_NUMBER)) {
connectionId = msg.getConnectionId();
}
return new CloseStatementRequest(connectionId, msg.getStatementId());
}
@Override Requests.CloseStatementRequest serialize() {
Requests.CloseStatementRequest.Builder builder = Requests.CloseStatementRequest.newBuilder();
if (null != connectionId) {
builder.setConnectionId(connectionId);
}
return builder.setStatementId(statementId).build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, connectionId);
result = p(result, statementId);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof CloseStatementRequest
&& statementId == ((CloseStatementRequest) o).statementId
&& Objects.equals(connectionId, ((CloseStatementRequest) o).connectionId);
}
}
/** Response from
* {@link org.apache.calcite.avatica.remote.Service.CloseStatementRequest}. */
class CloseStatementResponse extends Response {
public final RpcMetadataResponse rpcMetadata;
public CloseStatementResponse() {
rpcMetadata = null;
}
@JsonCreator
public CloseStatementResponse(@JsonProperty("rpcMetadata") RpcMetadataResponse rpcMetadata) {
this.rpcMetadata = rpcMetadata;
}
@Override CloseStatementResponse deserialize(Message genericMsg) {
final Responses.CloseStatementResponse msg = ProtobufService.castProtobufMessage(genericMsg,
Responses.CloseStatementResponse.class);
final Descriptor desc = msg.getDescriptorForType();
RpcMetadataResponse metadata = null;
if (ProtobufService.hasField(msg, desc,
Responses.CloseStatementResponse.METADATA_FIELD_NUMBER)) {
metadata = RpcMetadataResponse.fromProto(msg.getMetadata());
}
return new CloseStatementResponse(metadata);
}
@Override Responses.CloseStatementResponse serialize() {
Responses.CloseStatementResponse.Builder builder =
Responses.CloseStatementResponse.newBuilder();
if (null != rpcMetadata) {
builder.setMetadata(rpcMetadata.serialize());
}
return builder.build();
}
@Override public int hashCode() {
int result = 1;
result = p(result, rpcMetadata);
return result;
}
@Override public boolean equals(Object o) {
return o == this
|| o instanceof CloseStatementResponse
&& Objects.equals(rpcMetadata, ((CloseStatementResponse) o).rpcMetadata);
}
}
/** Request for
* {@link Meta#openConnection}. */
class OpenConnectionRequest extends Request {
public final String connectionId;
public final Map info;
public OpenConnectionRequest() {
connectionId = null;
info = null;
}
@JsonCreator
public OpenConnectionRequest(@JsonProperty("connectionId") String connectionId,
@JsonProperty("info") Map info) {
this.connectionId = connectionId;
this.info = info;
}
@Override OpenConnectionResponse accept(Service service) {
return service.apply(this);
}
/**
* Serializes the necessary properties into a Map.
*
* @param props The properties to serialize.
* @return A representation of the Properties as a Map.
*/
public static Map serializeProperties(Properties props) {
Map infoAsString = new HashMap<>();
for (Map.Entry