|
38 | 38 | import java.util.concurrent.atomic.AtomicBoolean; |
39 | 39 | import java.util.concurrent.atomic.AtomicInteger; |
40 | 40 | import java.util.Map; |
41 | | -import java.util.HashMap; |
42 | 41 | import java.util.List; |
43 | 42 | import java.util.stream.Collectors; |
44 | 43 |
|
@@ -465,10 +464,7 @@ private void queryWithQuerySpec() throws Exception { |
465 | 464 | executeQueryWithQuerySpecPrintSingleResult(querySpec); |
466 | 465 | } |
467 | 466 |
|
468 | | - // Step 1-4: Create multiple documents (some with duplicate partition keys) and collect latest session tokens per partition. |
469 | | - // Uses a dedicated CosmosAsyncClient (writer) and ensures the latest session token per partition key overrides earlier values. |
470 | 467 | private Map<String, String> upsertMultipleDocumentsCollectSessionTokens(String dbName, String containerName, int totalDocuments) { |
471 | | - // Use a HashMap to store the latest session token per stringified partition key |
472 | 468 | Map<String, String> partitionToSessionToken = new ConcurrentHashMap<>(); |
473 | 469 |
|
474 | 470 | // Use a dedicated client instance for creates/upserts |
@@ -520,7 +516,6 @@ private Map<String, String> upsertMultipleDocumentsCollectSessionTokens(String |
520 | 516 | f.setLastName(pkValue); |
521 | 517 | f.setId(UUID.randomUUID().toString()); |
522 | 518 |
|
523 | | - // Convert the typed response into Object to avoid compile-time dependency on CosmosItemResponse in generics. |
524 | 519 | Mono<CosmosItemResponse<Family>> upsertMono = writerContainer |
525 | 520 | .upsertItem(f, new PartitionKey(pkValue), new CosmosItemRequestOptions()) |
526 | 521 | .map(response -> { |
@@ -663,7 +658,10 @@ private void shutdown() { |
663 | 658 | logger.info("Done with sample."); |
664 | 659 | } |
665 | 660 |
|
666 | | - // Full cross-partition query using a compound session token built from multiple partition-specific session tokens |
| 661 | + // Steps: |
| 662 | + // 1. Create multiple documents (some with duplicate partition keys) and collect latest session tokens per partition key. |
| 663 | + // 2. Build a compound session token by concatenating the session tokens using commas present in partitionKeyToLastRecordedSessionToken. |
| 664 | + // 3. Perform a cross-partition query using the compound session token. |
667 | 665 | private void queryCrossPartitionAsyncUsingSessionConsistency() { |
668 | 666 | logger.info("Starting cross-partition upserts and session-consistent query."); |
669 | 667 | try { |
|
0 commit comments