aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/clickhouse/client/columns/date.h
blob: 003d3a0707e0e74b013f00e627418159004167fc (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once

#include "numeric.h"

#include <util/datetime/base.h>

namespace NClickHouse {
    /** */
    class TColumnDate: public TColumn {
    public:
        static TIntrusivePtr<TColumnDate> Create();
        static TIntrusivePtr<TColumnDate> Create(const TVector<TInstant>& data);

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

        /// Returns element at given row number.
        std::time_t At(size_t n) const;

        /// Set element at given row number.
        void SetAt(size_t n, const TInstant& 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:
        TColumnDate();
        TColumnDate(const TVector<TInstant>& data);

        TIntrusivePtr<TColumnUInt16> Data_;
    };

    /** */
    class TColumnDateTime: public TColumn {
    public:
        static TIntrusivePtr<TColumnDateTime> Create();
        static TIntrusivePtr<TColumnDateTime> Create(const TVector<TInstant>& data);

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

        /// Returns element at given row number.
        std::time_t At(size_t n) const;

        /// Set element at given row number.
        void SetAt(size_t n, const TInstant& 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:
        TColumnDateTime();
        TColumnDateTime(const TVector<TInstant>& data);

        TIntrusivePtr<TColumnUInt32> Data_;
    };

}