Exemplo n.º 1
0
        /// <summary>
        ///     Initialize an empty datastore from a type description
        /// </summary>
        /// <param name="typeDescription"></param>
        /// <param name="evictionPolicy"></param>
        /// <param name="config"></param>
        public DataStore(TypeDescription typeDescription, EvictionPolicy evictionPolicy, NodeConfig config)
        {
            TypeDescription = typeDescription ?? throw new ArgumentNullException(nameof(typeDescription));

            EvictionPolicy = evictionPolicy ?? throw new ArgumentNullException(nameof(evictionPolicy));

            //initialize the primary key dictionary
            _dataByPrimaryKey = new Dictionary <KeyValue, CachedObject>();


            //initialize the unique keys dictionaries (une by unique key)
            _dataByUniqueKey = new Dictionary <string, Dictionary <KeyValue, CachedObject> >();

            foreach (var keyInfo in typeDescription.UniqueKeyFields)
            {
                _dataByUniqueKey.Add(keyInfo.Name, new Dictionary <KeyValue, CachedObject>());
            }

            //initialize the indexes (one by index key)
            _dataByIndexKey = new Dictionary <string, IndexBase>();

            // scalar indexed fields
            foreach (var indexField in typeDescription.IndexFields)
            {
                var index = IndexFactory.CreateIndex(indexField);
                _dataByIndexKey.Add(indexField.Name, index);
            }


            // list indexed fields
            foreach (var indexField in typeDescription.ListFields)
            {
                var index = IndexFactory.CreateIndex(indexField);
                _dataByIndexKey.Add(indexField.Name, index);
            }


            // create the full-text index if required
            if (typeDescription.FullText.Count > 0)
            {
                _fullTextIndex = new FullTextIndex(config.FullTextConfig)
                {
                    // a function that allows the full text engine to find the original line of text
                    LineProvider = pointer => _dataByPrimaryKey[pointer.PrimaryKey].FullText[pointer.Line]
                };
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Initialize an empty datastore from a type description
        /// </summary>
        /// <param name="collectionSchema"></param>
        /// <param name="evictionPolicy"></param>
        /// <param name="fullTextConfig"></param>
        public DataStore(CollectionSchema collectionSchema, EvictionPolicy evictionPolicy,
                         FullTextConfig fullTextConfig)
        {
            _fullTextConfig = fullTextConfig;

            CollectionSchema = collectionSchema ?? throw new ArgumentNullException(nameof(collectionSchema));

            EvictionPolicy = evictionPolicy ?? throw new ArgumentNullException(nameof(evictionPolicy));

            //initialize the primary key dictionary
            DataByPrimaryKey = new Dictionary <KeyValue, PackedObject>();


            //initialize the unique keys dictionaries (one by unique key)
            _dataByUniqueKey = new Dictionary <string, Dictionary <KeyValue, PackedObject> >();

            foreach (var keyInfo in collectionSchema.UniqueKeyFields)
            {
                _dataByUniqueKey.Add(keyInfo.Name, new Dictionary <KeyValue, PackedObject>());
            }

            //initialize the indexes (one by index key)
            _dataByIndexKey = new Dictionary <string, IndexBase>();

            // scalar indexed fields
            foreach (var indexField in collectionSchema.IndexFields)
            {
                var index = IndexFactory.CreateIndex(indexField);
                _dataByIndexKey.Add(indexField.Name, index);
            }


            // create the full-text index if required
            if (collectionSchema.FullText.Count > 0)
            {
                _fullTextIndex = new FullTextIndex(fullTextConfig)
                {
                    // a function that allows the full text engine to find the original line of text
                    LineProvider = pointer => DataByPrimaryKey[pointer.PrimaryKey].TokenizedFullText[pointer.Line]
                }
            }
            ;
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Initialize an empty datastore from a type description
        /// </summary>
        /// <param name="typeDescription"></param>
        /// <param name="evictionPolicy"></param>
        public DataStore(TypeDescription typeDescription, EvictionPolicy evictionPolicy)
        {
            TypeDescription = typeDescription ?? throw new ArgumentNullException(nameof(typeDescription));

            EvictionPolicy = evictionPolicy ?? throw new ArgumentNullException(nameof(evictionPolicy));

            //initialize the primary key dictionary
            _dataByPrimaryKey = new Dictionary <KeyValue, CachedObject>();


            //initialize the unique keys dictionaries (une by unique key)
            _dataByUniqueKey = new Dictionary <string, Dictionary <KeyValue, CachedObject> >();

            foreach (var keyInfo in typeDescription.UniqueKeyFields)
            {
                _dataByUniqueKey.Add(keyInfo.Name, new Dictionary <KeyValue, CachedObject>());
            }

            //initialize the indexes (one by index key)
            _dataByIndexKey = new Dictionary <string, IndexBase>();

            // scalar indexed fields
            foreach (var indexField in typeDescription.IndexFields)
            {
                var index = IndexFactory.CreateIndex(indexField);
                _dataByIndexKey.Add(indexField.Name, index);
            }


            // list indexed fields

            foreach (var indexField in typeDescription.ListFields)
            {
                var index = IndexFactory.CreateIndex(indexField);
                _dataByIndexKey.Add(indexField.Name, index);
            }
        }