Package io.pravega.client.tables.impl
Class KeyValueTableImpl
- java.lang.Object
-
- io.pravega.client.tables.impl.KeyValueTableImpl
-
- All Implemented Interfaces:
KeyValueTable,java.lang.AutoCloseable
public class KeyValueTableImpl extends java.lang.Object implements KeyValueTable, java.lang.AutoCloseable
Implementation forKeyValueTable.
-
-
Field Summary
-
Fields inherited from interface io.pravega.client.tables.KeyValueTable
MAXIMUM_VALUE_LENGTH
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes theKeyValueTable.java.util.concurrent.CompletableFuture<java.lang.Boolean>exists(@NonNull TableKey key)Determines if the givenTableKeyexists or not.java.util.concurrent.CompletableFuture<TableEntry>get(@NonNull TableKey key)Gets the latest value for aTableKey.java.util.concurrent.CompletableFuture<java.util.List<TableEntry>>getAll(@NonNull java.lang.Iterable<TableKey> keys)Gets the latest values for a set ofTableKeys.io.pravega.client.tables.impl.KeyValueTableIteratorImpl.Builderiterator()Creates a newKeyValueTableIterator.Builderthat can be used to construct and execute an Iterator over theTableKey/TableEntryinstances in thisKeyValueTable.java.util.concurrent.CompletableFuture<Version>update(@NonNull TableModification update)Performs a specificTableModificationto theKeyValueTable, as described below: Ifupdateis aInsert, this will be interpreted as a Conditional Insert, so theTableEntryUpdate.getValue()will only be inserted (and associated withTableModification.getKey()if there doesn't already exist aTableKeyin theKeyValueTablethat matchesTableModification.getKey().java.util.concurrent.CompletableFuture<java.util.List<Version>>update(@NonNull java.lang.Iterable<TableModification> updates)Performs a batch ofTableModifications to theKeyValueTableforTableKeys that have the sameTableKey.getPrimaryKey().
-
-
-
Method Detail
-
close
public void close()
Description copied from interface:KeyValueTableCloses theKeyValueTable. No more updates, removals, retrievals or iterators may be performed using it.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceKeyValueTable- See Also:
AutoCloseable.close()
-
update
public java.util.concurrent.CompletableFuture<Version> update(@NonNull @NonNull TableModification update)
Description copied from interface:KeyValueTablePerforms a specificTableModificationto theKeyValueTable, as described below:- If
updateis aInsert, this will be interpreted as a Conditional Insert, so theTableEntryUpdate.getValue()will only be inserted (and associated withTableModification.getKey()if there doesn't already exist aTableKeyin theKeyValueTablethat matchesTableModification.getKey(). - If
updateis aPut, this will be an update. IfPut.getVersion()is null, this will be interpreted as an Unconditional Update, and theTableEntryUpdate.getValue()will be associated withTableModification.getKey()in theKeyValueTableregardless of whether the Key existed before or not. IfPut.getVersion()is non-null, this will be interpreted as a Conditional Update, and theTableEntryUpdate.getValue()will only be associated withTableModification.getKey()if there exists aTableKeyin theKeyValueTablewhoseVersionmatchesPut.getVersion(). NOTE: ifPut.getVersion()equalsVersion.NOT_EXISTS, this is equivalent toInsert(i.e., it will be a Conditional Insert). - If
updateis aRemove, this will remove theTableModification.getKey()from theKeyValueTable. IfRemove.getVersion()is null, this will be interpreted as an Unconditional Removal, so the Key will be removed regardless of itsVersion(and the operation will also be successful if theTableModification.getKey()does not exist). IfRemove.getVersion()is non-null, this will be interpreted as a Conditional Removal, and the Key will only be removed if it exists and itsVersionmatchesRemove.getVersion().
- Specified by:
updatein interfaceKeyValueTable- Parameters:
update- TheTableModificationto apply to theKeyValueTable.- Returns:
- A CompletableFuture that, when completed, will contain the
Versionassociated with any newly updated or inserted entry (forInsertorPut) ornullforRemove.
- If
-
update
public java.util.concurrent.CompletableFuture<java.util.List<Version>> update(@NonNull @NonNull java.lang.Iterable<TableModification> updates)
Description copied from interface:KeyValueTablePerforms a batch ofTableModifications to theKeyValueTableforTableKeys that have the sameTableKey.getPrimaryKey(). All changes are performed atomically (either all or none will be accepted).See
KeyValueTable.update(TableModification)for details on Conditional/Unconditional Updates. Conditional and unconditional updates may be mixed together in this call. Each individualTableModificationwill be individually assessed (from a conditional point of view) and will prevent the entire batch from committing if it fails to meet the condition.- Specified by:
updatein interfaceKeyValueTable- Parameters:
updates- AnIterableofTableModifications to apply to theKeyValueTable. Note thatRemoveinstances may not be mixed together withInsertorPutinstances, butInserts andPuts may be mixed together.- Returns:
- A CompletableFuture that, when completed, will contain a List of
Versioninstances which represent the versions for the updated or inserted keys. The size of this list will be the same as the number of items inupdatesand the versions will be in the same order as theupdates. This list will be empty ifupdatescontains onlyRemoveinstances.
-
exists
public java.util.concurrent.CompletableFuture<java.lang.Boolean> exists(@NonNull @NonNull TableKey key)Description copied from interface:KeyValueTableDetermines if the givenTableKeyexists or not.- Specified by:
existsin interfaceKeyValueTable- Parameters:
key- TheTableKeyto check.- Returns:
- A CompletableFuture that, when completed, will contain a
Booleanrepresenting the result.
-
get
public java.util.concurrent.CompletableFuture<TableEntry> get(@NonNull @NonNull TableKey key)
Description copied from interface:KeyValueTableGets the latest value for aTableKey.- Specified by:
getin interfaceKeyValueTable- Parameters:
key- TheTableKeyto get the value for.- Returns:
- A CompletableFuture that, when completed, will contain the requested result. If no such
TableKeyexists, this will be completed with a null value.
-
getAll
public java.util.concurrent.CompletableFuture<java.util.List<TableEntry>> getAll(@NonNull @NonNull java.lang.Iterable<TableKey> keys)
Description copied from interface:KeyValueTableGets the latest values for a set ofTableKeys.- Specified by:
getAllin interfaceKeyValueTable- Parameters:
keys- AnIterableof @link TableKey} to get values for.- Returns:
- A CompletableFuture that, when completed, will contain a List of
TableEntryinstances for the requested keys. The size of the list will be the same askeys.size()and the results will be in the same order as the requested keys. Any keys which do not have a value will have a null entry at their index.
-
iterator
public io.pravega.client.tables.impl.KeyValueTableIteratorImpl.Builder iterator()
Description copied from interface:KeyValueTableCreates a newKeyValueTableIterator.Builderthat can be used to construct and execute an Iterator over theTableKey/TableEntryinstances in thisKeyValueTable.- Specified by:
iteratorin interfaceKeyValueTable- Returns:
- A new instance of a
KeyValueTableIterator.Builder.
-
-