API Cleanup: A couple ideas
Opened this issue · 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 ofArray[...]
? 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 aArray[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)?
+1
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.
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 notifications@github.com
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
#4 (comment)
.
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
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?
scala.collection.immutable.IndexedSeq
"..Indexed sequences support constant-time or near constant-time element access and length computation. T". Moreover "inserting" is not as efficient as in Arrays.
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?