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

Public Member Functions

 IndexSetInfo (ObjectName tableName)
 
void AddIndex (IndexInfo indexInfo)
 
IndexInfo GetIndex (int offset)
 
void RemoveIndexAt (int offset)
 
IndexInfo FindNamedIndex (string indexName)
 
IndexInfo FindNamedIndex (string indexName, bool ignoreCase)
 
int FindIndexOffset (string name)
 
int FindIndexOffset (string name, bool ignoreCase)
 
int FindIndexForColumns (string[] columnNames)
 
IndexSetInfo AsReadOnly ()
 
IEnumerator< IndexInfoGetEnumerator ()
 
void SerialiazeTo (Stream stream)
 

Static Public Member Functions

static IndexSetInfo DeserializeFrom (Stream stream)
 

Properties

ObjectName TableName [get, private set]
 
bool IsReadOnly [get, private set]
 
int IndexCount [get]
 

Private Member Functions

 IndexSetInfo (ObjectName tableName, IEnumerable< IndexInfo > indexes, bool readOnly)
 
void AssertNotReadOnly ()
 
IEnumerator IEnumerable. GetEnumerator ()
 

Private Attributes

readonly List< IndexInfoindexes
 

Detailed Description

Definition at line 25 of file IndexSetInfo.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.IndexSetInfo.IndexSetInfo ( ObjectName  tableName,
IEnumerable< IndexInfo indexes,
bool  readOnly 
)
inlineprivate

Definition at line 28 of file IndexSetInfo.cs.

