Click here to Skip to main content
15,879,096 members
Articles / Database Development / NoSQL

RaptorDB - the Key Value Store

Rate me:
Please Sign up or sign in to vote.
4.89/5 (118 votes)
22 Jan 2012CPOL22 min read 910.9K   9.9K   266  
Smallest, fastest embedded nosql persisted dictionary using b+tree or MurMur hash indexing. (Now with Hybrid WAH bitmap indexes)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RaptorDB
{
    public interface IRaptorDB
    {
        List<object> Query(string viewname, string filter, int start, int count);
        //List<T> Query<T>(string viewname, string filter, int start, int count);
        bool Save(object data);
        object Fetch(Guid docid);
        //T Fetch<T>(Guid docid);
        void Configure(object configsettings);
        void SetDocumentIDProperty(Type type, string IDproperty);
        object GetView(string viewname);
        void RegisterPrimaryView(Type type, string viewname);
    }

    public interface IMapApi
    {
        void Log(string message);
        List<object[]> Query(string viewname, string filter, int start, int count);
        object Fetch(Guid docid);
    }

    public class someview
    {

    }
    // main object
    public class dataobject
    {
        public Guid weirdid { get; set; }
    }

    // list for databject
    public class dataview
    {
        public Guid docid { get; set; }
        // other columns from map function
    }

    public class test
    {
        IRaptorDB _db;

        public void something()
        {
            Guid g = Guid.NewGuid();

            // guid property to use for docid, default if not defined = docid | id | guid --> error if not found or not guid
            _db.SetDocumentIDProperty(typeof(dataobject), "weirdid"); 
            
            dataobject d = new dataobject();
            // set properties

            // save document
            _db.Save(d);

            // get the data
            dataobject dd = (dataobject)_db.Fetch(g);
            //dd = _db.Fetch<dataobject>(g);

            List<object> list = _db.Query("customers", "code > 1000 and city='here'", 0, -1); // all data
            //List<dataview> dlist = _db.Query<dataview>("datalist", "date between ('2000/01/01' , '2001/01/31') ", 100, 10);

        }

        List<object[]> emitted = new List<object[]>(); 
        public void emit(Guid docid, int i, string name, bool disable)
        {
            object[] data = new object[4];
            data[0] = docid;
            data[1] = i;
            data[2] = name;
            data[3] = disable;

            emitted.Add(data);
        } 

        public void map(dataobject input, IMapApi api)
        {
            api.Log("starting");

            emit(input.weirdid, 10, "me", true);

            object somedoc = api.Fetch(Guid.NewGuid());
            dataobject dobj = (dataobject )api.Fetch(Guid.NewGuid());

            List<object[]> inventory = api.Query("inventoryview", "productcode = '1234' and qty>100", 0, -1);
            emit(input.weirdid, 11, "you", true);
            emit(input.weirdid, 12, "dupree", false);
        }
    }
}

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)


Written By
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 Platinum's on Code-Project (13th Jan'12)
* Mehdi is the 3rd person to get 7 out of 7 Platinum's on Code-Project (26th Aug'16)

Comments and Discussions