aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/clickhouse/client/columns/numeric.h
blob: 11a2ddac00772e57bebd857e846d1ce3ea7ced8b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#include "column.h"

namespace NClickHouse {
    /**
 * Represents various numeric columns.
 */
    template <typename T>
    class TColumnVector: public TColumn {
    public:
        static TIntrusivePtr<TColumnVector<T>> Create();
        static TIntrusivePtr<TColumnVector<T>> Create(const TVector<T>& data);
        static TIntrusivePtr<TColumnVector<T>> Create(TVector<T>&& data);

        /// Appends one element to the end of column.
        void Append(const T& value);

        /// Returns element at given row number.
        const T& At(size_t n) const;

        /// Returns element at given row number.
        const T& operator[](size_t n) const;

        /// Set element at given row number.
        void SetAt(size_t n, const T& value);

    public:
        /// Appends content of given column to the end of current one.
        void Append(TColumnRef column) override;

        /// Loads column data from input stream.
        bool Load(TCodedInputStream* input, size_t rows) override;

        /// Saves column data to output stream.
        void Save(TCodedOutputStream* output) override;

        /// Returns count of rows in the column.
        size_t Size() const override;

        /// Makes slice of the current column.
        TColumnRef Slice(size_t begin, size_t len) override;

    private:
        TColumnVector();
        TColumnVector(const TVector<T>& data);
        TColumnVector(TVector<T>&& data);

        TVector<T> Data_;
    };

    using TColumnUInt8 = TColumnVector<ui8>;
    using TColumnUInt16 = TColumnVector<ui16>;
    using TColumnUInt32 = TColumnVector<ui32>;
    using TColumnUInt64 = TColumnVector<ui64>;

    using TColumnInt8 = TColumnVector<i8>;
    using TColumnInt16 = TColumnVector<i16>;
    using TColumnInt32 = TColumnVector<i32>;
    using TColumnInt64 = TColumnVector<i64>;

    using TColumnFloat32 = TColumnVector<float>;
    using TColumnFloat64 = TColumnVector<double>;

}