28  {
29  if (tableName == null)
30  throw new ArgumentNullException("tableName");
31 
32  TableName = tableName;
33  this.indexes = new List<IndexInfo>();
34 
35  if (indexes != null)
36  this.indexes.AddRange(indexes);
37 
38  IsReadOnly = readOnly;
39  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
Deveel.Data.Sql.IndexSetInfo.IndexSetInfo ( ObjectName  tableName)
inline

Definition at line 41 of file IndexSetInfo.cs.

42  : this(tableName, null, false) {
43  }

Member Function Documentation

void Deveel.Data.Sql.IndexSetInfo.AddIndex ( IndexInfo  indexInfo)
inline

Definition at line 58 of file IndexSetInfo.cs.

58  {
60 
61  indexes.Add(indexInfo);
62  indexInfo.Offset = indexes.Count;
63  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
IndexSetInfo Deveel.Data.Sql.IndexSetInfo.AsReadOnly ( )
inline

Definition at line 119 of file IndexSetInfo.cs.

119  {
120  return new IndexSetInfo(TableName, indexes.ToArray(), true);
121  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
IndexSetInfo(ObjectName tableName, IEnumerable< IndexInfo > indexes, bool readOnly)
Definition: IndexSetInfo.cs:28
void Deveel.Data.Sql.IndexSetInfo.AssertNotReadOnly ( )
inlineprivate

Definition at line 53 of file IndexSetInfo.cs.

53  {
54  if (IsReadOnly)
55  throw new ArgumentException("The set is read-only.");
56  }
static IndexSetInfo Deveel.Data.Sql.IndexSetInfo.DeserializeFrom ( Stream  stream)
inlinestatic

Definition at line 152 of file IndexSetInfo.cs.

152  {
153  var reader = new BinaryReader(stream, Encoding.Unicode);
154 
155  var version = reader.ReadInt32();
156  if (version != 2)
157  throw new FormatException("Invalid version number of the Index-Set Info");
158 
159  var catName = reader.ReadString();
160  var schemaName = reader.ReadString();
161  var tableName = reader.ReadString();
162 
163  ObjectName objSchemaName;
164  if (String.IsNullOrEmpty(catName)) {
165  objSchemaName = new ObjectName(schemaName);
166  } else {
167  objSchemaName = new ObjectName(new ObjectName(catName), schemaName);
168  }
169 
170  var objTableName = new ObjectName(objSchemaName, tableName);
171 
172  var indexCount = reader.ReadInt32();
173 
174  var indices = new List<IndexInfo>();
175  for (int i = 0; i < indexCount; i++) {
176  var indexInfo = IndexInfo.DeserializeFrom(stream);
177  indices.Add(indexInfo);
178  }
179 
180  return new IndexSetInfo(objTableName, indices.ToArray(), false);
181  }
A long string in the system.
IndexSetInfo(ObjectName tableName, IEnumerable< IndexInfo > indexes, bool readOnly)
Definition: IndexSetInfo.cs:28
int Deveel.Data.Sql.IndexSetInfo.FindIndexForColumns ( string[]  columnNames)
inline

Definition at line 99 of file IndexSetInfo.cs.

99  {
100  int sz = IndexCount;
101  for (int i = 0; i < sz; ++i) {
102  string[] columns = indexes[i].ColumnNames;
103  if (columns.Length == columnNames.Length) {
104  bool passed = true;
105  for (int n = 0; n < columns.Length && passed; ++n) {
106  if (!columns[n].Equals(columnNames[n])) {
107  passed = false;
108  }
109  }
110  if (passed) {
111  return i;
112  }
113  }
114  }
115  return -1;
116  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
int Deveel.Data.Sql.IndexSetInfo.FindIndexOffset ( string  name)
inline

Definition at line 84 of file IndexSetInfo.cs.

84  {
85  return FindIndexOffset(name, true);
86  }
int FindIndexOffset(string name)
Definition: IndexSetInfo.cs:84
int Deveel.Data.Sql.IndexSetInfo.FindIndexOffset ( string  name,
bool  ignoreCase 
)
inline

Definition at line 88 of file IndexSetInfo.cs.

88  {
89  var compare = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
90  for (int i = 0; i < indexes.Count; i++) {
91  var indexInfo = indexes[i];
92  if (indexInfo.IndexName.Equals(name, compare))
93  return i;
94  }
95 
96  return -1;
97  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
IndexInfo Deveel.Data.Sql.IndexSetInfo.FindNamedIndex ( string  indexName)
inline

Definition at line 75 of file IndexSetInfo.cs.

75  {
76  return FindNamedIndex(indexName, true);
77  }
IndexInfo FindNamedIndex(string indexName)
Definition: IndexSetInfo.cs:75
IndexInfo Deveel.Data.Sql.IndexSetInfo.FindNamedIndex ( string  indexName,
bool  ignoreCase 
)
inline

Definition at line 79 of file IndexSetInfo.cs.

79  {
80  var compare = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
81  return indexes.FirstOrDefault(x => x.IndexName.Equals(indexName, compare));
82  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
IEnumerator<IndexInfo> Deveel.Data.Sql.IndexSetInfo.GetEnumerator ( )
inline

Definition at line 123 of file IndexSetInfo.cs.

123  {
124  return indexes.GetEnumerator();
125  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
IEnumerator IEnumerable. Deveel.Data.Sql.IndexSetInfo.GetEnumerator ( )
inlineprivate

Definition at line 127 of file IndexSetInfo.cs.

127  {
128  return GetEnumerator();
129  }
IEnumerator< IndexInfo > GetEnumerator()
IndexInfo Deveel.Data.Sql.IndexSetInfo.GetIndex ( int  offset)
inline

Definition at line 65 of file IndexSetInfo.cs.

65  {
66  return indexes.FirstOrDefault(x => x.Offset == offset);
67  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
void Deveel.Data.Sql.IndexSetInfo.RemoveIndexAt ( int  offset)
inline

Definition at line 69 of file IndexSetInfo.cs.

69  {
71 
72  indexes.RemoveAt(offset);
73  }
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
void Deveel.Data.Sql.IndexSetInfo.SerialiazeTo ( Stream  stream)
inline

Definition at line 131 of file IndexSetInfo.cs.

131  {
132  var schemaName = TableName.Parent;
133  var catName = schemaName != null && schemaName.Parent != null ? schemaName.Parent.Name : String.Empty;
134  var schema = schemaName != null ? schemaName.Name : String.Empty;
135 
136  var writer = new BinaryWriter(stream, Encoding.Unicode);
137  writer.Write(2); // Version
138  writer.Write(catName);
139  writer.Write(schema);
140  writer.Write(TableName.Name);
141 
142  int indexCount = indexes.Count;
143 
144  writer.Write(indexCount);
145 
146  for (int i = 0; i < indexCount; i++) {
147  var index = indexes[i];
148  index.SerializeTo(stream);
149  }
150  }
A long string in the system.
readonly List< IndexInfo > indexes
Definition: IndexSetInfo.cs:26
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
Definition: ObjectName.cs:99
string Name
Gets the name of the object being referenced.
Definition: ObjectName.cs:108

Member Data Documentation

readonly List<IndexInfo> Deveel.Data.Sql.IndexSetInfo.indexes
private

Definition at line 26 of file IndexSetInfo.cs.

Property Documentation

int Deveel.Data.Sql.IndexSetInfo.IndexCount
get

Definition at line 49 of file IndexSetInfo.cs.

bool Deveel.Data.Sql.IndexSetInfo.IsReadOnly
getprivate set

Definition at line 47 of file IndexSetInfo.cs.

ObjectName Deveel.Data.Sql.IndexSetInfo.TableName
getprivate set

Definition at line 45 of file IndexSetInfo.cs.


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