Package io.crate.operation.merge

Examples of io.crate.operation.merge.MergeOperation


        planNodeStreamerVisitor = new PlanNodeStreamerVisitor(functions);
        this.contextManager = new DistributedRequestContextManager(new DownstreamOperationFactory<MergeNode>() {
            @Override
            public DownstreamOperation create(MergeNode node) {
                return new MergeOperation(
                        clusterService,
                        settings,
                        transportActionProvider,
                        implementationSymbolVisitor,
                        node
View Full Code Here


        if (upstreamResults == null) {
            result.set(TaskResult.EMPTY_RESULT);
            return;
        }

        final MergeOperation mergeOperation = new MergeOperation(
                clusterService, settings, transportActionProvider, symbolVisitor, mergeNode);
        final AtomicInteger countdown = new AtomicInteger(upstreamResults.size());
        final UUID operationId = UUID.randomUUID();
        statsTables.operationStarted(operationId, mergeNode.contextId(), mergeNode.id());

        Futures.addCallback(mergeOperation.result(), new FutureCallback<Object[][]>() {
            @Override
            public void onSuccess(@Nullable Object[][] rows) {
                statsTables.operationFinished(operationId, null);
                result.set(new QueryResult(rows));
            }

            @Override
            public void onFailure(@Nonnull Throwable t) {
                statsTables.operationFinished(operationId, Exceptions.messageOf(t));
                result.setException(t);
            }
        });

        for (final ListenableFuture<TaskResult> upstreamResult : upstreamResults) {
            Futures.addCallback(upstreamResult, new FutureCallback<TaskResult>() {
                @Override
                public void onSuccess(@Nullable TaskResult rows) {
                    assert rows != null;
                    traceLogResult(rows);
                    boolean shouldContinue;

                    try {
                        shouldContinue = mergeOperation.addRows(rows.rows());
                    } catch (Exception ex) {
                        statsTables.operationFinished(operationId, Exceptions.messageOf(ex));
                        result.setException(ex);
                        logger.error("Failed to add rows", ex);
                        return;
                    }

                    if (countdown.decrementAndGet() == 0 || !shouldContinue) {
                        mergeOperation.finished();
                    }
                }

                @Override
                public void onFailure(@Nonnull Throwable t) {
View Full Code Here

TOP

Related Classes of io.crate.operation.merge.MergeOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.