influxdb-cxx icon indicating copy to clipboard operation
influxdb-cxx copied to clipboard

support for uint64_t values for fields

Open pkousha opened this issue 3 years ago • 4 comments

Hi

I am getting errors for supporting uint64_t values insertions into influxDB What is your suggestion to fix this?

test.cpp:122:114: error: cannot convert ‘long long unsigned int’ to ‘const std::variant<int, long long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>&’
  122 |  db->write(influxdb::Point{"pooya"}.addTag("guid","2032489038270972513").addTag("port","5").addField("rcv_data", (unsigned long long int)18446744073709551615).addField("unicast_xmit_pkts",2072512).addField("unicast_rcv_pkts", 2512).addField("multicast_xmit_pkts",55805).addField("multicast_rcv_pkts",29));
      |                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                                                  |
      |                                                                                                                  long long unsigned int
In file included from /usr/local/include/InfluxDB.h:38,
                 from /usr/local/include/InfluxDBFactory.h:31,
                 from test.cpp:32:
/usr/local/include/Point.h:55:106: note:   initializing argument 2 of ‘influxdb::Point&& influxdb::Point::addField(std::string_view, const std::variant<int, long long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>&)’
   55 |     Point&& addField(std::string_view name, const std::variant<int, long long int, std::string, double>& value);
      |                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~

pkousha avatar May 16 '22 15:05 pkousha

addField() doesn't support unsigned types yet. If your values fit into a int64_t you can cast them.

Support for unsigned types is possible to implement though.

offa avatar May 16 '22 16:05 offa

Following up on this. Have you implemented the support for unsigned types?

pkousha avatar Jun 13 '22 15:06 pkousha

Thanks for the ping, I'm quite behind my todos.

According to docs, the only integer type is signed 64-bit. ~~So deprecating the current addField() and adding one with uint64 instead of int and long long int should work – instead of extending the current variant.~~

offa avatar Jun 13 '22 16:06 offa

Thinking further, I'm not sure whether uint64 is a good idea, given uint64 can hold a larger value than the specified int64.

Update: Influxdb 2.x supports uint64: https://docs.influxdata.com/influxdb/cloud/reference/syntax/line-protocol/#uinteger

offa avatar Jun 14 '22 15:06 offa