示例#1
0
文件: Test.cs 项目: e2wugui/zeze
        public static void RunWrap(string url)
        {
            Console.WriteLine("RunWrap");

            var tikvDb = new DatabaseTikv(url);
            var table  = tikvDb.OpenTable("_testtable_");
            var key    = Zeze.Serialize.ByteBuffer.Allocate(64);

            key.WriteString("key");
            var value = Zeze.Serialize.ByteBuffer.Allocate(64);
            //value.WriteString("value");

            var outvalue = table.Find(key);

            Console.WriteLine("Find1 " + outvalue);
            tikvDb.Flush(null,
                         () =>
            {
                table.Replace(key, value);
            });

            outvalue = table.Find(key);
            Console.WriteLine("Find2 " + outvalue);
            tikvDb.Flush(null,
                         () =>
            {
                table.Remove(key);
            });

            outvalue = table.Find(key);
            Console.WriteLine("Find3 " + outvalue);
        }
示例#2
0
文件: Test.cs 项目: e2wugui/zeze
        public static void RunScan(string url)
        {
            Console.WriteLine("RunScan");

            // for keyprefix
            var tikvDb = new DatabaseTikv(url);
            var table  = tikvDb.OpenTable("_testtable_") as DatabaseTikv.TableTikv;

            // prepare data
            var key = Zeze.Serialize.ByteBuffer.Allocate(64);

            key.WriteString("key");
            var value = Zeze.Serialize.ByteBuffer.Allocate(64);

            value.WriteString("value");
            tikvDb.Flush(null,
                         () =>
            {
                table.Replace(key, value);
            });

            var outvalue = table.Find(key);

            Console.WriteLine("Scan Find1 " + outvalue);

            // connect an begin transaction
            table.Walk(
                (key, value) =>
            {
                Console.WriteLine($"Scan Callback: {BitConverter.ToString(key)}=>{BitConverter.ToString(value)}");
                return(true);
            });
        }
示例#3
0
            public TableTikv(DatabaseTikv database, string name)
            {
                Database = database;
                Name     = name;
                var nameutf8 = Encoding.UTF8.GetBytes(name);

                KeyPrefix = ByteBuffer.Allocate(nameutf8.Length + 1);
                KeyPrefix.Append(nameutf8);
                KeyPrefix.WriteByte(0);
            }
示例#4
0
 public OperatesTikv(DatabaseTikv tikv)
 {
     Database = tikv;
 }