Java Code Examples for org.apache.calcite.avatica.Meta#StatementHandle

The following examples show how to use org.apache.calcite.avatica.Meta#StatementHandle . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalciteJdbc41Factory.java    From calcite with Apache License 2.0 5 votes vote down vote up
public CalciteJdbc41Statement newStatement(AvaticaConnection connection,
    Meta.StatementHandle h,
    int resultSetType,
    int resultSetConcurrency,
    int resultSetHoldability) {
  return new CalciteJdbc41Statement(
      (CalciteConnectionImpl) connection,
      h,
      resultSetType, resultSetConcurrency,
      resultSetHoldability);
}
 
Example 2
Source File: Service.java    From calcite-avatica with Apache License 2.0 5 votes vote down vote up
@JsonCreator
public ExecuteRequest(
    @JsonProperty("statementHandle") Meta.StatementHandle statementHandle,
    @JsonProperty("parameterValues") List<TypedValue> parameterValues,
    @JsonProperty("maxRowCount") int maxRowCount) {
  this.statementHandle = statementHandle;
  this.parameterValues = parameterValues;
  this.maxRowCount = maxRowCount;
}
 
Example 3
Source File: AbstractService.java    From calcite-avatica with Apache License 2.0 5 votes vote down vote up
PrepareResponse finagle(PrepareResponse response) {
  final Meta.StatementHandle statement = finagle(response.statement);
  if (statement == response.statement) {
    return response;
  }
  return new PrepareResponse(statement, rpcMetadata);
}
 
Example 4
Source File: LocalService.java    From calcite-avatica with Apache License 2.0 5 votes vote down vote up
public ExecuteResponse apply(PrepareAndExecuteRequest request) {
  try (final Context ignore = prepareAndExecuteTimer.start()) {
    final Meta.StatementHandle sh =
        new Meta.StatementHandle(request.connectionId, request.statementId, null);
    try {
      final Meta.ExecuteResult executeResult =
          meta.prepareAndExecute(sh, request.sql, request.maxRowCount,
              request.maxRowsInFirstFrame, 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, serverLevelRpcMetadata);
    } catch (NoSuchStatementException e) {
      // The Statement doesn't exist anymore, bubble up this information
      return new ExecuteResponse(null, true, serverLevelRpcMetadata);
    }
  }
}
 
Example 5
Source File: QuicksqlJdbc41Factory.java    From Quicksql with MIT License 5 votes vote down vote up
public AvaticaPreparedStatement newPreparedStatement(
    AvaticaConnection connection,
    Meta.StatementHandle h,
    Signature signature,
    int resultSetType,
    int resultSetConcurrency,
    int resultSetHoldability) throws SQLException {
  return new QuickSqlJdbc41PreparedStatement(
      (QuicksqlConnectionImpl) connection, h,
       signature, resultSetType,
      resultSetConcurrency, resultSetHoldability);
}
 
Example 6
Source File: QuarkJdbc41Factory.java    From quark with Apache License 2.0 5 votes vote down vote up
@Override
public QuarkStatement newStatement(AvaticaConnection connection,
                                   Meta.StatementHandle statementHandle,
                                   int resultSetType,
                                   int resultSetConcurrency,
                                   int resultSetHoldability) {
  return new QuarkJdbc41Statement((QuarkConnectionImpl) connection,
      statementHandle,
      resultSetType,
      resultSetConcurrency,
      resultSetHoldability);
}
 
Example 7
Source File: CalciteConnectionImpl.java    From calcite with Apache License 2.0 5 votes vote down vote up
public CalciteServerStatement getStatement(Meta.StatementHandle h)
    throws NoSuchStatementException {
  CalciteServerStatement statement = statementMap.get(h.id);
  if (statement == null) {
    throw new NoSuchStatementException(h);
  }
  return statement;
}
 
Example 8
Source File: CalciteConnectionImpl.java    From Quicksql with MIT License 5 votes vote down vote up
public void addStatement(CalciteConnection connection,
    Meta.StatementHandle h) {
  final CalciteConnectionImpl c = (CalciteConnectionImpl) connection;
  final CalciteServerStatement previous =
      statementMap.put(h.id, new CalciteServerStatementImpl(c));
  if (previous != null) {
    throw new AssertionError();
  }
}
 
