Пример #1
0
        private static void CreateSimplesKeyValue(LMDBEnvironment env, int count)
        {
            Logger.LogInfo("CreateSimplesKeyValue");

            DateTime        dtStart = DateTime.Now;
            LMDBTransaction tx      = env.BeginTransaction(TransactionBeginFlags.NoSync);

            using (var db = tx.OpenDatabase(null,
                                            new DatabaseConfiguration {
                Flags = DatabaseOpenFlags.Create
            }))
            {
                Logger.LogInfo("count:" + count);
                for (int i = 0; i < count; i++)
                {
                    string key   = String.Format("key_{0}", i);
                    string value = String.Format("value_{0}", i);

                    tx.Put(db, key, value);
                }
                tx.Commit();
            }

            DateTime dtStop = DateTime.Now;
            TimeSpan ts     = dtStop - dtStart;
            string   str    = String.Format("Time elapsed for set:{0} ms", ts.TotalMilliseconds);

            Logger.LogInfo(str);
        }
Пример #2
0
        private static void GetSimplesKeyValue(LMDBEnvironment env, int count)
        {
            Logger.LogInfo("GetSimplesKeyValue");

            DateTime        dtStart = DateTime.Now;
            LMDBTransaction tx      = env.BeginTransaction(TransactionBeginFlags.ReadOnly);

            using (LMDBDatabase db = tx.OpenDatabase(null))
            {
                Logger.LogInfo("count:" + count);
                for (int i = 0; i < count; i++)
                {
                    string key = String.Format("key_{0}", i);
                    //string value = String.Format("value_{0}", i);

                    var value = tx.Get(db, key);
                    if (i % 10000 == 0)
                    {
                        string strD = String.Format("key:{0} => value:{1}", key, value);
                        Logger.LogInfo(strD);
                    }
                }
            }

            DateTime dtStop = DateTime.Now;
            TimeSpan ts     = dtStop - dtStart;
            string   str    = String.Format("Time elapsed for get:{0} ms", ts.TotalMilliseconds);

            Logger.LogInfo(str);
        }
Пример #3
0
        private static void EnumData(LMDBEnvironment env)
        {
            Logger.LogInfo("EnumData");

            DateTime        dtStart = DateTime.Now;
            LMDBTransaction tx      = env.BeginTransaction(TransactionBeginFlags.NoSync);

            using (LMDBDatabase db = tx.OpenDatabase(null,
                                                     new DatabaseConfiguration {
                Flags = DatabaseOpenFlags.Create
            }))
            {
                var cur = tx.CreateCursor(db);
                //cur.MoveToFirst();
                int count1 = 0;
                while (cur.MoveNext())
                {
                    var fKey   = Encoding.UTF8.GetString(cur.Current.Key);
                    var fValue = Encoding.UTF8.GetString(cur.Current.Value);
                    if (count1 % 10000 == 0)
                    {
                        string str3 = String.Format("count:{2} - key:{0} => value:{1}", fKey, fValue, count1);
                        Logger.LogInfo(str3);
                    }

                    ++count1;
                }
                tx.Commit();
            }

            DateTime dtStop = DateTime.Now;
            TimeSpan ts     = dtStop - dtStart;
            string   str    = String.Format("Time elapsed for enum:{0} ms", ts.TotalMilliseconds);

            Logger.LogInfo(str);
        }