Beispiel #1
0
        public bool Initialize(DatabaseContext _dbContext, CollectionConfiguration config)
        {
            //eviction is always enabled for now and can not be turned off.
            _isEvictionEnabled = true;
            if (_parent.CollectionConfiguration.EvictionConfiguration != null)  //TODO this check is added if eviction configuration is not available at collection level in db.config
            {
                //_isEvictionEnabled = _parent.CollectionConfiguration.EvictionConfiguration.EnabledEviction;
                if (_parent.CollectionConfiguration.EvictionConfiguration.Policy.ToLower() == "lru")
                {
                    _evictionPolicy = new LRUEvictionPolicy(_parent.DbContext.StatsIdentity);
                }
            }
            else
            {
                _evictionPolicy = new LRUEvictionPolicy(_parent.DbContext.StatsIdentity);
            }

            _persistenceManager = _parent.DbContext.PersistenceManager;
            _persistenceManager.AddMetadataIndex(_parent.Name, _parent.MetadataIndex);

            _indexManager = new CollectionIndexManager(_dbContext, _dbContext.IndexPersistanceManager, this, config.CollectionName);
            if (!_indexManager.Initialize(config.Indices))
            {
                return(false);
            }
            //if (_statsCollector != null)
            //    _statsCollector.SetStatsValue(StatisticsType.PendingPersistentDocuments, _dirtyDocuments.Count);

            if (_persistenceManager == null)
            {
                return(false);
            }
            return(true);
        }
 public CostBasedOptimizer(CollectionIndexManager indexManager)
 {
     _indexManager   = indexManager;
     _predicateCache = new LightCache <ITreePredicate, IPredicate>();
 }