public IEnumerable <ICdlRecord> EnumRows(ArrayDataRecord record) { int page = 0; while (page < _directory.Count) { lock (_directory) { BinaryReader br = new BinaryReader(_cache); _cache.Seek(_directory[page], SeekOrigin.Begin); ChunkInfo info = ChunkInfo.LoadInfo(br); for (int i = 0; i < info.Count; i++) { if (record == null) { yield return(CdlTool.LoadRecord(br, _table)); } else { CdlTool.LoadRecord(br, record); yield return(record); } } } page++; } }
internal void SaveRecord(ICdlRecord rec) { long pos0 = Data.Length; CdlTool.SaveRecord(rec.FieldCount, rec, m_writer); Lengths.Add((int)(Data.Length - pos0)); }
public void SaveToXml(XmlElement xml) { using (XmlWriter xw = xml.CreateNavigator().AppendChild()) { CdlTool.SaveToXml(m_structure, Rows, xw); xw.Flush(); } }
public InMemoryTable(TableInfo table, XmlElement xml) { Initialize(); m_structure = table.CloneTable(); using (XmlNodeReader xr = new XmlNodeReader(xml)) { foreach (var rec in CdlTool.LoadFromXml(m_structure, xr)) { m_rows.Add(new ArrayDataRecord(rec)); } } }
public CdlTable LoadTableData(int start = 0, int?count = null) { lock (_directory) { CdlTable table = new CdlTable(_table); if (count == null) { count = _serializedRows; } if (start >= _serializedRows) { return(table); } int curdic = start / BUFFER_SIZE, skiprec = start % BUFFER_SIZE; _cache.Seek(_directory[curdic], SeekOrigin.Begin); int availtables = _directory.Count - curdic; BinaryReader br = new BinaryReader(_cache); while (table.Rows.Count < count && availtables >= 1) { ChunkInfo info = ChunkInfo.LoadInfo(br); if (skiprec > 0) { int skipbytes = 0; for (int i = 0; i < skiprec; i++) { skipbytes += info.Lengths[i]; } _cache.Seek(skipbytes, SeekOrigin.Current); } int rec = skiprec; while (rec < info.Count) { table.AddRowInternal(CdlTool.LoadRecord(br, _table)); rec++; } availtables--; skiprec = 0; } return(table); } }