This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persistent storage refactoring (#4512)
* Storage refactor. * Style fixes. * Updated docs. * Wrong copy fixed. * Some refactorings. * Renamed. * Fix tests. * Change access modifier. * Update comments. * Remove ? * Simple fixes. * Refactored to use ByteString.
- Loading branch information
Showing
16 changed files
with
534 additions
and
249 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
atlasdb-api/src/main/java/com/palantir/atlasdb/persistent/api/LogicalPersistentStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* (c) Copyright 2020 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.palantir.atlasdb.persistent.api; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import com.palantir.atlasdb.persistent.api.PhysicalPersistentStore.StoreNamespace; | ||
|
||
public interface LogicalPersistentStore<K, V> { | ||
/** | ||
* Retrieve the value associated with the given {@code key}. | ||
* | ||
* @param storeNamespace from which to retrieve the value | ||
* @param key of the cache entry | ||
* @return value associated or null if the entry is missing | ||
*/ | ||
Optional<V> get(StoreNamespace storeNamespace, @Nonnull K key); | ||
|
||
/** | ||
* Retrieves values for all supplied {@code keys}. | ||
* | ||
* @param storeNamespace from which to retrieve the values | ||
* @param keys for which entries we are interested in | ||
* @return map of key, value pairs containing only entries which are stored | ||
*/ | ||
Map<K, V> get(StoreNamespace storeNamespace, List<K> keys); | ||
|
||
/** | ||
* Stores the given entry pair. | ||
* | ||
* @param storeNamespace where to store the entry | ||
* @param key of the entry | ||
* @param value of the entry | ||
*/ | ||
void put(StoreNamespace storeNamespace, @Nonnull K key, @Nonnull V value); | ||
|
||
/** | ||
* Stores all entry pairs specified in {@code toWrite}. | ||
* | ||
* @param storeNamespace where to store the entries | ||
* @param toWrite entry pairs to store | ||
*/ | ||
void put(StoreNamespace storeNamespace, Map<K, V> toWrite); | ||
|
||
/** | ||
* Creates a {@link StoreNamespace} with the given name. Multiple calls with the same {@code name} will return | ||
* different namespaces. | ||
* | ||
* @param name of the namespace | ||
* @return handle to the underlying namespace | ||
*/ | ||
StoreNamespace createNamespace(@Nonnull String name); | ||
|
||
/** | ||
* Given the namespace handle represented by {@code storeNamespace} drops the internal structures. | ||
* | ||
* @param storeNamespace which should be dropped | ||
*/ | ||
void dropNamespace(StoreNamespace storeNamespace); | ||
} |
102 changes: 0 additions & 102 deletions
102
atlasdb-api/src/main/java/com/palantir/atlasdb/persistent/api/PersistentTimestampStore.java
This file was deleted.
Oops, something went wrong.
98 changes: 98 additions & 0 deletions
98
atlasdb-api/src/main/java/com/palantir/atlasdb/persistent/api/PhysicalPersistentStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* (c) Copyright 2020 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.palantir.atlasdb.persistent.api; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import org.immutables.value.Value; | ||
|
||
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException; | ||
|
||
import okio.ByteString; | ||
|
||
public interface PhysicalPersistentStore extends AutoCloseable { | ||
@Value.Immutable | ||
interface StoreNamespace { | ||
String humanReadableName(); | ||
UUID uniqueName(); | ||
} | ||
|
||
/** | ||
* Gets the value associated with the entry specified by {@code key}. | ||
* | ||
* @param storeNamespace handle to the namespace from which we want to retrieve the value | ||
* @param key entry key for which we want to retrieve the value | ||
* @return the {@link Optional} containing the value or empty if there is no associated value | ||
* @throws SafeIllegalArgumentException when {@code storeNamespace} is a handle to a non existing namespace | ||
*/ | ||
Optional<ByteString> get(StoreNamespace storeNamespace, @Nonnull ByteString key); | ||
|
||
/** | ||
* Gets the values associated with the entries specified by {@code keys}. | ||
* | ||
* @param storeNamespace handle to the namespace from which we want to retrieve the values | ||
* @param keys representing keys for which we want to retrieve the values | ||
* @return a map from keys to values | ||
*/ | ||
Map<ByteString, ByteString> get(StoreNamespace storeNamespace, List<ByteString> keys); | ||
|
||
/** | ||
* Stores the {@code value} for the associated {@code key} while overwriting the existing value in the specified | ||
* {@code storeNamespace}. | ||
* | ||
* @param storeNamespace of the store to which we should store the entry | ||
* @param key entry key | ||
* @param value entry value | ||
* @throws SafeIllegalArgumentException when {@code storeNamespace} is a handle to a non existing namespace | ||
*/ | ||
void put(StoreNamespace storeNamespace, @Nonnull ByteString key, @Nonnull ByteString value); | ||
|
||
/** | ||
* Stores the entry pairs given in {@code toWrite}, overwriting the existing values. | ||
* | ||
* @param storeNamespace of the store to which we should store the entry | ||
* @param toWrite entry pairs to write | ||
* @throws SafeIllegalArgumentException when {@code storeNamespace} is a handle to a non existing namespace | ||
*/ | ||
void put(StoreNamespace storeNamespace, Map<ByteString, ByteString> toWrite); | ||
|
||
/** | ||
* Creates a handle of type {@link StoreNamespace} with a {@link StoreNamespace#humanReadableName()} equals to | ||
* {@code name}. Multiple calls with the same supplied {@code name} will generate multiple namespaces. Users of this | ||
* API are required to keep uniqueness at the {@link StoreNamespace#humanReadableName()} level; otherwise, multiple | ||
* {@link StoreNamespace} backed by internal data structures will be maintained for the same AtlasDB namespace, | ||
* which is inefficient. | ||
* | ||
* @param name in human readable format of the namespace to be created | ||
* @return {@link StoreNamespace} which represents a handle to the created namespace | ||
*/ | ||
StoreNamespace createNamespace(@Nonnull String name); | ||
|
||
/** | ||
* Drops the namespace specified by the supplied handle. Dropping of a namespace may fail if there are concurrent | ||
* calls on the same namespace or if the namespace has already been dropped. | ||
* | ||
* @param storeNamespace handle | ||
* @throws SafeIllegalArgumentException if the {@code storeNamespace} does not exist | ||
*/ | ||
void dropNamespace(StoreNamespace storeNamespace); | ||
} |
Oops, something went wrong.