Beispiel #1
0
        private static VectorTree DeserializeTree(string dir)
        {
            var ix = new SortedList <ulong, SortedList <uint, VectorNode> >();

            foreach (var ixFileName in Directory.GetFiles(dir, "*.ix"))
            {
                var name    = Path.GetFileNameWithoutExtension(ixFileName).Split(".", StringSplitOptions.RemoveEmptyEntries);
                var colHash = ulong.Parse(name[0]);
                var keyId   = uint.Parse(name[1]);
                SortedList <uint, VectorNode> colIx;

                if (!ix.TryGetValue(colHash, out colIx))
                {
                    colIx = new SortedList <uint, VectorNode>();
                    ix.Add(colHash, colIx);
                }

                using (var treeStream = File.OpenRead(ixFileName))
                    using (var vecStream = File.OpenRead(Path.Combine(dir, string.Format("{0}.vec", colHash))))
                    {
                        var root = VectorNode.Deserialize(treeStream, vecStream);

                        ix[colHash].Add(keyId, root);
                    }
            }

            return(new VectorTree(ix));
        }
Beispiel #2
0
 public VectorNode DeserializeIndex(string ixFileName, string vecFileName)
 {
     using (var treeStream = new FileStream(ixFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
         using (var vecStream = new FileStream(vecFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
         {
             return(VectorNode.Deserialize(treeStream, vecStream));
         }
 }
Beispiel #3
0
 private async Task <VectorNode> DeserializeIndex(string ixFileName, string vecFileName)
 {
     using (var treeStream = new FileStream(ixFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, true))
         using (var vecStream = new FileStream(vecFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, true))
         {
             return(await VectorNode.Deserialize(treeStream, vecStream));
         }
 }