internal CdlRow(CdlTable table, ICdlRecord original, CdlRowState initialState, TableInfo structure) { m_table = table; m_fields = new FieldRec[m_table.Structure.Columns.Count]; m_original = original; m_structure = structure; RowState = initialState; }
public static CdlTable ToBinaryTable(this ICdlReader reader, int? maximumRecords) { //TableInfo ts = reader.GetTableInfo(); CdlTable dt = new CdlTable(reader.Structure); int allow_recs = maximumRecords != null ? maximumRecords.Value : -1; while (reader.Read() && (maximumRecords == null || allow_recs > 0)) { dt.AddRow(reader); allow_recs--; } return dt; }
public CdlTable LoadTableData(string query) { var table = new CdlTable(_table); using (var selcmd = _conn.CreateCommand()) { selcmd.CommandText = query; using (var reader = selcmd.ExecuteReader()) { while (reader.Read()) { var row = new ArrayDataRecord(_table); for (int i = 0; i < _table.ColumnCount; i++) { row.SeekValue(i); var type = (TypeStorage)reader.GetInt32(i * 2); StorageTool.ReadValue(reader, i * 2 + 1, type, row); } table.AddRowInternal(row); } } } return(table); }
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; } }
//private string CreateQuery(int start = 0, int? count = null) //{ // var sb = new StringBuilder(); // sb.AppendFormat("select {0} from {1} order by rowid", ColumnsText, TABLE_NAME); // if (count != null) sb.AppendFormat(" limit {0},{1}", start, count); // return sb.ToString(); //} public CdlTable LoadTableData(string query) { var table = new CdlTable(_table); using (var selcmd = _conn.CreateCommand()) { selcmd.CommandText = query; using (var reader = selcmd.ExecuteReader()) { while (reader.Read()) { var row = new ArrayDataRecord(_table); for (int i = 0; i < _table.ColumnCount; i++) { row.SeekValue(i); var type = (TypeStorage)reader.GetInt32(i * 2); StorageTool.ReadValue(reader, i * 2 + 1, type, row); } table.AddRowInternal(row); } } } return table; }