SlumberDB Service

Key/Value Store for JSON for Boon

License

License

Categories

Categories

JSON Data fastjson
GroupId

GroupId

io.fastjson
ArtifactId

ArtifactId

slumberdb-service
Last Version

Last Version

0.34
Release Date

Release Date

Type

Type

jar
Description

Description

SlumberDB Service
Key/Value Store for JSON for Boon

Download slumberdb-service

How to add to project

<!-- https://jarcasting.com/artifacts/io.fastjson/slumberdb-service/ -->
<dependency>
    <groupId>io.fastjson</groupId>
    <artifactId>slumberdb-service</artifactId>
    <version>0.34</version>
</dependency>
// https://jarcasting.com/artifacts/io.fastjson/slumberdb-service/
implementation 'io.fastjson:slumberdb-service:0.34'
// https://jarcasting.com/artifacts/io.fastjson/slumberdb-service/
implementation ("io.fastjson:slumberdb-service:0.34")
'io.fastjson:slumberdb-service:jar:0.34'
<dependency org="io.fastjson" name="slumberdb-service" rev="0.34">
  <artifact name="slumberdb-service" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.fastjson', module='slumberdb-service', version='0.34')
)
libraryDependencies += "io.fastjson" % "slumberdb-service" % "0.34"
[io.fastjson/slumberdb-service "0.34"]

Dependencies

compile (3)

Group / Artifact Type Version
io.fastjson : slumberdb-service-model jar 0.34
io.vertx : vertx-core jar 2.1.2
io.vertx : vertx-platform jar 2.1.2

provided (1)

Group / Artifact Type Version
io.vertx : vertx-hazelcast jar 2.1.2

test (2)

Group / Artifact Type Version
io.vertx : testtools jar 2.0.3-final
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Got a question? Ask here. Get help from the Boon community. https://groups.google.com/forum/#!forum/boonjava

__________                              _____          __   .__
\______   \ ____   ____   ____   /\    /     \ _____  |  | _|__| ____    ____
 |    |  _//  _ \ /  _ \ /    \  \/   /  \ /  \\__  \ |  |/ /  |/    \  / ___\
 |    |   (  <_> |  <_> )   |  \ /\  /    Y    \/ __ \|    <|  |   |  \/ /_/  >
 |______  /\____/ \____/|___|  / \/  \____|__  (____  /__|_ \__|___|  /\___  /
        \/                   \/              \/     \/     \/       \//_____/
     ____.                     ___________   _____    ______________.___.
    |    |____ ___  _______    \_   _____/  /  _  \  /   _____/\__  |   |
    |    \__  \\  \/ /\__  \    |    __)_  /  /_\  \ \_____  \  /   |   |
