示例#1
0
        static void Main(string[] args)
        {
            ////System.IO.
            ////Console.WriteLine("Hello World!");
            //var hash = new HashFile("c:\\hash1.db");
            //string str = "10";
            //string value = "only ascii";
            //hash.Put(System.Text.ASCIIEncoding.ASCII.GetBytes(str),

            //    System.Text.ASCIIEncoding.ASCII.GetBytes(value)
            //    );
            //Console.WriteLine(System.Text.ASCIIEncoding.ASCII.GetString(hash.Get(System.Text.ASCIIEncoding.ASCII.GetBytes(str))));
            //Console.Read();
            //File.Delete("c:\\seq.db");
            var seqf = new SequenceFile("c:\\seq.db");

            for (int i = 0; i < 10000; i++)
            {
                seqf.Add(2);
                seqf.Add(3);
                seqf.Add(453455345);
                seqf.Add(45534345);
                seqf.Add(45543345);
            }

            //seqf.Close();
            var list = seqf.GetRange(0, 4);
        }
示例#2
0
 public void Insert(long key, string value)
 {
     byte[] keyBytesbytes = BitConverter.GetBytes(key);
     if (hashf.Get(keyBytesbytes) != null)
     {
         throw new Exception($"cant insert because hashfile has this item:{key}");
     }
     byte[] valBytes = ASCIIEncoding.ASCII.GetBytes(value);
     //1.插入hash文件
     hashf.Put(keyBytesbytes, valBytes);
     //2.插入索引
     seqf.Add(key);
 }