-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to insert batch data of array #47
Comments
influxdb_cpp::builder()
.meas("foo") // series 1
.field("x", 10)
.meas("bar") // series 2
.field("y", 10.3)
.send_udp("127.0.0.1", 8091); |
This answer does not answer my question which is the same as above. std::vector<double> values = {1,2,3,4,5};
auto builder = influxdb_cpp::builder();
for (double value: values) {
builder = builder.meas("foo").field("x", value);
}
builder.send_udp("127.0.0.1", 8091); This is what I can not do right now. |
I think I found a solution. auto influx_builder = influxdb_cpp::builder();
int point_idx = 0;
for (double value: values) {
if (0 == point_idx) {
influx_builder
.meas("means")
.tag("tag", "t")
.field("value", value)
.timestamp(time.time_since_epoch().count());
} else {
reinterpret_cast<influxdb_cpp::detail::ts_caller&>(influx_builder)
.meas("means")
.tag("tag", "t")
.field("value", value)
.timestamp(time.time_since_epoch().count());
}
point_idx ++;
}
reinterpret_cast<influxdb_cpp::detail::ts_caller&>(influx_builder)
.post_http(db_server_info_); This trick worked for me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
x = [1,2,3,4,5]
y = [1,2,3,4,5]
how to insert batch data once instead of insert five times?
The text was updated successfully, but these errors were encountered: