Interface VectorCollection<K,V>
- Type Parameters:
K- key type.V- value type.
- All Superinterfaces:
com.hazelcast.core.DistributedObject
VectorDocuments.
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 givenkeyto a document, if such an association existed.CompletionStage<com.hazelcast.vector.VectorDocument<V>>Asynchronously gets theVectorDocumentassociated with the given key ornullif 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 thevalueVectorDocument, returning theVectorDocumentpreviously associated with thekeyif such an association existed.CompletionStage<com.hazelcast.vector.VectorDocument<V>>putIfAbsentAsync(K key, com.hazelcast.vector.VectorDocument<V> value) If the givenkeyis not already associated with aVectorDocument, associates it with the givenvalueand returnsnull, else returns the current value.CompletionStage<com.hazelcast.vector.VectorDocument<V>>removeAsync(K key) Removes asynchronously the association of givenkeyto a document, if such an association existed, returning theVectorDocumentpreviously associated with thekeyif 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 thevalueVectorDocument.longsize()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 theVectorDocumentassociated with the given key ornullif no such association exists.- Parameters:
key- the key of the entry- Returns:
- the
VectorDocumentassociated with the given key ornullif 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 thevalueVectorDocument, returning theVectorDocumentpreviously associated with thekeyif such an association existed.- Parameters:
key- the key of the entryvalue- the value to associate the entry with- Returns:
- the
VectorDocumentpreviously associated withkeyornullif noVectorDocumentwas previously associated withkey.
-
setAsync
CompletionStage<Void> setAsync(@Nonnull K key, @Nonnull com.hazelcast.vector.VectorDocument<V> value) Asynchronously associates the given key with thevalueVectorDocument.- 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 givenkeyis not already associated with aVectorDocument, associates it with the givenvalueand returnsnull, else returns the current value.- Parameters:
key- the key of the entryvalue- the value to associate the entry with- Returns:
- the previous
VectorDocumentassociated withkeyornullif 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- aMapof key-document associations to insert in theVectorCollection.
-
removeAsync
Removes asynchronously the association of givenkeyto a document, if such an association existed, returning theVectorDocumentpreviously associated with thekeyif such an association existed.- Parameters:
key- the key to remove from theVectorCollection- Returns:
- the
VectorDocumentpreviously associated with the givenkeyornullif no such association existed.
-
deleteAsync
Removes asynchronously the association of givenkeyto 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.- Parameters:
indexName- the name of the index to be optimized or null for the only index- Returns:
- a
CompletionStagewith a void value if the process finishes successfully; or completed exceptionally with anIndexMutationDisallowedExceptionif the index is currently undergoing an optimization operation; or completed exceptionally with anIllegalArgumentExceptionif 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.- Returns:
- a
CompletionStagewith a void value if the process finishes successfully; or completed exceptionally with anIndexMutationDisallowedExceptionif the index is currently undergoing an optimization operation; or completed exceptionally with anIllegalArgumentExceptionif the collection has more than one index.
-
clearAsync
CompletionStage<Void> clearAsync()Asynchronously clears all entries in the vector collection.- Returns:
- A
CompletionStagethat 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:
SearchResultsobject 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)
-