C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

sql/modifier.h
1 /* file: modifier.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 #ifndef __DATA_SOURCE_MODIFIERS_SQL_MODIFIER_H__
19 #define __DATA_SOURCE_MODIFIERS_SQL_MODIFIER_H__
20 
21 #include "data_management/data_source/modifiers/modifier.h"
22 
23 namespace daal
24 {
25 namespace data_management
26 {
27 namespace modifiers
28 {
32 namespace sql
33 {
37 namespace interface1
38 {
50 class ConfigIface : public modifiers::ConfigIface { };
51 
57 class Config : public Base, public ConfigIface { };
58 
63 class ContextIface : public modifiers::ContextIface
64 {
65 public:
70  virtual size_t getNumberOfColumns() const = 0;
71 
77  virtual services::BufferView<char> getRawValue(size_t columnIndex) const = 0;
78 };
79 
85 class Context : public Base, public ContextIface
86 {
87 public:
88  template<typename T>
89  T getValue(size_t columnIndex) const
90  {
91  /* Very simple implementation of conversion between C and SQL types.
92  * There is no guarantee that returned value contains valid data if the
93  * type does not match the type of SQL column. For more information see
94  * https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/conve
95  * rting-data-from-sql-to-c-data-types */
96  const services::BufferView<char> rawValue = getRawValue(columnIndex);
97  DAAL_ASSERT( rawValue.size() == sizeof(T) );
98  return *( (const T *)(rawValue.data()) );
99  }
100 };
101 
106 class FeatureModifierIface : public modifiers::FeatureModifierIface<Config, Context> { };
107 typedef services::SharedPtr<FeatureModifierIface> FeatureModifierIfacePtr;
108 
113 class FeatureModifier : public Base, public FeatureModifierIface
114 {
115 public:
120  virtual void initialize(Config &config) DAAL_C11_OVERRIDE { }
121 
126  virtual void finalize(Config &config) DAAL_C11_OVERRIDE { }
127 };
128 typedef services::SharedPtr<FeatureModifier> FeatureModifierPtr;
129 
130 
131 /* Specifications of the Context::getValue method */
132 
133 template<>
134 services::StringView Context::getValue<services::StringView>(size_t columnIndex) const
135 {
136  const services::BufferView<char> buffer = getRawValue(columnIndex);
137  return services::StringView( buffer.data(), buffer.size() );
138 }
139 
140 template<>
141 std::string Context::getValue<std::string>(size_t columnIndex) const
142 {
143  const services::BufferView<char> buffer = getRawValue(columnIndex);
144  return std::string( buffer.data(), buffer.size() );
145 }
146 
147 template<>
148 std::vector<char> Context::getValue<std::vector<char> >(size_t columnIndex) const
149 {
150  const services::BufferView<char> buffer = getRawValue(columnIndex);
151  return std::vector<char>( buffer.data(), buffer.data() + buffer.size() );
152 }
153 
155 } // namespace interface1
156 
157 using interface1::Config;
158 using interface1::Context;
159 using interface1::FeatureModifierIface;
160 using interface1::FeatureModifierIfacePtr;
161 using interface1::FeatureModifier;
162 using interface1::FeatureModifierPtr;
163 
164 } // namespace sql
165 } // namespace modifiers
166 } // namespace data_management
167 } // namespace daal
168 
169 #endif
daal::data_management::modifiers::sql::interface1::FeatureModifier
Base class for feature modifier, intended for inheritance from the user side.
Definition: sql/modifier.h:113
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:41
daal::data_management::modifiers::sql::interface1::FeatureModifier::finalize
virtual void finalize(Config &config) DAAL_C11_OVERRIDE
Definition: sql/modifier.h:126
daal::data_management::modifiers::sql::interface1::FeatureModifierIface
Specialization of modifiers::FeatureModifierIface for SQL feature modifier.
Definition: sql/modifier.h:106
daal::data_management::modifiers::sql::interface1::ContextIface::getRawValue
virtual services::BufferView< char > getRawValue(size_t columnIndex) const =0
Gets the raw buffer retrieved from SQL table.
daal::data_management::modifiers::sql::interface1::Context
Base class that represents modifier context, object of that class is passed to the modifier as an arg...
Definition: sql/modifier.h:85
daal::data_management::modifiers::sql::interface1::ConfigIface
Abstract class that defines interface of modifier configuration.
Definition: sql/modifier.h:50
daal::data_management::modifiers::sql::interface1::Config
Base class that represents modifier configuration, object of that class is passed to the modifier on ...
Definition: sql/modifier.h:57
daal::data_management::modifiers::sql::interface1::FeatureModifier::initialize
virtual void initialize(Config &config) DAAL_C11_OVERRIDE
Definition: sql/modifier.h:120
daal::data_management::modifiers::sql::interface1::ContextIface::getNumberOfColumns
virtual size_t getNumberOfColumns() const =0
daal::data_management::modifiers::sql::interface1::ContextIface
Abstract class that defines interface of modifier context.
Definition: sql/modifier.h:63

For more complete information about compiler optimizations, see our Optimization Notice.