com.azure.cosmos.models.CosmosBulkExecutionThresholdsState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-cosmos Show documentation
Show all versions of azure-cosmos Show documentation
This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.models;
import com.azure.cosmos.implementation.ImplementationBridgeHelpers;
import com.azure.cosmos.implementation.batch.PartitionScopeThresholds;
import com.azure.cosmos.util.Beta;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Encapsulates internal state used to dynamically determine max micro batch size for bulk operations.
* It allows passing this state for one `{@link CosmosBulkExecutionOptions}` to another in case bulk operations are
* expected to have similar characteristics and the context for determining the micro batch size should be preserved.
*/
@Beta(value = Beta.SinceVersion.V4_19_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
public final class CosmosBulkExecutionThresholdsState {
private final ConcurrentMap partitionScopeThresholds;
/**
* Constructor
*/
@Beta(value = Beta.SinceVersion.V4_19_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
public CosmosBulkExecutionThresholdsState() {
this.partitionScopeThresholds = new ConcurrentHashMap<>();
}
CosmosBulkExecutionThresholdsState(ConcurrentMap partitionScopeThresholds) {
this.partitionScopeThresholds = partitionScopeThresholds;
}
ConcurrentMap getPartitionScopeThresholds() {
return this.partitionScopeThresholds;
}
///////////////////////////////////////////////////////////////////////////////////////////
// the following helper/accessor only helps to access this class outside of this package.//
///////////////////////////////////////////////////////////////////////////////////////////
static {
ImplementationBridgeHelpers.CosmosBulkExecutionThresholdsStateHelper.setBulkExecutionThresholdsAccessor(
new ImplementationBridgeHelpers.CosmosBulkExecutionThresholdsStateHelper.CosmosBulkExecutionThresholdsStateAccessor() {
@Override
public ConcurrentMap getPartitionScopeThresholds(CosmosBulkExecutionThresholdsState thresholds) {
return thresholds.getPartitionScopeThresholds();
}
@Override
public CosmosBulkExecutionThresholdsState createWithPartitionScopeThresholds(ConcurrentMap partitionScopeThresholds) {
return new CosmosBulkExecutionThresholdsState(partitionScopeThresholds);
}
}
);
}
}