Пример #1
0
        static void Main(string[] args)
        {
            var log    = FasterFactory.CreateLogDevice(Path.GetTempPath() + "hybridlog");
            var objlog = FasterFactory.CreateObjectLogDevice(Path.GetTempPath() + "hybridlog");

            var h = FasterFactory.Create
                    <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions>
                        (128, new MyFunctions(),
                        new LogSettings {
                LogDevice = log, ObjectLogDevice = objlog, MemorySizeBits = 29
            }
                        );

            h.StartSession();

            for (int i = 0; i < 20000; i++)
            {
                h.Upsert(new MyKey {
                    key = i
                }, new MyValue {
                    value = i
                }, default(MyContext), 0);
                if (i % 32 == 0)
                {
                    h.Refresh();
                }
            }
            MyOutput g1 = new MyOutput();

            h.Read(new MyKey {
                key = 23
            }, new MyInput(), ref g1, new MyContext(), 0);

            h.CompletePending(true);

            MyOutput g2 = new MyOutput();

            h.Read(new MyKey {
                key = 46
            }, new MyInput(), ref g2, new MyContext(), 0);
            h.CompletePending(true);

            Console.WriteLine("Success!");
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var log = FASTERFactory.CreateLogDevice(Path.GetTempPath() + "hybridlog.log");
            var h   = FASTERFactory.Create
                      <MyKey, MyValue, MyInput, MyOutput, MyContext, MyFunctions>
                          (128, log, new MyFunctions(),
                          LogPageSizeBits: 10,
                          LogTotalSizeBytes: 1L << 14
                          );

            h.StartSession();

            for (int i = 0; i < 20000; i++)
            {
                h.Upsert(new MyKey {
                    key = i
                }, new MyValue {
                    value = i
                }, default(MyContext), 0);
                if (i % 32 == 0)
                {
                    h.Refresh();
                }
            }
            MyOutput g1 = new MyOutput();

            h.Read(new MyKey {
                key = 23
            }, new MyInput(), ref g1, new MyContext(), 0);

            h.CompletePending(true);

            MyOutput g2 = new MyOutput();

            h.Read(new MyKey {
                key = 46
            }, new MyInput(), ref g2, new MyContext(), 0);
            h.CompletePending(true);

            Console.WriteLine("Success!");
            Console.ReadLine();
        }