Interface VectorCollection<K,V>
- Type Parameters:
K
- key type.V
- value type.
- All Superinterfaces:
com.hazelcast.core.DistributedObject
VectorDocument
s.
Important note
Key-based operations such as getAsync(Object)
or putAsync(Object, VectorDocument)
do not use hashCode
and equals
implementations of key's class.
Instead, they use hashCode
and equals
of the serialized form of the key.
Each mutating operation requires that no optimization process is currently being performed on any index.
If any index is undergoing an optimization process,
the mutable method will throw an exception IndexMutationDisallowedException
.
If an index is already undergoing an optimization process,
attempting to start a second optimization process on the same index
will result an exception IndexMutationDisallowedException
.
Multiple optimization processes can be performed simultaneously on different indexes.
- Since:
- 5.5
-
Method Summary
Modifier and TypeMethodDescriptionAsynchronously clears all entries in the vector collection.deleteAsync
(K key) Removes asynchronously the association of givenkey
to a document, if such an association existed.CompletionStage<com.hazelcast.vector.VectorDocument<V>>
Asynchronously gets theVectorDocument
associated with the given key ornull
if no such association exists.static <K,
V> VectorCollection<K, V> getCollection
(com.hazelcast.core.HazelcastInstance instance, com.hazelcast.config.vector.VectorCollectionConfig collectionConfig) static <K,
V> VectorCollection<K, V> getCollection
(com.hazelcast.core.HazelcastInstance instance, String name) default CompletionStage<Void>
Optimize the only index by fully removing nodes marked for deletion, trimming neighbor sets to the advertised degree, and updating the entry node as necessary.optimizeAsync
(String indexName) Optimize the specified index by fully removing nodes marked for deletion, trimming neighbor sets to the advertised degree, and updating the entry node as necessary.putAllAsync
(Map<? extends K, com.hazelcast.vector.VectorDocument<V>> documents) Inserts asynchronously the given map of key-document pairs.CompletionStage<com.hazelcast.vector.VectorDocument<V>>
Asynchronously associates the given key with thevalue
VectorDocument
, returning theVectorDocument
previously associated with thekey
if such an association existed.CompletionStage<com.hazelcast.vector.VectorDocument<V>>
putIfAbsentAsync
(K key, com.hazelcast.vector.VectorDocument<V> value) If the givenkey
is not already associated with aVectorDocument
, associates it with the givenvalue
and returnsnull
, else returns the current value.CompletionStage<com.hazelcast.vector.VectorDocument<V>>
removeAsync
(K key) Removes asynchronously the association of givenkey
to a document, if such an association existed, returning theVectorDocument
previously associated with thekey
if such an association existed.searchAsync
(com.hazelcast.vector.VectorValues vectors, com.hazelcast.vector.SearchOptions searchOptions) Perform asynchronously a similarity search according to the options in givensearchOptions
.Asynchronously associates the given key with thevalue
VectorDocument
.long
size()
Returns the number of values in the vector collection.Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getDestroyContextForTenant, getName, getPartitionKey, getServiceName
-
Method Details
-
getAsync
Asynchronously gets theVectorDocument
associated with the given key ornull
if no such association exists.- Parameters:
key
- the key of the entry- Returns:
- the
VectorDocument
associated with the given key ornull
if no such association exists.
-
putAsync
CompletionStage<com.hazelcast.vector.VectorDocument<V>> putAsync(@Nonnull K key, @Nonnull com.hazelcast.vector.VectorDocument<V> value) Asynchronously associates the given key with thevalue
VectorDocument
, returning theVectorDocument
previously associated with thekey
if such an association existed.- Parameters:
key
- the key of the entryvalue
- the value to associate the entry with- Returns:
- the
VectorDocument
previously associated withkey
ornull
if noVectorDocument
was previously associated withkey
.
-
setAsync
CompletionStage<Void> setAsync(@Nonnull K key, @Nonnull com.hazelcast.vector.VectorDocument<V> value) Asynchronously associates the given key with thevalue
VectorDocument
.- Parameters:
key
- the key of the entryvalue
- the value to associate the entry with
-
putIfAbsentAsync
CompletionStage<com.hazelcast.vector.VectorDocument<V>> putIfAbsentAsync(@Nonnull K key, @Nonnull com.hazelcast.vector.VectorDocument<V> value) If the givenkey
is not already associated with aVectorDocument
, associates it with the givenvalue
and returnsnull
, else returns the current value.- Parameters:
key
- the key of the entryvalue
- the value to associate the entry with- Returns:
- the previous
VectorDocument
associated withkey
ornull
if no such association existed.
-
putAllAsync
CompletionStage<Void> putAllAsync(Map<? extends K, com.hazelcast.vector.VectorDocument<V>> documents) Inserts asynchronously the given map of key-document pairs.- Parameters:
documents
- aMap
of key-document associations to insert in theVectorCollection
.
-
removeAsync
Removes asynchronously the association of givenkey
to a document, if such an association existed, returning theVectorDocument
previously associated with thekey
if such an association existed.- Parameters:
key
- the key to remove from theVectorCollection
- Returns:
- the
VectorDocument
previously associated with the givenkey
ornull
if no such association existed.
-
deleteAsync
Removes asynchronously the association of givenkey
to a document, if such an association existed.- Parameters:
key
- the key to remove from theVectorCollection
-
optimizeAsync
Optimize the specified index by fully removing nodes marked for deletion, trimming neighbor sets to the advertised degree, and updating the entry node as necessary.Backups of this operation are always executed as async backups.
- Parameters:
indexName
- the name of the index to be optimized or null for the only index- Returns:
- a
CompletionStage
with a void value if the process finishes successfully; or completed exceptionally with anIndexMutationDisallowedException
if the index is currently undergoing an optimization operation; or completed exceptionally with anIllegalArgumentException
if index does not exist.
-
optimizeAsync
Optimize the only index by fully removing nodes marked for deletion, trimming neighbor sets to the advertised degree, and updating the entry node as necessary.Backups of this operation are always executed as async backups.
- Returns:
- a
CompletionStage
with a void value if the process finishes successfully; or completed exceptionally with anIndexMutationDisallowedException
if the index is currently undergoing an optimization operation; or completed exceptionally with anIllegalArgumentException
if the collection has more than one index.
-
clearAsync
CompletionStage<Void> clearAsync()Asynchronously clears all entries in the vector collection.Backups of this operation are always executed as async backups.
- Returns:
- A
CompletionStage
that completes when the clear operation is finished.
-
size
long size()Returns the number of values in the vector collection.- Returns:
- the number of values in the vector collection as a long.
-
searchAsync
CompletionStage<SearchResults<K,V>> searchAsync(com.hazelcast.vector.VectorValues vectors, com.hazelcast.vector.SearchOptions searchOptions) Perform asynchronously a similarity search according to the options in givensearchOptions
.If there are many concurrent modifications during search, it is possible but extremely unlikely to receive fewer results than requested, even when the collection contains enough items.
- Parameters:
vectors
- the search vector. Can be unnamed if the collection has only one index, otherwise it has to be associated with index namesearchOptions
- the search options- Returns:
SearchResults
object that allows to iterate over search results in order of descending similarity score
-
getCollection
static <K,V> VectorCollection<K,V> getCollection(com.hazelcast.core.HazelcastInstance instance, com.hazelcast.config.vector.VectorCollectionConfig collectionConfig) -
getCollection
static <K,V> VectorCollection<K,V> getCollection(com.hazelcast.core.HazelcastInstance instance, String name)
-