Search in sources :

Example 1 with AsyncMycatDataContextImpl

use of io.mycat.AsyncMycatDataContextImpl in project Mycat2 by MyCATApache.

the class PrepareExecutor method getMysqlPayloadObjectObservable.

@NotNull
public static Observable<MysqlPayloadObject> getMysqlPayloadObjectObservable(ArrayBindable bindable, AsyncMycatDataContextImpl newMycatDataContext, MycatRowMetaData rowMetaData) {
    Observable<MysqlPayloadObject> rowObservable = Observable.<MysqlPayloadObject>create(emitter -> {
        emitter.onNext(new MySQLColumnDef(rowMetaData));
        try {
            Object bindObservable;
            bindObservable = bindable.bindObservable(newMycatDataContext);
            Observable<Object[]> observable;
            if (bindObservable instanceof Observable) {
                observable = (Observable) bindObservable;
            } else {
                Enumerable<Object[]> enumerable = (Enumerable) bindObservable;
                observable = toObservable(newMycatDataContext, enumerable);
            }
            observable.subscribe(objects -> emitter.onNext(new MysqlObjectArrayRow(objects)), throwable -> {
                newMycatDataContext.endFuture().onComplete(event -> emitter.onError(throwable));
            }, () -> {
                CompositeFuture compositeFuture = newMycatDataContext.endFuture();
                compositeFuture.onSuccess(event -> emitter.onComplete());
                compositeFuture.onFailure(event -> emitter.onError(event));
            });
        } catch (Throwable throwable) {
            CompositeFuture compositeFuture = newMycatDataContext.endFuture();
            compositeFuture.onComplete(event -> emitter.onError(throwable));
        }
    });
    return rowObservable;
}
Also used : MySQLColumnDef(io.mycat.api.collector.MySQLColumnDef) CompositeFuture(io.vertx.core.CompositeFuture) ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder) MycatRowMetaData(io.mycat.beans.mycat.MycatRowMetaData) Getter(lombok.Getter) Iterator(java.util.Iterator) VectorSchemaRoot(org.apache.arrow.vector.VectorSchemaRoot) Enumerable(org.apache.calcite.linq4j.Enumerable) MycatRxJavaUtl(io.mycat.MycatRxJavaUtl) Future(io.vertx.core.Future) ArrayBindable(org.apache.calcite.runtime.ArrayBindable) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) CompositeFuture(io.vertx.core.CompositeFuture) MysqlObjectArrayRow(io.mycat.api.collector.MysqlObjectArrayRow) List(java.util.List) AsyncMycatDataContextImpl(io.mycat.AsyncMycatDataContextImpl) MySQLColumnDef(io.mycat.api.collector.MySQLColumnDef) MysqlPayloadObject(io.mycat.api.collector.MysqlPayloadObject) Observable(io.reactivex.rxjava3.core.Observable) Enumerator(org.apache.calcite.linq4j.Enumerator) RowBaseIterator(io.mycat.api.collector.RowBaseIterator) NotNull(org.jetbrains.annotations.NotNull) Enumerable(org.apache.calcite.linq4j.Enumerable) MysqlObjectArrayRow(io.mycat.api.collector.MysqlObjectArrayRow) MysqlPayloadObject(io.mycat.api.collector.MysqlPayloadObject) MysqlPayloadObject(io.mycat.api.collector.MysqlPayloadObject) Observable(io.reactivex.rxjava3.core.Observable) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AsyncMycatDataContextImpl (io.mycat.AsyncMycatDataContextImpl)1 MycatRxJavaUtl (io.mycat.MycatRxJavaUtl)1 MySQLColumnDef (io.mycat.api.collector.MySQLColumnDef)1 MysqlObjectArrayRow (io.mycat.api.collector.MysqlObjectArrayRow)1 MysqlPayloadObject (io.mycat.api.collector.MysqlPayloadObject)1 RowBaseIterator (io.mycat.api.collector.RowBaseIterator)1 MycatRowMetaData (io.mycat.beans.mycat.MycatRowMetaData)1 ResultSetBuilder (io.mycat.beans.mycat.ResultSetBuilder)1 Observable (io.reactivex.rxjava3.core.Observable)1 CompositeFuture (io.vertx.core.CompositeFuture)1 Future (io.vertx.core.Future)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Objects (java.util.Objects)1 TimeUnit (java.util.concurrent.TimeUnit)1 Getter (lombok.Getter)1 VectorSchemaRoot (org.apache.arrow.vector.VectorSchemaRoot)1 Enumerable (org.apache.calcite.linq4j.Enumerable)1 Enumerator (org.apache.calcite.linq4j.Enumerator)1 ArrayBindable (org.apache.calcite.runtime.ArrayBindable)1