示例#1
0
        public BulkInsertOpeartionResult BulkDeleteDocuments(string query, int?deleteBatchSize = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            _metaDataOperator.AddActivity(_databaseName, _collectionName, DateTimeOffset.Now, ActivityStrength.Hot).Wait();
            lock (bulkDeleteLock)
            {
                var scaleOperation = ScaleLogic.ScaleUpMaxCollectionAsync(_client, _metaDataOperator, _databaseName, _collectionName, _minRu, _maxRu).GetAwaiter().GetResult();
                var response       = _bulkExecutor.BulkDeleteAsync(query, deleteBatchSize, cancellationToken).GetAwaiter().GetResult();

                return(new BulkInsertOpeartionResult
                {
                    ScaleOperations = new List <ScaleOperation>()
                    {
                        scaleOperation
                    },
                    OperationSuccess = true
                });
            }
        }
示例#2
0
        public BulkInsertOpeartionResult BulkInsertDocuments(IEnumerable <object> documents, bool enableUpsert = false, bool disableAutomaticIdGeneration = true, int?maxConcurrencyPerPartitionKeyRange = null,
                                                             int?maxInMemorySortingBatchSize = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            _metaDataOperator.AddActivity(_databaseName, _collectionName, DateTimeOffset.Now, ActivityStrength.Hot).Wait();
            lock (bulkInsertLock)
            {
                var scaleOperation = ScaleLogic.ScaleUpMaxCollectionAsync(_client, _metaDataOperator, _databaseName, _collectionName, _minRu, _maxRu).GetAwaiter().GetResult();
                _bulkExecutor.BulkImportAsync(documents, enableUpsert, disableAutomaticIdGeneration, maxConcurrencyPerPartitionKeyRange, maxInMemorySortingBatchSize, cancellationToken).Wait();

                return(new BulkInsertOpeartionResult
                {
                    ScaleOperations = new List <ScaleOperation>()
                    {
                        scaleOperation
                    },
                    OperationSuccess = true
                });
            }
        }