|
23 | 23 | import com.datastax.astra.client.exception.DataAPIFaultyResponseException;
|
24 | 24 | import com.datastax.astra.client.exception.DataApiException;
|
25 | 25 | import com.datastax.astra.client.exception.TooManyDocumentsToCountException;
|
26 |
| -import com.datastax.astra.client.model.BulkWriteOptions; |
27 |
| -import com.datastax.astra.client.model.BulkWriteResult; |
28 | 26 | import com.datastax.astra.client.model.CollectionIdTypes;
|
29 | 27 | import com.datastax.astra.client.model.CollectionInfo;
|
30 | 28 | import com.datastax.astra.client.model.CollectionOptions;
|
31 |
| -import com.datastax.astra.client.model.Command; |
32 |
| -import com.datastax.astra.client.model.CommandOptions; |
33 | 29 | import com.datastax.astra.client.model.CountDocumentsOptions;
|
34 |
| -import com.datastax.astra.client.model.DataAPIKeywords; |
35 | 30 | import com.datastax.astra.client.model.DeleteManyOptions;
|
36 | 31 | import com.datastax.astra.client.model.DeleteOneOptions;
|
37 | 32 | import com.datastax.astra.client.model.DeleteResult;
|
38 | 33 | import com.datastax.astra.client.model.DistinctIterable;
|
39 | 34 | import com.datastax.astra.client.model.Document;
|
40 | 35 | import com.datastax.astra.client.model.EstimatedCountDocumentsOptions;
|
41 |
| -import com.datastax.astra.client.model.Filter; |
42 |
| -import com.datastax.astra.client.model.Filters; |
43 | 36 | import com.datastax.astra.client.model.FindIterable;
|
44 | 37 | import com.datastax.astra.client.model.FindOneAndDeleteOptions;
|
45 | 38 | import com.datastax.astra.client.model.FindOneAndReplaceOptions;
|
|
51 | 44 | import com.datastax.astra.client.model.InsertManyResult;
|
52 | 45 | import com.datastax.astra.client.model.InsertOneOptions;
|
53 | 46 | import com.datastax.astra.client.model.InsertOneResult;
|
54 |
| -import com.datastax.astra.client.model.ObjectId; |
55 | 47 | import com.datastax.astra.client.model.Page;
|
56 | 48 | import com.datastax.astra.client.model.ReplaceOneOptions;
|
57 | 49 | import com.datastax.astra.client.model.ReturnDocument;
|
58 |
| -import com.datastax.astra.client.model.UUIDv6; |
59 |
| -import com.datastax.astra.client.model.UUIDv7; |
60 | 50 | import com.datastax.astra.client.model.Update;
|
61 | 51 | import com.datastax.astra.client.model.UpdateManyOptions;
|
62 | 52 | import com.datastax.astra.client.model.UpdateOneOptions;
|
63 | 53 | import com.datastax.astra.client.model.UpdateResult;
|
| 54 | +import com.datastax.astra.client.model.command.Command; |
| 55 | +import com.datastax.astra.client.model.command.CommandOptions; |
| 56 | +import com.datastax.astra.client.model.query.Filter; |
| 57 | +import com.datastax.astra.client.model.query.Filters; |
| 58 | +import com.datastax.astra.client.model.types.DataAPIKeywords; |
| 59 | +import com.datastax.astra.client.model.types.ObjectId; |
| 60 | +import com.datastax.astra.client.model.types.UUIDv6; |
| 61 | +import com.datastax.astra.client.model.types.UUIDv7; |
64 | 62 | import com.datastax.astra.internal.api.ApiResponse;
|
65 | 63 | import com.datastax.astra.internal.command.AbstractCommandRunner;
|
66 | 64 | import com.datastax.astra.internal.command.CommandObserver;
|
|
89 | 87 |
|
90 | 88 | import static com.datastax.astra.client.exception.DataApiException.ERROR_CODE_INTERRUPTED;
|
91 | 89 | import static com.datastax.astra.client.exception.DataApiException.ERROR_CODE_TIMEOUT;
|
92 |
| -import static com.datastax.astra.client.model.DataAPIKeywords.SORT_VECTOR; |
| 90 | +import static com.datastax.astra.client.model.types.DataAPIKeywords.SORT_VECTOR; |
93 | 91 | import static com.datastax.astra.internal.utils.AnsiUtils.cyan;
|
94 | 92 | import static com.datastax.astra.internal.utils.AnsiUtils.green;
|
95 | 93 | import static com.datastax.astra.internal.utils.AnsiUtils.magenta;
|
@@ -260,32 +258,6 @@ protected Collection(Database db, String collectionName, CommandOptions<?> comma
|
260 | 258 | // --- Global Information ----
|
261 | 259 | // ----------------------------
|
262 | 260 |
|
263 |
| - /** |
264 |
| - * Retrieves the name of the parent namespace associated with this collection. A namespace in |
265 |
| - * this context typically refers to a higher-level categorization or grouping mechanism within |
266 |
| - * the database that encompasses one or more collections. This method allows for identifying |
267 |
| - * the broader context in which this collection exists, which can be useful for operations |
268 |
| - * requiring knowledge of the database structure or for dynamic database interaction patterns. |
269 |
| - * |
270 |
| - * @return A {@code String} representing the name of the parent namespace of the current |
271 |
| - * collection. This name serves as an identifier for the namespace and can be used |
272 |
| - * to navigate or query the database structure. |
273 |
| - * |
274 |
| - * <p>Example usage:</p> |
275 |
| - * <pre> |
276 |
| - * {@code |
277 |
| - * Collection myCollection = ... // assume myCollection is already initialized |
278 |
| - * String namespaceName = myCollection.getNamespaceName(); |
279 |
| - * System.out.println("The collection belongs to the namespace: " + namespaceName); |
280 |
| - * } |
281 |
| - * </pre> |
282 |
| - * @deprecated use {@link #getKeyspaceName()} instead |
283 |
| - */ |
284 |
| - @Deprecated |
285 |
| - public String getNamespaceName() { |
286 |
| - return getDatabase().getKeyspaceName(); |
287 |
| - } |
288 |
| - |
289 | 261 | /**
|
290 | 262 | * Retrieves the name of the parent keyspace associated with this collection. A keyspace in
|
291 | 263 | * this context typically refers to a higher-level categorization or grouping mechanism within
|
@@ -413,9 +385,9 @@ public String getName() {
|
413 | 385 | * at the collection definition level you can enforce property `defaultId` to work with specialize ids.</p>
|
414 | 386 | * <ul>
|
415 | 387 | * <li>If {@code defaultId} is set to {@code uuid}, ids will be uuid v4 {@link java.util.UUID}</li>
|
416 |
| - * <li>If {@code defaultId} is set to {@code objectId}, ids will be an {@link com.datastax.astra.client.model.ObjectId}</li> |
417 |
| - * <li>If {@code defaultId} is set to {@code uuidv6}, ids will be an {@link com.datastax.astra.client.model.UUIDv6}</li> |
418 |
| - * <li>If {@code defaultId} is set to {@code uuidv7}, ids will be an {@link com.datastax.astra.client.model.UUIDv7}</li> |
| 388 | + * <li>If {@code defaultId} is set to {@code objectId}, ids will be an {@link ObjectId}</li> |
| 389 | + * <li>If {@code defaultId} is set to {@code uuidv6}, ids will be an {@link UUIDv6}</li> |
| 390 | + * <li>If {@code defaultId} is set to {@code uuidv7}, ids will be an {@link UUIDv7}</li> |
419 | 391 | * </ul>
|
420 | 392 | *
|
421 | 393 | * <p>The method returns an {@code InsertOneResult} object, which provides details about the
|
@@ -470,9 +442,9 @@ public final InsertOneResult insertOne(T document) {
|
470 | 442 | * at the collection definition level you can enforce property `defaultId` to work with specialize ids.</p>
|
471 | 443 | * <ul>
|
472 | 444 | * <li>If {@code defaultId} is set to {@code uuid}, ids will be uuid v4 {@link java.util.UUID}</li>
|
473 |
| - * <li>If {@code defaultId} is set to {@code objectId}, ids will be an {@link com.datastax.astra.client.model.ObjectId}</li> |
474 |
| - * <li>If {@code defaultId} is set to {@code uuidv6}, ids will be an {@link com.datastax.astra.client.model.UUIDv6}</li> |
475 |
| - * <li>If {@code defaultId} is set to {@code uuidv7}, ids will be an {@link com.datastax.astra.client.model.UUIDv7}</li> |
| 445 | + * <li>If {@code defaultId} is set to {@code objectId}, ids will be an {@link ObjectId}</li> |
| 446 | + * <li>If {@code defaultId} is set to {@code uuidv6}, ids will be an {@link UUIDv6}</li> |
| 447 | + * <li>If {@code defaultId} is set to {@code uuidv7}, ids will be an {@link UUIDv7}</li> |
476 | 448 | * </ul>
|
477 | 449 | *
|
478 | 450 | * <p>The method returns an {@code InsertOneResult} object, which provides details about the
|
@@ -1924,7 +1896,7 @@ public UpdateResult replaceOne(Filter filter, T replacement, ReplaceOneOptions r
|
1924 | 1896 | * @return
|
1925 | 1897 | * command result
|
1926 | 1898 | */
|
1927 |
| - private FindOneAndReplaceResult<T> executeFindOneAndReplace(Command cmd, CommandOptions options) { |
| 1899 | + private FindOneAndReplaceResult<T> executeFindOneAndReplace(Command cmd, CommandOptions<?> options) { |
1928 | 1900 | // Run Command
|
1929 | 1901 | ApiResponse apiResponse = runCommand(cmd, options);
|
1930 | 1902 | // Parse Command Result
|
@@ -2181,67 +2153,6 @@ public Optional<T> findOneAndDelete(Filter filter, FindOneAndDeleteOptions optio
|
2181 | 2153 | return Optional.empty();
|
2182 | 2154 | }
|
2183 | 2155 |
|
2184 |
| - // ---------------------------- |
2185 |
| - // --- Bulk Write ---- |
2186 |
| - // ---------------------------- |
2187 |
| - |
2188 |
| - /** |
2189 |
| - * Executes a mix of inserts, updates, replaces, and deletes. |
2190 |
| - * |
2191 |
| - * @param commands |
2192 |
| - * list of commands to run |
2193 |
| - * @return |
2194 |
| - * the result of the bulk write |
2195 |
| - */ |
2196 |
| - @Deprecated(since = "1.3.0", forRemoval = true) |
2197 |
| - public BulkWriteResult bulkWrite(List<Command> commands) { |
2198 |
| - return bulkWrite(commands, new BulkWriteOptions()); |
2199 |
| - } |
2200 |
| - |
2201 |
| - /** |
2202 |
| - * Executes a mix of inserts, updates, replaces, and deletes. |
2203 |
| - * |
2204 |
| - * @param options |
2205 |
| - * if requests must be ordered or not |
2206 |
| - * @param commands |
2207 |
| - * list of commands to run |
2208 |
| - * @return |
2209 |
| - * the result of the bulk write |
2210 |
| - */ |
2211 |
| - @Deprecated(since = "1.3.0", forRemoval = true) |
2212 |
| - public BulkWriteResult bulkWrite(List<Command> commands, BulkWriteOptions options) { |
2213 |
| - notNull(commands, ARG_COMMANDS); |
2214 |
| - notNull(options, ARG_OPTIONS); |
2215 |
| - if (options.getConcurrency() > 1 && options.isOrdered()) { |
2216 |
| - throw new IllegalArgumentException("Cannot run ordered bulk_write concurrently."); |
2217 |
| - } |
2218 |
| - BulkWriteResult result = new BulkWriteResult(commands.size()); |
2219 |
| - if (options.isOrdered()) { |
2220 |
| - result.setResponses(commands |
2221 |
| - .stream() |
2222 |
| - .map(cmd -> runCommand(cmd, options)) |
2223 |
| - .collect(Collectors.toList())); |
2224 |
| - } else { |
2225 |
| - try { |
2226 |
| - ExecutorService executor = Executors.newFixedThreadPool(options.getConcurrency()); |
2227 |
| - List<Future<ApiResponse>> futures = new ArrayList<>(); |
2228 |
| - commands.forEach(req -> futures.add(executor.submit(() -> runCommand(req, options)))); |
2229 |
| - executor.shutdown(); |
2230 |
| - for (Future<ApiResponse> future : futures) { |
2231 |
| - result.getResponses().add(future.get()); |
2232 |
| - } |
2233 |
| - } catch (InterruptedException e) { |
2234 |
| - Thread.currentThread().interrupt(); |
2235 |
| - throw new IllegalStateException("Thread was interrupted while waiting for command results", e); |
2236 |
| - } catch (RuntimeException e) { |
2237 |
| - throw new IllegalStateException("Cannot access command results", e); |
2238 |
| - } catch (Exception e) { |
2239 |
| - throw new IllegalStateException("Error occurred during command execution", e.getCause()); |
2240 |
| - } |
2241 |
| - } |
2242 |
| - return result; |
2243 |
| - } |
2244 |
| - |
2245 | 2156 | /**
|
2246 | 2157 | * Register a listener to execute commands on the collection. Please now use {@link CommandOptions}.
|
2247 | 2158 | *
|
|
0 commit comments