protected override IFullTextIndexHeader GetIndexHeader() { var header = indexInfo.Read(); var dictionaryType = PersistentDictionaryFactory.GetName(name.DictionaryType); var fieldsType = PersistentMetadataFactory.GetName(name.FieldsType); var postingType = PostingListIOFactory.GetName(name.PostingType); var textEncoding = TextEncodingFactory.GetName(name.TextEncoding); if (header == null) { header = new IndexHeaderData { Type = $"{nameof(PersistentIndex)} {dictionaryType} {fieldsType} {postingType} {textEncoding}", MaxTokenSize = MaxTokenSize, NextDocumentId = 0, CreatedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, }; } else { var types = header.Type.Split(' '); if (types[0] != nameof(PersistentIndex)) { throw new InvalidOperationException("Index type and name mismatch"); } if (types[1] != dictionaryType) { throw new InvalidOperationException("Field type and name mismatch"); } if (types[2] != fieldsType) { throw new InvalidOperationException("Field type and name mismatch"); } if (types[3] != postingType) { throw new InvalidOperationException("Posting type and name mismatch"); } if (types[4] != textEncoding) { throw new InvalidOperationException("Text encoding type and name mismatch"); } } return(header); }
public static ITermDictionary Create(string dictionaryType, string folder, string fileNameDictionary, int maxTokenLength, string encodingName) { if (dictionaryType == PersistentIndexName.DefaultValue || dictionaryType == PersistentDictionaryTst.Id) { return(new PersistentDictionaryTst(folder, fileNameDictionary, maxTokenLength, TextEncodingFactory.GetByName(encodingName))); } if (dictionaryType == PersistentDictionaryFst.Id) { return(new PersistentDictionaryFst(folder, fileNameDictionary, maxTokenLength, TextEncodingFactory.GetByName(encodingName))); } throw new NotSupportedException($"Dictionary type {dictionaryType} is not supported"); }