Skip to content
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

Why we must collect points to use the batch api? #381

Closed
IdanFridman opened this issue Nov 5, 2017 · 2 comments
Closed

Why we must collect points to use the batch api? #381

IdanFridman opened this issue Nov 5, 2017 · 2 comments

Comments

@IdanFridman
Copy link

If I understand right we must aggregate Points in advanced in order to use the batchapi properly.

BatchPoints batchPoints = BatchPoints.database(influxDatabase).build();
for (Point point : points) {
batchPoints.point(point);
}
influxDB.write(batchPoints);

That mean I need to have a 'batching' logic that collect points and then every once in a while I need to use batchPoints.point(point) (the way I used above) to actually submit them.

Cant we just submit single points using batchPoints.point and relay on the batchingapi that every X time will do the insertion to the database?

thanks.

@majst01
Copy link
Collaborator

majst01 commented Nov 5, 2017

Nothing prevents you from doing so, just add a singe Point to the Batchpoints on every write, or am i missing something ?

@fmachado
Copy link
Contributor

fmachado commented Nov 9, 2017

If I understand right we must aggregate Points in advanced in order to use the batchapi properly.

Nope, you are mixing a bit the concepts. I would suggest you to keep things simple and make use of the available batch processor (i.e. don't use the class BatchPoints).

You must follow the same example that you provided 16 days ago here but paying attention to the fact that if you query before the batch processor was executed, you won't receive the last added points.

As explained on that thread, you have two ways to get the most recent data: wait more than 100ms (100ms was the value you passed as parameter) or force a flush by calling influxdb.flush().

If this solves your problem, could you please close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants