|
39 | 39 | import static io.qdrant.client.grpc.Points.DiscoverBatchResponse; |
40 | 40 | import static io.qdrant.client.grpc.Points.DiscoverPoints; |
41 | 41 | import static io.qdrant.client.grpc.Points.DiscoverResponse; |
| 42 | +import static io.qdrant.client.grpc.Points.PointsUpdateOperation; |
| 43 | +import static io.qdrant.client.grpc.Points.UpdateBatchPoints; |
| 44 | +import static io.qdrant.client.grpc.Points.UpdateBatchResponse; |
42 | 45 | import static io.qdrant.client.grpc.Collections.GetCollectionInfoRequest; |
43 | 46 | import static io.qdrant.client.grpc.Collections.GetCollectionInfoResponse; |
44 | 47 | import static io.qdrant.client.grpc.Collections.ListAliasesRequest; |
@@ -1551,7 +1554,7 @@ public ListenableFuture<UpdateResult> overwritePayloadAsync( |
1551 | 1554 | } |
1552 | 1555 |
|
1553 | 1556 | /** |
1554 | | - * Overwrites the payload for the given ids. |
| 1557 | + * Overwrites the payload for the filtered points. |
1555 | 1558 | * |
1556 | 1559 | * @param collectionName The name of the collection. |
1557 | 1560 | * @param payload New payload values |
@@ -1696,7 +1699,7 @@ public ListenableFuture<UpdateResult> deletePayloadAsync( |
1696 | 1699 | } |
1697 | 1700 |
|
1698 | 1701 | /** |
1699 | | - * Delete specified key payload for the given ids. |
| 1702 | + * Delete specified key payload for the filtered points. |
1700 | 1703 | * |
1701 | 1704 | * @param collectionName The name of the collection. |
1702 | 1705 | * @param keys List of keys to delete. |
@@ -1832,7 +1835,7 @@ public ListenableFuture<UpdateResult> clearPayloadAsync( |
1832 | 1835 | } |
1833 | 1836 |
|
1834 | 1837 | /** |
1835 | | - * Removes all payload for the given ids. |
| 1838 | + * Removes all payload for the filtered points. |
1836 | 1839 | * |
1837 | 1840 | * @param collectionName The name of the collection. |
1838 | 1841 | * @param filter A filter selecting the points for which to remove the payload. |
@@ -2204,6 +2207,68 @@ public ListenableFuture<List<BatchResult>> recommendBatchAsync( |
2204 | 2207 | MoreExecutors.directExecutor()); |
2205 | 2208 | } |
2206 | 2209 |
|
| 2210 | + /** |
| 2211 | + * Performs a batch update of points. |
| 2212 | + * |
| 2213 | + * @param collectionName The name of the collection. |
| 2214 | + * @param operations The list of point update operations. |
| 2215 | + * |
| 2216 | + * @return a new instance of {@link ListenableFuture} |
| 2217 | + */ |
| 2218 | + public ListenableFuture<List<UpdateResult>> batchUpdateAsync(String collectionName, List<PointsUpdateOperation> operations) { |
| 2219 | + return batchUpdateAsync(collectionName, operations, null, null, null); |
| 2220 | + } |
| 2221 | + |
| 2222 | + /** |
| 2223 | + * Performs a batch update of points. |
| 2224 | + * |
| 2225 | + * @param collectionName The name of the collection. |
| 2226 | + * @param operations The list of point update operations. |
| 2227 | + * @param wait Whether to wait until the changes have been applied. Defaults to <code>true</code>. |
| 2228 | + * @param ordering Write ordering guarantees. |
| 2229 | + * @param timeout The timeout for the call. |
| 2230 | + * |
| 2231 | + * @return a new instance of {@link ListenableFuture} |
| 2232 | + */ |
| 2233 | + public ListenableFuture<List<UpdateResult>> batchUpdateAsync( |
| 2234 | + String collectionName, |
| 2235 | + List<PointsUpdateOperation> operations, |
| 2236 | + @Nullable Boolean wait, |
| 2237 | + @Nullable WriteOrdering ordering, |
| 2238 | + @Nullable Duration timeout) { |
| 2239 | + |
| 2240 | + UpdateBatchPoints.Builder requestBuilder = UpdateBatchPoints.newBuilder() |
| 2241 | + .setCollectionName(collectionName) |
| 2242 | + .addAllOperations(operations) |
| 2243 | + .setWait(wait == null || wait); |
| 2244 | + |
| 2245 | + if (ordering != null) { |
| 2246 | + requestBuilder.setOrdering(ordering); |
| 2247 | + } |
| 2248 | + return batchUpdateAsync(requestBuilder.build(), timeout); |
| 2249 | + } |
| 2250 | + |
| 2251 | + |
| 2252 | + /** |
| 2253 | + * Performs a batch update of points. |
| 2254 | + * |
| 2255 | + * @param request The update batch request. |
| 2256 | + * @param timeout The timeout for the call. |
| 2257 | + * |
| 2258 | + * @return a new instance of {@link ListenableFuture} |
| 2259 | + */ |
| 2260 | + public ListenableFuture<List<UpdateResult>> batchUpdateAsync(UpdateBatchPoints request, @Nullable Duration timeout) { |
| 2261 | + String collectionName = request.getCollectionName(); |
| 2262 | + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); |
| 2263 | + logger.debug("Batch update points on '{}'", collectionName); |
| 2264 | + ListenableFuture<UpdateBatchResponse> future = getPoints(timeout).updateBatch(request); |
| 2265 | + addLogFailureCallback(future, "Batch update points"); |
| 2266 | + return Futures.transform( |
| 2267 | + future, |
| 2268 | + UpdateBatchResponse::getResultList, |
| 2269 | + MoreExecutors.directExecutor()); |
| 2270 | + } |
| 2271 | + |
2207 | 2272 | /** |
2208 | 2273 | * Look for the points which are closer to stored positive examples and at the same time further to negative |
2209 | 2274 | * examples, grouped by a given field |
|
0 commit comments