class CountTask extends AbstractTask {

    private final CountPhase countPhase;
    private final TransactionContext txnCtx;
    private final CountOperation countOperation;
    private final RowConsumer consumer;
    private final Map<String, IntIndexedContainer> indexShardMap;
    private CompletableFuture<Long> countFuture;
    private volatile Throwable killReason;

    CountTask(CountPhase countPhase,
              TransactionContext txnCtx,
              CountOperation countOperation,
              RowConsumer consumer,
              Map<String, IntIndexedContainer> indexShardMap) {
        super(countPhase.phaseId());
        this.countPhase = countPhase;
        this.txnCtx = txnCtx;
        this.countOperation = countOperation;
        this.consumer = consumer;
        this.indexShardMap = indexShardMap;
    }

    @Override
    public synchronized CompletableFuture<Void> innerStart() {
        try {
            countFuture = countOperation.count(txnCtx, indexShardMap, countPhase.where());
        } catch (Throwable t) {
            consumer.accept(null, t);
            return null;
        }
        countFuture.whenComplete((rowCount, failure) -> {
            Throwable killed = killReason;  // 1 volatile read
            failure = killed == null ? failure : killed;
            if (failure == null) {
                consumer.accept(InMemoryBatchIterator.of(new Row1(rowCount), SENTINEL), null);
                close();
            } else {
                consumer.accept(null, failure);
                kill(failure);
            }
        });
        return null;
    }

    @Override
    public synchronized void innerKill(@NotNull Throwable throwable) {<FILL_FUNCTION_BODY>}

    @Override
    public String name() {
        return countPhase.name();
    }

    @Override
    public long bytesUsed() {
        return -1;
    }
}

        if (countFuture == null) {
            consumer.accept(null, throwable);
        } else {
            killReason = throwable;
            countFuture.cancel(true);
        }
    
<methods>public CompletableFuture<java.lang.Void> completionFuture() ,public int id() ,public final void kill(java.lang.Throwable) ,public final CompletableFuture<java.lang.Void> start() <variables>private final java.util.concurrent.atomic.AtomicBoolean firstClose,private final CompletableFuture<java.lang.Void> future,protected final non-sealed int id