DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Public Member Functions | Package Functions | Properties | Private Member Functions | List of all members
Deveel.Data.Sql.Cursors.Cursor Class Reference
Inheritance diagram for Deveel.Data.Sql.Cursors.Cursor:
Deveel.Data.Sql.IDbObject

Classes

class  CursorArgumentPreparer
 

Public Member Functions

void Open (IRequest context, params SqlExpression[] args)
 
void Close ()
 
void FetchInto (FetchContext context)
 
void Dispose ()
 

Package Functions

 Cursor (CursorInfo cursorInfo)
 

Properties

CursorInfo CursorInfo [get, private set]
 
CursorStatus Status [get]
 
CursorState State [get, private set]
 
ObjectName IDbObject. FullName [get]
 
DbObjectType IDbObject. ObjectType [get]
 
SqlQueryExpression QueryExpression [get]
 
- Properties inherited from Deveel.Data.Sql.IDbObject
ObjectName FullName [get]
 Gets the fully qualified name of the object used to resolve it uniquely within the database. More...
 
DbObjectType ObjectType [get]
 Gets the type of database object that the implementation is for More...
 

Private Member Functions

 ~Cursor ()
 
void AssertNotDisposed ()
 
SqlQueryExpression PrepareQuery (SqlExpression[] args)
 
Dictionary< string, SqlExpressionBuildArgs (IEnumerable< CursorParameter > parameters, SqlExpression[] args)
 
ITable Evaluate (IRequest context, SqlExpression[] args)
 
void FetchIntoVatiable (IRequest request, Row row, string varName)
 
void FetchIntoReference (IRequest request, Row row, ObjectName reference)
 
void Dispose (bool disposing)
 

Detailed Description

Definition at line 26 of file Cursor.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Cursors.Cursor.Cursor ( CursorInfo  cursorInfo)
inlinepackage

Definition at line 27 of file Cursor.cs.

27  {
28  if (cursorInfo == null)
29  throw new ArgumentNullException("cursorInfo");
30 
31  CursorInfo = cursorInfo;
32  State = new CursorState(this);
33  }
Deveel.Data.Sql.Cursors.Cursor.~Cursor ( )
inlineprivate

Definition at line 35 of file Cursor.cs.

35  {
36  Dispose(false);
37  }

Member Function Documentation

void Deveel.Data.Sql.Cursors.Cursor.AssertNotDisposed ( )
inlineprivate

Definition at line 59 of file Cursor.cs.

59  {
60  if (Status == CursorStatus.Disposed)
61  throw new ObjectDisposedException("Cursor");
62  }
Dictionary<string, SqlExpression> Deveel.Data.Sql.Cursors.Cursor.BuildArgs ( IEnumerable< CursorParameter parameters,
SqlExpression[]  args 
)
inlineprivate

Definition at line 75 of file Cursor.cs.

75  {
76  var orderedParams = parameters.OrderBy(x => x.Offset).ToArray();
77  if (args == null || args.Length != orderedParams.Length)
78  throw new ArgumentException();
79 
80  var result = new Dictionary<string, SqlExpression>();
81  for (int i = 0; i < orderedParams.Length; i++) {
82  var param = orderedParams[i];
83  var arg = args[i];
84  result[param.ParameterName] = arg;
85  }
86 
87  return result;
88  }
void Deveel.Data.Sql.Cursors.Cursor.Close ( )
inline

Definition at line 113 of file Cursor.cs.

113  {
114  lock (this) {
116  State.Close();
117  }
118  }
void Deveel.Data.Sql.Cursors.Cursor.Dispose ( )
inline

Definition at line 158 of file Cursor.cs.

158  {
159  Dispose(true);
160  GC.SuppressFinalize(this);
161  }
void Deveel.Data.Sql.Cursors.Cursor.Dispose ( bool  disposing)
inlineprivate

Definition at line 163 of file Cursor.cs.

163  {
164  if (disposing) {
165  if (State != null)
166  State.Dispose();
167  }
168 
169  State = null;
170  }
ITable Deveel.Data.Sql.Cursors.Cursor.Evaluate ( IRequest  context,
SqlExpression[]  args 
)
inlineprivate

Definition at line 90 of file Cursor.cs.

90  {
91  try {
92  var prepared = PrepareQuery(args);
93  var queryPlan = context.Query.Context.QueryPlanner().PlanQuery(new QueryInfo(context, prepared));
94  return queryPlan.Evaluate(context);
95  } catch (Exception) {
96 
97  throw;
98  }
99  }
SqlQueryExpression PrepareQuery(SqlExpression[] args)
Definition: Cursor.cs:64
void Deveel.Data.Sql.Cursors.Cursor.FetchInto ( FetchContext  context)
inline