/\__|    |/ __ \\   /  / __ \_  |        \/    |    \/        \ \____   |
\________(____  /\_/  (____  / /_______  /\____|__  /_______  / / ______|
              \/           \/          \/         \/        \/  \/

Status

Boon is now at version 0.26. There are a few more features to implement, and then Boon will be 1.0. This last push fixed a lot of long lived bugs. Boon now compiles (again) in JDK 1.8.

License

Apache 2

YourKit

YourKit supports Boon open source project with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .Net profiler.

YourKit Logo

YourKit Logo

Philosophy

Use it as you wish. Give me some credit if you fork it or copy major portions of it. Use the lib or copy it into your code, tweak it. Blog about. Use it. Give me feedback. I am doing this for the street cred and to learn.

Do I like new task lists in MarkDown?

  • Yes
  • No
  • Maybe

Java Boon

Simple opinionated Java for the novice to expert level Java Programmer.

Low Ceremony. High Productivity.

Boon Home: http://richardhightower.github.io/site/Boon/Welcome.html

Boon is in maven central repo:

http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.fastjson%22%20AND%20a%3A%22boon%22

Brief introduction to Boon

Here are some basic Java types, list, array, veggies, primitive char array, and a primitive byte array.

    //Boon works with lists, arrays, sets, maps, sorted maps, etc.
    List<String> fruitList;
    String [] fruitArray;
    Set<String> veggiesSet;
    char [] letters;
    byte [] bytes;
    NavigableMap <Integer, String> favoritesMap;
    Map<String, Integer> map;

    //In Java a TreeMap is a SortedMap and a NavigableMap by the way.

Boon comes with helper methods that allow you to easily create lists, sets, maps, concurrent maps, sorted maps, sorted sets, etc. The helper methods are safeList, list, set, sortedSet, safeSet, safeSortedSet, etc. The idea is to make Java feel more like list and maps are built in types.

    veggiesSet  =  set( "salad", "broccoli", "spinach");
    fruitList   =  list( "apple", "oranges", "pineapple");
    fruitArray  =  array( "apple", "oranges", "pineapple");
    letters     =  array( 'a', 'b', 'c');
    bytes       =  array( new byte[]{0x1, 0x2, 0x3, 0x4});

There are even methods to create maps and sorted maps called map, sortedMap, safeMap (concurrent) and sortedSafeMap (concurrent). These were mainly created because Java does not have literals for lists, maps, etc.

     favoritesMap = sortedMap(
            2, "pineapple",
            1, "oranges",
            3, "apple"
     );


     map =    map (
        "pineapple",  2,
        "oranges",    1,
        "apple",      3
     );

You can index maps, lists, arrays, etc. using the idx operator.

     //Using idx to access a value.

     assert idx( veggiesSet, "b").equals("broccoli");

     assert idx( fruitList, 1 ).equals("oranges");

     assert idx( fruitArray, 1 ).equals("oranges");

     assert idx( letters, 1 ) == 'b';

     assert idx( bytes, 1 )      == 0x2;

     assert idx( favoritesMap, 2 ).equals("pineapple");

     assert idx( map, "pineapple" )  == 2;

The idx operators works with negative indexes as well.

               //Negative indexes

                assert idx( fruitList, -2 ).equals("oranges");

                assert idx( fruitArray, -2 ).equals("oranges");

                assert idx( letters, -2 ) == 'b';

                assert idx( bytes, -3 )   == 0x2;

Ruby, Groovy and Python have this feature. Now you can use this in Java as well. The Java version (Boon) works with primitive arrays (with no autoboxing).

Boon has the concept of universal operators similar to Python like len.

     // Getting the length
     assert len( veggiesSet )        == 3;
     assert len( fruitList )         == 3;
     assert len( fruitArray )        == 3;
     assert len( letters )           == 3;
     assert len( bytes )             == 4;
     assert len( favoritesMap )      == 3;
     assert len( map )               == 3;

Boon utility methods

Boon can read in an entire file in one line of code:

        File testFile = new File(testDir, "testfile.txt");
        List<String> lines = IO.readLines(testFile);

No really!

        File testFile = new File(testDir, "testfile.txt");
        List<String> lines = IO.readLines("~/github/boon/testfiles/testfile.txt");

There is also support for lambda expressions:

        File testFile = new File(testDir, "testfile.txt");



        IO.eachLine(testFile.toString(), (line, index) -> {
            System.out.println(index + " " + line);
            return true;
        });

        }

The readLines and read methods can read from URIs as well:

        List<String> lines = IO.readLines("http://localhost:9666/test");

News in Boon

Boon 0.11 is out. Thanks Stephane Landelle! Boon JSON parser still faster than GSON and Jackson. Up to 3x faster.

See and fork: https://github.com/RichardHightower/json-parsers-benchmark

Added lightweight JSON DI container that supports @Inject, @PostConstruct, @Required, @Autowire, and more.

public class CoffeeApp implements Runnable {
    @Inject
    CoffeeMaker coffeeMaker;
    @Inject
    Coffee coffee;
    @Inject
    Sugar sugar;
    @Inject
    Bacon bacon;
    @Inject
    @Named( "brown" )
    Bacon brownBacon;

JSON support now support @JsonProperty, @JsonView, and more. Learn more here: http://rick-hightower.blogspot.com/2014/01/boon-json-in-five-minutes-faster-json.html

Wrote invoker library to work JSON posts. It is a better way to do REST and WebSocket with Boon.

Wrote functional library based on work that I did with EasyJava.

You can do reflection based filters or regular Predicate filters.

        List<Employee> list = list( new Employee("Bob"), new Employee("Sally") );
        setListProperty( list, "salary", 200 );
        list.addAll(Lists.list(new Employee("Rick"), new Employee("Joe")));

        //Reflection
        List<Employee> filtered = filterBy(list, new Object() {
            boolean t(Employee e) { return e.salary>150; }
        });


        ...

         //Predicate based
         List<Employee> filtered = filterBy(list, new Predicate<Employee>() {
                    @Override
                    public boolean test(Employee input) {
                        return input.salary > 150;
                    }
         });

My goal is take some previous work that I did with invoke dynamic and make the reflection based predicate faster than the Predicate interface.

You can also filter with static or non-static methods

        List<Employee> filtered = filterBy(list, ListsTest.class, "filterBySalary");
        ...

        List<Employee> filtered = filterBy(list, this, "filterBySalaryMethod");

Also don't forget that Boon ships with a full in-memory query engine that is actually faster than the predicate based filters.

      List<Employee> filtered = query( list, gt("salary", 150) );

Learn more about the Boon data repo here:

http://rick-hightower.blogspot.com/2013/11/what-if-java-collections-and-java.html

But I digress back to functional framework:

The usual suspects are here:

        ...

        //Reflection Mapper -- Convert Employee object into HRObject
        List<HRObject> wrap = (List<HRObject>) mapBy(list, new Object() {
           HRObject hr(Employee e) {return new HRObject(e);}
        });

        ...
        //Reflection static or non-static methods
        List<HRObject> wrap = (List<HRObject>) mapBy(list, ListsTest.class, "createHRO" );

        List<HRObject> wrap = (List<HRObject>) mapBy(list, this, "createHROMethod" );

        ...
        //Constructor mapping
        List<Employee> list = list(new Employee("Bob"), new Employee("Sally"));
        List<HRObject> wrap = wrap(HRObject.class, list);
        ...


        //
        List<Employee> list =  list(  new Employee("Bob"), new Employee("Sally"));
        List<HRObject> wrap =  mapBy( list, new Function<Employee, HRObject>() {
            @Override
            public HRObject apply(Employee employee) {
                return new HRObject(employee);
            }
        });

Here is one you don't see much:

    @Test
    public void reduce() {
      long sum =  (int) reduceBy(Lists.list(1,2,3,4,5,6,7,8), new Object() {
          int sum(int s, int b) {return s+b;}
      });

      boolean ok = sum == 36 || die();
      puts (sum);



      sum =  (long) reduceBy(new Integer[]{1,2,3,4,5,6,7,8}, new Object() {
            long sum(long s, int b) {return s+b;}
      });

      ok &= sum == 36 || die();



      sum =  (long) reduceBy(new int[]{1,2,3,4,5,6,7,8}, new Object() {
            long sum(long s, int b) {return s+b;}
      });

      ok &= sum == 36 || die();


       sum =   (long) reduceBy(Lists.list(1,2,3,4,5,6,7,8), new Reducer<Integer, Integer>() {
            @Override
            public Integer apply(Integer sum, Integer v) {
                return sum == null ? v : sum + v;
            }
        }).longValue();


    }

EasyJava had currying and all sorts of wild stuff, so I might port some of that here. I might not. Let me know.

String Parsing.... Boon has really fast String parsing about 2x speed what you could do with JDK readily, and a smaller GC foot print so instead of this:

    static Pattern newLine = Pattern.compile("(\n|\r)");
    ...
        int i=0;
        String[] splitLines = newLine.split(str);
        String[] stats;

        for (String line : splitLines) {
            stats = line.split( ",");
            i += Integer.parseInt(stats[1]);
        }
        return i;

You can do this (for 2x speed and a lot less GC overhead):

        int i=0;
        String[] splitLines = splitLines(str);
        String[] stats;

        for (String line : splitLines) {
            stats = splitComma(line);
            i += Integer.parseInt(stats[1]);
        }
        return i;

Or even this (2.5x faster and even less GC overhead):

        char[] chars = toCharArray(csv);
        int i=0;
        char[][] splitLines = splitLines(chars);
        char[][] stats;

        for (char[] line : splitLines) {
            stats = splitComma(line);
            i += parseInt(stats[1]);
        }
        return i;

Boon is not just fast. Boon is a flame throwing, turbo-charged, get-out-of-the-way-I-am-coming-in, speed-demon that sips GC, and makes CPUs and virtual cores wish they went into dentistry.

Thoughts

Thoughts? Write me at richard high tower AT g mail dot c-o-m (Rick Hightower).

Further Reading:

If you are new to boon start here:

Why Boon?

Easily read in files into lines or a giant string with one method call. Works with files, URLs, class-path, etc. Boon IO support will surprise you how easy it is. Boon has Slice notation for dealing with Strings, Lists, primitive arrays, Tree Maps, etc. If you are from Groovy land, Ruby land, Python land, or whatever land, and you have to use Java then Boon might give you some relief from API bloat. If you are like me, and you like to use Java, then Boon is for you too. Boon lets Java be Java, but adds the missing productive APIs from Python, Ruby, and Groovy. Boon may not be Ruby or Groovy, but its a real Boon to Java development.

Core Boon Philosophy

Core Boon will never have any dependencies. It will always be able to run as a single jar. This is not just NIH, but it is partly. My view of what Java needs is more inline with what Python, Ruby and Groovy provide. Boon is an addition on top of the JVM to make up the difference between the harder to use APIs that come with Java and the types of utilities that are built into Ruby, Python, PHP, Groovy etc. Boon is a Java centric view of those libs. The vision of Boon and the current implementation is really far apart.

===

Contact Info

blog|[twitter](https://twitter.com/RickHigh|[infoq]http://www.infoq.com/author/Rick-Hightower|[stackoverflow](http://stackoverflow.com/users/2876739/rickhigh)|[java lobby](http://java.dzone.com/users/rhightower)|Other | richard high tower AT g mail dot c-o-m (Rick Hightower)|work|cloud|nosql

io.fastjson

Boon Project

Boon, QBit, SlumberDB, high-speed SOA and in-memory computing

Versions

Version
0.34
0.30
0.29
0.5