Search in sources :

Example 1 with FixedWidthType

use of io.crate.types.FixedWidthType in project crate by crate.

the class Stats method estimateSizeForColumns.

public long estimateSizeForColumns(List<Symbol> toCollect) {
    long sum = 0L;
    for (int i = 0; i < toCollect.size(); i++) {
        Symbol symbol = toCollect.get(i);
        ColumnStats<?> columnStats = null;
        if (symbol instanceof Reference) {
            columnStats = statsByColumn.get(((Reference) symbol).column());
        } else if (symbol instanceof ScopedSymbol) {
            columnStats = statsByColumn.get(((ScopedSymbol) symbol).column());
        }
        if (columnStats == null) {
            if (symbol.valueType() instanceof FixedWidthType) {
                sum += ((FixedWidthType) symbol.valueType()).fixedSize();
            } else {
                sum += RamUsageEstimator.UNKNOWN_DEFAULT_RAM_BYTES_USED;
            }
        } else {
            sum += columnStats.averageSizeInBytes();
        }
    }
    return sum;
}
Also used : Symbol(io.crate.expression.symbol.Symbol) ScopedSymbol(io.crate.expression.symbol.ScopedSymbol) Reference(io.crate.metadata.Reference) ScopedSymbol(io.crate.expression.symbol.ScopedSymbol) FixedWidthType(io.crate.types.FixedWidthType)

Aggregations

ScopedSymbol (io.crate.expression.symbol.ScopedSymbol)1 Symbol (io.crate.expression.symbol.Symbol)1 Reference (io.crate.metadata.Reference)1 FixedWidthType (io.crate.types.FixedWidthType)1