All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yandex.ydb.table.query.DataQueryResult Maven / Gradle / Ivy

There is a newer version: 1.45.6
Show newest version
package com.yandex.ydb.table.query;

import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.yandex.ydb.ValueProtos;
import com.yandex.ydb.common.CommonProtos;
import com.yandex.ydb.table.result.ResultSetReader;
import com.yandex.ydb.table.result.impl.ProtoValueReaders;


/**
 * @author Sergey Polovko
 */
public class DataQueryResult {

    private final String txId;
    private final List resultSets;
    @Nullable
    private final CostInfo costInfo;

    public DataQueryResult(String txId, List resultSets) {
        this(txId, resultSets, null);
    }

    public DataQueryResult(String txId, List resultSets, @Nullable CostInfo costInfo) {
        this.txId = txId;
        this.resultSets = resultSets;
        this.costInfo = costInfo;
    }

    public String getTxId() {
        return txId;
    }

    public int getResultSetCount() {
        return resultSets.size();
    }

    public ResultSetReader getResultSet(int index) {
        return ProtoValueReaders.forResultSet(resultSets.get(index));
    }

    public boolean isTruncated(int index) {
        return resultSets.get(index).getTruncated();
    }

    public int getRowCount(int index) {
        return resultSets.get(index).getRowsCount();
    }

    public boolean isEmpty() {
        return txId.isEmpty() && resultSets.isEmpty();
    }

    @Nullable
    public CostInfo getCostInfo() {
        return costInfo;
    }

    public static class CostInfo {
        private final double consumedUnits;

        public CostInfo(@Nonnull CommonProtos.CostInfo costInfo) {
            this.consumedUnits = costInfo.getConsumedUnits();
        }

        public double getConsumedUnits() {
            return consumedUnits;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy