Esempio n. 1
0
        public override void Dispose()
        {
            foreach (var node in _dirty)
            {
                var ixFileName  = Path.Combine(SessionFactory.Dir, string.Format("{0}.{1}.ix", CollectionId, node.Key));
                var tmpFileName = string.Format("{0}.tmp_ix", Path.GetFileNameWithoutExtension(ixFileName));

                using (var indexStream = new FileStream(
                           tmpFileName, FileMode.Append, FileAccess.Write, FileShare.None))
                {
                    node.Value.Serialize(indexStream, VectorStream, PostingsStream);
                }

                SessionFactory.RefreshIndex(CollectionId, node.Key, node.Value);

                File.Copy(tmpFileName, ixFileName, overwrite: true);
                File.Delete(tmpFileName);
            }

            ValueStream.Flush();
            KeyStream.Flush();
            DocStream.Flush();
            ValueIndexStream.Flush();
            KeyIndexStream.Flush();
            DocIndexStream.Flush();
            PostingsStream.Flush();
            VectorStream.Flush();

            base.Dispose();
        }
Esempio n. 2
0
        public override void Dispose()
        {
            foreach (var node in _dirty)
            {
                var fn       = Path.Combine(Dir, node.Key + ".ix");
                var fileMode = File.Exists(fn) ? FileMode.Truncate : FileMode.Append;

                using (var stream = new FileStream(fn, fileMode, FileAccess.Write, FileShare.None))
                {
                    node.Value.Serialize(stream, VectorStream, PostingsStream);
                }
            }

            ValueStream.Flush();
            KeyStream.Flush();
            DocStream.Flush();
            ValueIndexStream.Flush();
            KeyIndexStream.Flush();
            DocIndexStream.Flush();
            PostingsStream.Flush();
            VectorStream.Flush();

            base.Dispose();
        }