Beispiel #1
0
        public ClassInfoIndex AddIndexOn(string name, string[] indexFields, bool acceptMultipleValuesForSameKey)
        {
            if (_indexes == null)
            {
                _indexes = new OdbList <ClassInfoIndex>();
            }

            var cii = new ClassInfoIndex
            {
                ClassInfoId = _oidInfo.ID,
                Name        = name,
                IsUnique    = !acceptMultipleValuesForSameKey
            };

            var attributeIds = new int[indexFields.Length];

            for (var i = 0; i < indexFields.Length; i++)
            {
                attributeIds[i] = GetAttributeId(indexFields[i]);
            }

            cii.AttributeIds = attributeIds;
            _indexes.Add(cii);
            return(cii);
        }
        protected override IOdbComparable ComputeIndexKey(ClassInfoIndex index)
        {
            var constraint = Query.GetCriteria();
            var values = ((IInternalConstraint)constraint).GetValues();

            // if values.hasOid() is true, this means that we are working of the full object,
            // the index key is then the oid and not the object itself
            return values.HasOid()
                       ? new SimpleCompareKey(values.GetOid())
                       : base.ComputeIndexKey(index);
        }
Beispiel #3
0
 public void RemoveIndex(ClassInfoIndex cii)
 {
     _indexes.Remove(cii);
 }
Beispiel #4
0
        public ClassInfoIndex AddIndexOn(string name, string[] indexFields, bool acceptMultipleValuesForSameKey)
        {
            if (_indexes == null)
                _indexes = new OdbList<ClassInfoIndex>();

            var cii = new ClassInfoIndex
                {
                    ClassInfoId = _oidInfo.ID,
                    Name = name,
                    IsUnique = !acceptMultipleValuesForSameKey
                };

            var attributeIds = new int[indexFields.Length];

            for (var i = 0; i < indexFields.Length; i++)
                attributeIds[i] = GetAttributeId(indexFields[i]);

            cii.AttributeIds = attributeIds;
            _indexes.Add(cii);
            return cii;
        }
        private void Init()
        {
            _start = 0;
            _end = 0;

            // for instance, only manage index for one field query using 'equal'
            if (_classInfo.HasIndex() && _query.HasCriteria() &&
                ((IInternalConstraint) _query.GetCriteria()).CanUseIndex())
            {
                var fields = _query.GetAllInvolvedFields();
                if (fields.IsEmpty())
                    _useIndex = false;
                else
                {
                    var fieldIds = GetAllInvolvedFieldIds(fields);
                    _classInfoIndex = _classInfo.GetIndexForAttributeIds(fieldIds);
                    if (_classInfoIndex != null)
                        _useIndex = true;
                }
            }

            // Keep the detail
            _details = GetDetails();
        }
Beispiel #6
0
 public void RemoveIndex(ClassInfoIndex cii)
 {
     _indexes.Remove(cii);
 }