Class CosmosReadManyByPartitionKeysRequestOptions
readManyByPartitionKeys operation
in the Azure Cosmos DB database service.
This is distinct from CosmosReadManyRequestOptions (used by the
readMany(List<CosmosItemIdentity>) API). It exposes only the knobs that are
applicable to readManyByPartitionKeys — for example, properties that influence
query parallelism inside a single physical partition or a feed range filter are
intentionally not exposed because the operation is fully managed by the SDK.
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new readManyByPartitionKeys request options. -
Method Summary
Modifier and TypeMethodDescriptionGets the additional headers configured on this request options instance.Gets the composite continuation token used to resume a previousreadManyByPartitionKeysinvocation.Gets the custom item serializer defined for this instance of request options.Gets the dedicated gateway request options.Gets the diagnostic thresholds used as an override for a specific operation.Gets the list of regions to exclude for the request/retries.Gets the custom keyword identifiers.intGets the maximum size (in kilobytes) of the backend continuation token embedded inside the compositereadManyByPartitionKeyscontinuation token.Gets the maximum number of partition key values per batch query sent to a single physical partition.Gets the maximum number of per-physical-partition batches whose first page is prefetched concurrently.Gets the maximum number of items returned in a single page.Gets the read consistency strategy for the request.Gets the session token for use with session consistency.Gets the latency threshold for diagnostics on tracer.Gets the throughput control group name.booleanGets the option to enable populate query metrics.setAdditionalHeaders(Map<CosmosAdditionalHeaderName, String> additionalHeaders) Sets additional headers to be included with this specific request.setContinuationToken(String continuationToken) Sets the composite continuation token used to resume a previousreadManyByPartitionKeysinvocation.setCosmosEndToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig) Sets theCosmosEndToEndOperationLatencyPolicyConfigto be used for the request.setCustomItemSerializer(CosmosItemSerializer customItemSerializer) Sets a custom item serializer to be used for this operation.setDedicatedGatewayRequestOptions(DedicatedGatewayRequestOptions dedicatedGatewayRequestOptions) Sets the dedicated gateway request options.setDiagnosticsThresholds(CosmosDiagnosticsThresholds operationSpecificThresholds) Allows overriding the diagnostic thresholds for a specific operation.setExcludedRegions(List<String> excludeRegions) List of regions to be excluded for the request/retries.setKeywordIdentifiers(Set<String> keywordIdentifiers) Sets the custom keyword identifiers.setMaxBackendContinuationTokenSizeInKb(int limitInKb) Sets the maximum size (in kilobytes) of the backend continuation token embedded inside the compositereadManyByPartitionKeyscontinuation token.setMaxBatchSize(int maxBatchSize) Sets the maximum number of partition key values per batch query sent to a single physical partition.setMaxConcurrentBatchPrefetch(int maxConcurrentBatchPrefetch) Sets the maximum number of per-physical-partition batches whose first page is prefetched concurrently.setMaxItemCount(int maxItemCount) Sets the maximum number of items returned in a single page.setQueryMetricsEnabled(boolean queryMetricsEnabled) Sets the option to enable/disable query metrics.setReadConsistencyStrategy(ReadConsistencyStrategy readConsistencyStrategy) Sets the read consistency strategy required for the request.setSessionToken(String sessionToken) Sets the session token for use with session consistency.setThresholdForDiagnosticsOnTracer(Duration thresholdForDiagnosticsOnTracer) Sets the latency threshold for diagnostics on tracer.setThroughputControlGroupName(String throughputControlGroupName) Sets the throughput control group name.
-
Constructor Details
-
CosmosReadManyByPartitionKeysRequestOptions
public CosmosReadManyByPartitionKeysRequestOptions()Instantiates a new readManyByPartitionKeys request options.
-
-
Method Details
-
getContinuationToken
Gets the composite continuation token used to resume a previousreadManyByPartitionKeysinvocation.- Returns:
- the continuation token, or null if not set.
-
setContinuationToken
Sets the composite continuation token used to resume a previousreadManyByPartitionKeysinvocation. The token must have been returned by a prior invocation ofreadManyByPartitionKeyson the same container, with the same partition-key set and the same custom query.- Parameters:
continuationToken- the composite continuation token from a previous invocation.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
getMaxConcurrentBatchPrefetch
Gets the maximum number of per-physical-partition batches whose first page is prefetched concurrently. This bounds the prefetch parallelism the SDK uses while sequentially draining batches.- Returns:
- the max concurrent batch prefetch, or null if the SDK default is in effect.
-
setMaxConcurrentBatchPrefetch
public CosmosReadManyByPartitionKeysRequestOptions setMaxConcurrentBatchPrefetch(int maxConcurrentBatchPrefetch) Sets the maximum number of per-physical-partition batches whose first page is prefetched concurrently. The default isMath.max(1, Math.min(Runtime.getRuntime().availableProcessors(), 8)).Increase this to trade memory for lower end-to-end latency on wide containers; decrease it (e.g. to
1) when running in environments where a single task already saturates the network/CPU and additional prefetch only adds memory pressure.- Parameters:
maxConcurrentBatchPrefetch- the max concurrent batch prefetch (must be >= 1).- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining. - Throws:
IllegalArgumentException- ifmaxConcurrentBatchPrefetchis < 1.
-
getMaxBatchSize
Gets the maximum number of partition key values per batch query sent to a single physical partition. Returnsnullif not set, in which case the SDK default is used (currently100, configurable globally via the system property or environment variableCOSMOS.READ_MANY_BY_PK_MAX_BATCH_SIZE).- Returns:
- the max batch size, or null if the SDK default is in effect.
-
setMaxBatchSize
Sets the maximum number of partition key values per batch query sent to a single physical partition. The default is 100 (overridable globally via the system propertyCOSMOS.READ_MANY_BY_PK_MAX_BATCH_SIZE). This per-request setting takes precedence over the global default.Increasing this value reduces the number of batches (and round-trips) but produces larger IN-clause queries that consume more RUs per request. Decreasing it increases the number of batches but keeps individual requests lighter.
- Parameters:
maxBatchSize- the maximum number of PKs per batch (must be >= 1).- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining. - Throws:
IllegalArgumentException- ifmaxBatchSizeis < 1.
-
getReadConsistencyStrategy
Gets the read consistency strategy for the request.- Returns:
- the read consistency strategy.
-
setReadConsistencyStrategy
public CosmosReadManyByPartitionKeysRequestOptions setReadConsistencyStrategy(ReadConsistencyStrategy readConsistencyStrategy) Sets the read consistency strategy required for the request.Honored across Direct, Gateway V1 (compute gateway), and Gateway V2 (thin client proxy) connection modes.
GLOBAL_STRONGis rejected client-side with aCosmosException(HTTP 400) when the account's default consistency is notConsistencyLevel.STRONG. Such failures must NOT be retried.- Parameters:
readConsistencyStrategy- the read consistency strategy.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
getSessionToken
Gets the session token for use with session consistency.- Returns:
- the session token.
-
setSessionToken
Sets the session token for use with session consistency.- Parameters:
sessionToken- the session token.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
setMaxBackendContinuationTokenSizeInKb
public CosmosReadManyByPartitionKeysRequestOptions setMaxBackendContinuationTokenSizeInKb(int limitInKb) Sets the maximum size (in kilobytes) of the backend continuation token embedded inside the compositereadManyByPartitionKeyscontinuation token.Note: this only constrains the per-batch backend continuation that the SDK wraps inside the public composite token; the public composite token itself is always larger because it also carries the remaining batch definitions, query hash, and partition-key-set hash.
- Parameters:
limitInKb- backend continuation token size limit (must be >= 1).- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
getMaxBackendContinuationTokenSizeInKb
public int getMaxBackendContinuationTokenSizeInKb()Gets the maximum size (in kilobytes) of the backend continuation token embedded inside the compositereadManyByPartitionKeyscontinuation token. Returns 0 if not set.- Returns:
- the configured backend continuation token size limit, or 0 if not set.
-
getMaxItemCount
Gets the maximum number of items returned in a single page.- Returns:
- the max item count, or null if not set (the SDK default applies).
-
setMaxItemCount
Sets the maximum number of items returned in a single page.- Parameters:
maxItemCount- the maximum number of items per page.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
setCosmosEndToEndOperationLatencyPolicyConfig
public CosmosReadManyByPartitionKeysRequestOptions setCosmosEndToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig) Sets theCosmosEndToEndOperationLatencyPolicyConfigto be used for the request.- Parameters:
cosmosEndToEndOperationLatencyPolicyConfig- theCosmosEndToEndOperationLatencyPolicyConfig- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
setExcludedRegions
List of regions to be excluded for the request/retries.- Parameters:
excludeRegions- the regions to exclude- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptions
-
getExcludedRegions
Gets the list of regions to exclude for the request/retries.- Returns:
- the list of excluded regions
-
isQueryMetricsEnabled
public boolean isQueryMetricsEnabled()Gets the option to enable populate query metrics. By default query metrics are enabled.- Returns:
- whether query metrics are enabled
-
setQueryMetricsEnabled
public CosmosReadManyByPartitionKeysRequestOptions setQueryMetricsEnabled(boolean queryMetricsEnabled) Sets the option to enable/disable query metrics.- Parameters:
queryMetricsEnabled- whether to enable or disable query metrics- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
getThroughputControlGroupName
Gets the throughput control group name.- Returns:
- the throughput control group name.
-
setThroughputControlGroupName
public CosmosReadManyByPartitionKeysRequestOptions setThroughputControlGroupName(String throughputControlGroupName) Sets the throughput control group name.- Parameters:
throughputControlGroupName- the throughput control group name.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
getDedicatedGatewayRequestOptions
Gets the dedicated gateway request options.- Returns:
- the dedicated gateway request options.
-
setDedicatedGatewayRequestOptions
public CosmosReadManyByPartitionKeysRequestOptions setDedicatedGatewayRequestOptions(DedicatedGatewayRequestOptions dedicatedGatewayRequestOptions) Sets the dedicated gateway request options.- Parameters:
dedicatedGatewayRequestOptions- the dedicated gateway request options.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
getThresholdForDiagnosticsOnTracer
Gets the latency threshold for diagnostics on tracer.- Returns:
- the latency threshold for diagnostics on tracer.
-
setThresholdForDiagnosticsOnTracer
public CosmosReadManyByPartitionKeysRequestOptions setThresholdForDiagnosticsOnTracer(Duration thresholdForDiagnosticsOnTracer) Sets the latency threshold for diagnostics on tracer.- Parameters:
thresholdForDiagnosticsOnTracer- the latency threshold for diagnostics on tracer.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
setDiagnosticsThresholds
public CosmosReadManyByPartitionKeysRequestOptions setDiagnosticsThresholds(CosmosDiagnosticsThresholds operationSpecificThresholds) Allows overriding the diagnostic thresholds for a specific operation.- Parameters:
operationSpecificThresholds- the diagnostic threshold override for this operation- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
getDiagnosticsThresholds
Gets the diagnostic thresholds used as an override for a specific operation.- Returns:
- the diagnostic thresholds for this operation.
-
getCustomItemSerializer
Gets the custom item serializer defined for this instance of request options.- Returns:
- the custom item serializer.
-
setCustomItemSerializer
public CosmosReadManyByPartitionKeysRequestOptions setCustomItemSerializer(CosmosItemSerializer customItemSerializer) Sets a custom item serializer to be used for this operation.- Parameters:
customItemSerializer- the custom item serializer for this operation.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
setKeywordIdentifiers
public CosmosReadManyByPartitionKeysRequestOptions setKeywordIdentifiers(Set<String> keywordIdentifiers) Sets the custom keyword identifiers.- Parameters:
keywordIdentifiers- the custom keyword identifiers.- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining.
-
getKeywordIdentifiers
Gets the custom keyword identifiers.- Returns:
- the custom keyword identifiers.
-
setAdditionalHeaders
public CosmosReadManyByPartitionKeysRequestOptions setAdditionalHeaders(Map<CosmosAdditionalHeaderName, String> additionalHeaders) Sets additional headers to be included with this specific request.The
CosmosAdditionalHeaderNameclass defines exactly which headers are supported. This allows per-request header customization, such as setting a workload ID that overrides the client-level default set viaCosmosClientBuilder.additionalHeaders(java.util.Map).If the same header is also set at the client level, the request-level value takes precedence.
Note: This method uses additive (merge) semantics — headers from multiple calls are merged into the existing set. Passing
nullor an empty map does not clear previously set headers. To reset headers, create a new options instance.- Parameters:
additionalHeaders- map ofCosmosAdditionalHeaderNameto value- Returns:
- the
CosmosReadManyByPartitionKeysRequestOptionsfor fluent chaining. - Throws:
IllegalArgumentException- if the workload-id value is not a valid integer
-
getAdditionalHeaders
Gets the additional headers configured on this request options instance.- Returns:
- unmodifiable map of additional headers, or
nullif none are set
-