All Projects → cesarferreira → Rxpaper

cesarferreira / Rxpaper

Licence: mit
Reactive extension for NoSQL data storage on Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxpaper

Hangfire.postgresql
PostgreSql Storage Provider for Hangfire
Stars: ✭ 149 (-16.76%)
Mutual labels:  storage
Bookstore
📚 Notebook storage and publishing workflows for the masses
Stars: ✭ 162 (-9.5%)
Mutual labels:  storage
Cloudexplorer
Cloud Explorer
Stars: ✭ 170 (-5.03%)
Mutual labels:  storage
Tera
An Internet-Scale Database.
Stars: ✭ 1,846 (+931.28%)
Mutual labels:  storage
Vue Warehouse
A Cross-browser storage for Vue.js and Nuxt.js, with plugins support and easy extensibility based on Store.js.
Stars: ✭ 161 (-10.06%)
Mutual labels:  storage
Kvdo
A pair of kernel modules which provide pools of deduplicated and/or compressed block storage.
Stars: ✭ 168 (-6.15%)
Mutual labels:  storage
Awesome Web Scraper
A collection of awesome web scaper, crawler.
Stars: ✭ 147 (-17.88%)
Mutual labels:  storage
Put.io Adder
OS X put.io client that acts as handler for magnet: links and .torrent files, and adds them to your put.io download queue
Stars: ✭ 172 (-3.91%)
Mutual labels:  storage
Linkis
Linkis helps easily connect to various back-end computation/storage engines(Spark, Python, TiDB...), exposes various interfaces(REST, JDBC, Java ...), with multi-tenancy, high performance, and resource control.
Stars: ✭ 2,323 (+1197.77%)
Mutual labels:  storage
Udisks
The UDisks project provides a daemon, tools and libraries to access and manipulate disks, storage devices and technologies.
Stars: ✭ 170 (-5.03%)
Mutual labels:  storage
Space Daemon
The Space Daemon packages together IPFS, Textile Threads/Buckets, and Textile Powergate (Filecoin*) into one easy to install Daemon to make it easy to build peer to peer and privacy focused apps.
Stars: ✭ 151 (-15.64%)
Mutual labels:  storage
Uptoc
A static file deployment tool that supports multiple platforms./ 一个支持多家云厂商的静态文件部署工具
Stars: ✭ 159 (-11.17%)
Mutual labels:  storage
Mars
Asynchronous Block-Level Storage Replication
Stars: ✭ 168 (-6.15%)
Mutual labels:  storage
Jstarcraft Core
目标是提供一个通用的Java核心编程框架,作为搭建其它框架或者项目的基础. 让相关领域的研发人员能够专注高层设计而不用关注底层实现. 涵盖了缓存,存储,编解码,资源,脚本,监控,通讯,事件,事务9个方面.
Stars: ✭ 150 (-16.2%)
Mutual labels:  storage
Dosa
DOSA is a data object abstraction layer
Stars: ✭ 172 (-3.91%)
Mutual labels:  storage
Pins
Pin, Discover and Share Resources
Stars: ✭ 149 (-16.76%)
Mutual labels:  storage
Sharesniffer
Network share sniffer and auto-mounter for crawling remote file systems
Stars: ✭ 168 (-6.15%)
Mutual labels:  storage
Amplify Cli
The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Stars: ✭ 2,399 (+1240.22%)
Mutual labels:  storage
Tus Ruby Server
Ruby server for tus resumable upload protocol
Stars: ✭ 172 (-3.91%)
Mutual labels:  storage
Maya
Manage Container Attached Storage (CAS) - Data Engines in Kubernetes
Stars: ✭ 169 (-5.59%)
Mutual labels:  storage

RxPaper

Build Status

RxPaper is a RxJava wrapper for the cool paper library, a fast NoSQL data storage for Android that lets you save/restore Java objects by using efficient Kryo serialization and handling data structure changes automatically.

For the RxJava 2 version please go to RxPaper2 made by Pakoito.

Paper icon

What's new for the new PaperDB 2.0 (starting on 0.5.0+ version)

  • Update internal Kryo serializer to 4.0. The data format is changed, but Paper supports backward data compatibility automatically;
  • Now 58% less methods count : 4037;
  • Depends on data structure you may experience faster reading but slower writing.

Add dependency

repositories {
    jcenter()
    maven { url "https://jitpack.io" }
 }
dependencies {
    compile 'com.cesarferreira.rxpaper:rxpaper:0.5.0'
}

Install

Init the library in your Application class

public class SampleApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        RxPaper.init(this);
    }
}

Save

Save data object. Your custom classes must have no-arg constructor. Paper creates separate data file for each key.

RxPaper.book()
        .write(key, value)
        .subscribe(success -> /* all good */ );

I'm serious: Your custom classes must have no-arg constructor.

Read

Read data objects. Paper instantiates exactly the classes which has been used in saved data. The limited backward and forward compatibility is supported. See Handle data class changes.

Use default values if object doesn't exist in the storage.

RxPaper.book()
        .read(key, defaultPersonValue)
        .subscribe(person -> /* all good */ );

Delete

Delete data for one key.

RxPaper.book()
       .delete(key)
       .subscribe();

Completely destroys Paper storage.

RxPaper.book()
       .destroy()
       .subscribe();

Exists

Check if a key is persisted

RxPaper.book()
       .exists(key)
       .subscribe(success -> /* all good */);

Get all keys

Returns all keys for objects in the book.

RxPaper.book()
       .getAllKeys()
       .subscribe(allKeys -> /* all good */);

Use custom book

You can create custom Book book separate storage using

RxPaper.book("custom-book")...;

Any changes in one book doesn't affect to others books.

Important information

Don't forget to specify which threads you want to use before subscribing to any data manipulation, or else it'll run on the UI thread.

...
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(...

Handle data structure changes

Class fields which has been removed will be ignored on restore and new fields will have their default values. For example, if you have following data class saved in Paper storage:

class Person {
    public String firstName; // Cesar
    public String middleName; // Costa
}

And then you realized you need to change the class like:

class Person {
    public String firstName; // Cesar
    // public String middleName; removed field, who cares about middle names
    public String lastName; // New field
}

Then on restore the middleName field will be ignored and new lastName field will have its default value null.

Exclude fields

Use transient keyword for fields which you want to exclude from saving process.

public transient String tempId = "default"; // Won't be saved

Proguard config

  • Keep data classes:
-keep class my.package.data.model.** { *; }

alternatively you can implement Serializable in all your data classes and keep all of them using:

-keep class * implements java.io.Serializable { *; }
  • Keep library classes and its dependencies
-keep class io.paperdb.** { *; }
-keep class com.esotericsoftware.** { *; }
-dontwarn com.esotericsoftware.**
-keep class de.javakaffee.kryoserializers.** { *; }
-dontwarn de.javakaffee.kryoserializers.**

How it works

Paper is based on the following assumptions:

  • Saved data on mobile are relatively small;
  • Random file access on flash storage is very fast.

So each data object is saved in separate file and write/read operations write/read whole file.

The Kryo is used for object graph serialization and to provide data compatibility support.

Benchmark results

Running Benchmark on Nexus 4, in ms:

Benchmark Paper Hawk
Read/write 500 contacts 187 447
Write 500 contacts 108 221
Read 500 contacts 79 155
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].