Esempio n. 1
0
        public virtual bool Initialize(BaseCollection parent)
        {
            try
            {
                _parent = parent;
                bool check = _metadataPersister.CreateCollection(GetLasRowIdCollection(), typeof(string), typeof(long));

                if (check)
                {
                    ITransaction transaction = _metadataPersister.BeginTransaction(null, false);
                    _metadataPersister.StoreDocument(transaction, GetLasRowIdCollection(), "LastRowId", _lastRowId);
                    _metadataPersister.Commit(transaction);
                }

                _metadataPersister.CreateCollection(GetKeyMetadataCollection(), typeof(long), typeof(byte[]));

                RegenerateLastRowId();
                RegeneratekeyMetadata();

                //if (_statsCollector != null)
                //{
                //    _statsCollector.IncrementStatsValue(StatisticsType.DocumentCount, _rowToFileIndex.Count);
                //    SetAverageDocumentSize();
                //}
                return(true);
            }
            catch (Exception e)
            {
                if (LoggerManager.Instance.StorageLogger != null && LoggerManager.Instance.StorageLogger.IsErrorEnabled)
                {
                    LoggerManager.Instance.StorageLogger.Error("Error Initializing MetadataIndex.", e);
                }
                throw;
            }
        }
Esempio n. 2
0
        public virtual bool Initialize(StorageConfiguration configuration, StatsIdentity statsIdentity)
        {
            _userConfig = (StorageConfiguration)configuration.Clone();
            if (configuration == null || configuration.StorageProvider == null)
            {
                throw new ConfigurationException("PersistenceProvider configuration not found.");
            }

            _statsCollector = StatsManager.Instance.GetStatsCollector(statsIdentity);

            RegenerateMetaData();

            ITransaction transaction = _metadataPersister.BeginTransaction(null, false);

            CreateNextFile(transaction);
            _metadataPersister.Commit(transaction);

            DisplaySize();

            return(true);
        }