Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rocksdb plugin to support OptimisticTransactionDb and TransactionDb #5328

Merged
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bf3b9f8
Refactor to make RocksDBColumnarKeyValueStorage abstract and extend i…
gfukushima Apr 11, 2023
a6062c3
Refactor to use RocksDB class where possible
gfukushima Apr 11, 2023
9b7d68e
Replace RocksDBColumnarKeyValueStorage for equivalent use case
gfukushima Apr 11, 2023
de371a9
Add config to identify storage mode
gfukushima Apr 11, 2023
93322ea
javadoc
gfukushima Apr 12, 2023
46be43f
Removing unnecessary addition to plugin api
gfukushima Apr 12, 2023
11c8a61
Refactor to remove duplicated code
gfukushima Apr 12, 2023
f8e848e
Introduce concept of DataStorageFormat.FOREST to the rocksDB plugin
gfukushima Apr 12, 2023
42e7924
Removing code added during spike
gfukushima Apr 13, 2023
c230472
Merge branch 'main' into rocksdb-to-support-opTxDb-pessimisticTxDB
gfukushima Apr 13, 2023
c223ab5
Moving to the segmented folder since this is segmented DB tests
gfukushima Apr 17, 2023
c1c6bce
Remove takeSnapshot method from abstract and pessimistic class
gfukushima Apr 17, 2023
aaba2bc
Rename class and remove takeSnapshot method since it's not supported
gfukushima Apr 17, 2023
4e24937
Make takeSnapshot a public method of the class
gfukushima Apr 17, 2023
ebda4cf
Use nonSnappableAdapter for forest segmented storage
gfukushima Apr 17, 2023
3238f97
Add NonSnappableSegmentedKeyValueStorageAdapter for forest
gfukushima Apr 17, 2023
32adbf6
spdx
gfukushima Apr 17, 2023
a0cdd20
Extend RocksDBColumnarKeyValueStorageTest to use Optimistic and Trans…
gfukushima Apr 17, 2023
298ab61
spdx
gfukushima Apr 17, 2023
894dfb8
Merge branch 'main' into rocksdb-to-support-opTxDb-pessimisticTxDB
gfukushima Apr 17, 2023
2076716
javadoc rename fix
gfukushima Apr 17, 2023
bc4e3fc
Clean up code
gfukushima Apr 18, 2023
6ed4df6
Merge branch 'main' into rocksdb-to-support-opTxDb-pessimisticTxDB
gfukushima Apr 18, 2023
80b9470
changelog
gfukushima Apr 18, 2023
7cee988
Use SegmentedKeyValueStorageAdapter as base class for Snappable adapter
gfukushima Apr 18, 2023
df8a0aa
Merge branch 'main' into rocksdb-to-support-opTxDb-pessimisticTxDB
gfukushima Apr 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add NonSnappableSegmentedKeyValueStorageAdapter for forest
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
  • Loading branch information
gfukushima committed Apr 17, 2023
commit 3238f979c7ed79615b242694b4d55f7d81ddce9d
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.services.kvstore;

import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction;
import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier;

import java.io.IOException;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;

import org.apache.commons.lang3.tuple.Pair;

/**
* The type Segmented key value storage adapter.
*
* @param <S> the type parameter
*/
public class NonSnappableSegmentedKeyValueStorageAdapter<S> implements KeyValueStorage {
gfukushima marked this conversation as resolved.
Show resolved Hide resolved

private final S segmentHandle;
private final SegmentedKeyValueStorage<S> storage;

/**
* Instantiates a new Segmented key value storage adapter.
*
* @param segment the segment
* @param storage the storage
*/
public NonSnappableSegmentedKeyValueStorageAdapter(
final SegmentIdentifier segment, final SegmentedKeyValueStorage<S> storage) {
segmentHandle = storage.getSegmentIdentifierByName(segment);
this.storage = storage;
}

@Override
public void clear() {
storage.clear(segmentHandle);
}

@Override
public boolean containsKey(final byte[] key) throws StorageException {
return storage.containsKey(segmentHandle, key);
}

@Override
public Optional<byte[]> get(final byte[] key) throws StorageException {
return storage.get(segmentHandle, key);
}

@Override
public Set<byte[]> getAllKeysThat(final Predicate<byte[]> returnCondition) {
return storage.getAllKeysThat(segmentHandle, returnCondition);
}

@Override
public Set<byte[]> getAllValuesFromKeysThat(final Predicate<byte[]> returnCondition) {
return storage.getAllValuesFromKeysThat(segmentHandle, returnCondition);
}

@Override
public Stream<Pair<byte[], byte[]>> stream() {
return storage.stream(segmentHandle);
}

@Override
public Stream<byte[]> streamKeys() {
return storage.streamKeys(segmentHandle);
}

@Override
public boolean tryDelete(final byte[] key) {
return storage.tryDelete(segmentHandle, key);
}

@Override
public void close() throws IOException {
storage.close();
}

@Override
public KeyValueStorageTransaction startTransaction() throws StorageException {
final SegmentedKeyValueStorage.Transaction<S> transaction = storage.startTransaction();
return new KeyValueStorageTransaction() {

@Override
public void put(final byte[] key, final byte[] value) {
transaction.put(segmentHandle, key, value);
}

@Override
public void remove(final byte[] key) {
transaction.remove(segmentHandle, key);
}

@Override
public void commit() throws StorageException {
transaction.commit();
}

@Override
public void rollback() {
transaction.rollback();
}
};
}
}