InfluxCommunity / influxdb3-go

The go package that provides a simple and convenient way to interact with InfluxDB 3.
https://pkg.go.dev/github.com/InfluxCommunity/influxdb3-go
MIT License
21 stars 11 forks source link

QueryIterator: wrapper for underlying ipc.Reader.Read() #64

Open karel-rehor opened 4 months ago

karel-rehor commented 4 months ago

Use Case

Comparing the iterator with Java iterators I was bothered that there is now HasNext() method to peek as to whether it contained an empty result. This lead to inspecting the underlying ipc.Reader which has a Read() method returning rec, err and error can be EOF. It would be nice if QueryIterator simply wrapped this method in its own Read() method, without having to go directly to Raw().

Expected behavior

Would like to be able to detect empty response from the iterator before attempting iteration. For example in Java an iterator has a HasNext() method.

Actual behavior

Without using Raw(), currently just start with iterator.Next() without peeking first to see that the iterator response has any next record to get.

Using Raw().Read() returns rec, err and the err can be EOF which kind of provides the desired check. It would be nicer though to have Read()(record, err) as a direct Method of QueryIterator.

Additional info

No response