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

LevelDB support #258

Merged
merged 32 commits into from
May 22, 2015
Merged

LevelDB support #258

merged 32 commits into from
May 22, 2015

Conversation

BenFradet
Copy link
Contributor

As per #51, this is the first draft for supporting LevelDB inside storehaus, feedback is more than welcome.

I'm planning on doing multiGet and multiPut in the coming week.

I intend to do the same thing with RocksDB once I'm done here.

* store fails to return a value for a given key, that should be represented
* by a Future.exception.
*/
override def multiGet[K1 <: Array[Byte]](ks: Set[K1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is defined in the parent class so not needed here right? Likewise for multiPut and close(time: Time)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, please disregard. Just saw your PR comment about implementing this.

@rubanm
Copy link
Contributor

rubanm commented Mar 19, 2015

@BenFradet Thanks for the PR. Mostly minor comments on this version.

@BenFradet
Copy link
Contributor Author

Thanks a lot for your feedback, will take it into account.

@BenFradet
Copy link
Contributor Author

All unit tests for the module are passing.

* @author Ben Fradet
* @since 10/03/15
*/
class LevelDBStore(val dir: File, val options: Options, val numThreads: Int)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numThreads can be defaulted to Runtime.getRuntime.availableProcessors perhaps. Some of the other store wrappers that use future pool do this.

class LevelDBStore(val dir: File, val options: Options, val numThreads: Int)
extends Store[Array[Byte], Array[Byte]] {

private lazy val db = factory.open(dir, options)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this thread-safe? Can you link to docs showing this? If not, we should use:
https://github.com/twitter/util/blob/master/util-core/src/main/scala/com/twitter/concurrent/AsyncMutex.scala

Then we'd do something like:

dbMutex.acquireAndRun(futurePool {
  // method logic here.
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look into it and post my findings.

@BenFradet
Copy link
Contributor Author

Thanks for the feedback, will take it into account.

// http://stackoverflow.com/questions/19425613/unsatisfiedlinkerror-with-native-library-under-sbt
testOptions in Test := Seq(),
fork in Test := true
).dependsOn(storehausAlgebra % "test->test;compile->compile")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be just storehausCore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I think that's what I meant to do when I did this.

@rubanm
Copy link
Contributor

rubanm commented Apr 30, 2015

LGTM! @johnynek / @ianoc could one of you take another look and merge if all good?

@BenFradet
Copy link
Contributor Author

I haven't looked into whether

private lazy val db = factory.open(dir, options)

was thread-safe or not yet.

@BenFradet
Copy link
Contributor Author

Indeed, it's not thread-safe (cf the code), I'll follow @johnynek's advice and use a mutex.

@BenFradet
Copy link
Contributor Author

My bad, it seems to be thread-safe after all (cf this).

* It is undefined what happens on get/multiGet after close
*/
override def close(time: Time): Future[Unit] = {
futurePool { db.close() }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be: futurePool { db.close() }.flatMap { _ => super.close(time) }

@johnynek
Copy link
Collaborator

one minor issue, and remerge with develop and it should be good. Thanks.

@BenFradet
Copy link
Contributor Author

Will do.

@BenFradet
Copy link
Contributor Author

Travis fails due to an ElasticSearch test.

@rubanm
Copy link
Contributor

rubanm commented May 18, 2015

Restarted the build.

@BenFradet
Copy link
Contributor Author

I'll merge develop in order to take advantage of #267 soon.

@rubanm
Copy link
Contributor

rubanm commented May 21, 2015

@BenFradet Sorry, looks like we missed this one for the ongoing minor version release. Yes let's merge once this is green and we can add it to the next release.

@BenFradet
Copy link
Contributor Author

@rubanm yup, no problem. Hopefully, it'll turn green this time.

@rubanm
Copy link
Contributor

rubanm commented May 22, 2015

Merging, thanks!

rubanm added a commit that referenced this pull request May 22, 2015
@rubanm rubanm merged commit adca6a5 into twitter:develop May 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants