public void BlittableLogCompactionCustomFunctionsTest2()
        {
            // Update: irrelevant as session compaction no longer uses Copy/CopyInPlace
            // This test checks if CopyInPlace returning false triggers call to Copy

            using var session = fht.For(new FunctionsCompaction()).NewSession <FunctionsCompaction>();

            var key = new KeyStruct {
                kfield1 = 100, kfield2 = 101
            };
            var value = new ValueStruct {
                vfield1 = 10, vfield2 = 20
            };

            session.Upsert(ref key, ref value, 0, 0);

            fht.Log.Flush(true);

            value = new ValueStruct {
                vfield1 = 11, vfield2 = 21
            };
            session.Upsert(ref key, ref value, 0, 0);

            fht.Log.Flush(true);

            var compactionFunctions = new Test2CompactionFunctions();

            session.Compact(fht.Log.TailAddress, true, compactionFunctions);

            Assert.IsFalse(compactionFunctions.CopyCalled);

            var input  = default(InputStruct);
            var output = default(OutputStruct);
            var status = session.Read(ref key, ref input, ref output, 0, 0);

            if (status == Status.PENDING)
            {
                session.CompletePending(true);
            }
            else
            {
                Assert.IsTrue(status == Status.OK);
                Assert.IsTrue(output.value.vfield1 == value.vfield1);
                Assert.IsTrue(output.value.vfield2 == value.vfield2);
            }
        }
Exemplo n.º 2
0
        public void GenericLogCompactionCustomFunctionsTest2()
        {
            // Update: irrelevant as session compaction no longer uses Copy/CopyInPlace
            // This test checks if CopyInPlace returning false triggers call to Copy

            using var session = fht.For(new MyFunctionsDelete()).NewSession <MyFunctionsDelete>();

            var key = new MyKey {
                key = 100
            };
            var value = new MyValue {
                value = 20
            };

            session.Upsert(ref key, ref value, 0, 0);

            fht.Log.Flush(true);

            value = new MyValue {
                value = 21
            };
            session.Upsert(ref key, ref value, 0, 0);

            fht.Log.Flush(true);

            var compactionFunctions = new Test2CompactionFunctions();

            session.Compact(fht.Log.TailAddress, true, compactionFunctions);

            Assert.IsFalse(compactionFunctions.CopyCalled);

            var input  = default(MyInput);
            var output = default(MyOutput);
            var status = session.Read(ref key, ref input, ref output, 0, 0);

            if (status == Status.PENDING)
            {
                session.CompletePending(true);
            }
            else
            {
                Assert.IsTrue(status == Status.OK);
                Assert.IsTrue(output.value.value == value.value);
            }
        }
        public void LogCompactCopyInPlaceCustomFctnTest([Values] CompactionType compactionType)
        {
            // Update: irrelevant as session compaction no longer uses Copy/CopyInPlace
            // This test checks if CopyInPlace returning false triggers call to Copy

            using var session = fht.For(new MyFunctionsDelete()).NewSession <MyFunctionsDelete>();

            var key = new MyKey {
                key = 100
            };
            var value = new MyValue {
                value = 20
            };

            session.Upsert(ref key, ref value, 0, 0);

            fht.Log.Flush(true);

            value = new MyValue {
                value = 21
            };
            session.Upsert(ref key, ref value, 0, 0);

            fht.Log.Flush(true);

            var compactionFunctions = new Test2CompactionFunctions();
            var compactUntil        = session.Compact(fht.Log.TailAddress, compactionType, compactionFunctions);

            fht.Log.Truncate();

            var input  = default(MyInput);
            var output = default(MyOutput);
            var status = session.Read(ref key, ref input, ref output, 0, 0);

            if (status.IsPending)
            {
                session.CompletePendingWithOutputs(out var outputs, wait: true);
                (status, output) = GetSinglePendingResult(outputs);
            }
            Assert.IsTrue(status.Found);
            Assert.AreEqual(value.value, output.value.value);
        }