Ejemplo n.º 1
0
        /// <summary>
        /// Adiciona uma chave e um valor para o indice.
        /// </summary>
        /// <param name="key">Chave que será adicionada.</param>
        /// <param name="value">Valor que será adicionado.</param>
        public virtual void AddToIndex(object key, object value)
        {
            if (!(value is Hashtable))
            {
                throw new ArgumentException("Value is not Hashtable");
            }
            IDictionaryEnumerator enumerator = (value as Hashtable).GetEnumerator();

            while (enumerator.MoveNext())
            {
                string      indexKey = (string)enumerator.Key;
                IIndexStore store    = _indexTable[indexKey] as IIndexStore;
                if (store == null)
                {
                    if (indexKey == "$Tag$")
                    {
                        store = CreateIndexStore();
                        _indexTable[indexKey] = store;
                    }
                    else
                    {
                        string str2 = this.ConvertToNamedTagKey(indexKey);
                        store = _indexTable[str2] as IIndexStore;
                        if (store == null)
                        {
                            store             = CreateIndexStore();
                            _indexTable[str2] = store;
                        }
                    }
                }
                if (store != null)
                {
                    object obj2 = enumerator.Value;
                    if (obj2 != null)
                    {
                        store.Add(obj2, key);
                    }
                    else
                    {
                        store.Add(CacheNull.Value, key);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public virtual void AddToIndex(object key, object value)
        {
            lock (_mutex)
            {
                QueryItemContainer    container       = (QueryItemContainer)value;
                CacheEntry            entry           = container.Item;
                Hashtable             attributeValues = container.ItemArrtributes;
                IDictionaryEnumerator valuesDic       = attributeValues.GetEnumerator();
                INodeReference        keyNode         = null;
                while (valuesDic.MoveNext())
                {
                    string      indexKey  = (string)valuesDic.Key;
                    string      storeName = indexKey;
                    IIndexStore store     = _indexTable[indexKey] as IIndexStore;
                    keyNode = null;

                    if (store != null)
                    {
                        long   prev = store.IndexInMemorySize;
                        object val  = valuesDic.Value;

                        if (val != null)
                        {
                            keyNode = (INodeReference)store.Add(val, key);
                        }

                        _attributeIndexSize += store.IndexInMemorySize - prev;
                    }

                    storeName = Common.Util.StringPool.PoolString(storeName);

                    IndexInformation info;

                    if (entry.IndexInfo != null)
                    {
                        info = entry.IndexInfo;
                    }
                    else
                    {
                        info = new IndexInformation();
                    }

                    long prevSize = info.IndexInMemorySize;

                    info.Add(storeName, store, keyNode);

                    this._keyIndexInformationSize += info.IndexInMemorySize - prevSize;
                    entry.IndexInfo = info;
                }
            }
        }
Ejemplo n.º 3
0
        public virtual void AddToIndex(object key, object value)
        {
            Hashtable             attributeValues = value as Hashtable;
            IDictionaryEnumerator valuesDic       = attributeValues.GetEnumerator();
            RedBlackNodeReference keyNode         = null;

            while (valuesDic.MoveNext())
            {
                string      indexKey  = (string)valuesDic.Key;
                string      storeName = indexKey;
                IIndexStore store     = _indexTable[indexKey] as IIndexStore;
                keyNode = null;

                if (store != null)
                {
                    long   prev = store.IndexInMemorySize;
                    object val  = valuesDic.Value;

                    if (val != null)
                    {
                        keyNode = (RedBlackNodeReference)store.Add(val, key);
                    }

                    _attributeIndexSize += store.IndexInMemorySize - prev;
                }

                storeName = Common.Util.StringPool.PoolString(storeName);

                IndexInformation info;

                if (_keyIndexTable.Contains(key))
                {
                    info = _keyIndexTable[key] as IndexInformation;
                }
                else
                {
                    info = new IndexInformation();
                }

                long prevSize = info.IndexInMemorySize;

                info.Add(storeName, store, keyNode);
                _keyIndexTable[key] = info;

                this._keyIndexInformationSize += info.IndexInMemorySize - prevSize;
                if (_keyIndexTable.Count > _keyIndexTableMaxCount)
                {
                    _keyIndexTableMaxCount = _keyIndexTable.Count;
                }
            }
        }
Ejemplo n.º 4
0
        public virtual void AddToIndex(object key, object value)
        {
            lock (_mutex)
            {
                QueryItemContainer    container       = (QueryItemContainer)value;
                CacheEntry            entry           = container.Item;
                Hashtable             attributeValues = container.ItemArrtributes;
                IDictionaryEnumerator valuesDic       = attributeValues.GetEnumerator();
                INodeReference        keyNode;
                while (valuesDic.MoveNext())
                {
                    string indexKey = (string)valuesDic.Key;
                    object val      = valuesDic.Value;

                    string      storeName = indexKey;
                    IIndexStore store     = IndexTable[indexKey] as IIndexStore;
                    keyNode = null;

                    if (store == null)
                    {
                        if (indexKey == TAG_INDEX_KEY)
                        {
                            Type genericType =
                                typeof(RBStore <>).MakeGenericType(
                                    Common.MemoryUtil.GetDataType(Common.MemoryUtil.Net_System_String));
                            store =
                                (IIndexStore)
                                Activator.CreateInstance(genericType,
                                                         new object[]
                                                         { CacheName, Common.MemoryUtil.Net_System_String, indexKey, _haveDuplicateKeys });
                            IndexTable[indexKey] = store;
                        }
                        else
                        {
                            string namedTagIndexKey = ConvertToNamedTagKey(indexKey);
                            storeName = namedTagIndexKey;
                            store     = IndexTable[namedTagIndexKey] as IIndexStore;


                            if (store == null)
                            {
                                String storeDataType = String.Empty;
                                if (val != null)
                                {
                                    Type type = val.GetType();
                                    storeDataType = type.FullName;
                                }
                                Type genericType =
                                    typeof(RBStore <>).MakeGenericType(Common.MemoryUtil.GetDataType(storeDataType));
                                store =
                                    (IIndexStore)
                                    Activator.CreateInstance(genericType,
                                                             new object[]
                                                             { CacheName, storeDataType, namedTagIndexKey, _haveDuplicateKeys });

                                IndexTable.Add(namedTagIndexKey, store);
                            }
                        }
                    }

                    if (store != null)
                    {
                        long prev = store.IndexInMemorySize;

                        if (val != null)
                        {
                            keyNode = (INodeReference)store.Add(val, key);
                        }
                        _attributeIndexSize += store.IndexInMemorySize - prev;
                    }

                    storeName = StringPool.PoolString(storeName);

                    IndexInformation info;

                    if (entry.IndexInfo != null)
                    {
                        info = entry.IndexInfo;
                    }
                    else
                    {
                        info = new IndexInformation();
                    }
                    long prevSize = info.IndexInMemorySize;

                    info.Add(storeName, store, keyNode);

                    _keyIndexInformationSize += info.IndexInMemorySize - prevSize;
                    entry.IndexInfo           = info;
                }
            }
        }