예제 #1
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                ClusteredArrayList keyList = null;

                if (Inverse)
                {
                    store.GetData(
                        generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues),
                        ComparisonType.LESS_THAN_EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                }
                else
                {
                    store.GetData(
                        generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues),
                        ComparisonType.GREATER_THAN, queryContext.InternalQueryResult, CollectionOperation.Union);
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" +
                                                   ((MemberFunction)functor).MemberName + "'");
            }
        }
        /// <summary>
        /// See attribute-level indexes can't be used in this predicate.
        /// </summary>
        /// <param name="queryContext"></param>
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            ClusteredArrayList keyList = null;

            pattern = (string)generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues);
            pattern = pattern.Trim('\'');

            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                if (Inverse)
                {
                    store.GetData(pattern, ComparisonType.NOT_LIKE, queryContext.InternalQueryResult, CollectionOperation.Union, queryContext.CancellationToken);
                }
                else
                {
                    store.GetData(pattern, ComparisonType.LIKE, queryContext.InternalQueryResult, CollectionOperation.Union, queryContext.CancellationToken);
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #3
0
        internal override void ExecuteInternal(QueryContext queryContext, ref SortedList list)
        {
            ArrayList keyList = null;

            pattern = (string)generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues);
            pattern = pattern.Trim('\'');

            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                if (Inverse)
                {
                    keyList = store.GetData(pattern, ComparisonType.NOT_LIKE);
                }
                else
                {
                    keyList = store.GetData(pattern, ComparisonType.LIKE);
                }


                if (keyList != null)
                {
                    list.Add(keyList.Count, keyList);
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #4
0
        internal override void ExecuteInternal(QueryContext queryContext, ref SortedList list)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                ArrayList keyList = null;

                if (Inverse)
                {
                    keyList = store.GetData(generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues), ComparisonType.LESS_THAN_EQUALS);
                }
                else
                {
                    keyList = store.GetData(generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues), ComparisonType.GREATER_THAN);
                }

                if (keyList != null)
                {
                    list.Add(keyList.Count, keyList);
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #5
0
        internal override void ExecuteInternal(QueryContext queryContext, CollectionOperation mergeType)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                members = queryContext.AttributeValues[((MemberFunction)functor).MemberName] as ArrayList;
                if (members == null)
                {
                    if (queryContext.AttributeValues.Count > 0)
                    {
                        members = new ArrayList();
                        members.Add(queryContext.AttributeValues[((MemberFunction)functor).MemberName]);
                    }
                    else
                    {
                        throw new Exception("Value(s) not specified for indexed attribute " + ((MemberFunction)functor).MemberName + ".");
                    }
                }

                IQueryResult tempResult = queryContext.InternalQueryResult;
                queryContext.InternalQueryResult = new Common.Queries.HashedQueryResult();


                if (!Inverse)
                {
                    for (int i = 0; i < members.Count; i++)
                    {
                        store.GetData(members[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                    }
                }
                else
                {
                    store.GetData(members[0], ComparisonType.NOT_EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                    if (queryContext.InternalQueryResult != null)
                    {
                        if (queryContext.InternalQueryResult.Count > 0)
                        {
                            for (int i = 1; i < members.Count; i++)
                            {
                                store.GetData(members[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Subtract);
                            }
                        }
                    }
                }
                queryContext.InternalQueryResult.Merge(tempResult, mergeType);
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #6
0
        internal override void ExecuteInternal(QueryContext queryContext, CollectionOperation mergeType)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                var values = GetComparibleValues(queryContext);

                IQueryResult tempResult = queryContext.InternalQueryResult;
                queryContext.InternalQueryResult = new Common.Queries.HashedQueryResult(queryContext.KeyFilter, queryContext.CompoundFilter);


                if (!Inverse)
                {
                    for (int i = 0; i < values.Count; i++)
                    {
                        if (queryContext.CancellationToken != null && queryContext.CancellationToken.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        store.GetData(values[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union, queryContext.CancellationToken);
                    }
                }
                else
                {
                    store.GetData(values[0], ComparisonType.NOT_EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union, queryContext.CancellationToken);
                    if (queryContext.InternalQueryResult != null)
                    {
                        if (queryContext.InternalQueryResult.Count > 0)
                        {
                            for (int i = 1; i < values.Count; i++)
                            {
                                if (queryContext.CancellationToken != null && queryContext.CancellationToken.IsCancellationRequested)
                                {
                                    throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                                }
                                store.GetData(values[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Subtract, queryContext.CancellationToken);
                            }
                        }
                    }
                }
                queryContext.InternalQueryResult.Merge(tempResult, mergeType);
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #7
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                var values = GetComparibleValues(queryContext);

                ClusteredArrayList keyList = new ClusteredArrayList();
                if (!Inverse)
                {
                    ClusteredArrayList distinctMembers = new ClusteredArrayList();

                    for (int i = 0; i < values.Count; i++)
                    {
                        if (!distinctMembers.Contains(values[i]))
                        {
                            distinctMembers.Add(values[i]);
                            store.GetData(values[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                        }
                    }
                }
                else
                {
                    ArrayList distinctMembers = new ArrayList();
                    queryContext.InternalQueryResult = new HashedQueryResult(queryContext.KeyFilter, queryContext.CompoundFilter);
                    store.GetData(values[0], ComparisonType.NOT_EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                    if (queryContext.InternalQueryResult != null)
                    {
                        if (queryContext.InternalQueryResult.Count > 0)
                        {
                            for (int i = 1; i < values.Count; i++)
                            {
                                if (!distinctMembers.Contains(values[i]))
                                {
                                    distinctMembers.Add(values[i]);
                                    store.GetData(values[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Subtract);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
        /// <summary>
        /// Executa o predicado.
        /// </summary>
        /// <param name="queryContext">Contexto da consulta.</param>
        /// <param name="nextPredicate"></param>
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            ArrayList data = null;

            _pattern = (string)_generator.Evaluate(queryContext.AttributeValues);
            _pattern = _pattern.Trim(new char[] {
                '\''
            });
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)_functor).GetStore(index);

            if (store == null)
            {
                if (queryContext.Cache.Count != 0)
                {
                    throw new ParserException("Index is not defined for attribute '" + ((MemberFunction)_functor).MemberName + "'");
                }
            }
            else
            {
                if (base.Inverse)
                {
                    data = store.GetData(_pattern, ComparisonType.NOT_LIKE);
                }
                else
                {
                    data = store.GetData(_pattern, ComparisonType.LIKE);
                }
                if ((data != null) && (data.Count > 0))
                {
                    IEnumerator enumerator = data.GetEnumerator();
                    if (!queryContext.PopulateTree)
                    {
                        while (enumerator.MoveNext())
                        {
                            if (queryContext.Tree.LeftList.Contains(enumerator.Current))
                            {
                                queryContext.Tree.Shift(enumerator.Current);
                            }
                        }
                    }
                    else
                    {
                        queryContext.Tree.RightList = data;
                        queryContext.PopulateTree   = false;
                    }
                }
            }
        }
예제 #9
0
        private void GetCombinedKeysFromEveryType(string tag, HashVector finalResult, CancellationToken token, bool wildCardSupport = false)
        {
            if (_indexMap == null)
            {
                return;
            }
            IDictionaryEnumerator typeEnumerator;

            lock (_indexMap.SyncRoot)
            {
                typeEnumerator = _indexMap.GetEnumerator();
            }

            while (typeEnumerator.MoveNext())
            {
                if (token != null && token.IsCancellationRequested)
                {
                    throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                }

                AttributeIndex index = typeEnumerator.Value as AttributeIndex;
                IIndexStore    store = index.GetStore("$Tag$");

                if (store != null)
                {
                    IKeyFilter keyFilter = _cache != null?_cache.GetBucketFilter() : null;

                    IKeyFilter compoundFilter = _cache != null?_cache.GetCompoundFilter() : null;

                    IQueryResult result = new ListQueryResult(keyFilter, compoundFilter);

                    if (wildCardSupport)
                    {
                        store.GetData(tag.ToLower(), ComparisonType.LIKE, result, CollectionOperation.Union, token);
                    }
                    else
                    {
                        store.GetData(tag.ToLower(), ComparisonType.EQUALS, result, CollectionOperation.Union, token);
                    }


                    foreach (string key in result)
                    {
                        finalResult[key] = null;
                    }
                }
            }
        }
예제 #10
0
        /// <summary>
        /// See attribute-level indexes can't be used in this predicate.
        /// </summary>
        /// <param name="queryContext"></param>
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            ArrayList keyList = null;

            pattern = (string)generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues);
            pattern = pattern.Trim('\'');

            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                if (Inverse)
                {
                    keyList = store.GetData(pattern, ComparisonType.NOT_LIKE);
                }
                else
                {
                    keyList = store.GetData(pattern, ComparisonType.LIKE);
                }

                if (keyList != null && keyList.Count > 0)
                {
                    IEnumerator keyListEnum = keyList.GetEnumerator();

                    if (queryContext.PopulateTree)
                    {
                        queryContext.Tree.RightList = keyList;

                        queryContext.PopulateTree = false;
                    }
                    else
                    {
                        while (keyListEnum.MoveNext())
                        {
                            if (queryContext.Tree.LeftList.Contains(keyListEnum.Current))
                            {
                                queryContext.Tree.Shift(keyListEnum.Current);
                            }
                        }
                    }
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #11
0
        private void GetCombinedKeysFromEveryType(string tag, HashVector finalResult)
        {
            if (_indexMap == null)
            {
                return;
            }
            IDictionaryEnumerator typeEnumerator;

            lock (_indexMap.SyncRoot)
            {
                typeEnumerator = _indexMap.GetEnumerator();
            }

            while (typeEnumerator.MoveNext())
            {
                AttributeIndex index = typeEnumerator.Value as AttributeIndex;
                IIndexStore    store = index.GetStore("$Tag$");

                if (store != null)
                {
                    IKeyFilter keyFilter = _cache != null?_cache.GetBucketFilter() : null;

                    IKeyFilter compoundFilter = _cache != null?_cache.GetCompoundFilter() : null;

                    IQueryResult result = new ListQueryResult(keyFilter, compoundFilter);
                    store.GetData(tag.ToLower(), ComparisonType.EQUALS, result, CollectionOperation.Union);
                    foreach (string key in result)
                    {
                        finalResult[key] = null;
                    }
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Recupera a combinação das chaves de qualquer tipo.
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        private ArrayList GetCombinedKeysFromEveryType(string tag)
        {
            if (base.IndexMapInternal == null)
            {
                return(null);
            }
            ArrayList             data       = null;
            Hashtable             hashtable  = new Hashtable();
            IDictionaryEnumerator enumerator = base.IndexMapInternal.GetEnumerator();

            while (enumerator.MoveNext())
            {
                IIndexStore store = (enumerator.Value as AttributeIndex).GetStore("$Tag$");
                if (store != null)
                {
                    data = store.GetData(tag.ToLower(), ComparisonType.EQUALS);
                    if ((data != null) && (data.Count > 0))
                    {
                        for (int i = 0; i < data.Count; i++)
                        {
                            hashtable[data[i]] = null;
                        }
                    }
                }
            }
            return(new ArrayList(hashtable.Keys));
        }
예제 #13
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                ArrayList keyList = null;

                if (Inverse)
                {
                    keyList = store.GetData(generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues), ComparisonType.LESS_THAN_EQUALS);
                }
                else
                {
                    keyList = store.GetData(generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues), ComparisonType.GREATER_THAN);
                }

                if (keyList != null && keyList.Count > 0)
                {
                    IEnumerator keyListEnum = keyList.GetEnumerator();

                    if (queryContext.PopulateTree)
                    {
                        queryContext.Tree.RightList = keyList;

                        queryContext.PopulateTree = false;
                    }
                    else
                    {
                        while (keyListEnum.MoveNext())
                        {
                            if (queryContext.Tree.LeftList.Contains(keyListEnum.Current))
                            {
                                queryContext.Tree.Shift(keyListEnum.Current);
                            }
                        }
                    }
                }
            }
            else //straight-forward. no index.
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #14
0
        internal override void ExecuteInternal(QueryContext queryContext, CollectionOperation mergeType)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                ClusteredArrayList keyList = null;

                if (Inverse)
                {
                    store.GetData(generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues), ComparisonType.NOT_EQUALS, queryContext.InternalQueryResult, mergeType);
                }
                else
                {
                    store.GetData(generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues), ComparisonType.EQUALS, queryContext.InternalQueryResult, mergeType);
                }
            }
            else
            {
                //if (queryContext.Cache.Count != 0)
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
        /// <summary>
        /// Executa o predicado.
        /// </summary>
        /// <param name="queryContext"></param>
        /// <param name="list"></param>
        internal override void ExecuteInternal(QueryContext queryContext, ref SortedList list)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)_functor).GetStore(index);

            if (store != null)
            {
                var data = store.GetData(_generator.Evaluate(queryContext.AttributeValues), base.Inverse ? ComparisonType.GREATER_THAN_EQUALS : ComparisonType.LESS_THAN);
                if (data != null)
                {
                    list.Add(data.Count, data);
                }
            }
            else if (queryContext.Cache.Count != 0)
            {
                throw new ParserException("Index is not defined for attribute '" + ((MemberFunction)_functor).MemberName + "'");
            }
        }
        /// <summary>
        /// Executa o predicado.
        /// </summary>
        /// <param name="queryContext"></param>
        /// <param name="list"></param>
        internal override void ExecuteInternal(QueryContext queryContext, ref SortedList list)
        {
            _pattern = (string)_generator.Evaluate(queryContext.AttributeValues);
            _pattern = _pattern.Trim(new char[] {
                '\''
            });
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)_functor).GetStore(index);

            if (store != null)
            {
                var data = store.GetData(_pattern, base.Inverse ? ComparisonType.NOT_LIKE : ComparisonType.LIKE);
                if (data != null)
                {
                    list.Add(data.Count, data);
                }
            }
            else if (queryContext.Cache.Count != 0)
            {
                throw new ParserException("Index is not defined for attribute '" + ((MemberFunction)_functor).MemberName + "'");
            }
        }
        /// <summary>
        /// Executa o predicado.
        /// </summary>
        /// <param name="queryContext"></param>
        /// <param name="nextPredicate"></param>
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)_functor).GetStore(index);

            if (store == null)
            {
                if (queryContext.Cache.Count != 0)
                {
                    throw new ParserException("Index is not defined for attribute '" + ((MemberFunction)_functor).MemberName + "'");
                }
            }
            else
            {
                var data = store.GetData(_generator.Evaluate(queryContext.AttributeValues), base.Inverse ? ComparisonType.GREATER_THAN_EQUALS : ComparisonType.LESS_THAN);
                if ((data != null) && (data.Count > 0))
                {
                    IEnumerator enumerator = data.GetEnumerator();
                    if (!queryContext.PopulateTree)
                    {
                        while (enumerator.MoveNext())
                        {
                            if (queryContext.Tree.LeftList.Contains(enumerator.Current))
                            {
                                queryContext.Tree.Shift(enumerator.Current);
                            }
                        }
                    }
                    else
                    {
                        queryContext.Tree.RightList = data;
                        queryContext.PopulateTree   = false;
                    }
                }
            }
        }
예제 #18
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                members = queryContext.AttributeValues[((MemberFunction)functor).MemberName] as ArrayList;

                if (members == null)
                {
                    if (queryContext.AttributeValues.Count > 0)
                    {
                        members = new ArrayList();
                        members.Add(queryContext.AttributeValues[((MemberFunction)functor).MemberName]);
                    }
                    else
                    {
                        throw new Exception("Value(s) not specified for indexed attribute " + ((MemberFunction)functor).MemberName + ".");
                    }
                }

                ArrayList keyList = new ArrayList();

                if (!Inverse)
                {
                    ArrayList distinctMembers = new ArrayList();

                    for (int i = 0; i < members.Count; i++)
                    {
                        if (!distinctMembers.Contains(members[i]))
                        {
                            distinctMembers.Add(members[i]);
                            ArrayList temp = store.GetData(members[i], ComparisonType.EQUALS);
                            if (temp != null)
                            {
                                if (temp.Count > 0)
                                {
                                    keyList.AddRange(temp);
                                }
                            }
                        }
                    }
                }
                else
                {
                    ArrayList distinctMembers = new ArrayList();

                    ArrayList temp = store.GetData(members[0], ComparisonType.NOT_EQUALS);
                    if (temp != null)
                    {
                        if (temp.Count > 0)
                        {
                            for (int i = 0; i < members.Count; i++)
                            {
                                if (!distinctMembers.Contains(members[i]))
                                {
                                    distinctMembers.Add(members[i]);
                                    ArrayList extras = store.GetData(members[i], ComparisonType.EQUALS);
                                    if (extras != null)
                                    {
                                        IEnumerator ie = extras.GetEnumerator();
                                        if (ie != null)
                                        {
                                            while (ie.MoveNext())
                                            {
                                                if (temp.Contains(ie.Current))
                                                {
                                                    temp.Remove(ie.Current);
                                                }
                                            }
                                        }
                                    }
                                }
                                keyList = temp;
                            }
                        }
                    }
                }

                if (keyList != null && keyList.Count > 0)
                {
                    IEnumerator keyListEnum = keyList.GetEnumerator();

                    if (queryContext.PopulateTree)
                    {
                        queryContext.Tree.RightList = keyList;

                        queryContext.PopulateTree = false;
                    }
                    else
                    {
                        while (keyListEnum.MoveNext())
                        {
                            if (queryContext.Tree.LeftList.Contains(keyListEnum.Current))
                            {
                                queryContext.Tree.Shift(keyListEnum.Current);
                            }
                        }
                    }
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #19
0
        internal override void ExecuteInternal(QueryContext queryContext, ref SortedList list)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            ArrayList keyList = new ArrayList();

            if (store != null)
            {
                members = queryContext.AttributeValues[((MemberFunction)functor).MemberName] as ArrayList;
                if (members == null)
                {
                    if (queryContext.AttributeValues.Count > 0)
                    {
                        members = new ArrayList();
                        members.Add(queryContext.AttributeValues[((MemberFunction)functor).MemberName]);
                    }
                    else
                    {
                        throw new Exception("Value(s) not specified for indexed attribute " + ((MemberFunction)functor).MemberName + ".");
                    }
                }

                if (!Inverse)
                {
                    for (int i = 0; i < members.Count; i++)
                    {
                        ArrayList temp = store.GetData(members[i], ComparisonType.EQUALS);
                        if (temp != null)
                        {
                            if (temp.Count > 0)
                            {
                                keyList.AddRange(temp);
                            }
                        }
                    }
                }
                else
                {
                    ArrayList temp = store.GetData(members[0], ComparisonType.NOT_EQUALS);
                    if (temp != null)
                    {
                        if (temp.Count > 0)
                        {
                            for (int i = 1; i < members.Count; i++)
                            {
                                ArrayList extras = store.GetData(members[i], ComparisonType.EQUALS);
                                if (extras != null)
                                {
                                    IEnumerator ie = extras.GetEnumerator();
                                    if (ie != null)
                                    {
                                        while (ie.MoveNext())
                                        {
                                            if (temp.Contains(ie.Current))
                                            {
                                                temp.Remove(ie.Current);
                                            }
                                        }
                                    }
                                }
                            }

                            keyList.AddRange(temp);
                        }
                    }
                }

                if (keyList != null)
                {
                    list.Add(keyList.Count, keyList);
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #20
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                members = queryContext.AttributeValues[((MemberFunction)functor).MemberName] as ArrayList;

                if (members == null)
                {
                    if (queryContext.AttributeValues.Count > 0)
                    {
                        members = new ArrayList();
                        members.Add(queryContext.AttributeValues[((MemberFunction)functor).MemberName]);
                    }
                    else
                    {
                        throw new Exception("Value(s) not specified for indexed attribute " + ((MemberFunction)functor).MemberName + ".");
                    }
                }

                ClusteredArrayList keyList = new ClusteredArrayList();
                if (!Inverse)
                {
                    ClusteredArrayList distinctMembers = new ClusteredArrayList();

                    for (int i = 0; i < members.Count; i++)
                    {
                        if (!distinctMembers.Contains(members[i]))
                        {
                            distinctMembers.Add(members[i]);
                            store.GetData(members[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                        }
                    }
                }
                else
                {
                    ArrayList distinctMembers = new ArrayList();
                    queryContext.InternalQueryResult = new HashedQueryResult();
                    store.GetData(members[0], ComparisonType.NOT_EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                    if (queryContext.InternalQueryResult != null)
                    {
                        if (queryContext.InternalQueryResult.Count > 0)
                        {
                            for (int i = 1; i < members.Count; i++)
                            {
                                if (!distinctMembers.Contains(members[i]))
                                {
                                    distinctMembers.Add(members[i]);
                                    store.GetData(members[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Subtract);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
예제 #21
0
        /// <summary>
        /// Executa o predicado.
        /// </summary>
        /// <param name="queryContext"></param>
        /// <param name="list"></param>
        internal override void ExecuteInternal(QueryContext queryContext, ref SortedList list)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)_functor).GetStore(index);
            ArrayList      list2 = new ArrayList();

            if (store == null)
            {
                throw new ParserException("Index is not defined for attribute '" + ((MemberFunction)_functor).MemberName + "'");
            }
            _members = queryContext.AttributeValues[((MemberFunction)_functor).MemberName] as ArrayList;
            if (_members == null)
            {
                if (queryContext.AttributeValues.Count <= 0)
                {
                    throw new Exception("Value(s) not specified for indexed attribute " + ((MemberFunction)_functor).MemberName + ".");
                }
                _members = new ArrayList();
                _members.Add(queryContext.AttributeValues[((MemberFunction)_functor).MemberName]);
            }
            if (!base.Inverse)
            {
                for (int i = 0; i < _members.Count; i++)
                {
                    ArrayList data = store.GetData(_members[i], ComparisonType.EQUALS);
                    if ((data != null) && (data.Count > 0))
                    {
                        list2.AddRange(data);
                    }
                }
            }
            else
            {
                ArrayList c = store.GetData(_members[0], ComparisonType.NOT_EQUALS);
                if ((c != null) && (c.Count > 0))
                {
                    for (int j = 1; j < _members.Count; j++)
                    {
                        ArrayList list5 = store.GetData(_members[j], ComparisonType.EQUALS);
                        if (list5 != null)
                        {
                            IEnumerator enumerator = list5.GetEnumerator();
                            if (enumerator != null)
                            {
                                while (enumerator.MoveNext())
                                {
                                    if (c.Contains(enumerator.Current))
                                    {
                                        c.Remove(enumerator.Current);
                                    }
                                }
                            }
                        }
                    }
                    list2.AddRange(c);
                }
            }
            if (list2 != null)
            {
                list.Add(list2.Count, list2);
            }
        }
예제 #22
0
        /// <summary>
        /// Executa o predicado.
        /// </summary>
        /// <param name="queryContext"></param>
        /// <param name="nextPredicate"></param>
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)_functor).GetStore(index);

            if (store == null)
            {
                throw new ParserException("Index is not defined for attribute '" + ((MemberFunction)_functor).MemberName + "'");
            }
            _members = queryContext.AttributeValues[((MemberFunction)_functor).MemberName] as ArrayList;
            if (_members == null)
            {
                if (queryContext.AttributeValues.Count <= 0)
                {
                    throw new Exception("Value(s) not specified for indexed attribute " + ((MemberFunction)_functor).MemberName + ".");
                }
                _members = new ArrayList();
                _members.Add(queryContext.AttributeValues[((MemberFunction)_functor).MemberName]);
            }
            ArrayList list = new ArrayList();

            if (!base.Inverse)
            {
                for (int i = 0; i < _members.Count; i++)
                {
                    ArrayList data = store.GetData(_members[i], ComparisonType.EQUALS);
                    if ((data != null) && (data.Count > 0))
                    {
                        list.AddRange(data);
                    }
                }
            }
            else
            {
                ArrayList c = store.GetData(_members[0], ComparisonType.NOT_EQUALS);
                if ((c != null) && (c.Count > 0))
                {
                    for (int j = 1; j < _members.Count; j++)
                    {
                        ArrayList list4 = store.GetData(_members[j], ComparisonType.EQUALS);
                        if (list4 != null)
                        {
                            IEnumerator enumerator = list4.GetEnumerator();
                            if (enumerator != null)
                            {
                                while (enumerator.MoveNext())
                                {
                                    if (c.Contains(enumerator.Current))
                                    {
                                        c.Remove(enumerator.Current);
                                    }
                                }
                            }
                        }
                    }
                    list.AddRange(c);
                }
            }
            if ((list != null) && (list.Count > 0))
            {
                IEnumerator enumerator2 = list.GetEnumerator();
                if (!queryContext.PopulateTree)
                {
                    while (enumerator2.MoveNext())
                    {
                        if (queryContext.Tree.LeftList.Contains(enumerator2.Current))
                        {
                            queryContext.Tree.Shift(enumerator2.Current);
                        }
                    }
                }
                else
                {
                    queryContext.Tree.RightList = list;
                    queryContext.PopulateTree   = false;
                }
            }
        }
예제 #23
0
 /// <summary>
 /// Recupera os dados filtrando pelo
 /// </summary>
 /// <param name="store">Armazenamento.</param>
 /// <param name="values">Valores dos parametros.</param>
 /// <param name="comparisonType">Tipo de comparação.</param>
 /// <param name="key">Chave que será usada na comparação.</param>
 /// <returns></returns>
 public System.Collections.ArrayList GetData(IIndexStore store, System.Collections.IDictionary values, ComparisonType comparisonType, object key)
 {
     return(store.GetData(key, comparisonType));
 }