Example #1
0
        private void CreateLoadIndexes(ViewRowDefinition viewRowDefinition)
        {
            int i = 0;

            _indexes.Add(_docid, new TypeIndexes <Guid>(_Path, _docid, 16));
            // load indexes
            foreach (var c in viewRowDefinition.Columns)
            {
                if (c.Key != "docid")
                {
                    _indexes.Add(_schema.Columns[i].Key,
                                 CreateIndex(
                                     _schema.Columns[i].Key,
                                     _schema.Columns[i].Value));
                }
                i++;
            }
        }
Example #2
0
        private void GenerateSchemaColumns(ViewBase _view)
        {
            // generate schema columns from schema
            _schema      = new ViewRowDefinition();
            _schema.Name = _view.Name;

            foreach (var p in _view.Schema.GetProperties())
            {
                Type t = p.PropertyType;

                if (_view.NoIndexingColumns.Contains(p.Name) || _view.NoIndexingColumns.Contains(p.Name.ToLower()))
                {
                    _schema.Add(p.Name, typeof(NoIndexing));
                }
                else
                {
                    if (p.GetCustomAttributes(typeof(FullTextAttribute), true).Length > 0)
                    {
                        t = typeof(FullTextString);
                    }
                    if (_view.FullTextColumns.Contains(p.Name) || _view.FullTextColumns.Contains(p.Name.ToLower()))
                    {
                        t = typeof(FullTextString);
                    }
                    if (p.Name != "docid")
                    {
                        _schema.Add(p.Name, t);
                    }

                    if (p.GetCustomAttributes(typeof(CaseInsensitiveAttribute), true).Length > 0)
                    {
                        _nocase.Add(p.Name, 0);
                    }
                    if (_view.CaseInsensitiveColumns.Contains(p.Name) || _view.CaseInsensitiveColumns.Contains(p.Name.ToLower()))
                    {
                        _nocase.Add(p.Name, 0);
                    }

                    var a = p.GetCustomAttributes(typeof(StringIndexLength), false);
                    if (a.Length > 0)
                    {
                        byte l = (a[0] as StringIndexLength).Length;
                        _idxlen.Add(p.Name, l);
                    }
                    if (_view.StringIndexLength.ContainsKey(p.Name) || _view.StringIndexLength.ContainsKey(p.Name.ToLower()))
                    {
                        byte b = 0;
                        if (_view.StringIndexLength.TryGetValue(p.Name, out b))
                        {
                            _idxlen.Add(p.Name, b);
                        }
                        if (_view.StringIndexLength.TryGetValue(p.Name.ToLower(), out b))
                        {
                            _idxlen.Add(p.Name, b);
                        }
                    }
                }
            }

            foreach (var f in _view.Schema.GetFields())
            {
                Type t = f.FieldType;
                if (_view.NoIndexingColumns.Contains(f.Name) || _view.NoIndexingColumns.Contains(f.Name.ToLower()))
                {
                    _schema.Add(f.Name, typeof(NoIndexing));
                }
                else
                {
                    if (f.GetCustomAttributes(typeof(FullTextAttribute), true).Length > 0)
                    {
                        t = typeof(FullTextString);
                    }
                    if (_view.FullTextColumns.Contains(f.Name) || _view.FullTextColumns.Contains(f.Name.ToLower()))
                    {
                        t = typeof(FullTextString);
                    }
                    if (f.Name != "docid")
                    {
                        _schema.Add(f.Name, t);
                    }

                    if (f.GetCustomAttributes(typeof(CaseInsensitiveAttribute), true).Length > 0)
                    {
                        _nocase.Add(f.Name, 0);
                    }
                    if (_view.CaseInsensitiveColumns.Contains(f.Name) || _view.CaseInsensitiveColumns.Contains(f.Name.ToLower()))
                    {
                        _nocase.Add(f.Name, 0);
                    }

                    var a = f.GetCustomAttributes(typeof(StringIndexLength), false);
                    if (a.Length > 0)
                    {
                        byte l = (a[0] as StringIndexLength).Length;
                        _idxlen.Add(f.Name, l);
                    }
                    if (_view.StringIndexLength.ContainsKey(f.Name) || _view.StringIndexLength.ContainsKey(f.Name.ToLower()))
                    {
                        byte b = 0;
                        if (_view.StringIndexLength.TryGetValue(f.Name, out b))
                        {
                            _idxlen.Add(f.Name, b);
                        }
                        if (_view.StringIndexLength.TryGetValue(f.Name.ToLower(), out b))
                        {
                            _idxlen.Add(f.Name, b);
                        }
                    }
                }
            }
            _schema.Add("docid", typeof(Guid));

            foreach (var s in _schema.Columns)
            {
                _colnames.Add(s.Key);
            }

            // set column index for nocase
            for (int i = 0; i < _colnames.Count; i++)
            {
                int j = 0;
                if (_nocase.TryGetValue(_colnames[i], out j))
                {
                    _nocase[_colnames[i]] = i;
                }
            }
        }