Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/usethesource/capsule

The Capsule Hash Trie Collections Library
https://github.com/usethesource/capsule

hashmap hashset immutable immutable-collections java performance persistent-data-structure trie

Last synced: about 2 months ago
JSON representation

The Capsule Hash Trie Collections Library

Awesome Lists containing this project

README

        

# The Capsule Hash Trie Collections Library

## Status

![capsule build status](https://github.com/usethesource/capsule/actions/workflows/build.yaml/badge.svg)

## Synopsis

Capsule aims to become a full-fledged (immutable) collections library for Java 11+ that is solely built around persistent tries. The library is designed for standalone use and for being embedded in domain-specific languages. Capsule still has to undergo some incubation before it can ship as a well-rounded collection library. Nevertheless, the code is stable and performance is solid. Feel free to use it and let us know about your experiences!

# Getting Started

Binary builds of Capsule are deployed in the usethesource repository. In case you use Maven for dependency management, you have to add another repository location to your pom.xml file:

```


usethesource
https://releases.usethesource.io/maven/

```

Furthermore, you have to declare Capsule as a dependency.

To obtain the latest release for Java 11+, insert the following snippet in your `pom.xml` file:

```

io.usethesource
capsule
0.7.1

```

To obtain the latest available version for Java 8, insert the following snippet in your `pom.xml` file:

```

io.usethesource
capsule
0.6.4

```

Snippets for other build tools and dependency management systems may vary slightly.

## Exploring Capsule

Build the library and spawn a Java shell to interactively explore Capsule, e.g.:

```shell
$ ./gradlew clean build
$ jshell --class-path ./build/libs/capsule-*-SNAPSHOT.jar

| Welcome to JShell
| For an introduction type: /help intro

jshell> var set = io.usethesource.capsule.Set.Immutable.of(1, 2);
set ==> {1, 2}
```

# Background: Efficient Immutable Data Structures on the JVM
The standard libraries of recent Java Virtual Machine languages, such as Clojure or Scala, contain scalable and well-performing immutable collection data structures that are implemented as Hash-Array Mapped Tries (HAMTs). HAMTs already feature efficient lookup, insert, and delete operations, however due to their tree-based nature their memory footprints and the runtime performance of iteration and equality checking lag behind array-based counterparts.

We introduce CHAMP (Compressed Hash-Array Mapped Prefix-tree), an evolutionary improvement over HAMTs. The new design increases the overall performance of immutable sets and maps. Furthermore, its resulting general purpose design increases cache locality and features a canonical representation.

# References and Further Readings

## Talks
* [JVM Language Summit 2016 - Efficient and Expressive Immutable Collections (Speaker: Michael Steindorfer)](https://www.youtube.com/watch?v=pUXeNAeyY34)
* [JVM Language Summit 2017 - Lightweight Relations (Speaker: Michael Steindorfer)](https://www.youtube.com/watch?v=D8Y294vHdqI)
* [Clojure/west 2016 - Hash Maps: More Room on the Bottom (Speaker: Peter Schuck)](https://www.youtube.com/watch?v=GibNOQVelFY)

## Publications
* [PhD Thesis: Efficient Immutable Collections (2017)](https://michael.steindorfer.name/publications/phd-thesis-efficient-immutable-collections)
* [Paper: Optimizing Hash-Array Mapped Tries for Fast and Lean Immutable JVM Collections (OOPSLA 2015)](https://michael.steindorfer.name/publications/oopsla15.pdf)
* [Paper: To-Many or To-One? All-in-One! Efficient Purely Functional Multi-maps with Type-Heterogeneous Hash-Tries (PLDI 2018)](https://michael.steindorfer.name/publications/pldi18.pdf)
* [Paper: Towards a Software Product Line of Trie-Based Collections (Short Paper, GPCE 2016)](https://michael.steindorfer.name/publications/gpce16.pdf)
* [Paper: Code Specialization for Memory Efficient Hash Tries (Short Paper, GPCE 2014)](https://michael.steindorfer.name/publications/gpce14.pdf)