Definition at line 120 of file Cursor.cs.

120  {
121  if (context == null)
122  throw new ArgumentNullException("context");
123 
124  if (!CursorInfo.IsScroll &&
125  context.Direction != FetchDirection.Next)
126  throw new ArgumentException(String.Format("Cursor '{0}' is not SCROLL: can fetch only NEXT value.", CursorInfo.CursorName));
127 
128  var table = State.Result;
130  table = Evaluate(context.Request, State.OpenArguments);
131 
132  var fetchRow = State.FetchRowFrom(table, context.Direction, context.Offset);
133 
134  if (context.IsGlobalReference) {
135  var reference = ((SqlReferenceExpression) context.Reference).ReferenceName;
136  FetchIntoReference(context.Request, fetchRow, reference);
137  } else if (context.IsVariableReference) {
138  var varName = ((SqlVariableReferenceExpression) context.Reference).VariableName;
139  FetchIntoVatiable(context.Request, fetchRow, varName);
140  }
141  }
An expression that references an object within a context.
A long string in the system.
void FetchIntoReference(IRequest request, Row row, ObjectName reference)
Definition: Cursor.cs:147
void FetchIntoVatiable(IRequest request, Row row, string varName)
Definition: Cursor.cs:143
ITable Evaluate(IRequest context, SqlExpression[] args)
Definition: Cursor.cs:90
Row FetchRowFrom(ITable table, FetchDirection direction, int offset)
Definition: CursorState.cs:56
void Deveel.Data.Sql.Cursors.Cursor.FetchIntoReference ( IRequest  request,
Row  row,
ObjectName  reference 
)
inlineprivate

Definition at line 147 of file Cursor.cs.

147  {
148  if (reference == null)
149  throw new ArgumentNullException("reference");
150 
151  var table = request.Query.GetMutableTable(reference);
152  if (table == null)
153  throw new ObjectNotFoundException(reference);
154 
155  throw new NotImplementedException();
156  }
void Deveel.Data.Sql.Cursors.Cursor.FetchIntoVatiable ( IRequest  request,
Row  row,
string  varName 
)
inlineprivate

Definition at line 143 of file Cursor.cs.

143  {
144  throw new NotImplementedException();
145  }
void Deveel.Data.Sql.Cursors.Cursor.Open ( IRequest  context,
params SqlExpression[]  args 
)
inline

Definition at line 101 of file Cursor.cs.

101  {
102  lock (this) {
104 
105  ITable result = null;
107  result = Evaluate(context, args);
108 
109  State.Open(result, args);
110  }
111  }
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
void Open(ITable result, SqlExpression[] args)
Definition: CursorState.cs:45
ITable Evaluate(IRequest context, SqlExpression[] args)
Definition: Cursor.cs:90
SqlQueryExpression Deveel.Data.Sql.Cursors.Cursor.PrepareQuery ( SqlExpression[]  args)
inlineprivate

Definition at line 64 of file Cursor.cs.

64  {
66  if (CursorInfo.Parameters.Count > 0) {
67  var cursorArgs = BuildArgs(CursorInfo.Parameters, args);
68  var preparer = new CursorArgumentPreparer(cursorArgs);
69  query = query.Prepare(preparer) as SqlQueryExpression;
70  }
71 
72  return query;
73  }
Dictionary< string, SqlExpression > BuildArgs(IEnumerable< CursorParameter > parameters, SqlExpression[] args)
Definition: Cursor.cs:75
SqlQueryExpression QueryExpression
Definition: CursorInfo.cs:59
virtual SqlExpression Prepare(IExpressionPreparer preparer)
ICollection< CursorParameter > Parameters
Definition: CursorInfo.cs:46

Property Documentation

CursorInfo Deveel.Data.Sql.Cursors.Cursor.CursorInfo
getprivate set

Definition at line 39 of file Cursor.cs.

ObjectName IDbObject. Deveel.Data.Sql.Cursors.Cursor.FullName
getprivate

Definition at line 47 of file Cursor.cs.

DbObjectType IDbObject. Deveel.Data.Sql.Cursors.Cursor.ObjectType
getprivate

Definition at line 51 of file Cursor.cs.

SqlQueryExpression Deveel.Data.Sql.Cursors.Cursor.QueryExpression
get

Definition at line 55 of file Cursor.cs.

CursorState Deveel.Data.Sql.Cursors.Cursor.State
getprivate set

Definition at line 45 of file Cursor.cs.

CursorStatus Deveel.Data.Sql.Cursors.Cursor.Status
get

Definition at line 41 of file Cursor.cs.


The documentation for this class was generated from the following file: