Search in sources :

Example 1 with ObjectArrayDecoder

use of io.mycat.mysqlclient.decoder.ObjectArrayDecoder in project Mycat2 by MyCATApache.

the class VertxMycatConnectionPool method query.

@Override
public synchronized Future<RowSet> query(String sql, List<Object> params) {
    String psql = deparameterize(sql, params);
    Future<RowSet> rowSetFuture = queryCloseFuture.flatMap(unused -> {
        Promise<RowSet> promise = Promise.promise();
        ObjectArrayDecoder objectArrayDecoder = new ObjectArrayDecoder();
        Observable<Object[]> query = connection.query(psql, objectArrayDecoder);
        onSend();
        Single<RowSet> map = query.subscribeOn(Schedulers.computation()).toList().map(objects -> {
            MycatMySQLRowMetaData mycatMySQLRowMetaData = new MycatMySQLRowMetaData(Arrays.asList(objectArrayDecoder.getColumnDefPackets()));
            return new RowSet(mycatMySQLRowMetaData, objects);
        });
        map = map.doOnSuccess(objects -> promise.tryComplete(objects));
        map = map.doOnError(objects -> promise.tryFail(objects));
        map = map.doOnTerminate(() -> onRev());
        map.subscribe();
        return promise.future();
    });
    this.queryCloseFuture = rowSetFuture.mapEmpty();
    return rowSetFuture;
}
Also used : Single(io.reactivex.rxjava3.core.Single) Arrays(java.util.Arrays) RowSet(io.mycat.newquery.RowSet) PreparedStatement(io.mycat.PreparedStatement) Function(java.util.function.Function) Schedulers(io.reactivex.rxjava3.schedulers.Schedulers) MySqlASTVisitorAdapter(com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter) ImmutableList(com.google.common.collect.ImmutableList) MycatMySQLRowMetaData(io.mycat.beans.mycat.MycatMySQLRowMetaData) Observable(io.reactivex.rxjava3.core.Observable) JdbcDatasourcePoolImpl(io.mycat.commands.JdbcDatasourcePoolImpl) ObjectArrayDecoder(io.mycat.mysqlclient.decoder.ObjectArrayDecoder) AsyncResult(io.vertx.core.AsyncResult) MycatRelDataType(io.mycat.beans.mycat.MycatRelDataType) SQLVariantRefExpr(com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr) BufferAllocator(org.apache.arrow.memory.BufferAllocator) SQLUtils(com.alibaba.druid.sql.SQLUtils) NewMycatConnection(io.mycat.newquery.NewMycatConnection) ColumnDefPacket(io.mycat.beans.mysql.packet.ColumnDefPacket) VectorSchemaRoot(org.apache.arrow.vector.VectorSchemaRoot) SQLReplaceable(com.alibaba.druid.sql.ast.SQLReplaceable) Promise(io.vertx.core.Promise) MysqlCollector(io.mycat.newquery.MysqlCollector) SqlResult(io.mycat.newquery.SqlResult) Future(io.vertx.core.Future) List(java.util.List) Buffer(io.vertx.core.buffer.Buffer) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement) Handler(io.vertx.core.Handler) MycatMySQLRowMetaData(io.mycat.beans.mycat.MycatMySQLRowMetaData) RowSet(io.mycat.newquery.RowSet) ObjectArrayDecoder(io.mycat.mysqlclient.decoder.ObjectArrayDecoder)

Aggregations

SQLUtils (com.alibaba.druid.sql.SQLUtils)1 SQLReplaceable (com.alibaba.druid.sql.ast.SQLReplaceable)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)1 MySqlASTVisitorAdapter (com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter)1 ImmutableList (com.google.common.collect.ImmutableList)1 PreparedStatement (io.mycat.PreparedStatement)1 MycatMySQLRowMetaData (io.mycat.beans.mycat.MycatMySQLRowMetaData)1 MycatRelDataType (io.mycat.beans.mycat.MycatRelDataType)1 ColumnDefPacket (io.mycat.beans.mysql.packet.ColumnDefPacket)1 JdbcDatasourcePoolImpl (io.mycat.commands.JdbcDatasourcePoolImpl)1 ObjectArrayDecoder (io.mycat.mysqlclient.decoder.ObjectArrayDecoder)1 MysqlCollector (io.mycat.newquery.MysqlCollector)1 NewMycatConnection (io.mycat.newquery.NewMycatConnection)1 RowSet (io.mycat.newquery.RowSet)1 SqlResult (io.mycat.newquery.SqlResult)1 Observable (io.reactivex.rxjava3.core.Observable)1 Single (io.reactivex.rxjava3.core.Single)1 Schedulers (io.reactivex.rxjava3.schedulers.Schedulers)1 AsyncResult (io.vertx.core.AsyncResult)1