• Stars
    star
    116
  • Rank 303,894 (Top 6 %)
  • Language
    Java
  • Created over 9 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

File-backed append-only object store.

java-dirty

Build Status

A fast file-based append-only object store, using memory mapped files.

Is java-dirty safe to use with multiple concurrent writers?

Absolutely not - but it's fast enough that putting it behind e.g. a Disruptor and consuming writes in a single thread should be fine.

Downloading from Maven

<dependency>
  <groupId>uk.co.probablyfine</groupId>
  <artifactId>java-dirty</artifactId>
  <version>1.6</version>
</dependency>

Usage

Creating a store.

Store<Foo> store = Store.of(Foo.class).from("/path/to/file");

Inserting an object

store.put(new Foo(1,2));

Iterating over all objects in the store

store.all().forEach(System.out::println);

Iterate over objects, most recent first

store.reverse().forEach(System.out::println);

Iterate over objects from a starting index

store.from(100).forEach(System.out::println);

Access an index directly

Optional<Foo> foo = store.get(1234);

Reset the entire store

store.reset(); // Reset position to 0, overwriting old entries

Close the store and its backing file

store.close();

Trying to read from/write to a closed store will throw a ClosedStoreException.

Observe each write

store.observeWrites((object, index) ->
  System.out.println("Stored "+object+" at "+index);
);

java-dirty does not support replacements, or deletions. Both .all() and .reverse() expose a Stream.

Examples

Look up most recent version of an object by index

Optional<StoredObject> first = store
    .reverse()
    .filter(x -> x.indexField == valueToFind)
    .findFirst();

Build an lookup index using write observers

Store<StoredObject> store = Store.of(StoredObject.class).from("/some/path");

Map<Integer, Integer> index = new HashMap<>();

store.observeWrites((object, location) -> {
  index.put(object.indexField, location);
});

store.put(new StoredObject(1234,5));

store.get(index.get(1234)); // Optional[StoredObject(1234,5)];

Supported Fields

java-dirty will only persist primitive fields on objects. All primitive types are currently supported.

Performance

See the README in java-dirty-benchmarks for the latest

More Repositories

1

byte-monkey

๐Ÿ’ Bytecode-level fault injection for the JVM.
Java
225
star
2

adr-viewer

Generate easy-to-read web pages for your Architecture Decision Records
Python
156
star
3

helixdns

DNS server that serves records from etcd.
Go
94
star
4

docker-flume

๐Ÿณ Docker image containing Apache Flume
Shell
53
star
5

ebook-publishers-vs-drm

List of publishers and whether or not they sell DRM-free ebooks
10
star
6

mrwilson-multipkg

Multipackage type and providers for Puppet
Ruby
7
star
7

squib

Sqlite3 extension library for statistical functions.
C
7
star
8

fb-psql

PostgreSQL wrapper for Facebook's FQL api
Python
7
star
9

femto

A teeny-tiny dependency injection library written in pure standard Java
Java
6
star
10

salt-config

Configuration for salt-stack
Scheme
5
star
11

ankirepo

Repository of all 3rd year revision Anki cards
5
star
12

advent-of-code-2021

It's back. It's worse.
jq
5
star
13

sopn-publish-date

๐Ÿ—ณ๏ธDerive publish dates of Statements of Persons Nominated for UK elections
Python
4
star
14

advent-of-code-2022

๐Ÿฆ†I can't believe I'm doing this again ๐Ÿฆ†
Shell
4
star
15

ansible-sqlite

Ansible role for installing sqlite.
4
star
16

advent-of-code-2020

This place is not a place of honor. No highly esteemed deed is commemorated here. Nothing valued is here. What is here was dangerous and repulsive to us.
C
4
star
17

jqunit

A test framework for JQ, written in Rust, on top of libjq.
Rust
4
star
18

java-working-days

๐ŸŒ ๐Ÿ—“๏ธ A small library to calculate working days between dates for multiple countries
Java
3
star
19

java-8-matchers

A hard fork of unruly/java-8-matchers
Java
3
star
20

wordle-text-description

A browser extension to generate a screen-reader-friendly representation of a Wordle game
JavaScript
3
star
21

shudder-py

An unofficial Python API client for horror streaming service Shudder
Python
3
star
22

beanstalk-lua

Lua client for beanstalkd
Lua
3
star
23

govuk-onelogin-webidentity-spike

JavaScript
3
star
24

leggings

Java
2
star
25

jenever

Java Package and Environment Manager
Java
2
star
26

conventional-commit

A small java library to parse conventional commits
Java
2
star
27

jump

Java
2
star
28

waste-receptacle-locations

๐Ÿ“Š ๐Ÿ—‘๏ธ โ™ป๏ธ Open-data repository for public waste disposal locations
Python
1
star
29

rust-katas

A collection of coding katas implemented in rust
Rust
1
star
30

ansible-snitch

Ansible module for handling snitches at https://deadmanssnitch.com
1
star
31

exercises

Various experiments with code exercises and stuff
Java
1
star
32

terraform-aws-protonmail-dns

Terraform module for DNS records to support custom domains on ProtonMail
HCL
1
star
33

shelua

Shell commands from lua
Lua
1
star
34

scrobbler

A command line track scrobbler
1
star
35

holst

YAML-based dsl for iptables rules
Python
1
star
36

woofplayer

Small java media player
Java
1
star
37

maven-plugins

A collection of custom maven plugins
Java
1
star
38

insant

Java
1
star
39

veggie-enhancement-suite

Improve UX for vegetarians / vegans on takeaway sites
JavaScript
1
star
40

gia

Executing groovy tests via annotations
Java
1
star
41

flume-tailer-source

Apache Flume source to tail files
Java
1
star
42

gradle-test-commit-revert-plugin

โœ… A gradle plugin to facilitate a Test-Commit-Revert workflow.
Groovy
1
star
43

appg-social-media

Keeping track of social media accounts for All-Party Parliamentary Groups (APPGs)
Python
1
star