1 #ifndef __GPUDB__GENERICRECORD_HPP__
2 #define __GPUDB__GENERICRECORD_HPP__
6 #include <avro/Schema.hh>
7 #include <avro/Specific.hh>
15 friend struct ::avro::codec_traits<GenericRecord>;
20 const ::avro::ValidSchema&
getSchema()
const;
22 template<
typename T> T&
value(
const size_t index)
24 return *boost::any_cast<T>(&m_values.at(index));
27 template<
typename T>
const T&
value(
const size_t index)
const
29 return *boost::any_cast<T>(&m_values.at(index));
32 template<
typename T> T&
value(
const std::string& name)
34 return *boost::any_cast<T>(&m_values[m_type.
getColumnIndex(name)]);
37 template<
typename T>
const T&
value(
const std::string& name)
const
39 return *boost::any_cast<T>(&m_values[m_type.
getColumnIndex(name)]);
42 std::vector<uint8_t>&
bytesValue(
const size_t index);
43 const std::vector<uint8_t>&
bytesValue(
const size_t index)
const;
44 std::vector<uint8_t>&
bytesValue(
const std::string& name);
45 const std::vector<uint8_t>&
bytesValue(
const std::string& name)
const;
48 const double&
doubleValue(
const size_t index)
const;
50 const double&
doubleValue(
const std::string& name)
const;
53 const float&
floatValue(
const size_t index)
const;
55 const float&
floatValue(
const std::string& name)
const;
57 int32_t&
intValue(
const size_t index);
58 const int32_t&
intValue(
const size_t index)
const;
59 int32_t&
intValue(
const std::string& name);
60 const int32_t&
intValue(
const std::string& name)
const;
63 const int64_t&
longValue(
const size_t index)
const;
64 int64_t&
longValue(
const std::string& name);
65 const int64_t&
longValue(
const std::string& name)
const;
68 const std::string&
stringValue(
const size_t index)
const;
70 const std::string&
stringValue(
const std::string& name)
const;
73 const boost::optional<std::vector<uint8_t> >&
nullableBytesValue(
const size_t index)
const;
75 const boost::optional<std::vector<uint8_t> >&
nullableBytesValue(
const std::string& name)
const;
90 const boost::optional<int32_t>&
nullableIntValue(
const std::string& name)
const;
102 bool isNull(
const size_t index)
const;
103 bool isNull(
const std::string& name)
const;
105 void getAsBytes(
const size_t index, std::vector<uint8_t>& result)
const;
106 void getAsBytes(
const std::string& name, std::vector<uint8_t>& result)
const;
107 std::vector<uint8_t>
getAsBytes(
const size_t index)
const;
108 std::vector<uint8_t>
getAsBytes(
const std::string& name)
const;
110 void getAsDouble(
const size_t index,
double& result)
const;
111 void getAsDouble(
const std::string& name,
double& result)
const;
115 void getAsFloat(
const size_t index,
float& result)
const;
116 void getAsFloat(
const std::string& name,
float& result)
const;
118 float getAsFloat(
const std::string& name)
const;
120 void getAsInt(
const size_t index, int32_t& result)
const;
121 void getAsInt(
const std::string& name, int32_t& result)
const;
122 int32_t
getAsInt(
const size_t index)
const;
123 int32_t
getAsInt(
const std::string& name)
const;
125 void getAsLong(
const size_t index, int64_t& result)
const;
126 void getAsLong(
const std::string& name, int64_t& result)
const;
127 int64_t
getAsLong(
const size_t index)
const;
128 int64_t
getAsLong(
const std::string& name)
const;
130 void getAsString(
const size_t index, std::string& result)
const;
131 void getAsString(
const std::string& name, std::string& result)
const;
133 std::string
getAsString(
const std::string& name)
const;
135 void getAsNullableBytes(
const size_t index, boost::optional<std::vector<uint8_t> >& result)
const;
136 void getAsNullableBytes(
const std::string& name, boost::optional<std::vector<uint8_t> >& result)
const;
138 boost::optional<std::vector<uint8_t> >
getAsNullableBytes(
const std::string& name)
const;
146 void getAsNullableFloat(
const std::string& name, boost::optional<float>& result)
const;
150 void getAsNullableInt(
const size_t index, boost::optional<int32_t>& result)
const;
151 void getAsNullableInt(
const std::string& name, boost::optional<int32_t>& result)
const;
155 void getAsNullableLong(
const size_t index, boost::optional<int64_t>& result)
const;
156 void getAsNullableLong(
const std::string& name, boost::optional<int64_t>& result)
const;
161 void getAsNullableString(
const std::string& name, boost::optional<std::string>& result)
const;
165 void setNull(
const size_t index);
166 void setNull(
const std::string& name);
168 void setAsBytes(
const size_t index,
const std::vector<uint8_t>& newValue);
169 void setAsBytes(
const std::string& name,
const std::vector<uint8_t>& newValue);
171 void setAsDouble(
const size_t index,
const double& newValue);
172 void setAsDouble(
const std::string& name,
const double& newValue);
174 void setAsFloat(
const size_t index,
const float& newValue);
175 void setAsFloat(
const std::string& name,
const float& newValue);
177 void setAsInt(
const size_t index,
const int32_t& newValue);
178 void setAsInt(
const std::string& name,
const int32_t& newValue);
180 void setAsLong(
const size_t index,
const int64_t& newValue);
181 void setAsLong(
const std::string& name,
const int64_t& newValue);
183 void setAsString(
const size_t index,
const std::string& newValue);
184 void setAsString(
const std::string& name,
const std::string& newValue);
186 void setAsNullableBytes(
const size_t index,
const boost::optional<std::vector<uint8_t> >& newValue);
187 void setAsNullableBytes(
const std::string& name,
const boost::optional<std::vector<uint8_t> >& newValue);
190 void setAsNullableDouble(
const std::string& name,
const boost::optional<double>& newValue);
193 void setAsNullableFloat(
const std::string& name,
const boost::optional<float>& newValue);
195 void setAsNullableInt(
const size_t index,
const boost::optional<int32_t>& newValue);
196 void setAsNullableInt(
const std::string& name,
const boost::optional<int32_t>& newValue);
198 void setAsNullableLong(
const size_t index,
const boost::optional<int64_t>& newValue);
199 void setAsNullableLong(
const std::string& name,
const boost::optional<int64_t>& newValue);
201 void setAsNullableString(
const size_t index,
const boost::optional<std::string>& newValue);
202 void setAsNullableString(
const std::string& name,
const boost::optional<std::string>& newValue);
204 void toString(
const size_t index, std::string& result)
const;
205 void toString(
const std::string& name, std::string& result)
const;
206 std::string
toString(
const size_t index)
const;
207 std::string
toString(
const std::string& name)
const;
210 static void transpose(
const std::string& schemaString,
const std::vector<uint8_t>& encodedData, std::vector<GenericRecord>& data);
213 std::vector<boost::any> m_values;
215 GenericRecord(
const std::vector<std::pair<Type::Column::ColumnType, bool> >& columnTypes);
224 template<>
struct codec_traits<gpudb::GenericRecord>
void setAsBytes(const size_t index, const std::vector< uint8_t > &newValue)
void setAsFloat(const size_t index, const float &newValue)
void setAsNullableFloat(const size_t index, const boost::optional< float > &newValue)
GenericRecord(const Type &type)
T & value(const size_t index)
void getAsNullableLong(const size_t index, boost::optional< int64_t > &result) const
boost::optional< double > & nullableDoubleValue(const size_t index)
void toString(const size_t index, std::string &result) const
int32_t & intValue(const size_t index)
boost::optional< int32_t > & nullableIntValue(const size_t index)
void setAsDouble(const size_t index, const double &newValue)
const T & value(const size_t index) const
size_t getColumnIndex(const std::string &name) const
GenericRecord DynamicTableRecord
bool isNull(const size_t index) const
void setAsNullableLong(const size_t index, const boost::optional< int64_t > &newValue)
void getAsNullableInt(const size_t index, boost::optional< int32_t > &result) const
std::string & stringValue(const size_t index)
void getAsLong(const size_t index, int64_t &result) const
void getAsNullableFloat(const size_t index, boost::optional< float > &result) const
void setAsNullableInt(const size_t index, const boost::optional< int32_t > &newValue)
void setAsNullableDouble(const size_t index, const boost::optional< double > &newValue)
void setAsString(const size_t index, const std::string &newValue)
boost::optional< int64_t > & nullableLongValue(const size_t index)
void getAsNullableString(const size_t index, boost::optional< std::string > &result) const
boost::optional< float > & nullableFloatValue(const size_t index)
float & floatValue(const size_t index)
int64_t & longValue(const size_t index)
void getAsNullableDouble(const size_t index, boost::optional< double > &result) const
void getAsBytes(const size_t index, std::vector< uint8_t > &result) const
void getAsFloat(const size_t index, float &result) const
const Type & getType() const
void setAsLong(const size_t index, const int64_t &newValue)
const T & value(const std::string &name) const
double & doubleValue(const size_t index)
void getAsInt(const size_t index, int32_t &result) const
void setAsNullableBytes(const size_t index, const boost::optional< std::vector< uint8_t > > &newValue)
boost::optional< std::string > & nullableStringValue(const size_t index)
void setNull(const size_t index)
void getAsNullableBytes(const size_t index, boost::optional< std::vector< uint8_t > > &result) const
const ::avro::ValidSchema & getSchema() const
T & value(const std::string &name)
boost::optional< std::vector< uint8_t > > & nullableBytesValue(const size_t index)
void getAsString(const size_t index, std::string &result) const
void setAsNullableString(const size_t index, const boost::optional< std::string > &newValue)
void getAsDouble(const size_t index, double &result) const
void setAsInt(const size_t index, const int32_t &newValue)
std::vector< uint8_t > & bytesValue(const size_t index)