public SessionDataSet(string sql, TSExecuteStatementResp resp, ConcurentClientQueue clientQueue) { this.clientQueue = clientQueue; this.sql = sql; this.query_dataset = resp.QueryDataSet; this.query_id = resp.QueryId; this.column_size = resp.Columns.Count; this.current_bitmap = new byte[this.column_size]; this.column_name_lst = new List <string> { }; this.time_buffer = new ByteBuffer(query_dataset.Time); this.column_name_index_map = new Dictionary <string, int> { }; this.column_type_lst = new List <string> { }; this.duplicate_location = new Dictionary <int, int> { }; this.value_buffer_lst = new List <ByteBuffer> { }; this.bitmap_buffer_lst = new List <ByteBuffer> { }; // some internal variable this.has_catched_result = false; this.row_index = 0; if (resp.ColumnNameIndexMap != null) { for (var index = 0; index < resp.Columns.Count; index++) { this.column_name_lst.Add(""); this.column_type_lst.Add(""); } for (var index = 0; index < resp.Columns.Count; index++) { var name = resp.Columns[index]; this.column_name_lst[resp.ColumnNameIndexMap[name]] = name; this.column_type_lst[resp.ColumnNameIndexMap[name]] = resp.DataTypeList[index]; } } else { this.column_name_lst = resp.Columns; this.column_type_lst = resp.DataTypeList; } for (int index = 0; index < this.column_name_lst.Count; index++) { var column_name = this.column_name_lst[index]; if (this.column_name_index_map.ContainsKey(column_name)) { this.duplicate_location[index] = this.column_name_index_map[column_name]; } else { this.column_name_index_map[column_name] = index; } this.value_buffer_lst.Add(new ByteBuffer(this.query_dataset.ValueList[index])); this.bitmap_buffer_lst.Add(new ByteBuffer(this.query_dataset.BitmapList[index])); } }
private bool fetch_results() { row_index = 0; var my_client = clientQueue.Take(); var req = new TSFetchResultsReq(my_client.sessionId, sql, fetch_size, query_id, true); req.Timeout = default_timeout; try{ var task = my_client.client.fetchResultsAsync(req); task.Wait(); var resp = task.Result; if (resp.HasResultSet) { this.query_dataset = resp.QueryDataSet; // reset buffer this.time_buffer = new ByteBuffer(resp.QueryDataSet.Time); this.value_buffer_lst = new List <ByteBuffer> { }; this.bitmap_buffer_lst = new List <ByteBuffer> { }; for (int index = 0; index < query_dataset.ValueList.Count; index++) { this.value_buffer_lst.Add(new ByteBuffer(query_dataset.ValueList[index])); this.bitmap_buffer_lst.Add(new ByteBuffer(query_dataset.BitmapList[index])); } // reset row index row_index = 0; } if (clientQueue != null) { clientQueue.Add(my_client); } return(resp.HasResultSet); } catch (TException e) { if (clientQueue != null) { clientQueue.Add(my_client); } var message = string.Format("Cannot fetch result from server, because of network connection"); throw new TException(message, e); } }