1 #ifndef __GPUDB__GENERICRECORD_HPP__ 2 #define __GPUDB__GENERICRECORD_HPP__ 6 #include <avro/Schema.hh> 7 #include <avro/Specific.hh> 18 friend struct ::avro::codec_traits<GenericRecord>;
23 const ::avro::ValidSchema&
getSchema()
const;
25 template<
typename T> T&
value(
const size_t index)
27 return *boost::any_cast<T>(&m_values.at(index));
30 template<
typename T>
const T&
value(
const size_t index)
const 32 return *boost::any_cast<T>(&m_values.at(index));
35 template<
typename T> T&
value(
const std::string& name)
37 return *boost::any_cast<T>(&m_values[m_type.
getColumnIndex(name)]);
40 template<
typename T>
const T&
value(
const std::string& name)
const 42 return *boost::any_cast<T>(&m_values[m_type.
getColumnIndex(name)]);
45 std::vector<uint8_t>&
bytesValue(
const size_t index);
46 const std::vector<uint8_t>&
bytesValue(
const size_t index)
const;
47 std::vector<uint8_t>&
bytesValue(
const std::string& name);
48 const std::vector<uint8_t>&
bytesValue(
const std::string& name)
const;
51 const double&
doubleValue(
const size_t index)
const;
53 const double&
doubleValue(
const std::string& name)
const;
56 const float&
floatValue(
const size_t index)
const;
58 const float&
floatValue(
const std::string& name)
const;
60 int32_t&
intValue(
const size_t index);
61 const int32_t&
intValue(
const size_t index)
const;
62 int32_t&
intValue(
const std::string& name);
63 const int32_t&
intValue(
const std::string& name)
const;
66 const int64_t&
longValue(
const size_t index)
const;
67 int64_t&
longValue(
const std::string& name);
68 const int64_t&
longValue(
const std::string& name)
const;
71 const std::string&
stringValue(
const size_t index)
const;
73 const std::string&
stringValue(
const std::string& name)
const;
76 const boost::optional<std::vector<uint8_t> >&
nullableBytesValue(
const size_t index)
const;
78 const boost::optional<std::vector<uint8_t> >&
nullableBytesValue(
const std::string& name)
const;
93 const boost::optional<int32_t>&
nullableIntValue(
const std::string& name)
const;
105 bool isNull(
const size_t index)
const;
106 bool isNull(
const std::string& name)
const;
108 void getAsBytes(
const size_t index, std::vector<uint8_t>& result)
const;
109 void getAsBytes(
const std::string& name, std::vector<uint8_t>& result)
const;
110 std::vector<uint8_t>
getAsBytes(
const size_t index)
const;
111 std::vector<uint8_t>
getAsBytes(
const std::string& name)
const;
113 void getAsDouble(
const size_t index,
double& result)
const;
114 void getAsDouble(
const std::string& name,
double& result)
const;
118 void getAsFloat(
const size_t index,
float& result)
const;
119 void getAsFloat(
const std::string& name,
float& result)
const;
121 float getAsFloat(
const std::string& name)
const;
123 void getAsInt(
const size_t index, int32_t& result)
const;
124 void getAsInt(
const std::string& name, int32_t& result)
const;
125 int32_t
getAsInt(
const size_t index)
const;
126 int32_t
getAsInt(
const std::string& name)
const;
128 void getAsLong(
const size_t index, int64_t& result)
const;
129 void getAsLong(
const std::string& name, int64_t& result)
const;
130 int64_t
getAsLong(
const size_t index)
const;
131 int64_t
getAsLong(
const std::string& name)
const;
133 void getAsString(
const size_t index, std::string& result)
const;
134 void getAsString(
const std::string& name, std::string& result)
const;
136 std::string
getAsString(
const std::string& name)
const;
138 void getAsNullableBytes(
const size_t index, boost::optional<std::vector<uint8_t> >& result)
const;
139 void getAsNullableBytes(
const std::string& name, boost::optional<std::vector<uint8_t> >& result)
const;
141 boost::optional<std::vector<uint8_t> >
getAsNullableBytes(
const std::string& name)
const;
149 void getAsNullableFloat(
const std::string& name, boost::optional<float>& result)
const;
153 void getAsNullableInt(
const size_t index, boost::optional<int32_t>& result)
const;
154 void getAsNullableInt(
const std::string& name, boost::optional<int32_t>& result)
const;
158 void getAsNullableLong(
const size_t index, boost::optional<int64_t>& result)
const;
159 void getAsNullableLong(
const std::string& name, boost::optional<int64_t>& result)
const;
164 void getAsNullableString(
const std::string& name, boost::optional<std::string>& result)
const;
168 void setNull(
const size_t index);
169 void setNull(
const std::string& name);
171 void setAsBytes(
const size_t index,
const std::vector<uint8_t>& newValue);
172 void setAsBytes(
const std::string& name,
const std::vector<uint8_t>& newValue);
174 void setAsDouble(
const size_t index,
const double& newValue);
175 void setAsDouble(
const std::string& name,
const double& newValue);
177 void setAsFloat(
const size_t index,
const float& newValue);
178 void setAsFloat(
const std::string& name,
const float& newValue);
180 void setAsInt(
const size_t index,
const int32_t& newValue);
181 void setAsInt(
const std::string& name,
const int32_t& newValue);
183 void setAsLong(
const size_t index,
const int64_t& newValue);
184 void setAsLong(
const std::string& name,
const int64_t& newValue);
186 void setAsString(
const size_t index,
const std::string& newValue);
187 void setAsString(
const std::string& name,
const std::string& newValue);
189 void setAsNullableBytes(
const size_t index,
const boost::optional<std::vector<uint8_t> >& newValue);
190 void setAsNullableBytes(
const std::string& name,
const boost::optional<std::vector<uint8_t> >& newValue);
193 void setAsNullableDouble(
const std::string& name,
const boost::optional<double>& newValue);
196 void setAsNullableFloat(
const std::string& name,
const boost::optional<float>& newValue);
198 void setAsNullableInt(
const size_t index,
const boost::optional<int32_t>& newValue);
199 void setAsNullableInt(
const std::string& name,
const boost::optional<int32_t>& newValue);
201 void setAsNullableLong(
const size_t index,
const boost::optional<int64_t>& newValue);
202 void setAsNullableLong(
const std::string& name,
const boost::optional<int64_t>& newValue);
204 void setAsNullableString(
const size_t index,
const boost::optional<std::string>& newValue);
205 void setAsNullableString(
const std::string& name,
const boost::optional<std::string>& newValue);
207 void toString(
const size_t index, std::string& result)
const;
208 void toString(
const std::string& name, std::string& result)
const;
209 std::string
toString(
const size_t index)
const;
210 std::string
toString(
const std::string& name)
const;
216 static void transpose(
const std::string& schemaString,
const std::vector<uint8_t>& encodedData, std::vector<GenericRecord>& data, gpudb_type_ptr_t &dataTypePtr );
219 std::vector<boost::any> m_values;
221 GenericRecord(
const std::vector<std::pair<Type::Column::ColumnType, bool> >& columnTypes);
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)
boost::shared_ptr< Type > gpudb_type_ptr_t
const Type & getType() const
boost::optional< double > & nullableDoubleValue(const size_t index)
void getAsBytes(const size_t index, std::vector< uint8_t > &result) const
const T & value(const std::string &name) const
bool isNull(const size_t index) const
void getAsNullableFloat(const size_t index, boost::optional< float > &result) const
int32_t & intValue(const size_t index)
void getAsNullableInt(const size_t index, boost::optional< int32_t > &result) const
boost::optional< int32_t > & nullableIntValue(const size_t index)
void setAsDouble(const size_t index, const double &newValue)
GenericRecord DynamicTableRecord
void setAsNullableLong(const size_t index, const boost::optional< int64_t > &newValue)
std::string & stringValue(const size_t index)
void getAsNullableBytes(const size_t index, boost::optional< std::vector< uint8_t > > &result) const
void getAsString(const size_t index, std::string &result) const
void setAsNullableInt(const size_t index, const boost::optional< int32_t > &newValue)
void getAsDouble(const size_t index, double &result) const
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 getAsFloat(const size_t index, float &result) const
void getAsLong(const size_t index, int64_t &result) const
void getAsInt(const size_t index, int32_t &result) const
boost::optional< float > & nullableFloatValue(const size_t index)
void getAsNullableString(const size_t index, boost::optional< std::string > &result) const
float & floatValue(const size_t index)
int64_t & longValue(const size_t index)
friend std::ostream & operator<<(std::ostream &os, GenericRecord &gr)
void setAsLong(const size_t index, const int64_t &newValue)
size_t getColumnIndex(const std::string &name) const
void getAsNullableDouble(const size_t index, boost::optional< double > &result) const
double & doubleValue(const size_t index)
const ::avro::ValidSchema & getSchema() 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 toString(const size_t index, std::string &result) const
T & value(const std::string &name)
void getAsNullableLong(const size_t index, boost::optional< int64_t > &result) const
boost::optional< std::vector< uint8_t > > & nullableBytesValue(const size_t index)
const T & value(const size_t index) const
void setAsNullableString(const size_t index, const boost::optional< std::string > &newValue)
void setAsInt(const size_t index, const int32_t &newValue)
std::vector< uint8_t > & bytesValue(const size_t index)