public void BulkInsert <T>(string tenantId, IReadOnlyCollection <T> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000) { var bulkInsertion = new BulkInsertion(Tenancy[tenantId], Options); bulkInsertion.BulkInsert(documents, mode, batchSize); }
public Task BulkInsertAsync <T>(string tenantId, IReadOnlyCollection <T> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000, CancellationToken cancellation = default) { var bulkInsertion = new BulkInsertion(Tenancy[tenantId], Options); return(bulkInsertion.BulkInsertAsync(documents, mode, batchSize, cancellation)); }
public Task BulkInsertDocumentsAsync(string tenantId, IEnumerable <object> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000, CancellationToken cancellation = default) { var bulkInsertion = new BulkInsertion(Tenancy[tenantId], Options); return(bulkInsertion.BulkInsertDocumentsAsync(documents, mode, batchSize, cancellation)); }
public void BulkInsertDocuments(string tenantId, IEnumerable <object> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000) { var bulkInsertion = new BulkInsertion(Tenancy[tenantId], Options); bulkInsertion.BulkInsertDocuments(documents, mode, batchSize); }
private void bulkInsertDocuments <T>(IReadOnlyCollection <T> documents, int batchSize, NpgsqlConnection conn, BulkInsertMode mode) { var provider = _tenant.Database.Providers.StorageFor <T>(); var loader = provider.BulkLoader; if (mode != BulkInsertMode.InsertsOnly) { var sql = loader.CreateTempTableForCopying(); conn.CreateCommand(sql).ExecuteNonQuery(); } if (documents.Count <= batchSize) { loadDocuments(documents, loader, mode, conn); } else { var batch = new List <T>(batchSize); foreach (var document in documents) { batch.Add(document); if (batch.Count < batchSize) { continue; } loadDocuments(batch, loader, mode, conn); batch.Clear(); } loadDocuments(batch, loader, mode, conn); } if (mode == BulkInsertMode.IgnoreDuplicates) { var copy = loader.CopyNewDocumentsFromTempTable(); conn.CreateCommand(copy).ExecuteNonQuery(); } else if (mode == BulkInsertMode.OverwriteExisting) { var overwrite = loader.OverwriteDuplicatesFromTempTable(); var copy = loader.CopyNewDocumentsFromTempTable(); conn.CreateCommand(overwrite + ";" + copy).ExecuteNonQuery(); } }
public void BulkInsertDocuments(IEnumerable <object> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000) { throw new NotImplementedException(); }
public void BulkInsert <T>(T[] documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000) { throw new NotImplementedException(); }
void IDocumentStore.BulkInsert <T>(string tenantId, IReadOnlyCollection <T> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000) { _documentStore.BulkInsert(tenantId, documents, mode, batchSize); }
private void loadDocuments <T>(IEnumerable <T> documents, IBulkLoader <T> loader, BulkInsertMode mode, NpgsqlConnection conn) { if (mode == BulkInsertMode.InsertsOnly) { loader.Load(_tenant, Serializer, conn, documents); } else { loader.LoadIntoTempTable(_tenant, Serializer, conn, documents); } }
public void BulkInsertDocuments(IEnumerable <object> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000) { var bulkInsertion = new BulkInsertion(Tenancy.Default, Options, _writerPool); bulkInsertion.BulkInsertDocuments(documents, mode, batchSize); }
public async Task BulkInsertAsync(int batchSize, NpgsqlConnection conn, BulkInsertion parent, BulkInsertMode mode, CancellationToken cancellation) { await parent._tenant.Database.EnsureStorageExistsAsync(typeof(T), cancellation).ConfigureAwait(true); await parent.bulkInsertDocumentsAsync(_documents, batchSize, conn, mode, cancellation).ConfigureAwait(false); }
void IDocumentStore.BulkInsertDocuments(string tenantId, IEnumerable <object> documents, BulkInsertMode mode, int batchSize) { _documentStore.BulkInsertDocuments(tenantId, documents, mode, batchSize); }
void IDocumentStore.BulkInsertDocuments(IEnumerable <object> documents, BulkInsertMode mode, int batchSize) { _documentStore.BulkInsertDocuments(documents, mode, batchSize); }
private async Task loadDocumentsAsync <T>(IReadOnlyCollection <T> documents, IBulkLoader <T> loader, BulkInsertMode mode, NpgsqlConnection conn, CancellationToken cancellation) { if (mode == BulkInsertMode.InsertsOnly) { await loader.LoadAsync(_tenant, Serializer, conn, documents, cancellation).ConfigureAwait(false); } else { await loader.LoadIntoTempTableAsync(_tenant, Serializer, conn, documents, cancellation).ConfigureAwait(false); } }
private void bulkInsertDocuments <T>(IReadOnlyCollection <T> documents, int batchSize, NpgsqlConnection conn, BulkInsertMode mode) { var loader = _tenant.BulkLoaderFor <T>(); if (mode != BulkInsertMode.InsertsOnly) { var sql = loader.CreateTempTableForCopying(); conn.RunSql(sql); } var writer = _writerPool.Lease(); try { if (documents.Count <= batchSize) { loadDocuments(documents, loader, mode, conn, writer); } else { var batch = new List <T>(batchSize); foreach (var document in documents) { batch.Add(document); if (batch.Count < batchSize) { continue; } loadDocuments(batch, loader, mode, conn, writer); batch.Clear(); } loadDocuments(batch, loader, mode, conn, writer); } } finally { if (writer != null) { _writerPool.Release(writer); } } if (mode == BulkInsertMode.IgnoreDuplicates) { var copy = loader.CopyNewDocumentsFromTempTable(); conn.RunSql(copy); } else if (mode == BulkInsertMode.OverwriteExisting) { var overwrite = loader.OverwriteDuplicatesFromTempTable(); var copy = loader.CopyNewDocumentsFromTempTable(); conn.RunSql(overwrite, copy); } }
public void BulkInsert(int batchSize, NpgsqlConnection connection, BulkInsertion parent, BulkInsertMode mode) { parent._tenant.Database.EnsureStorageExists(typeof(T)); parent.bulkInsertDocuments(_documents, batchSize, connection, mode); }
public void BulkInsert <T>(string tenantId, IReadOnlyCollection <T> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000) => throw new NotImplementedException();
public void BulkInsert <T>(IReadOnlyCollection <T> documents, BulkInsertMode mode = BulkInsertMode.InsertsOnly, int batchSize = 1000) { var bulkInsertion = new BulkInsertion(Tenancy.Default, Options, _writerPool); bulkInsertion.BulkInsert(documents, mode, batchSize); }
private async Task bulkInsertDocumentsAsync <T>(IReadOnlyCollection <T> documents, int batchSize, NpgsqlConnection conn, BulkInsertMode mode, CancellationToken cancellation) { var provider = _tenant.Providers.StorageFor <T>(); var loader = provider.BulkLoader; if (mode != BulkInsertMode.InsertsOnly) { var sql = loader.CreateTempTableForCopying(); await conn.CreateCommand(sql).ExecuteNonQueryAsync(cancellation).ConfigureAwait(false); } if (documents.Count <= batchSize) { await loadDocumentsAsync(documents, loader, mode, conn, cancellation).ConfigureAwait(false); } else { var batch = new List <T>(batchSize); foreach (var document in documents) { batch.Add(document); if (batch.Count < batchSize) { continue; } await loadDocumentsAsync(batch, loader, mode, conn, cancellation).ConfigureAwait(false); batch.Clear(); } await loadDocumentsAsync(batch, loader, mode, conn, cancellation).ConfigureAwait(false); } if (mode == BulkInsertMode.IgnoreDuplicates) { var copy = loader.CopyNewDocumentsFromTempTable(); await conn.CreateCommand(copy).ExecuteNonQueryAsync(cancellation).ConfigureAwait(false); } else if (mode == BulkInsertMode.OverwriteExisting) { var overwrite = loader.OverwriteDuplicatesFromTempTable(); var copy = loader.CopyNewDocumentsFromTempTable(); await conn.CreateCommand(overwrite + ";" + copy) .ExecuteNonQueryAsync(cancellation).ConfigureAwait(false); } }
private void bulkInsertDocuments <T>(T[] documents, int batchSize, NpgsqlConnection conn, BulkInsertMode mode) { var loader = Schema.BulkLoaderFor <T>(); if (mode != BulkInsertMode.InsertsOnly) { var sql = loader.CreateTempTableForCopying(); conn.RunSql(sql); } if (documents.Length <= batchSize) { if (mode == BulkInsertMode.InsertsOnly) { loader.Load(_serializer, conn, documents); } else { loader.LoadIntoTempTable(_serializer, conn, documents); } } else { var total = 0; var page = 0; while (total < documents.Length) { var batch = documents.Skip(page * batchSize).Take(batchSize).ToArray(); if (mode == BulkInsertMode.InsertsOnly) { loader.Load(_serializer, conn, batch); } else { loader.LoadIntoTempTable(_serializer, conn, batch); } page++; total += batch.Length; } } if (mode == BulkInsertMode.IgnoreDuplicates) { var copy = loader.CopyNewDocumentsFromTempTable(); conn.RunSql(copy); } else if (mode == BulkInsertMode.OverwriteExisting) { var overwrite = loader.OverwriteDuplicatesFromTempTable(); var copy = loader.CopyNewDocumentsFromTempTable(); conn.RunSql(overwrite, copy); } }
public Task BulkInsertAsync(int batchSize, NpgsqlConnection conn, BulkInsertion parent, BulkInsertMode mode, CancellationToken cancellation) { return(parent.bulkInsertDocumentsAsync(_documents, batchSize, conn, mode, cancellation)); }
public void BulkInsert(int batchSize, NpgsqlConnection connection, BulkInsertion parent, BulkInsertMode mode) { parent.bulkInsertDocuments(_documents, batchSize, connection, mode); }
void IDocumentStore.BulkInsert <T>(IReadOnlyCollection <T> documents, BulkInsertMode mode, int batchSize) => _documentStore.BulkInsert(documents, mode, batchSize);