17 using System.Collections.Generic;
21 namespace Deveel.Data.Protocol {
22 public sealed
class QueryResult : IDisposable {
42 private IList<int> rowIndexMap;
75 streamableBlobMap =
new Dictionary<long, StreamableObject>();
77 resultRowCount = result.RowCount;
83 IRowEnumerator rowEnum = result.GetRowEnumerator();
84 if (rowEnum.MoveNext()) {
85 int rowIndex = rowEnum.RowIndex;
86 for (
int c = 0; c < result.ColumnCount; ++c) {
87 result.GetCell(c, rowIndex);
92 resultIsSimpleEnum = (rowEnum is SimpleRowEnumerator);
96 if (!resultIsSimpleEnum) {
97 rowIndexMap =
new List<int>(result.RowCount);
99 IRowEnumerator en = result.GetRowEnumerator();
100 while (en.MoveNext()) {
101 rowIndexMap.Add(en.RowIndex);
109 int colCount = result.ColumnCount;
111 for (
int i = 0; i < colCount; ++i) {
112 VariableName v = result.GetResolvedVariable(i);
114 if (v.TableName == null) {
116 fieldName = String.Format(
"@a{0}", v.Name);
119 fieldName = String.Format(
"@f{0}", v);
136 if (!streamableBlobMap.TryGetValue(
id, out reference))
148 streamableBlobMap.Remove(
id);
174 throw new Exception(
"Table roots not locked!");
176 int realRow = resultIsSimpleEnum ? row : rowIndexMap[row];
177 TObject tob = result.GetCell(column, realRow);
181 if (tob.Object is IRef) {
182 var reference = (IRef) tob.Object;
183 streamableBlobMap[reference.Id] =
193 public int ColumnCount {
194 get {
return result.ColumnCount; }
200 public int RowCount {
201 get {
return resultRowCount; }
208 get {
return colDesc; }
216 result.LockRoot(key);
225 result.UnlockRoot(key);
QueryResult(SqlQuery query, Table result)
Constructs the result set.
readonly int resultRowCount
The number of rows in the result.
readonly Dictionary< long, StreamableObject > streamableBlobMap
A Dictionary of blob_reference_id values to IRef objects used to handle and streamable o...
QueryResultColumn[] colDesc
A set of QueryResultColumn that describes each column in the ResultSet.
void LockRoot(int key)
Locks the root of the result set.
TObject GetCellContents(int column, int row)
Gets the cell contents of the cell at the given row/column.
Table result
The table that is the result.
void RemoveRef(long id)
Removes a IRef that has been cached in this table object by its identifier value. ...
void UnlockRoot(int key)
Unlocks the root of the result set.
readonly bool resultIsSimpleEnum
Set to true if the result table has a SimpleRowEnumerator, therefore guarenteeing we do not need to s...
void Dispose()
Disposes this object.
SqlQuery query
The SqlQuery that was executed to produce this result.
An object that is streamable (such as a long binary object, or a long string object).
StreamableObject GetRef(long id)
Returns a IRef that has been cached in this table object by its identifier value. ...