public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var name = new NameWithSchema(table.FullName.Schema, table.FullName.Name, false); var entry = m_zip.PutNextEntry(XmlTool.NormalizeIdentifier(name.ToString()) + ".drs"); BedDataStats stats = new BedDataStats(); BedTool.WriteQueueToStream(queue, m_zip, stats); ProgressInfo.LogMessage("s_export", LogLevel.Info, Texts.Get("s_exported$table$rows$bytes", "rows", stats.Rows, "bytes", stats.Bytes, "table", table.FullName)); //ZipEntry entry = new ZipEntry(XmlTool.NormalizeIdentifier(table.FullName.ToString()) + ".xml"); //m_zip.PutNextEntry(entry); //XmlTool.WriteQueueToXml(queue, m_zip, "DataSet", "DataRow"); }
public static void WriteQueueToStream(IDataQueue queue, Stream fw, BedDataStats stats) { BinaryWriter bw = new BinaryWriter(fw); bw.Write(SIGNATURE); bw.Write((int)2); // version var ts = queue.GetRowFormat; bw.Write7BitEncodedInt(ts.Columns.Count); var pk = ts.FindConstraint <IPrimaryKey>(); foreach (IColumnStructure col in ts.Columns) { bw.Write(col.ColumnName); bw.Write((byte)col.DataType.DefaultStorage); ColFlags flags = 0; if (pk != null && pk.Columns.IndexOfIf(c => c.ColumnName == col.ColumnName) >= 0) { flags |= ColFlags.ISPK; } bw.Write((byte)flags); } MemoryStream rowdata = new MemoryStream(); BinaryWriter bwrow = new BinaryWriter(rowdata); try { while (!queue.IsEof) { rowdata.Position = 0; rowdata.SetLength(0); IBedRecord row = queue.GetRecord(); BedTool.SaveRecord(ts.Columns.Count, row, bwrow); bw.Write7BitEncodedInt((int)rowdata.Length); rowdata.WriteTo(bw.BaseStream); if (stats != null) { stats.Rows++; stats.Bytes += (int)rowdata.Length; stats.Bytes += 4; } } } finally { queue.CloseReading(); } // write EOF mark bw.Write7BitEncodedInt(-1); }