aboutsummaryrefslogtreecommitdiff
path: root/contrib/native/client/src/include/drill/fieldmeta.hpp
blob: 40c9cca9b2a2574f95f5af820d577e410aec9eaa (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FIELDMETA_H
#define FIELDMETA_H

#include "drill/common.hpp"
#include "drill/protobuf/Types.pb.h"

namespace exec{
    namespace shared{
        class SerializedField;
    };
    namespace user{
        class ResultColumnMetadata;
    };
};


namespace Drill {

class DECLSPEC_DRILL_CLIENT FieldMetadata{
    public:
        enum ColumnSearchability { UNKNOWN_SEARCHABILITY = 0, NONE = 1, CHAR = 2, NUMBER = 3, ALL = 4 };
        enum ColumnUpdatability { UNKNOWN_UPDATABILITY = 0, READ_ONLY = 1, WRITABLE = 2 };

        FieldMetadata(){};
        void set(const exec::shared::SerializedField& f);
        void set(const exec::user::ResultColumnMetadata& m);
        const std::string& getName() const{ return m_name;}
        common::MinorType getMinorType() const{ return m_minorType;}
        common::DataMode getDataMode() const{return m_dataMode;}
        uint32_t getValueCount() const{return m_valueCount;}
        uint32_t getScale() const{return m_scale;}
        uint32_t getPrecision() const{return m_precision;}
        uint32_t getBufferLength() const{return m_bufferLength;}
        const std::string& getCatalogName() const{return m_catalogName;}
        const std::string& getSchemaName() const{return m_schemaName;}
        const std::string& getTableName() const{return m_tableName;}
        const std::string& getLabel() const{return m_label;}
        const std::string& getSQLType() const{return m_sqlType;}
        bool isNullable() const{return m_nullable;}
        bool isSigned() const{return m_signed;}
        uint32_t getDisplaySize() const{return m_displaySize;}
        bool isAliased() const{return m_aliased;}
        ColumnSearchability getSearchability() const{return m_searchability;}
        ColumnUpdatability getUpdatability() const{return m_updatability;}
        bool isAutoIncremented() const{return m_autoIncremented;}
        bool isCaseSensitive() const{return m_caseSensitive;}
        bool isSortable() const{return m_sortable;}
        bool isCurrency() const{return m_currency;}
        void copy(Drill::FieldMetadata& f){
            m_name=f.m_name;
            m_minorType=f.m_minorType;
            m_dataMode=f.m_dataMode;
            m_valueCount=f.m_valueCount;
            m_scale=f.m_scale;
            m_precision=f.m_precision;
            m_bufferLength=f.m_bufferLength;
            m_catalogName=f.m_catalogName;
            m_schemaName=f.m_schemaName;
            m_tableName=f.m_tableName;
            m_label=f.m_label;
            m_sqlType=f.m_sqlType;
            m_nullable=f.m_nullable;
            m_signed=f.m_signed;
            m_displaySize=f.m_displaySize;
            m_aliased=f.m_aliased;
            m_searchability=f.m_searchability;
            m_updatability=f.m_updatability;
            m_autoIncremented=f.m_autoIncremented;
            m_caseSensitive=f.m_caseSensitive;
            m_sortable=f.m_sortable;
            m_currency=f.m_currency;
            m_columnSize=f.m_columnSize;
        }

    private:
        std::string m_name;
        common::MinorType m_minorType;
        common::DataMode m_dataMode;
        uint32_t m_valueCount;
        uint32_t m_scale;
        uint32_t m_precision;
        uint32_t m_bufferLength;
        std::string m_catalogName;
        std::string m_schemaName;
        std::string m_tableName;
        std::string m_label;
        std::string m_sqlType;
        bool m_nullable;
        bool m_signed;
        uint32_t m_displaySize;
        bool m_aliased;
        ColumnSearchability m_searchability;
        ColumnUpdatability m_updatability;
        bool m_autoIncremented;
        bool m_caseSensitive;
        bool m_sortable;
        bool m_currency;
        uint32_t m_columnSize;

};
} // namespace

#endif