public DocumentIndexMonitor(DocumentIndexType documentIndexType, Func <IDocumentIndex> documentIndexFactory, IActivityLogger logger)
 {
     _documentIndexFactory = documentIndexFactory;
     _logger            = logger;
     _gate              = new object();
     _documentIndexType = documentIndexType;
     BornOrRessurectIfDead();
 }
Example #2
0
 public DocumentIndex(DocumentIndexTypeToken documentIndexTypeToken, AccountName accountName, Action shuttingDown, DocumentIndexSetup documentIndexSetup, Action <string> log)
 {
     _documentType       = DocumentIndexTypes[documentIndexTypeToken];
     _hoot               = new Hoot(GetIndexPath(documentIndexSetup, accountName), _documentType.FileName, log, documentIndexSetup.MinStringLengthToSearch, documentIndexSetup.MaxStringLengthIgnore);
     _shuttingDown       = shuttingDown;
     _isAlive            = true;
     _gate               = new object();
     _documentIndexSetup = documentIndexSetup;
     UpdateToken();
 }
Example #3
0
        public DocumentIndexTyped(DocumentIndexType indexType, IPluginContext context, Action shuttedDown, DocumentIndexSetup documentIndexSetup, IActivityLoggerFactory loggerFactory, DocumentIndexOptimizeHintFactory optimizeHintFactory)
        {
            _indexType = indexType;
            _logger    = loggerFactory.Create(new PluginContextSnapshot(context));
            var indexPath = _indexType.GetFileFolder(context.AccountName, documentIndexSetup);

            _hoot               = new Hoot(indexPath, _indexType.FileName, _logger.Debug, _logger.Error, indexType.CreateTokensParser(documentIndexSetup), _logger.IsDebugEnabled);
            _shuttedDown        = shuttedDown;
            _isAlive            = true;
            _documentIndexSetup = documentIndexSetup;
            _optimizeHint       = optimizeHintFactory.Create(documentIndexSetup);
            _isOptimized        = true;
            UpdateLastUsedToken();
        }
Example #4
0
        private IDocumentIndex CreateDocumentIndex(IPluginContext context, DocumentIndexTypeToken documentIndexTypeToken, int?version = null)
        {
            DocumentIndexType charactersIndexType = null;
            DocumentIndexType digitsIndexType     = null;

            if (_documentIndexMetadata.Contains(documentIndexTypeToken, DocumentIndexDataTypeToken.Characters))
            {
                charactersIndexType = _documentIndexMetadata.GetDocumentIndexType(documentIndexTypeToken, DocumentIndexDataTypeToken.Characters);
            }
            if (_documentIndexMetadata.Contains(documentIndexTypeToken, DocumentIndexDataTypeToken.Digits))
            {
                digitsIndexType = _documentIndexMetadata.GetDocumentIndexType(documentIndexTypeToken, DocumentIndexDataTypeToken.Digits);
            }
            if (version != null)
            {
                if (charactersIndexType != null)
                {
                    charactersIndexType = charactersIndexType.CreateVersion(version.Value);
                }
                if (digitsIndexType != null)
                {
                    digitsIndexType = digitsIndexType.CreateVersion(version.Value);
                }
            }
            DocumentIndexMonitor monitor = null;
            Action detachIndex           = () =>
            {
                if (monitor != null)
                {
                    monitor.DetachIndex();
                }
            };
            IActivityLogger logger = _loggerFactory.Create(new PluginContextSnapshot(context));

            monitor = new DocumentIndexMonitor(charactersIndexType ?? digitsIndexType, () =>
            {
                if (charactersIndexType != null)
                {
                    return(digitsIndexType != null
                                                                   ? (IDocumentIndex) new DocumentIndex(charactersIndexType, digitsIndexType, context, detachIndex, _documentIndexSetup, _loggerFactory, _optimizeHintFactory)
                                                                   : new DocumentIndexTyped(charactersIndexType, context, detachIndex, _documentIndexSetup, _loggerFactory, _optimizeHintFactory));
                }
                throw new ApplicationException("Characters index for {0} type is not supported.".Fmt(documentIndexTypeToken));
            }, logger);
            return(monitor);
        }
Example #5
0
 public DocumentIndex(DocumentIndexType charactersIndexType, DocumentIndexType digitsIndexType, IPluginContext context, Action shuttedDown, DocumentIndexSetup documentIndexSetup, IActivityLoggerFactory loggerFactory, DocumentIndexOptimizeHintFactory optimizeHintFactory)
 {
     _charactersIndex = new DocumentIndexTyped(charactersIndexType, context, shuttedDown, documentIndexSetup, loggerFactory, optimizeHintFactory);
     _numberIndex     = new DocumentIndexTyped(digitsIndexType, context, shuttedDown, documentIndexSetup, loggerFactory, optimizeHintFactory);
 }
		private IDocumentIndex CreateDocumentIndex(AccountName accountName, DocumentIndexType documentIndexType, DocumentIndexSetup documentIndexSetup, IActivityLoggerFactory activityLoggerFactory)
		{
			return new DocumentIndexTyped(documentIndexType, new PluginContextMock { AccountName = accountName, ProfileName = "Qq" }, () => { }, documentIndexSetup, activityLoggerFactory, new DocumentIndexOptimizeHintFactory());
		}
		private IDocumentIndex CreateDocumentIndex(AccountName accountName, int version, DocumentIndexSetup documentIndexSetup, IActivityLoggerFactory activityLoggerFactory)
		{
			var indexType = new DocumentIndexType(DocumentIndexTypeToken.Entity, DocumentIndexDataTypeToken.Digits, "Entity", Enumerable.Empty<Enum>(), Enumerable.Empty<Enum>(), version, new DigitsDocumentIndexDataTypeService(), new FileService());
			return CreateDocumentIndex(accountName, indexType, documentIndexSetup, activityLoggerFactory);
		}
		public void CheckVersionParsing()
		{
			var t = new DocumentIndexType(DocumentIndexTypeToken.Entity, DocumentIndexDataTypeToken.Digits, "Entity", Enumerable.Empty<Enum>(), Enumerable.Empty<Enum>(), 2, new DigitsDocumentIndexDataTypeService(), new FileServiceStub());
			IEnumerable<int> versions = t.GetVersions(AccountName.Empty, new DocumentIndexSetup(string.Empty, 0, 0, 0));
			versions.Should(Be.EquivalentTo(new[] {1}), "versions.Should(Be.EquivalentTo(new[] {{i}}))");
		}
Example #9
0
 static DocumentIndex()
 {
     BasePath           = Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path));
     DocumentIndexTypes = DocumentIndexType.Load();
 }