influxdb-client-csharp icon indicating copy to clipboard operation
influxdb-client-csharp copied to clipboard

feat: Use IEnumerable in WriteApi to eliminate unnecessary memory all…

Open birdalicious opened this issue 1 year ago • 4 comments
trafficstars

Proposed Changes

Change WriteApi to use IEnumerable for collection arguments instead of List. Change WriteRecords(List<string> records) to WriteRecords(IEnumerable<string> records)

Calling ToList on a collection will incur a memory allocation as the data is copied to the new list. Making the argument IEnumerable means ToList doesn't need to be called and so no extra memory allocation. Internally this will eliminate the unnecessary memory allocation in WriteRecords(string[] record) call to ToList, and client code also won't have to make the allocation if their data isn't already in a List## Checklist

Checklist

  • [x] CHANGELOG.md updated
  • [x] Rebased/mergeable
  • [x] A test has been added if appropriate
  • [ ] dotnet test completes successfully
  • [x] Commit messages are conventional
  • [x] Sign CLA (if not already signed)

birdalicious avatar Feb 15 '24 13:02 birdalicious

Sorry for the long delay in updating this PR. I've attempted to run the test suit but most the tests fail on The request was canceled due to the configured HttpClient.Timeout of 10 seconds elapsing. or similar error messages. I've checked the master branch also does this for me. Is there something I'm missing, I've ran the influx-restart.sh script and have the containers running.

birdalicious avatar Feb 15 '24 14:02 birdalicious

Can you check that the InfluxDB 2 is running on the port 9999 by: curl -i -X GET 'http://localhost:9999/health' ?

bednar avatar Feb 19 '24 15:02 bednar

It is running and the server replies, all three are up and replying image

birdalicious avatar Feb 20 '24 08:02 birdalicious

@bednar fixed the code formatting

birdalicious avatar Aug 16 '24 08:08 birdalicious