Exemple #1
0
        public IIndexStore GetStore(string attrib)
        {
            bool        disacleException = QueryIndexManager.DisableException;
            IIndexStore store            = null;

            if (IndexTable.Contains(attrib))
            {
                store = IndexTable[attrib] as IIndexStore;
            }
            else
            {
                string namedTagKey = ConvertToNamedTagKey(attrib);

                if (IndexTable.Contains(namedTagKey))
                {
                    store = IndexTable[namedTagKey] as IIndexStore;
                }

                if (disacleException)
                {
                    if (store == null)
                    {
                        store = new HashStore();
                    }
                }
            }

            return(store);
        }
 /// <summary>
 /// Remove a specific key from a group or a sub group
 /// </summary>
 /// <param name="key"></param>
 /// <param name="group"></param>
 /// <param name="subGroup"></param>
 public void RemoveKey(object key)
 {
     if (_subGroupKeys.Contains(key))
     {
         _subGroupKeys.Remove(key);
     }
 }
Exemple #3
0
        public void Add(IDictionary other, CollectionOperation mergeType)
        {
            IDictionaryEnumerator ide = other.GetEnumerator();

            switch (mergeType)
            {
            case CollectionOperation.Union:
                while (ide.MoveNext())
                {
                    _resultKeys[ide.Key] = null;
                }
                break;

            case CollectionOperation.Intersection:
                while (ide.MoveNext())
                {
                    if (_resultKeys.Contains(ide.Key))
                    {
                        _temp[ide.Key] = null;
                    }
                }
                break;

            case CollectionOperation.Subtract:
                while (ide.MoveNext())
                {
                    _resultKeys.Remove(ide.Key);
                }
                break;
            }
        }
Exemple #4
0
        public override void GetKeyList(int bucketId, bool startLogging, out ClusteredArrayList keyList)
        {
            try
            {
                _rwBucketsLock.EnterWriteLock();
                if (startLogging)
                {
                    _logMgr.StartLogging(bucketId, LogMode.LogBeforeAfterActualOperation);
                }

                keyList = new ClusteredArrayList();
                if (_keyList != null)
                {
                    if (_keyList.Contains(bucketId))
                    {
                        BucketStatistcs bucketStats = _keyList[bucketId] as BucketStatistcs;
                        keyList = bucketStats.GetCacheKeys();
                    }
                }
            }
            finally
            {
                _rwBucketsLock.ExitWriteLock();
            }
        }
        public IIndexStore GetStore(string attrib)
        {
            bool        disacleException = QueryIndexManager.DisableException;
            IIndexStore store            = null;

            lock (_mutex)
            {
                if (_indexTable.Contains(attrib))
                {
                    store = _indexTable[attrib] as IIndexStore;
                }
                else
                {
                    if (disacleException)
                    {
                        if (store == null)
                        {
                            store = new HashStore();
                        }
                    }
                }
            }

            return(store);
        }