Example 9
Source File: QuarkJdbc41Factory.java    From quark with Apache License 2.0 5 votes vote down vote up
QuarkJdbc41Statement(QuarkConnectionImpl connection,
                     Meta.StatementHandle h,
                     int resultSetType,
                     int resultSetConcurrency,
                     int resultSetHoldability) {
  super(connection, h, resultSetType, resultSetConcurrency,
      resultSetHoldability);
}
 
Example 10
Source File: PlanExecutor.java    From quark with Apache License 2.0 5 votes vote down vote up
public PlanExecutor(Meta.StatementHandle h,
             QuarkConnectionImpl connection,
             Cache<String, Connection> connectionCache,
             long maxRowCount) {
  this.h = h;
  this.connection = connection;
  this.connectionCache = connectionCache;
  this.maxRowCount = maxRowCount;
}
 
Example 11
Source File: CalciteConnectionImpl.java    From calcite with Apache License 2.0 5 votes vote down vote up
public void addStatement(CalciteConnection connection,
    Meta.StatementHandle h) {
  final CalciteConnectionImpl c = (CalciteConnectionImpl) connection;
  final CalciteServerStatement previous =
      statementMap.put(h.id, new CalciteServerStatementImpl(c));
  if (previous != null) {
    throw new AssertionError();
  }
}
 
Example 12
Source File: CalciteConnectionImpl.java    From Quicksql with MIT License 4 votes vote down vote up
public void removeStatement(Meta.StatementHandle h) {
  statementMap.remove(h.id);
}
 
Example 13
Source File: CalciteConnectionImpl.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public AtomicBoolean getCancelFlag(Meta.StatementHandle handle)
    throws NoSuchStatementException {
  final CalciteServerStatement serverStatement = server.getStatement(handle);
  return ((CalciteServerStatementImpl) serverStatement).cancelFlag;
}
 
Example 14
Source File: QuarkServer.java    From quark with Apache License 2.0 4 votes vote down vote up
public QuarkJdbcStatement getStatement(Meta.StatementHandle h) {
  return statementMap.get(h.id);
}
 
Example 15
Source File: QuarkServer.java    From quark with Apache License 2.0 4 votes vote down vote up
public void addStatement(QuarkConnection connection,
                         Meta.StatementHandle h) {
  final QuarkConnectionImpl c = (QuarkConnectionImpl) connection;
  statementMap.put(h.id, new QuarkJdbcStatementImpl(c));
}
 
Example 16
Source File: CalcitePreparedStatement.java    From calcite with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a CalcitePreparedStatement.
 *
 * @param connection Connection
 * @param h Statement handle
 * @param signature Result of preparing statement
 * @param resultSetType Result set type
 * @param resultSetConcurrency Result set concurrency
 * @param resultSetHoldability Result set holdability
 * @throws SQLException if database error occurs
 */
protected CalcitePreparedStatement(CalciteConnectionImpl connection,
    Meta.StatementHandle h, Meta.Signature signature, int resultSetType,
    int resultSetConcurrency, int resultSetHoldability) throws SQLException {
  super(connection, h, signature, resultSetType, resultSetConcurrency,
      resultSetHoldability);
}
 
Example 17
Source File: CalcitePreparedStatement.java    From Quicksql with MIT License 3 votes vote down vote up
/**
 * Creates a CalcitePreparedStatement.
 *
 * @param connection Connection
 * @param h Statement handle
 * @param signature Result of preparing statement
 * @param resultSetType Result set type
 * @param resultSetConcurrency Result set concurrency
 * @param resultSetHoldability Result set holdability
 * @throws SQLException if database error occurs
 */
protected CalcitePreparedStatement(CalciteConnectionImpl connection,
    Meta.StatementHandle h, Meta.Signature signature, int resultSetType,
    int resultSetConcurrency, int resultSetHoldability) throws SQLException {
  super(connection, h, signature, resultSetType, resultSetConcurrency,
      resultSetHoldability);
}
 
Example 18
Source File: CalciteServer.java    From calcite with Apache License 2.0 2 votes vote down vote up
/** Returns the statement with a given handle.
 *
 * @param h Statement handle
 * @return Statement, never null
 * @throws NoSuchStatementException if handle does not represent a statement
 */
CalciteServerStatement getStatement(Meta.StatementHandle h)
    throws NoSuchStatementException;
 
Example 19
Source File: CalciteServer.java    From Quicksql with MIT License votes vote down vote up
void addStatement(CalciteConnection connection, Meta.StatementHandle h); 
Example 20
Source File: CalciteServer.java    From calcite with Apache License 2.0 votes vote down vote up
void removeStatement(Meta.StatementHandle h);