Click here to Skip to main content
Click here to Skip to main content
Articles » Database » NoSQL » General » Downloads
 
Add your own
alternative version

RaptorDB - The Key Value Store V2

, 10 Oct 2013 CPOL
Even faster Key/Value store nosql embedded database engine utilizing the new MGIndex data structure with MurMur2 Hashing and WAH Bitmap indexes for duplicates. (with MonoDroid support)
RaptorDB_v2.0.zip
RaptorDB
DataTypes
Indexes
Properties
Storage
testing
UnitTests
UnitTests release.nunit
UnitTests.nunit
Properties
UnitTests.nunit
RaptorDB_v2.1.zip
UnitTests release.nunit
UnitTests.nunit
UnitTests.nunit
RaptorDB_v2.2.zip
UnitTests release.nunit
UnitTests.nunit
UnitTests.nunit
RaptorDB_v2.3.zip
UnitTests release.nunit
UnitTests.nunit
UnitTests.nunit
RaptorDB_v2.4.zip
UnitTests release.nunit
UnitTests.nunit
UnitTests.nunit
RaptorDB_v2.5.zip
UnitTests release.nunit
UnitTests.nunit
UnitTests.nunit
RaptorDB_v2.6.zip
UnitTests release.nunit
UnitTests.nunit
UnitTests.nunit
RaptorDB_v2.7.0.zip
UnitTests.nunit
UnitTests.nunit
RaptorDB_v2.7.5.zip
UnitTests.nunit
UnitTests.nunit
using System;
using System.Diagnostics;
using System.Collections;
using System.IO;
using System.Text;
using System.Threading;
using RaptorDB;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace testing
{
    public class bplusTest
    {
        public static void StringKeyTest()
        {
            var db = RaptorDB<string>.Open("c:\\raptordbtest\\strings", 255, true);
            for (int i = 0; i < 100000; i++)
            {
                db.Set("asdfasd" + i, "" + i);
            }
            db.Shutdown();
        }

        private static void test()
        {
            int count = 10 * 1000000;
            string dbpath = "c:\\RaptorDbTest\\test1";
            var rap = RaptorDB<Guid>.Open(dbpath, true);

            Console.WriteLine("---------------");
            Console.WriteLine("Writing " + count.ToString("#,#"));
            List<Guid> guid = new List<Guid>();
            for (int i = 0; i < count; i++)
                guid.Add(Guid.NewGuid());

            DateTime dt = DateTime.Now;
            for (int i = 0; i < count; i++)
            {
                rap.Set(guid[i], "" + guid[i]);
                if (i % 100000 == 0)
                    Console.Write(".");
            }
            Console.WriteLine("set done");
            double st = DateTime.Now.Subtract(dt).TotalSeconds;

            //rap.Shutdown();
            //rap = RaptorDB<Guid>.Open(dbpath, true);
            dt = DateTime.Now;
            int failed = 0;
            for (int i = 0; i < count; i++)
            {
                if (i % 100000 == 0)
                    Console.Write(".");
                string str = "";
                if (rap.Get(guid[i], out str) == false)
                    failed++;
                else
                {
                    if (str != "" + guid[i])
                        failed++;
                }
            }
            Console.WriteLine("get done");
            if (failed > 0)
                Console.WriteLine("failed count = " + failed);
            Console.WriteLine(rap.GetStatistics());
            Console.WriteLine("set time = " + st);
            Console.WriteLine("get time = " + DateTime.Now.Subtract(dt).TotalSeconds);
            rap.Shutdown();
        }

        private static void testnoget()
        {
            int count = 100 * 1000000;
            string dbpath = "c:\\RaptorDbTest\\test1";
            var rap = RaptorDB<Guid>.Open(dbpath, true);

            Console.WriteLine("---------------");
            Console.WriteLine("Writing " + count.ToString("#,#"));
            //List<Guid> guid = new List<Guid>();
            //for (int i = 0; i < count; i++)
            //    guid.Add(Guid.NewGuid());

            DateTime dt = DateTime.Now;
            for (int i = 0; i < count; i++)
            {
                Guid g = Guid.NewGuid();
                rap.Set(g, "" + g);
                if (i % 100000 == 0)
                    Console.Write(".");
            }
            Console.WriteLine("set done");
            double st = DateTime.Now.Subtract(dt).TotalSeconds;

            //rap.Shutdown();
            //rap = RaptorDB<Guid>.Open(dbpath, true);
            //dt = DateTime.Now;
            //int failed = 0;
            //for (int i = 0; i < count; i++)
            //{
            //    if (i % 100000 == 0)
            //        Console.Write(".");
            //    string str = "";
            //    if (rap.Get(guid[i], out str) == false)
            //        failed++;
            //    else
            //    {
            //        if (str != "" + guid[i])
            //            failed++;
            //    }
            //}
            //Console.WriteLine("get done");
            //if (failed > 0)
            //    Console.WriteLine("failed count = " + failed);
            Console.WriteLine(rap.GetStatistics());
            Console.WriteLine("set time = " + st);
            //Console.WriteLine("get time = " + DateTime.Now.Subtract(dt).TotalSeconds);
            rap.Shutdown();
            Console.ReadKey();
        }

        public static void RunPageCount(ushort count)
        {
            Console.WriteLine("page item count = " + count);
            RaptorDB.Global.PageItemCount = count;
            Directory.Delete("c:\\RaptorDbTest\\", true);
            test();
        }

        public static void Main()
        {
            test();
            //testnoget();
            //RunPageCount(30000);
            //RunPageCount(20000);
            //RunPageCount(10000);
            //RunPageCount(5000);
            //RunPageCount(1000);

            Console.ReadKey();
            return;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mehdi Gholam
Architect
United Kingdom United Kingdom
Mehdi first started programming when he was 8 on BBC+128k machine in 6512 processor language, after various hardware and software changes he eventually came across .net and c# which he has been using since v1.0.
He is formally educated as a system analyst Industrial engineer, but his programming passion continues.
 
* Mehdi is the 5th person to get 6 out of 7 Platinums on CodeProject (13th Jan'12)

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411022.1 | Last Updated 11 Oct 2013
Article Copyright 2012 by Mehdi Gholam
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid