public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var colnames = from c in queue.GetRowFormat.Columns select c.ColumnName; bool autoinc = queue.GetRowFormat.FindAutoIncrementColumn() != null; if (autoinc) { m_dmp.AllowIdentityInsert(table.FullName, true); } try { if (Cfg != null && Cfg.JoinInserts) { int rowsInBatch = 0; while (!queue.IsEof) { if (Cfg.BatchLimit > 0 && rowsInBatch >= Cfg.BatchLimit) { m_dmp.EndCommand(); rowsInBatch = 0; } if (rowsInBatch > 0) { m_dmp.Put(";\n"); } IBedRecord row = queue.GetRecord(); m_dmp.Put("^insert ^into %f (%,i) ^values (%,v)", table, colnames, row); rowsInBatch++; } if (rowsInBatch > 0) { m_dmp.EndCommand(); } } else { while (!queue.IsEof) { IBedRecord row = queue.GetRecord(); m_dmp.PutCmd("^insert ^into %f (%,i) ^values (%,v)", table, colnames, row); } } } finally { queue.CloseReading(); } if (autoinc) { m_dmp.AllowIdentityInsert(table.FullName, false); } }
public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var colnames = from c in queue.GetRowFormat.Columns select c.ColumnName; try { if (Wcfg != null && Wcfg.ExtendedInserts) { int rowsInBatch = 0; while (!queue.IsEof) { if (Wcfg.BatchLimit > 0 && rowsInBatch >= Wcfg.BatchLimit) { m_dmp.EndCommand(); rowsInBatch = 0; } if (rowsInBatch == 0) { m_dmp.Put("^insert ^into %f (%,i) ^values\n", table, colnames); } else { m_dmp.Put(",\n"); } IBedRecord row = queue.GetRecord(); m_dmp.Put("(%,v)", row); rowsInBatch++; } if (rowsInBatch > 0) { m_dmp.EndCommand(); } } else { while (!queue.IsEof) { IBedRecord row = queue.GetRecord(); m_dmp.PutCmd("^insert ^into %f (%,i) ^values (%,v)", table, colnames, row); } } } finally { queue.CloseReading(); } }
public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var fmt = new BedValueFormatter(FormatSettings); ExcelXmlDataStore.WriteHeaders(m_fw, table, table.FullName.ToString()); try { while (!queue.IsEof) { var record = queue.GetRecord(); ExcelXmlDataStore.WriteRow(m_fw, table, record, fmt); } } finally { queue.CloseReading(); } m_fw.Write("</ss:Table>\n"); m_fw.Write("</Worksheet>\n"); }
public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { TableStructure dst = null; try { dst = (TableStructure)m_db.Tables[table.FullName]; } catch { throw new InternalError("DAE-00064 Table not found in target structure:" + table.FullName.ToString()); } InMemoryTable tbl = InMemoryTable.FromEnumerable(queue.GetRowFormat, queue.EnumRows()); if (tbl.Rows.Count == 0) { tbl = null; } dst.FixedData = tbl; }
public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { ITableStructure ts = queue.GetRowFormat; string fn = FileNameTemplate; fn = fn.Replace("#TABLE#", table.FullName.Name); fn = fn.Replace("#SCHEMA#", table.FullName.Schema ?? ""); string dir = Path.GetDirectoryName(fn); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var api = DataStore.StreamApi; using (StreamWriter fw = new StreamWriter(fn)) { object manager = null; api.WriteStart(fw, ts, ref manager); int index = 0; try { while (!queue.IsEof) { var record = queue.GetRecord(); api.WriteRecord(fw, ts, record, index, manager); index++; } } finally { queue.CloseReading(); } api.WriteEnd(fw, ts, manager); } }
public static async Task <KeyValuePair <string, TableStatistics> > CopyTableAsync(this CloudTable sourceTable, CloudTableClient targetClient, DateTime whenStartedUtc, TableCopyOptions copyOptions) { var targetTableName = sourceTable.Name; //return await await sourceContainer.CreateOrUpdateTargetContainerForCopyAsync(targetClient, targetContainerName, // async (targetContainer, findExistingAsync, renewAccessAsync, releaseAccessAsync) => // { // try // { // var existingTargetBlobs = await findExistingAsync(); // var pair = default(BlobContinuationToken).PairWithValue(ContainerStatistics.Default.Concat(existingTargetBlobs.Key)); // BlobAccess access = default(BlobAccess); // Func<Task<BlobAccess>> renewWhenExpiredAsync = // async () => // { // if (access.expiresUtc < DateTime.UtcNow + TimeSpan.FromMinutes(5)) // { // access = await renewAccessAsync(copyOptions.accessPeriod); // await Task.Delay(TimeSpan.FromSeconds(10)); // let settle in so first copy will be ok // } // return access; // }; // while (true) // { // pair = await await sourceContainer.FindNextBlobSegmentAsync<Task<KeyValuePair<BlobContinuationToken,ContainerStatistics>>>(pair.Key, // async (token, blobs) => // { // var stats = await blobs.CopyBlobsWithContainerKeyAsync(targetContainer, existingTargetBlobs.Value, copyOptions.checkCopyCompleteAfter, copyOptions.maxWaitForCopyComplete, renewWhenExpiredAsync, copyOptions.maxBatch, copyOptions.maxConcurrency); // blobs = null; // return token.PairWithValue(pair.Value.Concat(stats)); // }, // why => default(BlobContinuationToken).PairWithValue(pair.Value.Concat(new[] { why })).ToTask()); // if (default(BlobContinuationToken) == pair.Key) // { // if (pair.Value.retries.Any()) // { // var copyRetries = copyOptions.copyRetries; // existingTargetBlobs = await findExistingAsync(); // pair = default(BlobContinuationToken).PairWithValue(pair.Value.Concat(existingTargetBlobs.Key)); // while (copyRetries-- > 0) // { // var stats = await pair.Value.retries // .Select(x => x.Key) // .ToArray() // .CopyBlobsWithContainerKeyAsync(targetContainer, existingTargetBlobs.Value, copyOptions.checkCopyCompleteAfter, copyOptions.maxWaitForCopyComplete, renewWhenExpiredAsync, copyOptions.maxBatch, copyOptions.maxConcurrency); // pair = default(BlobContinuationToken).PairWithValue(new ContainerStatistics // { // errors = pair.Value.errors.Concat(stats.errors).ToArray(), // successes = pair.Value.successes + stats.successes, // retries = stats.retries, // failures = pair.Value.failures.Concat(stats.failures).ToArray() // }); // if (!pair.Value.retries.Any()) // break; // } // } // return sourceContainer.Name.PairWithValue(pair.Value); // } // } // } // catch (Exception e) // { // return sourceContainer.Name.PairWithValue(ContainerStatistics.Default.Concat(new [] { $"Exception copying container, Detail: {e.Message}" })); // } // finally // { // await releaseAccessAsync(); // } // }, // why => sourceContainer.Name.PairWithValue(ContainerStatistics.Default.Concat(new[] { why })).ToTask()); }