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

API Cleanup: A couple ideas

Open velvia opened this issue 11 years ago • 7 comments

Hey guys,

I'm liking InfluxDB so far but the API for this makes me slightly sad.

  • Can we have everything accept Seq[...] instead of Array[...]? Seqs are much more flexible and easier to work with.
  • It's not considered good Scala style to have var's especially in the Client class constructor. You don't really want to allow someone to change the database name in the middle of using the client.
  • I think a much better API than Array[Array[Any]] would be to have WriteSeries take case classes. Scala macros can deduce the fields from the case classes, and this way it is type safe. Using a Array[Any] forces boxing of all numeric values, which is very slow and expensive, and it is not type safe at all.

I might be interested in submitting PRs but wanted to run these things by you guys first.

Also, how about packaging and submitting jars to Maven Central, or at least Bintray (much easier than Maven Central)?

velvia avatar Nov 04 '14 06:11 velvia

+1

mfirry avatar Jan 08 '15 09:01 mfirry

I stopped maintain this library quite a while (...and I can imagine it's not up to date as well), so would be great if you send a pull request.

Regarding your questions: "Seqs are much more flexible and easier to work with." - it's not always true. Arrays gives you random access to data in O(1) time.

"It's not considered good Scala style to have var's especially in the Client class constructor." - If you do not like it, just send pull request. Btw. maybe some people wanted to reuse same client for different requests.

"I think a much better API than Array[Array[Any]] would be to have WriteSeries" - having basic, primitive types, you can do whatever you want. You can write any kind of customization good for you. Any kind of abstraction makes code less readable and my intention was to write something extremely simple and easy to extend/customize for all developers. And as I mentioned before - any pull request can make this simple client better.

kuba-- avatar Mar 04 '15 13:03 kuba--

By the way, most Seq's give you random access in O(1) time as well. You give the API users the choice to use whatever data structure works best for them.

On Wed, Mar 4, 2015 at 5:15 AM, Kuba Podgorski [email protected] wrote:

I stopped maintain this library quite a while (...and I can imagine it's not up to date as well), so would be great if you send a pull request.

Regarding your questions: "Seqs are much more flexible and easier to work with." - it's not always true. Arrays gives you random access to data in O(1) time.

"It's not considered good Scala style to have var's especially in the Client class constructor." - If you do not like it, just send pull request. Btw. maybe some people wanted to reuse same client for different requests.

"I think a much better API than Array[Array[Any]] would be to have WriteSeries" - having basic, primitive types, you can do whatever you want. You can write any kind of customization good for you. Any kind of abstraction makes code less readable and my intention was to write something extremely simple and easy to extend/customize for all developers. And as I mentioned before - any pull request can make this simple client better.

— Reply to this email directly or view it on GitHub https://github.com/influxdb/influxdb-scala/issues/4#issuecomment-77155186 .

The fruit of silence is prayer; the fruit of prayer is faith; the fruit of faith is love; the fruit of love is service; the fruit of service is peace. -- Mother Teresa

velvia avatar Mar 04 '15 18:03 velvia

Arrays worked for me, when I was implementing this client. Btw. I'm curious which Seq gives you access to i-th element in constant time?

kuba-- avatar Mar 04 '15 18:03 kuba--

scala.collection.immutable.IndexedSeq

mfirry avatar Mar 05 '15 10:03 mfirry

"..Indexed sequences support constant-time or near constant-time element access and length computation. T". Moreover "inserting" is not as efficient as in Arrays.

kuba-- avatar Mar 05 '15 10:03 kuba--

You're right. I still do believe Seqs are more "everyday toys" for Scala developers rather than Arrays. Plus scala.Predef provides handy implicit conversions.

Talking about PR, there was in fact a PR a while ago by @fsauer65 but was let go because it was using Scala 2.11.

I'll see if I can send you a PR before the end of this week.

@velvia any chance we can work on this together?

mfirry avatar Mar 05 '15 10:03 mfirry