Exemple #6
0
        public virtual void RemoveFromIndex(object key, object value)
        {
            lock (_mutex)
            {
                IDictionaryEnumerator valuesDic = ((Hashtable)value).GetEnumerator();

                while (valuesDic.MoveNext())
                {
                    string indexKey = (string)valuesDic.Key;

                    if (_indexTable.Contains(indexKey))
                    {
                        IIndexStore store = _indexTable[indexKey] as IIndexStore;
                        object      val   = valuesDic.Value;

                        if (val != null)
                        {
                            store.Remove(val, key);
                        }
                        else
                        {
                            store.Remove("null", key);
                        }

                        if (store.Count == 0 && indexKey == TAG_INDEX_KEY)
                        {
                            _indexTable.Remove(indexKey);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Add group information to the index
        /// </summary>
        /// <param name="key"></param>
        /// <param name="grpInfo"></param>
        public void AddToSubGroup(object key, String subGroup)
        {
            SubGroupInfoEntry subGroupInfoEntry = null;

            if (subGroup == null)
            {
                subGroup = "_DEFAULT_SUB_GRP_";
            }

            long prevSize = 0, currentSize = 0;

            if (_subGroups.Contains(subGroup))
            {
                subGroupInfoEntry = (SubGroupInfoEntry)_subGroups[subGroup];
                prevSize          = subGroupInfoEntry.IndexInMemorySize;
            }
            else
            {
                subGroupInfoEntry    = new SubGroupInfoEntry();
                _subGroups[subGroup] = subGroupInfoEntry;
            }

            subGroupInfoEntry.AddKey(key);

            currentSize = subGroupInfoEntry.IndexInMemorySize;

            ModifyIndexInMemorySize(currentSize - prevSize);
        }
Exemple #8
0
 internal bool Contains(long key, object value)
 {
     if (_index.Contains(key))
     {
         EvictionIndexEntry indexEntry = _index[key] as EvictionIndexEntry;
         return(indexEntry.Contains(value));
     }
     return(false);
 }
Exemple #9
0
 public void AddToIndex(object key, object value)
 {
     lock (_mutex)
     {
         if (_indexTable.Contains(value.GetType().ToString().ToLower()))
         {
             Hashtable tbl = _indexTable[value.GetType().ToString().ToLower()] as Hashtable;
             tbl[key] = null;
         }
     }
 }
Exemple #10
0
        public void Add(string id, IQueryResult queryResult)
        {
            if (_disposed)
            {
                throw new Exception("Database Disposed");
            }


            if (_queryResults.Contains(id))
            {
                throw new Exception("Reader already Present");
            }

            _queryResults[id] = queryResult;
        }
 public override void GetKeyList(int bucketId, bool startLogging, out ClusteredArrayList keyList)
 {
     if (startLogging)
     {
         _logMgr.StartLogging(bucketId, LogMode.LogBeforeAfterActualOperation);
     }
     keyList = new ClusteredArrayList();
     if (_keyList != null)
     {
         if (_keyList.Contains(bucketId))
         {
             HashVector keyTbl = _keyList[bucketId] as HashVector;
             keyList.AddRange(keyTbl.Keys);
         }
     }
 }
        /// <summary>
        /// Add group information to the index
        /// </summary>
        /// <param name="key"></param>
        /// <param name="grpInfo"></param>
        public void AddToGroup(object key, GroupInfo grpInfo)
        {
            if (grpInfo == null)
            {
                return;
            }

            string group    = grpInfo.Group;
            string subGroup = grpInfo.SubGroup;

            if (group == null)
            {
                return;
            }
            group = DoTrimming(group);
            if (subGroup != null)
            {
                subGroup = DoTrimming(subGroup);
            }

            lock (_groups.SyncRoot)
            {
                long prevSize = 0, currentSize = 0;

                if (_groups.Contains(group))
                {
                    GroupInfoEntry entry = (GroupInfoEntry)_groups[group];

                    prevSize = entry.IndexInMemorySize;

                    entry.AddToSubGroup(key, subGroup);

                    currentSize = entry.IndexInMemorySize;
                }
                else
                {
                    GroupInfoEntry entry = new GroupInfoEntry();
                    entry.AddToSubGroup(key, subGroup);
                    _groups[group] = entry;

                    currentSize = entry.IndexInMemorySize;
                }

                ModifyGroupIndexSize(currentSize - prevSize);
            }
        }
Exemple #13
0
        public void Initialize(string groupList)
        {
            if (groupList != null)
            {
                string[] gList = groupList.Split(new char[] { ',' });

                if (gList != null)
                {
                    for (int i = 0; i < gList.Length; i++)
                    {
                        if (_groupMap.Contains(gList[i]))
                        {
                            _groupMap.Add(gList[i], null);
                        }
                    }
                }
            }
        }
        public override void UpdateLocalBuckets(ArrayList bucketIds)
        {
            IEnumerator ie = bucketIds.GetEnumerator();

            while (ie.MoveNext())
            {
                if (LocalBuckets == null)
                {
                    LocalBuckets = new HashVector();
                }

                if (!LocalBuckets.Contains(ie.Current))
                {
                    LocalBuckets[ie.Current] = new BucketStatistics();
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// Get the keys that are not in the Hashtable
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public static object[] GetNotAvailableKeys(object[] keys, HashVector table)
        {
            object[] unAvailable = new object[keys.Length - table.Count];
            int      i           = 0;

            foreach (object key in keys)
            {
                if (table.Contains(key) == false)
                {
                    unAvailable[i] = key;
                    i++;
                }
            }
            return(unAvailable);
        }
Exemple #16
0
 public void StartLogging(int bucket, LogMode loggingMode)
 {
     if (!_loggers.Contains(bucket))
     {
         _loggers.Add(bucket, new OperationLogger(bucket, loggingMode));
     }
     else
     {
         OperationLogger logger = _loggers[bucket] as OperationLogger;
         logger.LoggingMode      = loggingMode;
         logger.BucketTransfered = false;
         logger.Clear();
     }
 }
Exemple #17
0
        public void UpdateIndex(object key, CacheEntry entry)
        {
            if (key == null || entry == null || entry.ExpirationHint == null || !entry.ExpirationHint.IsIndexable)
            {
                return;
            }

            ExpirationHint hint = entry.ExpirationHint;

            lock (_status_mutex)
            {
                int addSize = hint.InMemorySize;

                if (!IsInProgress)
                {
                    if (_mainIndex.Contains(key))
                    {
                        ExpirationHint expHint = _mainIndex[key] as ExpirationHint;
                        addSize -= expHint.InMemorySize;
                    }

                    _mainIndex[key] = hint;
                }
                else
                {
                    if (_transitoryIndex.ContainsKey(key))
                    {
                        ExpirationHint expHint = _transitoryIndex[key] as ExpirationHint;
                        if (expHint != null)
                        {
                            addSize -= expHint.InMemorySize;
                        }
                    }

                    _transitoryIndex[key] = hint;
                }
                _expirationManagerSize += addSize;
            }
        }
Exemple #18
0
        public virtual void AddToIndex(object key, object value, OperationContext operationContext)
        {
            CacheEntry entry     = (CacheEntry)value;
            Hashtable  queryInfo = entry.QueryInfo["query-info"] as Hashtable;

            if (queryInfo == null)
            {
                return;
            }


            lock (_indexMap.SyncRoot)
            {
                IDictionaryEnumerator queryInfoEnumerator = queryInfo.GetEnumerator();

                while (queryInfoEnumerator.MoveNext())
                {
                    int    handleId = (int)queryInfoEnumerator.Key;
                    string type     = _typeMap.GetTypeName(handleId);
                    if (_indexMap.Contains(type))
                    {
                        Hashtable indexAttribs    = new Hashtable();
                        Hashtable metaInfoAttribs = new Hashtable();

                        ArrayList values = (ArrayList)queryInfoEnumerator.Value;

                        ArrayList attribList = _typeMap.GetAttribList(handleId);
                        for (int i = 0; i < attribList.Count; i++)
                        {
                            string attribute = attribList[i].ToString();
                            string val       = _typeMap.GetAttributes(handleId)[attribList[i]] as string;
                            if (Common.Util.JavaClrTypeMapping.JavaToClr(val) != null)
                            {
                                val = Common.Util.JavaClrTypeMapping.JavaToClr(val);
                            }
                            Type t1 = Type.GetType(val, true, true);

                            object obj = null;

                            if (values[i] != null)
                            {
                                try
                                {
                                    if (t1 == typeof(System.DateTime))
                                    {
                                        obj = new DateTime(Convert.ToInt64(values[i]));
                                    }
                                    else
                                    {
                                        obj = Convert.ChangeType(values[i], t1);
                                    }
                                }
                                catch (Exception)
                                {
                                    throw new System.FormatException("Cannot convert '" + values[i] + "' to " + t1.ToString());
                                }

                                indexAttribs.Add(attribute, obj);
                            }
                            else
                            {
                                indexAttribs.Add(attribute, null);
                            }


                            metaInfoAttribs.Add(attribute, obj);
                        }

                        MetaInformation metaInformation = new MetaInformation(metaInfoAttribs);
                        metaInformation.CacheKey = key as string;
                        metaInformation.Type     = _typeMap.GetTypeName(handleId);

                        operationContext.Add(OperationContextFieldName.IndexMetaInfo, metaInformation);

                        entry.ObjectType = _typeMap.GetTypeName(handleId);

                        IQueryIndex index    = (IQueryIndex)_indexMap[type];
                        long        prevSize = index.IndexInMemorySize;
                        index.AddToIndex(key, new QueryItemContainer(entry, indexAttribs));

                        this._queryIndexMemorySize += index.IndexInMemorySize - prevSize;
                    }
                }
            }
        }
 internal bool Contains(object key)
 {
     return(_hintIndex.Contains(key));
 }