Exemple #1
0
 private void Write(FasterKV <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions> h, MyContext context)
 {
     for (int i = 0; i < iterations; i++)
     {
         var _key = new MyKey {
             key = i, name = i.ToString()
         };
         var value = new MyValue {
             value = i.ToString()
         };
         h.Upsert(ref _key, ref value, context, 0);
     }
 }
Exemple #2
0
        private void Read(FasterKV <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions> h, MyContext context, bool delete)
        {
            var key = new MyKey {
                key = 1, name = "1"
            };
            var      input  = default(MyInput);
            MyOutput g1     = new MyOutput();
            var      status = h.Read(ref key, ref input, ref g1, context, 0);

            if (status == Status.PENDING)
            {
                h.CompletePending(true);
                context.FinalizeRead(ref status, ref g1);
            }

            Assert.IsTrue(status == Status.OK);

            MyOutput g2 = new MyOutput();

            key = new MyKey {
                key = 2, name = "2"
            };
            status = h.Read(ref key, ref input, ref g2, context, 0);

            if (status == Status.PENDING)
            {
                h.CompletePending(true);
                context.FinalizeRead(ref status, ref g2);
            }

            Assert.IsTrue(status == Status.OK);

            if (delete)
            {
                var output = new MyOutput();
                h.Delete(ref key, context, 0);
                status = h.Read(ref key, ref input, ref output, context, 0);

                if (status == Status.PENDING)
                {
                    h.CompletePending(true);
                    context.FinalizeRead(ref status, ref output);
                }

                Assert.IsTrue(status == Status.NOTFOUND);
            }
        }
Exemple #3
0
        private void Write(ClientSession <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions> session, MyContext context, FasterKV <MyKey, MyValue> fht)
        {
            for (int i = 0; i < iterations; i++)
            {
                var _key = new MyKey {
                    key = i, name = i.ToString()
                };
                var value = new MyValue {
                    value = i.ToString()
                };
                session.Upsert(ref _key, ref value, context, 0);

                if (i % 100 == 0)
                {
                    fht.TakeFullCheckpoint(out _);
                    fht.CompleteCheckpointAsync().GetAwaiter().GetResult();
                }
            }
        }
Exemple #4
0
        private void Read(ClientSession <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions> session, MyContext context, bool delete)
        {
            for (int i = 0; i < iterations; i++)
            {
                var key = new MyKey {
                    key = i, name = i.ToString()
                };
                var      input  = default(MyInput);
                MyOutput g1     = new MyOutput();
                var      status = session.Read(ref key, ref input, ref g1, context, 0);

                if (status == Status.PENDING)
                {
                    session.CompletePending(true);
                    context.FinalizeRead(ref status, ref g1);
                }

                Assert.IsTrue(status == Status.OK);
                Assert.IsTrue(g1.value.value == i.ToString());
            }

            if (delete)
            {
                var key = new MyKey {
                    key = 1, name = "1"
                };
                var input  = default(MyInput);
                var output = new MyOutput();
                session.Delete(ref key, context, 0);
                var status = session.Read(ref key, ref input, ref output, context, 0);

                if (status == Status.PENDING)
                {
                    session.CompletePending(true);
                    context.FinalizeRead(ref status, ref output);
                }

                Assert.IsTrue(status == Status.NOTFOUND);
            }
        }