Esempio n. 1
0
        public void Setup()
        {
            if (test_path == null)
            {
                test_path = Path.GetTempPath() + Path.GetRandomFileName();
                if (!Directory.Exists(test_path))
                {
                    Directory.CreateDirectory(test_path);
                }
            }

            log    = FasterFactory.CreateLogDevice(test_path + "\\ort1hlog");
            objlog = FasterFactory.CreateObjectLogDevice(test_path + "\\ort1hlog");

            fht =
                FasterFactory.Create
                <AdId, NumClicks, Input, Output, Empty, Functions>
                (
                    keySpace, new Functions(),
                    new LogSettings {
                LogDevice = log, ObjectLogDevice = objlog
            },
                    new CheckpointSettings {
                CheckpointDir = test_path, CheckPointType = CheckpointType.FoldOver
            });
        }
Esempio n. 2
0
 public void TearDown()
 {
     fht.StopSession();
     fht.Dispose();
     fht = null;
     log.Close();
 }
Esempio n. 3
0
 public void TearDown()
 {
     fht.StopSession();
     fht = null;
     log.Close();
     objlog.Close();
     DeleteDirectory(test_path);
 }
Esempio n. 4
0
        public static void Setup(TestContext t)
        {
            var log = FasterFactory.CreateLogDevice(Path.GetTempPath() + "\\hybridlog_object.log");

            fht = FasterFactory.Create
                  <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions>
                      (indexSizeBuckets: 128, logDevice: log, functions: new MyFunctions(),
                      LogMutableFraction: 0.1, LogPageSizeBits: 9, LogTotalSizeBytes: 512 * 16
                      );
            fht.StartSession();
        }
Esempio n. 5
0
        public static void Setup(TestContext t)
        {
            log    = FasterFactory.CreateLogDevice("hlog", deleteOnClose: true);
            objlog = FasterFactory.CreateObjectLogDevice("hlog", deleteOnClose: true);

            fht = FasterFactory.Create
                  <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions>
                      (indexSizeBuckets: 128, logDevice: log, objectLogDevice: objlog, functions: new MyFunctions(),
                      LogMutableFraction: 0.1, LogPageSizeBits: 9, LogTotalSizeBytes: 512 * 16
                      );
            fht.StartSession();
        }
Esempio n. 6
0
        public void Setup()
        {
            log    = FasterFactory.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog", deleteOnClose: true);
            objlog = FasterFactory.CreateObjectLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog", deleteOnClose: true);

            fht = FasterFactory.Create
                  <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions>
                      (indexSizeBuckets: 128, functions: new MyFunctions(),
                      logSettings: new LogSettings {
                LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 29
            },
                      checkpointSettings: new CheckpointSettings {
                CheckPointType = CheckpointType.FoldOver
            }
                      );
            fht.StartSession();
        }
Esempio n. 7
0
        public void Setup()
        {
            if (test_path == null)
            {
                test_path = Path.GetTempPath() + Path.GetRandomFileName();
                if (!Directory.Exists(test_path))
                {
                    Directory.CreateDirectory(test_path);
                }
            }

            var log = FasterFactory.CreateLogDevice(test_path + "\\hlog");

            fht =
                FasterFactory.Create
                <AdId, NumClicks, Input, Output, Empty, Functions>
                    (keySpace, log, checkpointDir: test_path, functions: new Functions());
        }
Esempio n. 8
0
        public void LargeObjectTest1()
        {
            log    = FasterFactory.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog", deleteOnClose: true);
            objlog = FasterFactory.CreateObjectLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog", deleteOnClose: true);

            Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints");

            fht1 = FasterFactory.Create
                   <MyKey, MyLargeValue, MyInput, MyLargeOutput, MyContext, MyLargeFunctions>
                       (indexSizeBuckets: 128, functions: new MyLargeFunctions(),
                       logSettings: new LogSettings {
                LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 29
            },
                       checkpointSettings: new CheckpointSettings {
                CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints", CheckPointType = CheckpointType.Snapshot
            }
                       );

            fht2 = FasterFactory.Create
                   <MyKey, MyLargeValue, MyInput, MyLargeOutput, MyContext, MyLargeFunctions>
                       (indexSizeBuckets: 128, functions: new MyLargeFunctions(),
                       logSettings: new LogSettings {
                LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 29
            },
                       checkpointSettings: new CheckpointSettings {
                CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints", CheckPointType = CheckpointType.Snapshot
            }
                       );


            int maxSize = 1000;
            int numOps  = 5000;

            //var value = new MyLargeValue(size);

            fht1.StartSession();
            Random r = new Random(33);

            for (int key = 0; key < numOps; key++)
            {
                var value = new MyLargeValue(1 + r.Next(maxSize));
                fht1.Upsert(new MyKey {
                    key = key
                }, value, null, 0);
            }
            fht1.TakeFullCheckpoint(out Guid token);
            fht1.CompleteCheckpoint(true);
            fht1.StopSession();
            fht1.Dispose();

            MyLargeOutput output = new MyLargeOutput();

            fht2.Recover(token);
            fht2.StartSession();
            for (int key = 0; key < numOps; key++)
            {
                var status = fht2.Read(new MyKey {
                    key = key
                }, new MyInput(), ref output, null, 0);

                if (status == Status.PENDING)
                {
                    fht2.CompletePending(true);
                }
                else
                {
                    for (int i = 0; i < output.value.value.Length; i++)
                    {
                        Assert.IsTrue(output.value.value[i] == (byte)(output.value.value.Length + i));
                    }
                }
            }
            fht2.StopSession();
            fht2.Dispose();

            log.Close();
            objlog.Close();
            new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints").Delete(true);
        }
Esempio n. 9
0
 public void TearDown()
 {
     fht.StopSession();
     fht = null;
 }