示例#1
0
        internal virtual TrieIndexHeader GetHeader()
        {
            var serializer = new TrieIndexHeaderSerializer();
            var header     = serializer.Deserialize(_headerStream);

            return(header);
        }
示例#2
0
        /// <summary>
        /// Dont forget to close streams after read.
        /// </summary>
        /// <param name="headerStream"></param>
        /// <param name="indexStream"></param>
        /// <returns>Processed node count</returns>
        public int Build()
        {
            PrepareForBuild();

            var serializer = new TrieIndexHeaderSerializer();

            serializer.Serialize(_headerStream, _header);

            var processedNodeCount = TrieIndexSerializer.Serialize(_trie.Root, _header, _indexStream);

            return(processedNodeCount);
        }
        public static void CreateHeaderFile(this TrieIndexHeader header, string path)
        {
            var serializer = new TrieIndexHeaderSerializer();

            using (Stream stream = new FileStream(
                       path,
                       FileMode.OpenOrCreate,
                       FileAccess.Write,
                       FileShare.None
                       ))
            {
                serializer.Serialize(stream, header);
            }
        }
        public static TrieIndexHeader ReadHeaderFile(string path)
        {
            var serializer = new TrieIndexHeaderSerializer();

            using (Stream stream = new FileStream(
                       path,
                       FileMode.Open,
                       FileAccess.Read,
                       FileShare.Read
                       ))
            {
                return(serializer.Deserialize(stream));
            }
        }