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

Immutable data structures #353

Open
simerplaha opened this issue Dec 28, 2021 · 0 comments
Open

Immutable data structures #353

simerplaha opened this issue Dec 28, 2021 · 0 comments
Labels

Comments

@simerplaha
Copy link
Owner

simerplaha commented Dec 28, 2021

Support immutable data-structures.

Config

Being less complicated, Immutable data types can very easily be preconfigured to allow high performance in all areas so they should be supported internally.

Stream API

Updating existing data in an immutable data-structure should automatically create different queryable versions.

//example version stream API
map
  .get(key)
  .versions
  .foreach {
    case (key, value, version) => 
       //do something
  }

Creating data-structures API

Following similar API as Scala collections.

//in Scala collections we can create a map as following
val map = mutable.Map.empty[Int, String]

Following above In SwayDB this should be

//mutable
val map = mutable.persistent.Map[Int, String, Nothing, Glass](dir = "my_map")
//or immutable
val map = immutable.persistent.Map[Int, String, Nothing, Glass](dir = "my_map")

In Java this would be

//mutable
Map<Integer, String, Void> map =
  MutablePersistentMap
    .functionsOff(Paths.get("my_map"), intSerializer(), stringSerializer())
    .get();

//or immutable
Map<Integer, String, Void> map =
 ImmutablePersistentMap
    .functionsOff(Paths.get("my_map"), intSerializer(), stringSerializer())
    .get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant