Package io.pravega.client.tables.impl
Interface TableSegment
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface TableSegment extends java.lang.AutoCloseableDefines all operations that are supported on a Table Segment. Types of updates: * Unconditional Updates will insert and/or overwrite any existing values for the given Key, regardless of whether that Key previously existed or not, and regardless of what that Key's version is. * Conditional Updates will only overwrite an existing value if the specified version matches that Key's version. If the key does not exist, theTableSegmentKeyorTableSegmentEntrymust have been created withTableSegmentKeyVersion.NOT_EXISTSin order for the update to succeed. * Unconditional Removals will remove a Key regardless of what that Key's version is. The operation will also succeed (albeit with no effect) if the Key does not exist. * Conditional Removals will remove a Key only if the specifiedTableSegmentKey.getVersion()matches that Key's version. It will also fail (with no effect) if the Key does not exist and Version is not set toTableSegmentKeyVersion.NOT_EXISTS. A note aboutByteBufs. All the methods defined in this interface make use ofByteBufeither directly or viaTableSegmentKey/TableSegmentEntry. It is expected that no implementation of theTableSegmentinterface will either retain (ByteBuf.retain()) or release (ReferenceCounted.release()) these buffers during execution. The lifecycle of these buffers should be maintained externally by the calling code, using the following guidelines: * For methods that accept externally-providedByteBufs, the calling code should callByteBuf.retain()prior to invoking the method onTableSegmentand should invokeReferenceCounted.release()afterwards. * For methods that return internally-generatedByteBufs (such asget(io.netty.buffer.ByteBuf)), the calling code should invokeReferenceCounted.release()as soon as it is done with processing the result. If the result needs to be held onto for a longer duration, the caller should make a copy of it and release theByteBufthat was provided from the call.
-
-
Field Summary
Fields Modifier and Type Field Description static intMAXIMUM_BATCH_KEY_COUNTMaximum number of Entries that can be updated, removed or retrieved with a single request.static intMAXIMUM_BATCH_LENGTHMaximum total serialization length of all keys and values for any given request.static intMAXIMUM_KEY_LENGTHThe maximum length of a Table Segment Key.static intMAXIMUM_VALUE_LENGTHThe maximum length of a Table Segment Value.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()io.pravega.common.util.AsyncIterator<IteratorItem<TableSegmentEntry>>entryIterator(io.pravega.client.tables.impl.IteratorArgs args)Creates a new Iterator over all the Entries in the Table Segment.default java.util.concurrent.CompletableFuture<TableSegmentEntry>get(io.netty.buffer.ByteBuf key)Gets the latest value for the given Key.java.util.concurrent.CompletableFuture<java.util.List<TableSegmentEntry>>get(java.util.Iterator<io.netty.buffer.ByteBuf> keys)Gets the latest values for the given Keys.longgetSegmentId()Gets a value indicating the internal Id of the Table Segment, as assigned by the Controller.io.pravega.common.util.AsyncIterator<IteratorItem<TableSegmentKey>>keyIterator(io.pravega.client.tables.impl.IteratorArgs args)Creates a new Iterator over all the Keys in the Table Segment.default java.util.concurrent.CompletableFuture<TableSegmentKeyVersion>put(TableSegmentEntry entry)Inserts a new or updates an existing Table Entry into this Table Segment.java.util.concurrent.CompletableFuture<java.util.List<TableSegmentKeyVersion>>put(java.util.Iterator<TableSegmentEntry> entries)Inserts new or updates existing Table Entries into this Table Segment.default java.util.concurrent.CompletableFuture<java.lang.Void>remove(TableSegmentKey key)Removes the given key from this Table Segment.java.util.concurrent.CompletableFuture<java.lang.Void>remove(java.util.Iterator<TableSegmentKey> keys)Removes one or more keys from this Table Segment.
-
-
-
Field Detail
-
MAXIMUM_KEY_LENGTH
static final int MAXIMUM_KEY_LENGTH
The maximum length of a Table Segment Key. Synchronized with io.pravega.segmentstore.contracts.tables.TableStore.MAXIMUM_KEY_LENGTH.- See Also:
- Constant Field Values
-
MAXIMUM_VALUE_LENGTH
static final int MAXIMUM_VALUE_LENGTH
The maximum length of a Table Segment Value. Synchronized with io.pravega.segmentstore.contracts.tables.TableStore.MAXIMUM_VALUE_LENGTH.- See Also:
- Constant Field Values
-
MAXIMUM_BATCH_KEY_COUNT
static final int MAXIMUM_BATCH_KEY_COUNT
Maximum number of Entries that can be updated, removed or retrieved with a single request.- See Also:
- Constant Field Values
-
MAXIMUM_BATCH_LENGTH
static final int MAXIMUM_BATCH_LENGTH
Maximum total serialization length of all keys and values for any given request.- See Also:
- Constant Field Values
-
-
Method Detail
-
put
default java.util.concurrent.CompletableFuture<TableSegmentKeyVersion> put(TableSegmentEntry entry)
Inserts a new or updates an existing Table Entry into this Table Segment.- Parameters:
entry- The Entry to insert or update. IfTableEntry.getKey()TableKey.getVersion()indicates a conditional update this will perform a Conditional Update conditioned on the server-side version matching the provided one. SeeTableSegmentdoc for more details on Types of Updates.- Returns:
- A CompletableFuture that, when completed, will contain the
TableSegmentKeyVersionassociated with the newly inserted or updated entry. Notable exceptions:ConditionalTableUpdateExceptionIf this is a Conditional Update and the condition was not satisfied.
-
put
java.util.concurrent.CompletableFuture<java.util.List<TableSegmentKeyVersion>> put(java.util.Iterator<TableSegmentEntry> entries)
Inserts new or updates existing Table Entries into this Table Segment. All changes are performed atomically (either all or none will be accepted).- Parameters:
entries- An Iterator containing the entries to insert or update. If for at least one such entry,TableEntry.getKey()TableKey.getVersion()indicates a conditional update, this will perform an atomic Conditional Update conditioned on the server-side version for each such entry matching the provided one. SeeTableSegmentdoc for more details on Types of Updates.- Returns:
- A CompletableFuture that, when completed, will contain a List of
TableSegmentKeyVersioninstances which represent the versions for the inserted/updated keys. The returned list will contain the same number of elements as are remaining in the entries iterator and the resulting versions will be in the same order. Notable exceptions:ConditionalTableUpdateExceptionIf this is a Conditional Update and the condition was not satisfied.
-
remove
default java.util.concurrent.CompletableFuture<java.lang.Void> remove(TableSegmentKey key)
Removes the given key from this Table Segment.- Parameters:
key- The Key to remove. IfTableKey.getVersion()indicates a conditional update, this will perform an atomic removal conditioned on the server-side version matching the provided one. SeeTableSegmentdoc for more details on Types of Updates.- Returns:
- A CompletableFuture that, when completed, will indicate the Key has been removed. Notable exceptions:
ConditionalTableUpdateExceptionIf this is a Conditional Removal and the condition was not satisfied.
-
remove
java.util.concurrent.CompletableFuture<java.lang.Void> remove(java.util.Iterator<TableSegmentKey> keys)
Removes one or more keys from this Table Segment. All removals are performed atomically (either all keys or no key will be removed).- Parameters:
keys- An Iterator containing the keys to remove. If for at least one such key,TableKey.getVersion()indicates a conditional update, this will perform an atomic removal conditioned on the server-side version matching the provided one. SeeTableSegmentdoc for more details on Types of Updates.- Returns:
- A CompletableFuture that, when completed, will indicate that the keys have been removed. Notable exceptions:
ConditionalTableUpdateExceptionIf this is a Conditional Removal and the condition was not satisfied.
-
get
default java.util.concurrent.CompletableFuture<TableSegmentEntry> get(io.netty.buffer.ByteBuf key)
Gets the latest value for the given Key.- Parameters:
key- AByteBufrepresenting the Key to get the value for.- Returns:
- A CompletableFuture that, when completed, will contain the requested result. If no such Key exists, this will be completed with a null value.
-
get
java.util.concurrent.CompletableFuture<java.util.List<TableSegmentEntry>> get(java.util.Iterator<io.netty.buffer.ByteBuf> keys)
Gets the latest values for the given Keys.- Parameters:
keys- An Iterator ofByteBufinstances representing the Keys to get values for.- Returns:
- A CompletableFuture that, when completed, will contain a List of
TableSegmentEntryinstances for the requested keys. The returned list will contain the same number of elements as are remaining in the keys iterator 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.
-
keyIterator
io.pravega.common.util.AsyncIterator<IteratorItem<TableSegmentKey>> keyIterator(io.pravega.client.tables.impl.IteratorArgs args)
Creates a new Iterator over all the Keys in the Table Segment.- Parameters:
args- AIteratorArgsthat can be used to configure the iterator.- Returns:
- An
AsyncIteratorthat can be used to iterate over all the Keys in this Table Segment.
-
entryIterator
io.pravega.common.util.AsyncIterator<IteratorItem<TableSegmentEntry>> entryIterator(io.pravega.client.tables.impl.IteratorArgs args)
Creates a new Iterator over all the Entries in the Table Segment.- Parameters:
args- AIteratorArgsthat can be used to configure the iterator.- Returns:
- An
AsyncIteratorthat can be used to iterate over all the Entries in this Table Segment.
-
getSegmentId
long getSegmentId()
Gets a value indicating the internal Id of the Table Segment, as assigned by the Controller.- Returns:
- The Table Segment Id.
-
close
void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-