├── .blaze
├── blaze.conf
├── blaze.java
└── pom.xml
├── .github
└── workflows
│ ├── java11.yaml
│ ├── java17.yaml
│ ├── java21.yaml
│ ├── java8.yaml
│ ├── macos-arm64.yaml
│ └── windows-x64.yaml
├── .gitignore
├── CHANGELOG.md
├── README.md
├── bigmap-bom
└── pom.xml
├── bigmap-core
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── fizzed
│ │ └── bigmap
│ │ ├── BigMap.java
│ │ ├── BigMapDataException.java
│ │ ├── BigMapNonScalableException.java
│ │ ├── BigObject.java
│ │ ├── BigObjectCloser.java
│ │ ├── BigObjectListener.java
│ │ ├── BigObjectRegistry.java
│ │ ├── BigSet.java
│ │ ├── BigSortedMap.java
│ │ ├── BigSortedSet.java
│ │ ├── ByteCodec.java
│ │ ├── ByteCodecs.java
│ │ ├── Bytes.java
│ │ ├── Comparators.java
│ │ ├── MutableValue.java
│ │ ├── SerializableByteCodec.java
│ │ └── impl
│ │ ├── AbstractBigLinkedMap.java
│ │ ├── AbstractBigMap.java
│ │ ├── AbstractBigMapBuilder.java
│ │ ├── AbstractBigObjectBuilder.java
│ │ ├── AbstractBigObjectCloser.java
│ │ ├── AbstractBigSet.java
│ │ ├── AbstractBigSetBuilder.java
│ │ ├── BigLinkedMapCloser.java
│ │ ├── BigMapEntrySet.java
│ │ ├── BigMapHelper.java
│ │ ├── BigMapKeySet.java
│ │ ├── BigMapValueCollection.java
│ │ ├── BigObjectWeakReference.java
│ │ ├── ByteArrayBigMap.java
│ │ ├── KeyValueBytes.java
│ │ ├── MapMutableValue.java
│ │ └── None.java
│ └── test
│ └── java
│ └── com
│ └── fizzed
│ └── bigmap
│ ├── ByteCodecsTest.java
│ ├── BytesTest.java
│ └── ComparatorsTest.java
├── bigmap-demo
├── pom.xml
└── src
│ └── test
│ ├── java
│ └── com
│ │ └── fizzed
│ │ └── bigmap
│ │ ├── AbstractPerf.java
│ │ ├── MapDemo.java
│ │ ├── OffheapMap.java
│ │ ├── PerfManyMaps.java
│ │ └── PerfThroughput.java
│ └── resources
│ └── logback.xml
├── bigmap-integration-tests
├── pom.xml
└── src
│ └── test
│ └── java
│ └── com
│ └── fizzed
│ └── bigmap
│ ├── AbstractBigLinkedMapTest.java
│ ├── AbstractBigLinkedSetTest.java
│ ├── AbstractBigMapTest.java
│ ├── AbstractBigSetTest.java
│ ├── JavaHashMapTest.java
│ ├── JavaHashSetTest.java
│ ├── JavaLinkedHashMapTest.java
│ ├── JavaTreeMapTest.java
│ ├── JavaTreeSetTest.java
│ ├── LevelBigLinkedMapTest.java
│ ├── LevelBigLinkedSetTest.java
│ ├── LevelBigMapTest.java
│ ├── LevelBigSetTest.java
│ ├── RocksBigLinkedMapTest.java
│ ├── RocksBigLinkedSetTest.java
│ ├── RocksBigMapTest.java
│ ├── RocksBigSetTest.java
│ ├── TestIdentifier.java
│ ├── TkrzwBigLinkedMapTest.java
│ ├── TkrzwBigLinkedSetTest.java
│ ├── TkrzwBigMapTest.java
│ ├── TkrzwBigSetTest.java
│ ├── TokyoBigLinkedMapTest.java
│ ├── TokyoBigLinkedSetTest.java
│ ├── TokyoBigMapTest.java
│ └── TokyoBigSetTest.java
├── bigmap-jackson
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── fizzed
│ │ └── bigmap
│ │ └── jackson
│ │ └── JacksonByteCodec.java
│ └── test
│ └── java
│ └── com
│ └── fizzed
│ └── bigmap
│ └── jackson
│ └── JacksonByteCodecTest.java
├── bigmap-kryo
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── fizzed
│ │ └── bigmap
│ │ └── kryo
│ │ └── KryoByteCodec.java
│ └── test
│ └── java
│ └── com
│ └── fizzed
│ └── bigmap
│ └── kryo
│ └── KryoByteCodecTest.java
├── bigmap-leveldb
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── fizzed
│ │ └── bigmap
│ │ └── leveldb
│ │ ├── LevelBigLinkedMap.java
│ │ ├── LevelBigLinkedMapBuilder.java
│ │ ├── LevelBigLinkedSet.java
│ │ ├── LevelBigLinkedSetBuilder.java
│ │ ├── LevelBigMap.java
│ │ ├── LevelBigMapBuilder.java
│ │ ├── LevelBigObjectCloser.java
│ │ ├── LevelBigSet.java
│ │ ├── LevelBigSetBuilder.java
│ │ ├── LevelForwardIterator.java
│ │ └── LevelJavaComparator.java
│ └── test
│ └── java
│ └── com
│ └── fizzed
│ └── bigmap
│ └── leveldb
│ └── LevelBigMapTest.java
├── bigmap-rocksdb
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── fizzed
│ │ └── bigmap
│ │ └── rocksdb
│ │ ├── RocksBigLinkedMap.java
│ │ ├── RocksBigLinkedMapBuilder.java
│ │ ├── RocksBigLinkedSet.java
│ │ ├── RocksBigLinkedSetBuilder.java
│ │ ├── RocksBigMap.java
│ │ ├── RocksBigMapBuilder.java
│ │ ├── RocksBigObjectCloser.java
│ │ ├── RocksBigSet.java
│ │ ├── RocksBigSetBuilder.java
│ │ ├── RocksForwardIterator.java
│ │ └── RocksJavaComparator.java
│ └── test
│ └── java
│ └── com
│ └── fizzed
│ └── bigmap
│ └── rocksdb
│ └── RocksBigMapTest.java
├── bigmap-tkrzw
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── fizzed
│ │ └── bigmap
│ │ └── tkrzw
│ │ ├── TkrzwBigLinkedMap.java
│ │ ├── TkrzwBigLinkedMapBuilder.java
│ │ ├── TkrzwBigLinkedSet.java
│ │ ├── TkrzwBigLinkedSetBuilder.java
│ │ ├── TkrzwBigMap.java
│ │ ├── TkrzwBigMapBuilder.java
│ │ ├── TkrzwBigObjectCloser.java
│ │ ├── TkrzwBigSet.java
│ │ ├── TkrzwBigSetBuilder.java
│ │ └── TkrzwForwardIterator.java
│ └── test
│ └── java
│ └── com
│ └── fizzed
│ └── bigmap
│ └── tkrzw
│ ├── TkrzwBigMapTest.java
│ └── TkrzwBigSetTest.java
├── bigmap-tokyocabinet
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── fizzed
│ │ └── bigmap
│ │ └── tokyocabinet
│ │ ├── TokyoBigLinkedMap.java
│ │ ├── TokyoBigLinkedMapBuilder.java
│ │ ├── TokyoBigLinkedSet.java
│ │ ├── TokyoBigLinkedSetBuilder.java
│ │ ├── TokyoBigMap.java
│ │ ├── TokyoBigMapBuilder.java
│ │ ├── TokyoBigObjectCloser.java
│ │ ├── TokyoBigSet.java
│ │ ├── TokyoBigSetBuilder.java
│ │ └── TokyoForwardIterator.java
│ └── test
│ └── java
│ └── com
│ └── fizzed
│ └── bigmap
│ └── tokyocabinet
│ ├── TokyoBigMapTest.java
│ └── TokyoBigSetTest.java
├── blaze.jar
├── buildx-results.txt
└── pom.xml
/.blaze/blaze.conf:
--------------------------------------------------------------------------------
1 | blaze.dependencies = [
2 | "com.fizzed:blaze-ssh"
3 | "com.fizzed:blaze-public-project:1.0.1"
4 | ]
5 |
6 | java.source.version = 8
--------------------------------------------------------------------------------
/.blaze/blaze.java:
--------------------------------------------------------------------------------
1 | import com.fizzed.blaze.project.PublicBlaze;
2 |
3 | public class blaze extends PublicBlaze {
4 |
5 | // all public blaze methods
6 |
7 | }
--------------------------------------------------------------------------------
/.blaze/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | blaze
4 | bigmap-blaze
5 | 0.0.1
6 |
7 |
12 |
13 |
14 | 8
15 | 8
16 | true
17 | true
18 |
19 |
20 | ${project.basedir}
21 |
22 |
23 |
24 | org.apache.ivy
25 | ivy
26 | 2.5.2
27 |
28 |
29 | com.fizzed
30 | blaze-core
31 | 1.8.0
32 |
33 |
34 | commons-io
35 | commons-io
36 | 2.16.1
37 |
38 |
39 | com.typesafe
40 | config
41 | 1.4.3
42 |
43 |
44 | com.fizzed
45 | blaze-ivy
46 | 1.8.0
47 |
48 |
49 | org.slf4j
50 | slf4j-simple
51 | 2.0.13
52 |
53 |
54 | org.slf4j
55 | slf4j-api
56 | 2.0.13
57 |
58 |
59 | org.zeroturnaround
60 | zt-exec
61 | 1.12
62 |
63 |
64 | com.fizzed
65 | blaze-ssh
66 | 1.8.0
67 |
68 |
69 | com.fizzed
70 | blaze-public-project
71 | 1.0.0
72 |
73 |
74 |
--------------------------------------------------------------------------------
/.github/workflows/java11.yaml:
--------------------------------------------------------------------------------
1 | name: Java 11
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 11
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 11
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Test in Maven
17 | run: mvn --no-transfer-progress -B test
--------------------------------------------------------------------------------
/.github/workflows/java17.yaml:
--------------------------------------------------------------------------------
1 | name: Java 17
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 17
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 17
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Test in Maven
17 | run: mvn --no-transfer-progress -B test
--------------------------------------------------------------------------------
/.github/workflows/java21.yaml:
--------------------------------------------------------------------------------
1 | name: Java 21
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 21
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 21
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Test in Maven
17 | run: mvn --no-transfer-progress -B test
--------------------------------------------------------------------------------
/.github/workflows/java8.yaml:
--------------------------------------------------------------------------------
1 | name: Java 8
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 8
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 8
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Test in Maven
17 | run: mvn --no-transfer-progress -B test
--------------------------------------------------------------------------------
/.github/workflows/macos-arm64.yaml:
--------------------------------------------------------------------------------
1 | name: MacOS arm64
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: macos-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 11
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 11
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Test in Maven
17 | run: mvn --no-transfer-progress -B test
--------------------------------------------------------------------------------
/.github/workflows/windows-x64.yaml:
--------------------------------------------------------------------------------
1 | name: Windows x64
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: windows-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 11
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 11
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Test in Maven
17 | run: mvn --no-transfer-progress -B test
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | *.iml
3 | nb-configuration.xml
4 | .idea
5 | .buildx
6 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Bigmap for Java
2 |
3 | ## 1.1.0 - 2025-01-22
4 | - Bump tokyocabinet v0.0.16 (new support for freebsd/openbsd)
5 | - Bump tkrzw v0.0.9 (new support for freebsd/openbsd)
6 | - Bump rocksdb v9.8.4
7 | - Bump kryo v5.6.2
8 |
9 | ## 1.0.16 - 2023-11-04
10 | - Improved build system for cross testing different JDK versions
11 | - Bump tokyocabinet v0.0.15
12 | - Bump tkrzw v0.0.8
13 | - Bump rocksdb v8.3.2
14 | - CI workflows for Java 21
15 |
16 | ## 1.0.15 - 2023-01-18
17 | - Many releases before this one, starting changelog
--------------------------------------------------------------------------------
/bigmap-bom/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | bigmap-bom
5 | bigmap-bom
6 | pom
7 |
8 |
9 | com.fizzed
10 | bigmap
11 | 1.1.1-SNAPSHOT
12 |
13 |
14 |
15 |
16 |
17 |
18 | com.fizzed
19 | bigmap-core
20 | ${project.version}
21 |
22 |
23 |
24 | com.fizzed
25 | bigmap-kryo
26 | ${project.version}
27 |
28 |
29 |
30 | com.fizzed
31 | bigmap-jackson
32 | ${project.version}
33 |
34 |
35 |
36 | com.fizzed
37 | bigmap-leveldb
38 | ${project.version}
39 |
40 |
41 |
42 | com.fizzed
43 | bigmap-rocksdb
44 | ${project.version}
45 |
46 |
47 |
48 | com.fizzed
49 | bigmap-tokyocabinet
50 | ${project.version}
51 |
52 |
53 |
54 | com.fizzed
55 | bigmap-tkrzw
56 | ${project.version}
57 |
58 |
59 |
60 |
61 | com.fizzed
62 | tokyocabinet-bom
63 | ${tokyocabinet.version}
64 | pom
65 | import
66 |
67 |
68 |
69 |
70 | com.fizzed
71 | tkrzw-bom
72 | ${tkrzw.version}
73 | pom
74 | import
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/bigmap-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | bigmap-core
5 | bigmap-core
6 | jar
7 |
8 |
9 | com.fizzed
10 | bigmap
11 | 1.1.1-SNAPSHOT
12 |
13 |
14 |
15 |
16 |
17 | org.slf4j
18 | slf4j-api
19 |
20 |
21 |
22 |
23 |
24 | com.fizzed
25 | crux-util
26 | test
27 |
28 |
29 |
30 | com.google.guava
31 | guava
32 | 29.0-jre
33 | test
34 |
35 |
36 |
37 | org.mockito
38 | mockito-core
39 | test
40 |
41 |
42 |
43 | org.hamcrest
44 | java-hamcrest
45 | test
46 |
47 |
48 |
49 | org.junit.jupiter
50 | junit-jupiter
51 | test
52 |
53 |
54 |
55 | ch.qos.logback
56 | logback-classic
57 | test
58 |
59 |
60 |
61 | commons-io
62 | commons-io
63 | 2.7
64 | test
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/BigMapDataException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | public class BigMapDataException extends RuntimeException {
19 |
20 | public BigMapDataException(String msg) {
21 | super(msg);
22 | }
23 |
24 | public BigMapDataException(Throwable cause) {
25 | super(cause);
26 | }
27 |
28 | public BigMapDataException(String msg, Throwable cause) {
29 | super(msg, cause);
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/BigMapNonScalableException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | public class BigMapNonScalableException extends RuntimeException {
19 |
20 | public BigMapNonScalableException(String msg) {
21 | super(msg);
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/BigObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.io.Closeable;
19 | import java.nio.file.Path;
20 | import java.util.*;
21 |
22 | public interface BigObject extends Closeable {
23 |
24 | UUID getId();
25 |
26 | Path getPath();
27 |
28 | void setListener(BigObjectListener listener);
29 |
30 | BigObjectListener getListener();
31 |
32 | void open();
33 |
34 | BigObjectCloser getCloser();
35 |
36 | default void checkIfClosed() {
37 | if (this.isClosed()) {
38 | throw new IllegalStateException("Underlying database is closed. Unable to perform any operations.");
39 | }
40 | }
41 |
42 | boolean isClosed();
43 |
44 | boolean isPersistent();
45 |
46 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/BigObjectCloser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.io.Closeable;
19 | import java.nio.file.Path;
20 | import java.util.UUID;
21 |
22 | public interface BigObjectCloser extends Closeable {
23 |
24 | UUID getId();
25 |
26 | boolean isPersistent();
27 |
28 | Path getPath();
29 |
30 | boolean isClosed();
31 |
32 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/BigObjectListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.io.Closeable;
19 | import java.nio.file.Path;
20 | import java.util.UUID;
21 |
22 | public interface BigObjectListener {
23 |
24 | void onOpened(BigObject bigObject);
25 |
26 | void onClosed(BigObject bigObject);
27 |
28 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/BigSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.io.Closeable;
19 | import java.nio.file.Path;
20 | import java.util.Collection;
21 | import java.util.Comparator;
22 | import java.util.Set;
23 |
24 | public interface BigSet extends Set, BigObject {
25 |
26 | ByteCodec getValueCodec();
27 |
28 | Comparator getValueComparator();
29 |
30 | /**
31 | * IF YOU DO NOT NEED TO KNOW IF IT WAS REMOVED, PLEASE USE {@link #delete(Object)}
32 | *
33 | * With most implementations of a bigset, its two operations to remove a value AND return back if it existed. In
34 | * most cases, you ignore the returned value and it just costs more time/effort than is needed.
35 | *
36 | * Otherwise, this method works identical to a standard Map implementation.
37 | */
38 | @Override
39 | boolean remove(Object value);
40 |
41 | /**
42 | * Typically, this is more efficient than a {@link #remove(Object)} since the value is deleted and no check is
43 | * performed if it exists first.
44 | * @param value
45 | */
46 | void delete(V value);
47 |
48 | @Override
49 | default boolean containsAll(Collection> c) {
50 | if (c != null) {
51 | for (Object v : c) {
52 | if (!this.contains(v)) {
53 | return false;
54 | }
55 | }
56 | }
57 | return true;
58 | }
59 |
60 | @Override
61 | default boolean addAll(Collection extends V> c) {
62 | if (c != null) {
63 | for (V v : c) {
64 | this.add(v);
65 | }
66 | }
67 | return true;
68 | }
69 |
70 | @Override
71 | default boolean retainAll(Collection> c) {
72 | throw new BigMapNonScalableException("Not scalable to bulk retain values");
73 | }
74 |
75 | @Override
76 | default boolean removeAll(Collection> c) {
77 | if (c != null) {
78 | for (Object v : c) {
79 | this.remove(v);
80 | }
81 | }
82 | return true;
83 | }
84 |
85 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/BigSortedMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.util.*;
19 |
20 | public interface BigSortedMap extends BigMap, SortedMap {
21 |
22 | @Override
23 | default Comparator super K> comparator() {
24 | return this.getKeyComparator();
25 | }
26 |
27 | @Override
28 | default Set keySet() {
29 | return BigMap.super.keySet();
30 | }
31 |
32 | @Override
33 | default Set> entrySet() {
34 | return BigMap.super.entrySet();
35 | }
36 |
37 | @Override
38 | default Collection values() {
39 | return BigMap.super.values();
40 | }
41 |
42 | @Override
43 | default SortedMap subMap(K fromKey, K toKey) {
44 | throw new UnsupportedOperationException();
45 | }
46 |
47 | @Override
48 | default SortedMap headMap(K toKey) {
49 | throw new UnsupportedOperationException();
50 | }
51 |
52 | @Override
53 | default SortedMap tailMap(K fromKey) {
54 | throw new UnsupportedOperationException();
55 | }
56 |
57 | @Override
58 | default K firstKey() {
59 | return this.keySet().iterator().next();
60 | }
61 |
62 | @Override
63 | default K lastKey() {
64 | throw new UnsupportedOperationException();
65 | }
66 |
67 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/BigSortedSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.util.*;
19 |
20 | public interface BigSortedSet extends BigSet, SortedSet {
21 |
22 | @Override
23 | default Comparator super V> comparator() {
24 | return this.getValueComparator();
25 | }
26 |
27 | @Override
28 | default SortedSet subSet(V fromElement, V toElement) {
29 | throw new UnsupportedOperationException();
30 | }
31 |
32 | @Override
33 | default SortedSet headSet(V toElement) {
34 | throw new UnsupportedOperationException();
35 | }
36 |
37 | @Override
38 | default SortedSet tailSet(V fromElement) {
39 | throw new UnsupportedOperationException();
40 | }
41 |
42 | @Override
43 | default V first() {
44 | return this.iterator().next();
45 | }
46 |
47 | @Override
48 | default V last() {
49 | throw new UnsupportedOperationException();
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/ByteCodec.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | public interface ByteCodec {
19 |
20 | byte[] serialize(V value);
21 |
22 | V deserialize(byte[] bytes);
23 |
24 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/Bytes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | public class Bytes {
19 |
20 | static public boolean startsWith(
21 | byte[] bytes,
22 | byte[] prefix) {
23 |
24 | return startsWith(bytes, prefix, null);
25 | }
26 |
27 | /**
28 | * Verifies if the bytes start with the provided prefix. Optionally, a
29 | * wildcard byte can be provided, where if the prefix contains that byte
30 | * that position will be considered a match.
31 | * @param bytes
32 | * @param prefix
33 | * @param wildcardMarker
34 | * @return
35 | */
36 | static public boolean startsWith(
37 | byte[] bytes,
38 | byte[] prefix,
39 | Byte wildcardMarker) {
40 |
41 | if (bytes == null && prefix == null) {
42 | return true;
43 | }
44 | if (bytes == null || prefix == null) {
45 | return false;
46 | }
47 | if (prefix.length > bytes.length) {
48 | return false;
49 | }
50 | for (int i = 0; i < prefix.length; i++) {
51 | if (bytes[i] != prefix[i]
52 | && (wildcardMarker == null || prefix[i] != wildcardMarker)) {
53 | return false;
54 | }
55 | }
56 | return true;
57 | }
58 |
59 | static public boolean endsWith(
60 | byte[] bytes,
61 | byte[] suffix) {
62 |
63 | if (bytes == null && suffix == null) {
64 | return true;
65 | }
66 | if (bytes == null || suffix == null) {
67 | return false;
68 | }
69 | if (suffix.length > bytes.length) {
70 | return false;
71 | }
72 | int offset = bytes.length - suffix.length;
73 | for (int i = 0; i < suffix.length; i++) {
74 | if (bytes[offset+i] != suffix[i]) {
75 | return false;
76 | }
77 | }
78 | return true;
79 | }
80 |
81 | static public boolean endsWith(
82 | byte[] bytes,
83 | byte[] suffix,
84 | Byte wildcardMarker) {
85 |
86 | if (bytes == null && suffix == null) {
87 | return true;
88 | }
89 | if (bytes == null || suffix == null) {
90 | return false;
91 | }
92 | if (suffix.length > bytes.length) {
93 | return false;
94 | }
95 | int offset = bytes.length - suffix.length;
96 | for (int i = 0; i < suffix.length; i++) {
97 | if (bytes[offset+i] != suffix[i]
98 | && (wildcardMarker == null || suffix[i] != wildcardMarker)) {
99 | return false;
100 | }
101 | }
102 | return true;
103 | }
104 |
105 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/Comparators.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.util.Comparator;
19 |
20 | public class Comparators {
21 |
22 | static public Comparator autoComparator(Class type) {
23 | if (Comparable.class.isAssignableFrom(type)) {
24 | return (T o1, T o2) -> {
25 | Comparable c1 = (Comparable)o1;
26 | Comparable c2 = (Comparable)o2;
27 | if (c1 == null && c2 != null) {
28 | return 1;
29 | }
30 | else if (c2 == null && c1 != null) {
31 | return -1;
32 | }
33 | else {
34 | return c1.compareTo(c2);
35 | }
36 | };
37 | }
38 | return null;
39 | // throw new IllegalArgumentException("Only classes that implement Comparable are valid. "
40 | // + "Either supply a custom comparator or implement Comparable on your class!");
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/MutableValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | public interface MutableValue extends AutoCloseable {
19 |
20 | boolean isPresent();
21 |
22 | V get();
23 |
24 | void set(V value);
25 |
26 | public void close() throws RuntimeException;
27 |
28 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/SerializableByteCodec.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.io.*;
19 |
20 | public class SerializableByteCodec implements ByteCodec {
21 |
22 | @Override
23 | public byte[] serialize(K value) {
24 | try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
25 | ObjectOutputStream out = new ObjectOutputStream(bos);
26 | out.writeObject(value);
27 | out.flush();
28 | return bos.toByteArray();
29 | }
30 | catch (IOException e) {
31 | throw new UncheckedIOException(e);
32 | }
33 | }
34 |
35 | @Override
36 | public K deserialize(byte[] bytes) {
37 | if (bytes == null || bytes.length == 0) {
38 | return null;
39 | }
40 | try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes)) {
41 | ObjectInputStream in = new ObjectInputStream(bis);
42 | return (K)in.readObject();
43 | }
44 | catch (IOException e) {
45 | throw new UncheckedIOException(e);
46 | }
47 | catch (ClassNotFoundException e) {
48 | throw new RuntimeException(e);
49 | }
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/AbstractBigMapBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.impl;
17 |
18 | import com.fizzed.bigmap.BigObjectRegistry;
19 | import com.fizzed.bigmap.ByteCodec;
20 |
21 | import java.nio.file.Path;
22 | import java.util.Comparator;
23 | import java.util.Objects;
24 |
25 | import static com.fizzed.bigmap.ByteCodecs.resolveCodec;
26 | import static com.fizzed.bigmap.Comparators.autoComparator;
27 |
28 | abstract public class AbstractBigMapBuilder extends AbstractBigObjectBuilder {
29 |
30 | protected Class keyClass;
31 | protected Class valueClass;
32 | protected ByteCodec keyCodec;
33 | protected Comparator keyComparator;
34 | protected ByteCodec valueCodec;
35 |
36 | public T setKeyType(Class keyType) {
37 | this.setKeyType(keyType, resolveCodec(keyType));
38 | return (T)this;
39 | }
40 |
41 | public T setKeyType(Class keyType, Comparator keyComparator) {
42 | this.setKeyType(keyType, resolveCodec(keyType), keyComparator);
43 | return (T)this;
44 | }
45 |
46 | public T setKeyType(Class keyType, ByteCodec keyCodec) {
47 | this.setKeyType(keyType, keyCodec, autoComparator(keyType));
48 | return (T)this;
49 | }
50 |
51 | public T setKeyType(Class keyType, ByteCodec keyCodec, Comparator keyComparator) {
52 | Objects.requireNonNull(keyType, "keyType was null");
53 | Objects.requireNonNull(keyCodec, "keyCodec was null");
54 | // keyComparator is optional
55 | this.keyClass = keyType;
56 | this.keyCodec = keyCodec;
57 | this.keyComparator = keyComparator;
58 | return (T)this;
59 | }
60 |
61 | public T setValueType(Class valueType) {
62 | this.setValueType(valueType, resolveCodec(valueType));
63 | return (T)this;
64 | }
65 |
66 | public T setValueType(Class valueType, ByteCodec valueCodec) {
67 | this.valueClass = valueType;
68 | this.valueCodec = valueCodec;
69 | return (T)this;
70 | }
71 |
72 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/AbstractBigObjectBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.impl;
17 |
18 | import com.fizzed.bigmap.BigObjectRegistry;
19 |
20 | import java.nio.file.Path;
21 |
22 | import static com.fizzed.bigmap.ByteCodecs.resolveCodec;
23 |
24 | abstract public class AbstractBigObjectBuilder {
25 |
26 | protected Path scratchDirectory;
27 | protected String name;
28 | protected BigObjectRegistry registry;
29 |
30 | public AbstractBigObjectBuilder() {
31 | this.scratchDirectory = BigMapHelper.resolveTempDirectory().resolve("bigobjects");
32 | }
33 |
34 | public T autoCloseObjects() {
35 | this.autoCloseObjects(BigObjectRegistry.getDefault());
36 | return (T)this;
37 | }
38 |
39 | public T autoCloseObjects(BigObjectRegistry registry) {
40 | this.registry = registry;
41 | return (T)this;
42 | }
43 |
44 | public T setScratchDirectory(Path scratchDirectory) {
45 | this.scratchDirectory = scratchDirectory;
46 | return (T)this;
47 | }
48 |
49 | public T setName(String name) {
50 | this.name = name;
51 | return (T)this;
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/AbstractBigObjectCloser.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap.impl;
2 |
3 | import com.fizzed.bigmap.BigObjectCloser;
4 |
5 | import java.io.IOException;
6 | import java.nio.file.Path;
7 | import java.util.UUID;
8 |
9 | abstract public class AbstractBigObjectCloser implements BigObjectCloser {
10 |
11 | private final UUID id;
12 | private final boolean persistent;
13 | private final Path directory;
14 | private boolean closed;
15 |
16 | public AbstractBigObjectCloser(UUID id, boolean persistent, Path directory) {
17 | this.id = id;
18 | this.persistent = persistent;
19 | this.directory = directory;
20 | }
21 |
22 | @Override
23 | public UUID getId() {
24 | return this.id;
25 | }
26 |
27 | @Override
28 | public boolean isPersistent() {
29 | return persistent;
30 | }
31 |
32 | @Override
33 | public Path getPath() {
34 | return directory;
35 | }
36 |
37 | @Override
38 | public boolean isClosed() {
39 | return this.closed;
40 | }
41 |
42 | @Override
43 | synchronized public void close() throws IOException {
44 | // do nothing on multiple closes
45 | if (this.closed) {
46 | return;
47 | }
48 |
49 | this.doClose();
50 |
51 | if (!this.persistent) {
52 | // remove the scratch directory
53 | BigMapHelper.recursivelyDelete(this.directory);
54 | }
55 |
56 | this.closed = true;
57 | }
58 |
59 | abstract public void doClose() throws IOException;
60 |
61 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/AbstractBigSetBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.impl;
17 |
18 | import com.fizzed.bigmap.ByteCodec;
19 |
20 | import java.util.Comparator;
21 | import java.util.Objects;
22 |
23 | import static com.fizzed.bigmap.ByteCodecs.resolveCodec;
24 | import static com.fizzed.bigmap.Comparators.autoComparator;
25 |
26 | abstract public class AbstractBigSetBuilder extends AbstractBigObjectBuilder {
27 |
28 | protected Class valueClass;
29 | protected ByteCodec valueCodec;
30 | protected Comparator valueComparator;
31 |
32 | public T setValueType(Class valueType) {
33 | this.setValueType(valueType, resolveCodec(valueType));
34 | return (T)this;
35 | }
36 |
37 | public T setValueType(Class valueType, Comparator valueComparator) {
38 | this.setValueType(valueType, resolveCodec(valueType), valueComparator);
39 | return (T)this;
40 | }
41 |
42 | public T setValueType(Class valueType, ByteCodec valueCodec) {
43 | this.setValueType(valueType, valueCodec, autoComparator(valueType));
44 | return (T)this;
45 | }
46 |
47 | public T setValueType(Class valueType, ByteCodec valueCodec, Comparator valueComparator) {
48 | Objects.requireNonNull(valueType, "valueType was null");
49 | Objects.requireNonNull(valueCodec, "valueCodec was null");
50 | // valueComparator is optional
51 | this.valueClass = valueType;
52 | this.valueCodec = valueCodec;
53 | this.valueComparator = valueComparator;
54 | return (T)this;
55 | }
56 |
57 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/BigLinkedMapCloser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.impl;
17 |
18 | import com.fizzed.bigmap.BigMap;
19 |
20 | import java.io.IOException;
21 | import java.nio.file.Path;
22 | import java.util.UUID;
23 |
24 | public class BigLinkedMapCloser extends AbstractBigObjectCloser {
25 |
26 | private final BigMap dataMap;
27 | private final BigMap insertOrderToKeyMap;
28 | private final BigMap keyToInsertOrderMap;
29 |
30 | public BigLinkedMapCloser(
31 | UUID id,
32 | boolean persistent,
33 | Path directory,
34 | BigMap dataMap,
35 | BigMap insertOrderToKeyMap,
36 | BigMap keyToInsertOrderMap) {
37 |
38 | super(id, persistent, directory);
39 | this.dataMap = dataMap;
40 | this.insertOrderToKeyMap = insertOrderToKeyMap;
41 | this.keyToInsertOrderMap = keyToInsertOrderMap;
42 | }
43 |
44 | @Override
45 | public void doClose() throws IOException {
46 | this.dataMap.close();
47 | this.insertOrderToKeyMap.close();
48 | this.keyToInsertOrderMap.close();
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/BigMapEntrySet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.impl;
17 |
18 | import com.fizzed.bigmap.BigMap;
19 |
20 | import javax.print.attribute.UnmodifiableSetException;
21 | import java.util.Collection;
22 | import java.util.Iterator;
23 | import java.util.Map.Entry;
24 | import java.util.Set;
25 |
26 | public class BigMapEntrySet implements Set> {
27 |
28 | private final BigMap map;
29 |
30 | public BigMapEntrySet(BigMap map) {
31 | this.map = map;
32 | }
33 |
34 | @Override
35 | public int size() {
36 | return this.map.size();
37 | }
38 |
39 | @Override
40 | public boolean isEmpty() {
41 | return this.map.isEmpty();
42 | }
43 |
44 | @Override
45 | public boolean contains(Object o) {
46 | throw new UnsupportedOperationException();
47 | }
48 |
49 | @Override
50 | public void clear() {
51 | this.map.clear();
52 | }
53 |
54 | public Iterator> iterator() {
55 | final Iterator> iterator = this.map.forwardIterator();
56 |
57 | return new Iterator>() {
58 | @Override
59 | public boolean hasNext() {
60 | return iterator.hasNext();
61 | }
62 |
63 | @Override
64 | public Entry next() {
65 | return iterator.next();
66 | }
67 | };
68 | }
69 |
70 | @Override
71 | public Object[] toArray() {
72 | throw new UnsupportedOperationException();
73 | }
74 |
75 | @Override
76 | public T[] toArray(T[] a) {
77 | throw new UnsupportedOperationException();
78 | }
79 |
80 | @Override
81 | public boolean add(Entry e) {
82 | throw new UnmodifiableSetException();
83 | }
84 |
85 | @Override
86 | public boolean remove(Object o) {
87 | throw new UnmodifiableSetException();
88 | }
89 |
90 | @Override
91 | public boolean containsAll(Collection> c) {
92 | throw new UnsupportedOperationException();
93 | }
94 |
95 | @Override
96 | public boolean addAll(Collection extends Entry> c) {
97 | throw new UnmodifiableSetException();
98 | }
99 |
100 | @Override
101 | public boolean retainAll(Collection> c) {
102 | throw new UnmodifiableSetException();
103 | }
104 |
105 | @Override
106 | public boolean removeAll(Collection> c) {
107 | throw new UnmodifiableSetException();
108 | }
109 |
110 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/BigMapKeySet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.impl;
17 |
18 | import com.fizzed.bigmap.BigMap;
19 |
20 | import javax.print.attribute.UnmodifiableSetException;
21 | import java.util.Collection;
22 | import java.util.Iterator;
23 | import java.util.Set;
24 | import java.util.Map.Entry;
25 |
26 | public class BigMapKeySet implements Set {
27 |
28 | private final BigMap map;
29 |
30 | public BigMapKeySet(BigMap map) {
31 | this.map = map;
32 | }
33 |
34 | @Override
35 | public int size() {
36 | return this.map.size();
37 | }
38 |
39 | @Override
40 | public boolean isEmpty() {
41 | return this.map.isEmpty();
42 | }
43 |
44 | @Override
45 | public boolean remove(Object key) {
46 | return this.map.remove(key) != null;
47 | }
48 |
49 | @Override
50 | public boolean contains(Object key) {
51 | return this.map.containsKey(key);
52 | }
53 |
54 | @Override
55 | public void clear() {
56 | this.map.clear();
57 | }
58 |
59 | public Iterator iterator() {
60 | final Iterator> iterator = this.map.forwardIterator();
61 |
62 | return new Iterator() {
63 | @Override
64 | public boolean hasNext() {
65 | return iterator.hasNext();
66 | }
67 |
68 | @Override
69 | public K next() {
70 | final Entry entry = iterator.next();
71 |
72 | return entry.getKey();
73 | }
74 | };
75 | }
76 |
77 | @Override
78 | public Object[] toArray() {
79 | throw new UnsupportedOperationException();
80 | }
81 |
82 | @Override
83 | public T[] toArray(T[] a) {
84 | throw new UnsupportedOperationException();
85 | }
86 |
87 | @Override
88 | public boolean add(K e) {
89 | throw new UnmodifiableSetException();
90 | }
91 |
92 | @Override
93 | public boolean containsAll(Collection> c) {
94 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
95 | }
96 |
97 | @Override
98 | public boolean addAll(Collection extends K> c) {
99 | throw new UnmodifiableSetException();
100 | }
101 |
102 | @Override
103 | public boolean retainAll(Collection> c) {
104 | throw new UnmodifiableSetException();
105 | }
106 |
107 | @Override
108 | public boolean removeAll(Collection> c) {
109 | throw new UnmodifiableSetException();
110 | }
111 |
112 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/BigMapValueCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.impl;
17 |
18 | import com.fizzed.bigmap.BigMap;
19 | import com.fizzed.bigmap.BigMapNonScalableException;
20 |
21 | import java.util.Collection;
22 | import java.util.Iterator;
23 | import java.util.Map.Entry;
24 |
25 | public class BigMapValueCollection implements Collection {
26 |
27 | private final BigMap map;
28 |
29 | public BigMapValueCollection(BigMap map) {
30 | this.map = map;
31 | }
32 |
33 | @Override
34 | public int size() {
35 | return this.map.size();
36 | }
37 |
38 | @Override
39 | public boolean isEmpty() {
40 | return this.map.isEmpty();
41 | }
42 |
43 | @Override
44 | public boolean contains(Object o) {
45 | throw new BigMapNonScalableException("Checking if a value exists is a bad performance decision");
46 | }
47 |
48 | @Override
49 | public void clear() {
50 | this.map.clear();
51 | }
52 |
53 | public Iterator iterator() {
54 | final Iterator> iterator = this.map.forwardIterator();
55 |
56 | return new Iterator() {
57 | @Override
58 | public boolean hasNext() {
59 | return iterator.hasNext();
60 | }
61 |
62 | @Override
63 | public V next() {
64 | final Entry entry = iterator.next();
65 |
66 | return entry.getValue();
67 | }
68 | };
69 | }
70 |
71 | @Override
72 | public Object[] toArray() {
73 | throw new UnsupportedOperationException();
74 | }
75 |
76 | @Override
77 | public T[] toArray(T[] a) {
78 | throw new UnsupportedOperationException();
79 | }
80 |
81 | @Override
82 | public boolean add(V e) {
83 | throw new UnsupportedOperationException();
84 | }
85 |
86 | @Override
87 | public boolean remove(Object o) {
88 | throw new UnsupportedOperationException();
89 | }
90 |
91 | @Override
92 | public boolean containsAll(Collection> c) {
93 | throw new BigMapNonScalableException("Checking if a value exists is a bad performance decision");
94 | }
95 |
96 | @Override
97 | public boolean addAll(Collection extends V> c) {
98 | throw new UnsupportedOperationException();
99 | }
100 |
101 | @Override
102 | public boolean removeAll(Collection> c) {
103 | throw new UnsupportedOperationException();
104 | }
105 |
106 | @Override
107 | public boolean retainAll(Collection> c) {
108 | throw new UnsupportedOperationException();
109 | }
110 |
111 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/BigObjectWeakReference.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap.impl;
2 |
3 | import com.fizzed.bigmap.BigObject;
4 |
5 | import java.lang.ref.ReferenceQueue;
6 | import java.lang.ref.WeakReference;
7 | import java.nio.file.Path;
8 | import java.util.UUID;
9 | import java.util.concurrent.ConcurrentHashMap;
10 |
11 | public class BigObjectWeakReference extends WeakReference {
12 |
13 | private final UUID id;
14 |
15 | public BigObjectWeakReference(BigObject bigObject, ReferenceQueue referenceQueue) {
16 | super (bigObject, referenceQueue);
17 | this.id = bigObject.getId();
18 | }
19 |
20 | public UUID getId() {
21 | return id;
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/KeyValueBytes.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap.impl;
2 |
3 | public class KeyValueBytes {
4 |
5 | private final byte[] key;
6 | private final byte[] value;
7 |
8 | public KeyValueBytes(byte[] key, byte[] value) {
9 | this.key = key;
10 | this.value = value;
11 | }
12 |
13 | public byte[] getKey() {
14 | return key;
15 | }
16 |
17 | public byte[] getValue() {
18 | return value;
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/MapMutableValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.impl;
17 |
18 | import com.fizzed.bigmap.MutableValue;
19 |
20 | import java.io.IOException;
21 | import java.util.Map;
22 |
23 | public class MapMutableValue implements MutableValue {
24 |
25 | private final Map map;
26 | private final K key;
27 | private V value;
28 | private final boolean wasInitiallyNull;
29 | private boolean closed;
30 |
31 | public MapMutableValue(Map map, K key, V value) {
32 | this.map = map;
33 | this.key = key;
34 | this.value = value;
35 | this.wasInitiallyNull = value == null;
36 | }
37 |
38 | @Override
39 | protected void finalize() {
40 | if (!this.closed) {
41 | System.err.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
42 | System.err.println("MutableValue was not closed! Please check your code for improper usage!");
43 | System.err.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
44 | }
45 | }
46 |
47 | @Override
48 | public boolean isPresent() {
49 | return this.value != null;
50 | }
51 |
52 | @Override
53 | public V get() {
54 | return this.value;
55 | }
56 |
57 | @Override
58 | public void set(V value) {
59 | this.value = value;
60 | }
61 |
62 | @Override
63 | public void close() throws RuntimeException {
64 | this.closed = true;
65 |
66 | // now, if the value is/was null
67 | if (this.wasInitiallyNull && value == null) {
68 | // there's nothing to actually do
69 | } else if (value == null) {
70 | // this is essentially a delete of the key, since null values cannot be placed into BigMaps
71 | this.map.remove(this.key);
72 | } else {
73 | // otherwise, put the value back in
74 | this.map.put(this.key, this.value);
75 | }
76 | }
77 |
78 | }
--------------------------------------------------------------------------------
/bigmap-core/src/main/java/com/fizzed/bigmap/impl/None.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap.impl;
2 |
3 | public class None {
4 |
5 | static public final None NONE = new None();
6 |
7 | private None() {}
8 |
9 | }
--------------------------------------------------------------------------------
/bigmap-core/src/test/java/com/fizzed/bigmap/BytesTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.crux.util.Base16;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.hamcrest.MatcherAssert.assertThat;
22 | import static org.hamcrest.Matchers.is;
23 |
24 | public class BytesTest {
25 |
26 | @Test
27 | public void startsWith() {
28 | byte[] a = Base16.decode("01");
29 | byte[] b = Base16.decode("0102030405060708");
30 |
31 | assertThat(Bytes.startsWith(null, null), is(true));
32 | assertThat(Bytes.startsWith(a, null), is(false));
33 | assertThat(Bytes.startsWith(a, Base16.decode("00")), is(false));
34 | assertThat(Bytes.startsWith(a, Base16.decode("01")), is(true));
35 | assertThat(Bytes.startsWith(a, Base16.decode("0102")), is(false));
36 | assertThat(Bytes.startsWith(b, Base16.decode("0102")), is(true));
37 | assertThat(Bytes.startsWith(Base16.decode("0FF0FF"), Base16.decode("0FF0FF")), is(true));
38 | }
39 |
40 | @Test
41 | public void startsWithWildcard() {
42 | byte[] a = Base16.decode("01");
43 | byte[] b = Base16.decode("0102030405060708");
44 |
45 | assertThat(Bytes.startsWith(a, Base16.decode("00"), (byte)1), is(false));
46 | assertThat(Bytes.startsWith(a, Base16.decode("01"), (byte)1), is(true));
47 | assertThat(Bytes.startsWith(a, Base16.decode("01"), null), is(true));
48 | assertThat(Bytes.startsWith(a, Base16.decode("0102"), (byte)0), is(false));
49 | assertThat(Bytes.startsWith(b, Base16.decode("010003"), (byte)1), is(false));
50 | assertThat(Bytes.startsWith(b, Base16.decode("010003"), (byte)0), is(true));
51 | assertThat(Bytes.startsWith(b, Base16.decode("010203"), (byte)0), is(true));
52 | }
53 |
54 | @Test
55 | public void endsWith() {
56 | byte[] a = Base16.decode("01");
57 | byte[] b = Base16.decode("0102030405060708");
58 |
59 | assertThat(Bytes.endsWith(null, null), is(true));
60 | assertThat(Bytes.endsWith(a, null), is(false));
61 | assertThat(Bytes.endsWith(a, Base16.decode("00")), is(false));
62 | assertThat(Bytes.endsWith(a, Base16.decode("01")), is(true));
63 | assertThat(Bytes.endsWith(a, Base16.decode("0001")), is(false));
64 | assertThat(Bytes.endsWith(b, Base16.decode("0708")), is(true));
65 | assertThat(Bytes.endsWith(Base16.decode("0FF0FF"), Base16.decode("0FF0FF")), is(true));
66 | }
67 |
68 | @Test
69 | public void endsWithWildcard() {
70 | byte[] a = Base16.decode("01");
71 | byte[] b = Base16.decode("0102030405060708");
72 |
73 | assertThat(Bytes.endsWith(null, null), is(true));
74 | assertThat(Bytes.endsWith(a, null), is(false));
75 | assertThat(Bytes.endsWith(a, Base16.decode("00")), is(false));
76 | assertThat(Bytes.endsWith(a, Base16.decode("01")), is(true));
77 | assertThat(Bytes.endsWith(a, Base16.decode("0001")), is(false));
78 | assertThat(Bytes.endsWith(b, Base16.decode("0707"), (byte)0), is(false));
79 | assertThat(Bytes.endsWith(b, Base16.decode("0707"), (byte)7), is(true));
80 | assertThat(Bytes.endsWith(b, Base16.decode("0708"), (byte)2), is(true));
81 | assertThat(Bytes.endsWith(Base16.decode("0FF0FF"), Base16.decode("0FFFFF"), (byte)0xFF), is(true));
82 | }
83 |
84 | }
--------------------------------------------------------------------------------
/bigmap-core/src/test/java/com/fizzed/bigmap/ComparatorsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import org.junit.jupiter.api.Test;
19 |
20 | import static org.hamcrest.MatcherAssert.assertThat;
21 | import static org.hamcrest.Matchers.is;
22 | import static org.hamcrest.Matchers.not;
23 | import static org.hamcrest.Matchers.nullValue;
24 |
25 | public class ComparatorsTest {
26 |
27 | @Test
28 | public void autoComparator() {
29 |
30 | assertThat(Comparators.autoComparator(Long.class), is(not(nullValue())));
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/bigmap-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | bigmap-demo
5 | bigmap-demo
6 | jar
7 |
8 |
9 | com.fizzed
10 | bigmap
11 | 1.1.1-SNAPSHOT
12 |
13 |
14 |
15 | true
16 |
17 |
18 |
19 |
20 |
21 | com.fizzed
22 | bigmap-core
23 |
24 |
25 |
26 | com.fizzed
27 | bigmap-kryo
28 |
29 |
30 |
31 | com.fizzed
32 | bigmap-tokyocabinet
33 |
34 |
35 |
36 | com.fizzed
37 | bigmap-leveldb
38 |
39 |
40 |
41 | com.fizzed
42 | bigmap-rocksdb
43 |
44 |
45 |
46 |
47 |
48 | org.hamcrest
49 | java-hamcrest
50 | test
51 |
52 |
53 |
54 | ch.qos.logback
55 | logback-classic
56 | test
57 |
58 |
59 |
60 | com.fizzed
61 | crux-util
62 | test
63 |
64 |
65 |
66 | com.github.oshi
67 | oshi-core
68 | 6.4.0
69 | test
70 |
71 |
72 |
73 |
74 | com.h2database
75 | h2-mvstore
76 | 2.1.214
77 | test
78 |
79 |
80 |
81 |
82 | com.fizzed
83 | tkrzw-linux-x64
84 | 0.0.2
85 | test
86 |
87 |
88 |
89 |
90 | org.mapdb
91 | mapdb
92 | 3.0.9
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/bigmap-demo/src/test/java/com/fizzed/bigmap/MapDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.crux.util.StopWatch;
19 |
20 | import java.io.Serializable;
21 | import java.nio.file.Paths;
22 | import java.util.SortedMap;
23 | import java.util.TreeMap;
24 |
25 | public class MapDemo {
26 |
27 | static public void main(String[] args) throws Exception {
28 | final SortedMap map = new TreeMap<>();
29 |
30 | map.firstKey();
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/bigmap-demo/src/test/java/com/fizzed/bigmap/OffheapMap.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap;
2 |
3 | import java.nio.file.Path;
4 | import java.util.Collection;
5 | import java.util.Map;
6 | import java.util.Set;
7 |
8 | public class OffheapMap implements Map {
9 |
10 | private final Path directory;
11 | private final Map wrapped;
12 |
13 | public OffheapMap(Path directory, Map wrapped) {
14 | this.directory = directory;
15 | this.wrapped = wrapped;
16 | }
17 |
18 | public Path getDirectory() {
19 | return directory;
20 | }
21 |
22 | @Override
23 | public int size() {
24 | return this.wrapped.size();
25 | }
26 |
27 | @Override
28 | public boolean isEmpty() {
29 | return this.wrapped.isEmpty();
30 | }
31 |
32 | @Override
33 | public boolean containsKey(Object key) {
34 | return this.wrapped.containsKey(key);
35 | }
36 |
37 | @Override
38 | public boolean containsValue(Object value) {
39 | return this.wrapped.containsValue(value);
40 | }
41 |
42 | @Override
43 | public V get(Object key) {
44 | return this.wrapped.get(key);
45 | }
46 |
47 | @Override
48 | public V put(K key, V value) {
49 | return this.wrapped.put(key, value);
50 | }
51 |
52 | @Override
53 | public V remove(Object key) {
54 | return this.wrapped.remove(key);
55 | }
56 |
57 | @Override
58 | public void putAll(Map extends K, ? extends V> m) {
59 | this.wrapped.putAll(m);
60 | }
61 |
62 | @Override
63 | public void clear() {
64 | this.wrapped.clear();
65 | }
66 |
67 | @Override
68 | public Set keySet() {
69 | return this.wrapped.keySet();
70 | }
71 |
72 | @Override
73 | public Collection values() {
74 | return this.wrapped.values();
75 | }
76 |
77 | @Override
78 | public Set> entrySet() {
79 | return this.wrapped.entrySet();
80 | }
81 | }
--------------------------------------------------------------------------------
/bigmap-demo/src/test/java/com/fizzed/bigmap/PerfManyMaps.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.kryo.KryoByteCodec;
19 | import com.fizzed.bigmap.leveldb.LevelBigMapBuilder;
20 | import com.fizzed.bigmap.rocksdb.RocksBigLinkedMapBuilder;
21 | import com.fizzed.bigmap.rocksdb.RocksBigMapBuilder;
22 | import com.fizzed.bigmap.tokyocabinet.TokyoBigMapBuilder;
23 | import com.fizzed.crux.util.StopWatch;
24 | import oshi.SystemInfo;
25 | import oshi.software.os.OSProcess;
26 | import oshi.software.os.OperatingSystem;
27 |
28 | import java.io.IOException;
29 | import java.io.Serializable;
30 | import java.io.UncheckedIOException;
31 | import java.nio.file.Files;
32 | import java.nio.file.Path;
33 | import java.nio.file.Paths;
34 | import java.util.*;
35 |
36 | public class PerfManyMaps extends AbstractPerf {
37 |
38 | static public void main(String[] args) throws Exception {
39 | new PerfManyMaps().run();
40 | }
41 |
42 | public void run() throws Exception {
43 | //
44 | // config options
45 | //
46 |
47 | String type = "TokyoBigMap";
48 | // String type = "LevelBigMap";
49 | // String type = "RocksBigLinkedMap";
50 | // String type = "RocksBigMap";
51 | // String type = "MVStoreMap";
52 | // String type = "TokyoCabinetMap";
53 | // String type = "KyotoCabinetMap";
54 | // String type = "TkrzwCabinetMap";
55 | int mapCount = 20000;
56 | int entryCountPerMap = 3000;
57 |
58 | logMemory("At startup");
59 |
60 | for (int j = 0; j < mapCount; j++) {
61 | final Map map = buildMap(type, j);
62 |
63 | if (j % 500 == 0) {
64 | logMemory("Map #" + j);
65 | } else if (j % 25 == 0) {
66 | log.info("Processed map #{}", j);
67 | }
68 |
69 | // add some entries
70 | for (int i = 0; i < entryCountPerMap; i++) {
71 | Item item = new Item();
72 | item.a = (long) i;
73 | item.b = "This is sooooo cool dude! " + i;
74 | item.c = "Look mom no hands " + i;
75 | item.d = "Woooo baby! " + i;
76 | item.e = "Woza! " + i;
77 | item.g = "Blah blah aljlfjalfrjsd;lfjsdlfjsdlafjsdlfjsdlfjsdlfjsldafjlsdfjsdlfjsdlfjsdalfjsdlfjsdlfjdsjf" + i;
78 | item.h = i;
79 | map.put(i+"", item);
80 | }
81 |
82 | // get some entries
83 | for (int i = 0; i < entryCountPerMap; i += 200) {
84 | map.get(i+"");
85 | }
86 |
87 | // try a bunch of iterator's
88 | for (int i = 0; i < 1000; i++) {
89 | Collection- values = map.values();
90 | }
91 |
92 | // close map (does it clean up its resources)
93 | ((BigMap)map).close();
94 | }
95 |
96 | logMemory("After " + mapCount + " maps created & closed");
97 | }
98 |
99 | }
--------------------------------------------------------------------------------
/bigmap-demo/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/bigmap-integration-tests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | bigmap-integration-tests
5 | bigmap-integration-tests
6 | jar
7 |
8 |
9 | com.fizzed
10 | bigmap
11 | 1.1.1-SNAPSHOT
12 |
13 |
14 |
15 | true
16 |
17 |
18 |
19 |
20 |
21 | com.fizzed
22 | bigmap-core
23 |
24 |
25 |
26 | com.fizzed
27 | bigmap-kryo
28 |
29 |
30 |
31 | com.fizzed
32 | bigmap-leveldb
33 |
34 |
35 |
36 | com.fizzed
37 | bigmap-rocksdb
38 |
39 |
40 |
41 | com.fizzed
42 | bigmap-tokyocabinet
43 |
44 |
45 |
46 |
47 | com.fizzed
48 | tokyocabinet-all-natives
49 | provided
50 |
51 |
52 |
53 | com.fizzed
54 | bigmap-tkrzw
55 |
56 |
57 |
58 |
59 | com.fizzed
60 | tkrzw-all-natives
61 | provided
62 |
63 |
64 |
65 |
66 |
67 | org.hamcrest
68 | java-hamcrest
69 | test
70 |
71 |
72 |
73 | org.junit.jupiter
74 | junit-jupiter
75 | test
76 |
77 |
78 |
79 | ch.qos.logback
80 | logback-classic
81 | test
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/AbstractBigLinkedSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.junit.jupiter.api.Test;
20 | import java.io.IOException;
21 | import java.util.*;
22 | import static com.fizzed.bigmap.impl.BigMapHelper.*;
23 | import static org.hamcrest.CoreMatchers.hasItems;
24 | import static org.hamcrest.MatcherAssert.assertThat;
25 | import static org.hamcrest.Matchers.*;
26 |
27 | abstract public class AbstractBigLinkedSetTest extends AbstractBigSetTest {
28 |
29 | @Test @Disabled
30 | public void byteSizeTracking() {
31 | // we want to just ignore this
32 | }
33 |
34 | @Test
35 | public void addOrdered() {
36 | final Set set = this.newSet(Long.class);
37 |
38 | set.add(5L);
39 | set.add(1L);
40 | set.add(3L);
41 | set.add(2L);
42 |
43 | assertThat(toValueList(set), hasItems(5L, 1L, 3L, 2L));
44 |
45 | // adding a value does not change its insert ordering
46 | set.add(5L);
47 |
48 | assertThat(toValueList(set), hasItems(5L, 1L, 3L, 2L));
49 | }
50 |
51 | @Test
52 | public void removeOrdered() throws IOException {
53 | final Set set = this.newSet(String.class);
54 |
55 | set.add("4");
56 | set.add("1");
57 | set.add("3");
58 | set.add("2");
59 |
60 | assertThat(set, hasSize(4));
61 | assertThat(toValueList(set), hasItems("4", "1", "3", "2"));
62 |
63 | boolean removed;
64 |
65 | removed = set.remove("1");
66 |
67 | assertThat(removed, is(true));
68 | assertThat(toValueList(set), hasItems("4", "3", "2"));
69 |
70 | // try to remove it again
71 | removed = set.remove("1");
72 |
73 | assertThat(removed, is(false));
74 | assertThat(toValueList(set), hasItems("4", "3", "2"));
75 |
76 | removed = set.remove("4");
77 |
78 | assertThat(removed, is(true));
79 | assertThat(toValueList(set), hasItems("3", "2"));
80 | }
81 |
82 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/JavaHashMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.junit.jupiter.api.Test;
20 | import java.util.HashMap;
21 | import java.util.Map;
22 |
23 | public class JavaHashMapTest extends AbstractBigMapTest {
24 |
25 | @Override
26 | public Map newMap(Class keyType, Class valueType) {
27 | return new HashMap<>();
28 | }
29 |
30 | @Test @Disabled("nulls are technically allowed with a java hashmap")
31 | public void putNullKey() {
32 | super.putNullKey();
33 | }
34 |
35 | @Test @Disabled("nulls are technically allowed with a java hashmap")
36 | public void putNullValue() {
37 | super.putNullKey();
38 | }
39 |
40 | @Test @Disabled
41 | public void putAndGetWithComplexObject() {}
42 |
43 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/JavaHashSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import java.util.HashSet;
22 | import java.util.Set;
23 |
24 | public class JavaHashSetTest extends AbstractBigSetTest {
25 |
26 | @Override
27 | public Set newSet(Class valueType) {
28 | return new HashSet<>();
29 | }
30 |
31 | @Test
32 | @Disabled
33 | public void addAndContainsWithComplexObject() { }
34 |
35 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/JavaLinkedHashMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import java.util.LinkedHashMap;
22 | import java.util.Map;
23 |
24 | public class JavaLinkedHashMapTest extends AbstractBigLinkedMapTest {
25 |
26 | @Override
27 | public Map newMap(Class keyType, Class valueType) {
28 | return new LinkedHashMap<>();
29 | }
30 |
31 | @Test
32 | @Disabled("nulls are technically allowed with a java hashmap")
33 | public void putNullKey() {
34 | super.putNullKey();
35 | }
36 |
37 | @Test @Disabled("nulls are technically allowed with a java hashmap")
38 | public void putNullValue() {
39 | super.putNullKey();
40 | }
41 |
42 | @Test @Disabled
43 | public void putAndGetWithComplexObject() {}
44 |
45 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/JavaTreeMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import java.util.Map;
22 | import java.util.TreeMap;
23 |
24 | public class JavaTreeMapTest extends AbstractBigMapTest {
25 |
26 | @Override
27 | public Map newMap(Class keyType, Class valueType) {
28 | return new TreeMap<>();
29 | }
30 |
31 | @Test
32 | @Disabled("nulls are technically allowed with a java hashmap")
33 | public void putNullValue() {
34 | super.putNullKey();
35 | }
36 |
37 | @Test @Disabled("nulls are technically NOT allowed with a java treemap")
38 | public void containsKeyWithNull() {
39 | super.containsKeyWithNull();
40 | }
41 |
42 | @Test @Disabled
43 | public void putAndGetWithComplexObject() {}
44 |
45 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/JavaTreeSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import java.util.Set;
22 | import java.util.TreeSet;
23 |
24 | public class JavaTreeSetTest extends AbstractBigSetTest {
25 |
26 | @Override
27 | public Set newSet(Class valueType) {
28 | return new TreeSet<>();
29 | }
30 |
31 | @Test
32 | @Disabled
33 | public void addAndContainsWithComplexObject() { }
34 |
35 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/LevelBigLinkedMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.leveldb.LevelBigLinkedMapBuilder;
19 |
20 | import java.nio.file.Paths;
21 | import java.util.Map;
22 |
23 | public class LevelBigLinkedMapTest extends AbstractBigLinkedMapTest {
24 |
25 | @Override
26 | public Map newMap(Class keyType, Class valueType) {
27 | return new LevelBigLinkedMapBuilder()
28 | .setScratchDirectory(Paths.get("target"))
29 | .setKeyType(keyType)
30 | .setValueType(valueType)
31 | .autoCloseObjects()
32 | .build();
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/LevelBigLinkedSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.leveldb.LevelBigLinkedSetBuilder;
19 |
20 | import java.nio.file.Paths;
21 | import java.util.Set;
22 |
23 | public class LevelBigLinkedSetTest extends AbstractBigLinkedSetTest {
24 |
25 | @Override
26 | public Set newSet(Class valueType) {
27 | return new LevelBigLinkedSetBuilder()
28 | .setScratchDirectory(Paths.get("target"))
29 | .setValueType(valueType)
30 | .autoCloseObjects()
31 | .build();
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/LevelBigMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.leveldb.LevelBigMapBuilder;
19 |
20 | import java.nio.file.Paths;
21 | import java.util.Map;
22 |
23 | public class LevelBigMapTest extends AbstractBigMapTest {
24 |
25 | @Override
26 | public Map newMap(Class keyType, Class valueType) {
27 | return new LevelBigMapBuilder()
28 | .setScratchDirectory(Paths.get("target"))
29 | .setKeyType(keyType)
30 | .setValueType(valueType)
31 | .autoCloseObjects()
32 | .build();
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/LevelBigSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.leveldb.LevelBigSetBuilder;
19 |
20 | import java.nio.file.Paths;
21 | import java.util.Set;
22 |
23 | public class LevelBigSetTest extends AbstractBigSetTest {
24 |
25 | @Override
26 | public Set newSet(Class valueType) {
27 | return new LevelBigSetBuilder()
28 | .setScratchDirectory(Paths.get("target"))
29 | .setValueType(valueType)
30 | .autoCloseObjects()
31 | .build();
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/RocksBigLinkedMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.rocksdb.RocksBigLinkedMapBuilder;
19 | import com.fizzed.jne.HardwareArchitecture;
20 | import com.fizzed.jne.NativeTarget;
21 | import com.fizzed.jne.OperatingSystem;
22 | import org.junit.jupiter.api.condition.DisabledIf;
23 |
24 | import java.nio.file.Paths;
25 | import java.util.Map;
26 |
27 | @DisabledIf("isUnsupportedOs")
28 | public class RocksBigLinkedMapTest extends AbstractBigLinkedMapTest {
29 |
30 | static public boolean isUnsupportedOs() {
31 | final NativeTarget current = NativeTarget.detect();
32 | return current.getOperatingSystem() == OperatingSystem.FREEBSD
33 | || current.getOperatingSystem() == OperatingSystem.OPENBSD
34 | || (current.getOperatingSystem() == OperatingSystem.WINDOWS && current.getHardwareArchitecture() == HardwareArchitecture.ARM64)
35 | || (current.getOperatingSystem() == OperatingSystem.LINUX && current.getHardwareArchitecture() == HardwareArchitecture.RISCV64);
36 | }
37 |
38 | @Override
39 | public Map newMap(Class keyType, Class valueType) {
40 | return new RocksBigLinkedMapBuilder()
41 | .setScratchDirectory(Paths.get("target"))
42 | .setKeyType(keyType)
43 | .setValueType(valueType)
44 | .autoCloseObjects()
45 | .build();
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/RocksBigLinkedSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.rocksdb.RocksBigLinkedSetBuilder;
19 | import com.fizzed.jne.HardwareArchitecture;
20 | import com.fizzed.jne.NativeTarget;
21 | import com.fizzed.jne.OperatingSystem;
22 | import org.junit.jupiter.api.condition.DisabledIf;
23 |
24 | import java.nio.file.Paths;
25 | import java.util.Set;
26 |
27 | @DisabledIf("isUnsupportedOs")
28 | public class RocksBigLinkedSetTest extends AbstractBigLinkedSetTest {
29 |
30 | static public boolean isUnsupportedOs() {
31 | final NativeTarget current = NativeTarget.detect();
32 | return current.getOperatingSystem() == OperatingSystem.FREEBSD
33 | || current.getOperatingSystem() == OperatingSystem.OPENBSD
34 | || (current.getOperatingSystem() == OperatingSystem.WINDOWS && current.getHardwareArchitecture() == HardwareArchitecture.ARM64)
35 | || (current.getOperatingSystem() == OperatingSystem.LINUX && current.getHardwareArchitecture() == HardwareArchitecture.RISCV64);
36 | }
37 |
38 | @Override
39 | public Set newSet(Class valueType) {
40 | return new RocksBigLinkedSetBuilder()
41 | .setScratchDirectory(Paths.get("target"))
42 | .setValueType(valueType)
43 | .autoCloseObjects()
44 | .build();
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/RocksBigMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.rocksdb.RocksBigMapBuilder;
19 | import com.fizzed.jne.HardwareArchitecture;
20 | import com.fizzed.jne.NativeTarget;
21 | import com.fizzed.jne.OperatingSystem;
22 | import org.junit.jupiter.api.condition.DisabledIf;
23 |
24 | import java.nio.file.Paths;
25 | import java.util.Map;
26 |
27 | @DisabledIf("isUnsupportedOs")
28 | public class RocksBigMapTest extends AbstractBigMapTest {
29 |
30 | static public boolean isUnsupportedOs() {
31 | final NativeTarget current = NativeTarget.detect();
32 | return current.getOperatingSystem() == OperatingSystem.FREEBSD
33 | || current.getOperatingSystem() == OperatingSystem.OPENBSD
34 | || (current.getOperatingSystem() == OperatingSystem.WINDOWS && current.getHardwareArchitecture() == HardwareArchitecture.ARM64)
35 | || (current.getOperatingSystem() == OperatingSystem.LINUX && current.getHardwareArchitecture() == HardwareArchitecture.RISCV64);
36 | }
37 |
38 | @Override
39 | public Map newMap(Class keyType, Class valueType) {
40 | return new RocksBigMapBuilder()
41 | .setScratchDirectory(Paths.get("target"))
42 | .setKeyType(keyType)
43 | .setValueType(valueType)
44 | .autoCloseObjects()
45 | .build();
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/RocksBigSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.rocksdb.RocksBigSetBuilder;
19 | import com.fizzed.jne.HardwareArchitecture;
20 | import com.fizzed.jne.NativeTarget;
21 | import com.fizzed.jne.OperatingSystem;
22 | import org.junit.jupiter.api.condition.DisabledIf;
23 |
24 | import java.nio.file.Paths;
25 | import java.util.Set;
26 |
27 | @DisabledIf("isUnsupportedOs")
28 | public class RocksBigSetTest extends AbstractBigSetTest {
29 |
30 | static public boolean isUnsupportedOs() {
31 | final NativeTarget current = NativeTarget.detect();
32 | return current.getOperatingSystem() == OperatingSystem.FREEBSD
33 | || current.getOperatingSystem() == OperatingSystem.OPENBSD
34 | || (current.getOperatingSystem() == OperatingSystem.WINDOWS && current.getHardwareArchitecture() == HardwareArchitecture.ARM64)
35 | || (current.getOperatingSystem() == OperatingSystem.LINUX && current.getHardwareArchitecture() == HardwareArchitecture.RISCV64);
36 | }
37 |
38 | @Override
39 | public Set newSet(Class valueType) {
40 | return new RocksBigSetBuilder()
41 | .setScratchDirectory(Paths.get("target"))
42 | .setValueType(valueType)
43 | .autoCloseObjects()
44 | .build();
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TestIdentifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import java.io.Serializable;
19 |
20 | public class TestIdentifier implements Serializable {
21 |
22 | private String domain;
23 | private String name;
24 |
25 | public TestIdentifier(String domain, String name) {
26 | this.domain = domain;
27 | this.name = name;
28 | }
29 |
30 | public String getDomain() {
31 | return domain;
32 | }
33 |
34 | public TestIdentifier setDomain(String domain) {
35 | this.domain = domain;
36 | return this;
37 | }
38 |
39 | public String getName() {
40 | return name;
41 | }
42 |
43 | public TestIdentifier setName(String name) {
44 | this.name = name;
45 | return this;
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TkrzwBigLinkedMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.tkrzw.TkrzwBigLinkedMapBuilder;
19 | import org.junit.jupiter.api.condition.DisabledOnOs;
20 | import org.junit.jupiter.api.condition.OS;
21 |
22 | import java.nio.file.Paths;
23 | import java.util.Map;
24 |
25 | //@DisabledOnOs({ OS.FREEBSD, OS.OPENBSD })
26 | public class TkrzwBigLinkedMapTest extends AbstractBigLinkedMapTest {
27 |
28 | @Override
29 | public Map newMap(Class keyType, Class valueType) {
30 | return new TkrzwBigLinkedMapBuilder()
31 | .setScratchDirectory(Paths.get("target"))
32 | .setKeyType(keyType)
33 | .setValueType(valueType)
34 | .autoCloseObjects()
35 | .build();
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TkrzwBigLinkedSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.tkrzw.TkrzwBigLinkedSetBuilder;
19 | import org.junit.jupiter.api.condition.DisabledOnOs;
20 | import org.junit.jupiter.api.condition.OS;
21 |
22 | import java.nio.file.Paths;
23 | import java.util.Set;
24 |
25 | //@DisabledOnOs({ OS.FREEBSD, OS.OPENBSD })
26 | public class TkrzwBigLinkedSetTest extends AbstractBigLinkedSetTest {
27 |
28 | @Override
29 | public Set newSet(Class valueType) {
30 | return new TkrzwBigLinkedSetBuilder()
31 | .setScratchDirectory(Paths.get("target"))
32 | .setValueType(valueType)
33 | .autoCloseObjects()
34 | .build();
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TkrzwBigMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.tkrzw.TkrzwBigMapBuilder;
19 | import org.junit.jupiter.api.condition.DisabledOnOs;
20 | import org.junit.jupiter.api.condition.OS;
21 |
22 | import java.nio.file.Paths;
23 | import java.util.Map;
24 |
25 | //@DisabledOnOs({ OS.FREEBSD, OS.OPENBSD })
26 | public class TkrzwBigMapTest extends AbstractBigMapTest {
27 |
28 | @Override
29 | public Map newMap(Class keyType, Class valueType) {
30 | return new TkrzwBigMapBuilder()
31 | .setScratchDirectory(Paths.get("target"))
32 | .setKeyType(keyType)
33 | .setValueType(valueType)
34 | .autoCloseObjects()
35 | .build();
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TkrzwBigSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.tkrzw.TkrzwBigSetBuilder;
19 | import org.junit.jupiter.api.condition.DisabledOnOs;
20 | import org.junit.jupiter.api.condition.OS;
21 |
22 | import java.nio.file.Paths;
23 | import java.util.Set;
24 |
25 | //@DisabledOnOs({ OS.FREEBSD, OS.OPENBSD })
26 | public class TkrzwBigSetTest extends AbstractBigSetTest {
27 |
28 | @Override
29 | public Set newSet(Class valueType) {
30 | return new TkrzwBigSetBuilder()
31 | .setScratchDirectory(Paths.get("target"))
32 | .setValueType(valueType)
33 | .autoCloseObjects()
34 | .build();
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TokyoBigLinkedMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.tokyocabinet.TokyoBigLinkedMapBuilder;
19 | import org.junit.jupiter.api.condition.DisabledOnOs;
20 | import org.junit.jupiter.api.condition.OS;
21 |
22 | import java.nio.file.Paths;
23 | import java.util.Map;
24 |
25 | @DisabledOnOs({ OS.WINDOWS })
26 | public class TokyoBigLinkedMapTest extends AbstractBigLinkedMapTest {
27 |
28 | @Override
29 | public Map newMap(Class keyType, Class valueType) {
30 | return new TokyoBigLinkedMapBuilder()
31 | .setScratchDirectory(Paths.get("target"))
32 | .setKeyType(keyType)
33 | .setValueType(valueType)
34 | .autoCloseObjects()
35 | .build();
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TokyoBigLinkedSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.tokyocabinet.TokyoBigLinkedSetBuilder;
19 | import org.junit.jupiter.api.condition.DisabledOnOs;
20 | import org.junit.jupiter.api.condition.OS;
21 |
22 | import java.nio.file.Paths;
23 | import java.util.Set;
24 |
25 | @DisabledOnOs({ OS.WINDOWS })
26 | public class TokyoBigLinkedSetTest extends AbstractBigLinkedSetTest {
27 |
28 | @Override
29 | public Set newSet(Class valueType) {
30 | return new TokyoBigLinkedSetBuilder()
31 | .setScratchDirectory(Paths.get("target"))
32 | .setValueType(valueType)
33 | .autoCloseObjects()
34 | .build();
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TokyoBigMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.tokyocabinet.TokyoBigMapBuilder;
19 | import org.junit.jupiter.api.condition.DisabledOnOs;
20 | import org.junit.jupiter.api.condition.OS;
21 |
22 | import java.nio.file.Paths;
23 | import java.util.Map;
24 |
25 | @DisabledOnOs({ OS.WINDOWS })
26 | public class TokyoBigMapTest extends AbstractBigMapTest {
27 |
28 | @Override
29 | public Map newMap(Class keyType, Class valueType) {
30 | return new TokyoBigMapBuilder()
31 | .setScratchDirectory(Paths.get("target"))
32 | .setKeyType(keyType)
33 | .setValueType(valueType)
34 | .autoCloseObjects()
35 | .build();
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/bigmap-integration-tests/src/test/java/com/fizzed/bigmap/TokyoBigSetTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap;
17 |
18 | import com.fizzed.bigmap.tokyocabinet.TokyoBigSetBuilder;
19 | import org.junit.jupiter.api.condition.DisabledOnOs;
20 | import org.junit.jupiter.api.condition.OS;
21 |
22 | import java.nio.file.Paths;
23 | import java.util.Set;
24 |
25 | @DisabledOnOs({ OS.WINDOWS })
26 | public class TokyoBigSetTest extends AbstractBigSetTest {
27 |
28 | @Override
29 | public Set newSet(Class valueType) {
30 | return new TokyoBigSetBuilder()
31 | .setScratchDirectory(Paths.get("target"))
32 | .setValueType(valueType)
33 | .autoCloseObjects()
34 | .build();
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/bigmap-jackson/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | bigmap-jackson
5 | bigmap-jackson
6 | jar
7 |
8 |
9 | com.fizzed
10 | bigmap
11 | 1.1.1-SNAPSHOT
12 |
13 |
14 |
15 |
16 |
17 | com.fizzed
18 | bigmap-core
19 |
20 |
21 |
22 | com.fasterxml.jackson.core
23 | jackson-databind
24 | 2.9.2
25 | provided
26 |
27 |
28 |
29 |
30 |
31 | com.fizzed
32 | crux-util
33 | test
34 |
35 |
36 |
37 | org.hamcrest
38 | java-hamcrest
39 | test
40 |
41 |
42 |
43 | org.junit.jupiter
44 | junit-jupiter
45 | test
46 |
47 |
48 |
49 | ch.qos.logback
50 | logback-classic
51 | test
52 |
53 |
54 |
55 | com.fizzed
56 | crux-jackson
57 | 1.0.41
58 | test
59 |
60 |
61 |
62 | joda-time
63 | joda-time
64 | 2.10.9
65 | test
66 |
67 |
68 |
69 | org.joda
70 | joda-money
71 | 0.11
72 | test
73 |
74 |
75 |
76 | com.fasterxml.jackson.datatype
77 | jackson-datatype-joda
78 | 2.9.2
79 | test
80 |
81 |
82 |
83 | com.fasterxml.jackson.module
84 | jackson-module-parameter-names
85 | 2.9.2
86 | test
87 |
88 |
89 |
90 | com.fasterxml.jackson.datatype
91 | jackson-datatype-jdk8
92 | 2.9.2
93 | test
94 |
95 |
96 |
97 | com.fasterxml.jackson.datatype
98 | jackson-datatype-jsr310
99 | 2.9.2
100 | test
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/bigmap-jackson/src/main/java/com/fizzed/bigmap/jackson/JacksonByteCodec.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap.jackson;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 | import com.fizzed.bigmap.ByteCodec;
5 |
6 | import java.io.IOException;
7 | import java.io.UncheckedIOException;
8 |
9 | import static com.fizzed.bigmap.ByteCodecs.ZERO_BYTES;
10 |
11 | public class JacksonByteCodec implements ByteCodec {
12 |
13 | private final ObjectMapper objectMapper;
14 | private final Class type;
15 |
16 | public JacksonByteCodec(Class type) {
17 | this(type, new ObjectMapper());
18 | }
19 |
20 | public JacksonByteCodec(Class type, ObjectMapper objectMapper) {
21 | this.objectMapper = objectMapper;
22 | this.type = type;
23 | }
24 |
25 | @Override
26 | public byte[] serialize(K value) {
27 | if (value == null) {
28 | return ZERO_BYTES;
29 | }
30 | try {
31 | return this.objectMapper.writeValueAsBytes(value);
32 | } catch (IOException e) {
33 | throw new UncheckedIOException(e);
34 | }
35 | }
36 |
37 | @Override
38 | public K deserialize(byte[] bytes) {
39 | if (bytes == null || bytes.length == 0) {
40 | return null;
41 | }
42 | try {
43 | return this.objectMapper.readValue(bytes, type);
44 | } catch (IOException e) {
45 | throw new UncheckedIOException(e);
46 | }
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/bigmap-kryo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | bigmap-kryo
5 | bigmap-kryo
6 | jar
7 |
8 |
9 | com.fizzed
10 | bigmap
11 | 1.1.1-SNAPSHOT
12 |
13 |
14 |
15 |
16 |
17 | com.fizzed
18 | bigmap-core
19 |
20 |
21 |
22 | com.esotericsoftware
23 | kryo
24 | 5.6.2
25 |
26 |
27 |
28 |
29 |
30 | com.fizzed
31 | crux-util
32 | test
33 |
34 |
35 |
36 | org.hamcrest
37 | java-hamcrest
38 | test
39 |
40 |
41 |
42 | org.junit.jupiter
43 | junit-jupiter
44 | test
45 |
46 |
47 |
48 | ch.qos.logback
49 | logback-classic
50 | test
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/bigmap-kryo/src/main/java/com/fizzed/bigmap/kryo/KryoByteCodec.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap.kryo;
2 |
3 | import com.esotericsoftware.kryo.Kryo;
4 | import com.esotericsoftware.kryo.io.Input;
5 | import com.esotericsoftware.kryo.io.Output;
6 | import com.fizzed.bigmap.ByteCodec;
7 |
8 | import static com.fizzed.bigmap.ByteCodecs.ZERO_BYTES;
9 |
10 | public class KryoByteCodec implements ByteCodec {
11 |
12 | private final Kryo kryo;
13 | private final Class type;
14 |
15 | static public Kryo buildDefaultKryo() {
16 | Kryo kryo = new Kryo();
17 | kryo.setRegistrationRequired(false);
18 | return kryo;
19 | }
20 |
21 | public KryoByteCodec(Class type) {
22 | this(type, buildDefaultKryo());
23 | }
24 |
25 | public KryoByteCodec(Class type, Kryo kryo) {
26 | this.kryo = kryo;
27 | this.type = type;
28 | }
29 |
30 | @Override
31 | public byte[] serialize(K value) {
32 | if (value == null) {
33 | return ZERO_BYTES;
34 | }
35 | final Output output = new Output(1024, -1);
36 | this.kryo.writeObjectOrNull(output, value, this.type);
37 | return output.toBytes();
38 | }
39 |
40 | @Override
41 | public K deserialize(byte[] bytes) {
42 | // kryo does not allow zero byte arrays to be deserialized, so its null
43 | if (bytes == null || bytes.length == 0) {
44 | return null;
45 | }
46 | final Input input = new Input(bytes);
47 | return this.kryo.readObjectOrNull(input, this.type);
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/bigmap-kryo/src/test/java/com/fizzed/bigmap/kryo/KryoByteCodecTest.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap.kryo;
2 |
3 | import com.fizzed.bigmap.ByteCodecs;
4 | import com.fizzed.crux.util.Base16;
5 | import org.junit.jupiter.api.Test;
6 |
7 | import java.time.Instant;
8 | import java.util.Objects;
9 |
10 | import static org.hamcrest.CoreMatchers.is;
11 | import static org.hamcrest.CoreMatchers.nullValue;
12 | import static org.hamcrest.MatcherAssert.assertThat;
13 |
14 | public class KryoByteCodecTest {
15 |
16 | @Test
17 | public void nullsAndEmptyStrings() {
18 | final KryoByteCodec byteCodec = new KryoByteCodec<>(String.class);
19 |
20 | assertThat(byteCodec.serialize(null), is(ByteCodecs.ZERO_BYTES));
21 | assertThat(byteCodec.serialize(""), is(new byte[] {(byte)-127}));
22 |
23 | assertThat(byteCodec.deserialize(null), is(nullValue()));
24 | assertThat(byteCodec.deserialize(ByteCodecs.ZERO_BYTES), is(nullValue()));
25 | assertThat(byteCodec.deserialize(new byte[] {(byte)-127}), is(""));
26 | }
27 |
28 | @Test
29 | public void serializableObjects() {
30 | final KryoByteCodec byteCodec = new KryoByteCodec<>(Instant.class);
31 |
32 | final Instant i1 = Instant.parse("2022-11-05T01:02:03.456Z");
33 |
34 | //System.out.println(Base16.encode(byteCodec.serialize(i1)));
35 |
36 | assertThat(byteCodec.serialize(i1), is(Base16.decode("018bec969b068084b8d901")));
37 | assertThat(byteCodec.deserialize(Base16.decode("018bec969b068084b8d901")), is(i1));
38 | }
39 |
40 | @Test
41 | public void nonSerializableObjects() {
42 | final KryoByteCodec byteCodec = new KryoByteCodec<>(Widget.class);
43 |
44 | final Widget w1 = new Widget()
45 | .setS("a")
46 | .setI(5)
47 | .setType(WidgetType.A)
48 | .setCreatedAt(Instant.parse("2022-11-12T01:02:03.456Z"));
49 |
50 | //System.out.println(Base16.encode(byteCodec.serialize(w1)));
51 |
52 | assertThat(byteCodec.serialize(w1), is(Base16.decode("01018be1bb9b068084b8d901010a826101")));
53 | assertThat(byteCodec.deserialize(Base16.decode("01018be1bb9b068084b8d901010a826101")), is(w1));
54 | }
55 |
56 | static public enum WidgetType {
57 | A,
58 | B,
59 | C;
60 | }
61 |
62 | static public class Widget {
63 |
64 | private String s;
65 | private Integer i;
66 | private WidgetType type;
67 | private Instant createdAt;
68 |
69 | public String getS() {
70 | return s;
71 | }
72 |
73 | public Widget setS(String s) {
74 | this.s = s;
75 | return this;
76 | }
77 |
78 | public Integer getI() {
79 | return i;
80 | }
81 |
82 | public Widget setI(Integer i) {
83 | this.i = i;
84 | return this;
85 | }
86 |
87 | public WidgetType getType() {
88 | return type;
89 | }
90 |
91 | public Widget setType(WidgetType type) {
92 | this.type = type;
93 | return this;
94 | }
95 |
96 | public Instant getCreatedAt() {
97 | return createdAt;
98 | }
99 |
100 | public Widget setCreatedAt(Instant createdAt) {
101 | this.createdAt = createdAt;
102 | return this;
103 | }
104 |
105 | @Override
106 | public boolean equals(Object o) {
107 | if (this == o) return true;
108 | if (o == null || getClass() != o.getClass()) return false;
109 | Widget widget = (Widget) o;
110 | return Objects.equals(s, widget.s) && Objects.equals(i, widget.i) && type == widget.type && Objects.equals(createdAt, widget.createdAt);
111 | }
112 |
113 | @Override
114 | public int hashCode() {
115 | return Objects.hash(s, i, type, createdAt);
116 | }
117 | }
118 |
119 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | bigmap-leveldb
5 | bigmap-leveldb
6 | jar
7 |
8 |
9 | com.fizzed
10 | bigmap
11 | 1.1.1-SNAPSHOT
12 |
13 |
14 |
15 |
16 |
17 | com.fizzed
18 | bigmap-core
19 |
20 |
21 |
22 | org.iq80.leveldb
23 | leveldb
24 |
25 |
26 |
33 |
34 |
35 |
36 |
37 | org.hamcrest
38 | java-hamcrest
39 | test
40 |
41 |
42 |
43 | org.junit.jupiter
44 | junit-jupiter
45 | test
46 |
47 |
48 |
49 | ch.qos.logback
50 | logback-classic
51 | test
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelBigLinkedMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import com.fizzed.bigmap.impl.AbstractBigLinkedMap;
19 |
20 | import java.nio.file.Path;
21 | import java.util.UUID;
22 |
23 | public class LevelBigLinkedMap extends AbstractBigLinkedMap {
24 |
25 | protected LevelBigLinkedMap(
26 | UUID id,
27 | Path directory,
28 | boolean persistent,
29 | LevelBigMap dataMap,
30 | LevelBigMap insertOrderToKeyMap,
31 | LevelBigMap keyToInsertOrderMap) {
32 |
33 | super(id, directory, persistent, dataMap, insertOrderToKeyMap, keyToInsertOrderMap);
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelBigLinkedMapBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import com.fizzed.bigmap.*;
19 | import com.fizzed.bigmap.impl.AbstractBigMapBuilder;
20 | import com.fizzed.bigmap.impl.BigMapHelper;
21 |
22 | import java.nio.file.Path;
23 | import java.util.Comparator;
24 | import java.util.UUID;
25 |
26 | public class LevelBigLinkedMapBuilder extends AbstractBigMapBuilder> {
27 |
28 | public LevelBigLinkedMap build() {
29 | final UUID id = UUID.randomUUID();
30 | final Path dir = BigMapHelper.resolveScratchPath(this.scratchDirectory, false, id, "biglinkedmap-level");
31 |
32 | // we need 3 subdir paths
33 | final Path dataDir = dir.resolve("data");
34 | final Path i2kDir = dir.resolve("i2k");
35 | final Path k2iDir = dir.resolve("k2i");
36 |
37 | final ByteCodec integerByteCodec = ByteCodecs.integerCodec();
38 | final Comparator integerComparator = Comparators.autoComparator(Integer.class);
39 | final LevelBigMap dataMap = new LevelBigMap<>(UUID.randomUUID(), dataDir, this.keyCodec, this.keyComparator, this.valueCodec);
40 | final LevelBigMap insertOrderToKeyMap = new LevelBigMap<>(UUID.randomUUID(), i2kDir, integerByteCodec, integerComparator, this.keyCodec);
41 | final LevelBigMap keyToInsertOrderMap = new LevelBigMap<>(UUID.randomUUID(), k2iDir, this.keyCodec, this.keyComparator, integerByteCodec);
42 |
43 | final LevelBigLinkedMap map = new LevelBigLinkedMap<>(id, dir, false, dataMap, insertOrderToKeyMap, keyToInsertOrderMap);
44 | map.setListener(this.registry);
45 | map.open();
46 | return map;
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelBigLinkedSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import com.fizzed.bigmap.impl.AbstractBigSet;
19 | import com.fizzed.bigmap.impl.None;
20 |
21 | public class LevelBigLinkedSet extends AbstractBigSet {
22 |
23 | protected LevelBigLinkedSet(
24 | LevelBigLinkedMap map) {
25 |
26 | super(map);
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelBigLinkedSetBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import com.fizzed.bigmap.ByteCodec;
19 | import com.fizzed.bigmap.ByteCodecs;
20 | import com.fizzed.bigmap.Comparators;
21 | import com.fizzed.bigmap.impl.AbstractBigSetBuilder;
22 | import com.fizzed.bigmap.impl.BigMapHelper;
23 | import com.fizzed.bigmap.impl.None;
24 |
25 | import java.nio.file.Path;
26 | import java.util.Comparator;
27 | import java.util.UUID;
28 |
29 | public class LevelBigLinkedSetBuilder extends AbstractBigSetBuilder> {
30 |
31 | public LevelBigLinkedSet build() {
32 | final UUID id = UUID.randomUUID();
33 | final Path dir = BigMapHelper.resolveScratchPath(this.scratchDirectory, false, id, "biglinkedset-level");
34 |
35 | // we need 3 subdir paths
36 | final Path dataDir = dir.resolve("data");
37 | final Path i2kDir = dir.resolve("i2k");
38 | final Path k2iDir = dir.resolve("k2i");
39 |
40 | final ByteCodec integerByteCodec = ByteCodecs.integerCodec();
41 | final Comparator integerComparator = Comparators.autoComparator(Integer.class);
42 | final LevelBigMap dataMap = new LevelBigMap<>(UUID.randomUUID(), dataDir, this.valueCodec, this.valueComparator, ByteCodecs.noneCodec());
43 | final LevelBigMap insertOrderToKeyMap = new LevelBigMap<>(UUID.randomUUID(), i2kDir, integerByteCodec, integerComparator, this.valueCodec);
44 | final LevelBigMap keyToInsertOrderMap = new LevelBigMap<>(UUID.randomUUID(), k2iDir, this.valueCodec, this.valueComparator, integerByteCodec);
45 |
46 | final LevelBigLinkedMap map = new LevelBigLinkedMap<>(id, dir, false, dataMap, insertOrderToKeyMap, keyToInsertOrderMap);
47 |
48 | final LevelBigLinkedSet set = new LevelBigLinkedSet<>(map);
49 | set.setListener(this.registry);
50 | set.open();
51 | return set;
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelBigMapBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import com.fizzed.bigmap.impl.AbstractBigMapBuilder;
19 | import com.fizzed.bigmap.impl.BigMapHelper;
20 |
21 | import java.nio.file.Path;
22 | import java.util.UUID;
23 |
24 | public class LevelBigMapBuilder extends AbstractBigMapBuilder> {
25 |
26 | public LevelBigMap build() {
27 | final UUID id = UUID.randomUUID();
28 | final Path dir = BigMapHelper.resolveScratchPath(this.scratchDirectory, false, id, "bigmap-level");
29 |
30 | final LevelBigMap map = new LevelBigMap<>(id, dir, this.keyCodec, this.keyComparator, this.valueCodec);
31 | map.setListener(this.registry);
32 | map.open();
33 | return map;
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelBigObjectCloser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import com.fizzed.bigmap.impl.AbstractBigObjectCloser;
19 | import org.iq80.leveldb.DB;
20 |
21 | import java.io.IOException;
22 | import java.nio.file.Path;
23 | import java.util.UUID;
24 |
25 | public class LevelBigObjectCloser extends AbstractBigObjectCloser {
26 |
27 | private final DB db;
28 |
29 | public LevelBigObjectCloser(
30 | UUID id,
31 | boolean persistent,
32 | Path directory,
33 | DB db) {
34 |
35 | super(id, persistent, directory);
36 | this.db = db;
37 | }
38 |
39 | @Override
40 | public void doClose() throws IOException {
41 | this.db.close();
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelBigSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import com.fizzed.bigmap.impl.AbstractBigSet;
19 | import com.fizzed.bigmap.BigSortedSet;
20 | import com.fizzed.bigmap.impl.None;
21 |
22 | public class LevelBigSet extends AbstractBigSet implements BigSortedSet {
23 |
24 | protected LevelBigSet(
25 | LevelBigMap map) {
26 |
27 | super(map);
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelBigSetBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import com.fizzed.bigmap.ByteCodecs;
19 | import com.fizzed.bigmap.impl.AbstractBigSetBuilder;
20 | import com.fizzed.bigmap.impl.BigMapHelper;
21 | import com.fizzed.bigmap.impl.None;
22 |
23 | import java.nio.file.Path;
24 | import java.util.UUID;
25 |
26 | public class LevelBigSetBuilder extends AbstractBigSetBuilder> {
27 |
28 | public LevelBigSet build() {
29 | final UUID id = UUID.randomUUID();
30 | final Path dir = BigMapHelper.resolveScratchPath(this.scratchDirectory, false, id, "bigset-level");
31 |
32 | final LevelBigMap map = new LevelBigMap<>(id, dir, this.valueCodec, this.valueComparator, ByteCodecs.noneCodec());
33 |
34 | final LevelBigSet set = new LevelBigSet<>(map);
35 | set.setListener(this.registry);
36 | set.open();
37 | return set;
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelForwardIterator.java:
--------------------------------------------------------------------------------
1 | package com.fizzed.bigmap.leveldb;
2 |
3 | import com.fizzed.bigmap.impl.KeyValueBytes;
4 | import org.iq80.leveldb.DB;
5 | import org.iq80.leveldb.DBIterator;
6 |
7 | import java.util.Iterator;
8 | import java.util.Map;
9 | import java.util.NoSuchElementException;
10 |
11 | public class LevelForwardIterator implements Iterator {
12 |
13 | static public LevelForwardIterator build(DB db) {
14 | final DBIterator iter = db.iterator();
15 | iter.seekToFirst();
16 | return new LevelForwardIterator(iter);
17 | }
18 |
19 | private final DBIterator it;
20 |
21 | public LevelForwardIterator(DBIterator it) {
22 | this.it = it;
23 | }
24 |
25 | public boolean hasNext() {
26 | return it.hasNext();
27 | }
28 |
29 | public KeyValueBytes next() {
30 | // NOTE: this throws a NoSuchElementException is no element exists
31 | if (!it.hasNext()) {
32 | throw new NoSuchElementException();
33 | }
34 |
35 | // we are already on the item we want
36 | final Map.Entry entry = it.next();
37 |
38 | final KeyValueBytes kvb = new KeyValueBytes(entry.getKey(), entry.getValue());
39 |
40 | return kvb;
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/bigmap-leveldb/src/main/java/com/fizzed/bigmap/leveldb/LevelJavaComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.bigmap.leveldb;
17 |
18 | import org.iq80.leveldb.DBComparator;
19 | import com.fizzed.bigmap.ByteCodec;
20 | import java.util.Comparator;
21 | import java.util.Objects;
22 |
23 | public class LevelJavaComparator implements DBComparator {
24 |
25 | private final ByteCodec codec;
26 | private final Comparator comparator;
27 |
28 | public LevelJavaComparator(ByteCodec codec, Comparator