21 namespace Deveel.Data.Sql {
23 public IndexInfo(
string indexName,
string indexType,
string[] columnNames)
24 : this(indexName, indexType, columnNames, false) {
27 public IndexInfo(
string indexName,
string indexType,
string[] columnNames,
bool isUnique,
int offset) {
28 if (String.IsNullOrEmpty(indexType))
29 throw new ArgumentNullException(
"indexType");
30 if (String.IsNullOrEmpty(indexName))
31 throw new ArgumentNullException(
"indexName");
32 if (columnNames == null || columnNames.Length == 0)
33 throw new ArgumentNullException(
"columnNames");
35 IndexName = indexName;
36 IndexType = indexType;
37 ColumnNames = columnNames;
42 public IndexInfo(
string indexName,
string indexType,
string[] columnNames,
bool isUnique)
43 : this(indexName, indexType, columnNames, isUnique, -1) {
46 public string IndexName {
get;
private set; }
48 public string IndexType {
get;
private set; }
50 public string[] ColumnNames {
get;
private set; }
52 public bool IsUnique {
get;
private set; }
54 public int Offset {
get;
internal set; }
57 var writer =
new BinaryWriter(stream, Encoding.Unicode);
59 writer.Write(IndexType);
60 writer.Write(IndexName);
61 writer.Write(IsUnique ? (byte) 1 : (byte) 0);
64 var colCount = ColumnNames.Length;
65 writer.Write(colCount);
66 for (
int i = 0; i < colCount; i++) {
67 var colName = ColumnNames[i];
68 writer.Write(colName);
73 var reader =
new BinaryReader(stream, Encoding.Unicode);
75 var version = reader.ReadInt32();
77 throw new FormatException(
"Invalid version number for Index-Info");
79 var indexType = reader.ReadString();
80 var indexName = reader.ReadString();
81 var unique = reader.ReadByte() == 1;
82 var offset = reader.ReadInt32();
84 var colCount = reader.ReadInt32();
86 var columnNames =
new string[colCount];
87 for (
int i = 0; i < colCount; i++) {
88 var columnName = reader.ReadString();
89 columnNames[i] = columnName;
92 return new IndexInfo(indexName, indexType, columnNames, unique, offset);
IndexInfo(string indexName, string indexType, string[] columnNames)
void SerializeTo(Stream stream)
static IndexInfo DeserializeFrom(Stream stream)
IndexInfo(string indexName, string indexType, string[] columnNames, bool isUnique, int offset)
IndexInfo(string indexName, string indexType, string[] columnNames, bool isUnique)