示例#1
0
        public bool CommitToIndex()
        {
            try
            {
                if (_dirty.Count > 0)
                {
                    _log.Log(string.Format("committing {0} indexes to {1}", _dirty.Count, CollectionId));
                }

                foreach (var node in _dirty)
                {
                    var keyId = node.Key;
                    //var ixFileName = Path.Combine(SessionFactory.Dir, string.Format("{0}.{1}.ix", CollectionId, keyId));

                    //using (var ixStream = new FileStream(ixFileName, FileMode.Create, FileAccess.Write, FileShare.None))
                    //{
                    //    node.Value.Serialize(ixStream, VectorStream, PostingsStream);
                    //}

                    //node.Value.Serialize(PostingsStream);

                    //var size = node.Value.Size();

                    //_log.Log(string.Format("serialized index. col: {0} key_id:{1} w:{2} d:{3}",
                    //    CollectionId, keyId, size.width, size.depth));

                    SessionFactory.AddIndex(CollectionId, keyId, node.Value);

                    _log.Log(string.Format("refreshed index col: {0} key_id:{1}",
                                           CollectionId, keyId));
                }

                if (_dirty.Count > 0)
                {
                    _log.Log(string.Format("committed {0} indexes to {1}", _dirty.Count, CollectionId));
                }

                return(true);
            }
            catch (Exception ex)
            {
                _log.Log(ex.ToString());

                throw;
            }
        }