|
|
Comments and Discussions
|
|
 |

|
Excellent article. One thing that was lacking was byte-valued keys. Here ya' go: ByteKey gist[^]
He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Chinese Proverb]
Jonathan C Dickinson (C# Software Engineer)
|
|
|
|

|
Nice!
The only comment I have is that there is a 255 byte limit to key sizes in the index files.
Thanks Jonathan!
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi Mehdi,
I am evaluating RaptorDB and I have to say it works very well!
However, when I use it on a server with a slow disk there is a big degradation in performance, especially in throughput (20K reads/sec with a 20M data set).
Is there a way to load the entire DB into memory?
Thanks,
Alex.
|
|
|
|

|
Generally only the indexes are in memory as a memory/performance compromise.
The OS filesystem cache should help if you have enough memory (I guess if the disk is slow then that's it).
Currently I don't have plans for an all memory mode.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Should these handlers(double_handler,byte_handler,float_handler...) in DataTypes.cs be singleton instance?
|
|
|
|

|
Singleton are not needed but it could be a static class instead, I would have to test the performance difference.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
There are some helper methods in "SafeDictionary.cs",for example,ToInt32.
In .Net,"System.BitConverter" can do the same thing.
Why do you implement them by yourself?
|
|
|
|

|
The helper code are the same as BitConverter without some checking code which makes it faster.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
There is a way to list all the value ?
|
|
|
|

|
Kind of, you can use Enumerate(key) which will enumerate from the key provided.
I will add a Enumerate() method to do the same from the start of the dictionary.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
I found "RaptorDB-The Key Value Store V2" and "
RaptorDB - the Document Store",
what is the diffrence between two project?
Thank you.
|
|
|
|

|
One is a key value store like a dictionary of things, the other is a document store much like a "normal" database engine, the articles on both should be explanatory.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
I'm interested in trying this DB out; it looks like it's well implemented, and well supported. However, I'm ideally trying to find a solution that will work across a variety of .NET platforms, specifically Windows, Windows RT, and Windows Phone. Does RaptorDB support usage on Windows RT and/or Windows Phone? I'm not seeing any documentation that says it does, but figured it couldn't hurt to ask. If not, do you plan to add this support? Regardless, nice job!
Jamie Nordmeyer Portland, Oregon, USA
|
|
|
|

|
Thanks Jamie!
I haven't really tested on WinRT/Phone yet, but probably it should be fine and work.
I don't have the devices to test on so it would not be on my todo list in the near future.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi Mehdi,
Really great piece of code! I have a situation where I'm currently using a Dictionary with 10 milion items in it. The problem with this is the population of the Dictionary (can take a while).
RaptorDB could be a great to solve this start up time. However, everytime I open the DB, it's going to rebuild all indexes (even if I'm only using it for reading). With this 10 milion items, it takes about an minute.
2012-12-22 04:47:18|DEBUG|10|RaptorDB.KeyStore`1|| Current Count = 9,999,872
2012-12-22 04:47:18|DEBUG|10|RaptorDB.KeyStore`1|| Checking Index state...
2012-12-22 04:47:18|DEBUG|10|RaptorDB.KeyStore`1|| Rebuilding index...
2012-12-22 04:47:18|DEBUG|10|RaptorDB.KeyStore`1|| last index count = 0
2012-12-22 04:47:18|DEBUG|10|RaptorDB.KeyStore`1|| data items count = 9999872
2012-12-22 04:47:18|DEBUG|10|RaptorDB.KeyStore`1|| 100,000 items re-indexed
2012-12-22 04:47:18|DEBUG|10|RaptorDB.KeyStore`1|| 100,000 items re-indexed
Is there anything that I can do to prevent this?
Thanks,
Danny
|
|
|
|

|
Thanks Danny!
Make sure the engine shutdowns cleanly, and the rebuilding should not kick in to correct things.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Ah, I missed the Shutdown method. That works, thanks!
|
|
|
|

|
How we can make foreach enumeration on all keys?
foreach(var key in storage){
var itemContent = raptor.Get(key)....
//do something with value
//delete key
}
or
foreach(var item in storage){
var itemContent = item.Value;
//do something with value
//delete key
}
I want to store logs in raptorDB and later with Quartz to check if there is any keys and if any, copy to original DB.
Still amater
|
|
|
|

|
Can you please also tell us how to construct our schema? Currently im testing as static variable
public static RaptorDB.RaptorDB<int> raptor = RaptorDB.RaptorDB<int>.Open(raptorPath, 200, false);
and in every function i use this static variable
public bool Something(){
string some = string.empty;
raptor.get(1,out some);
}
But i noticed that i cant remove key and also everytime i check for keys count, it getting duplicated like 2,4,8,16...
I have two functions, one with just Set() and another one with Get() and RemoveKey()
Still amater
|
|
|
|

|
here are some screenshots
EnumerateStorageFile= http://prntscr.com/m4l39.
totalCount = http://prntscr.com/m4l8g
removeKey - dont work
Count - looks like give me *2 of total
Still amater
|
|
|
|

|
You should use the Enumerate() method instead of EnumerateStorageFile().
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Count() currently returns the storage file contents and RaptorDB does not delete data when you call RemoveKey(), so a "deleted" record is added to the storage file hence you get the sequence you referred to.
I'm changing the Count() method to use the index file instead so you will get a more accurate result.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
To enumerate you can use the Enumerate(T fromkey) method and supply a starting point.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi,
Thank you for this amazing library, I'm currently porting it to Windows CE (certainly will let you know how it helps us)
While reading the code of Helper.CompareMemCmp in SafeDictionary I've noticed that the return value of this function may not be the result of a general comparison function. As an example the following compare will return true, which is obviously not right. Can you confirm whether it is a bug or a particular optimization in your code based on usage pattern ?
byte[] left = new byte[] {1, 2, 3, 4, 5};
byte[] right = new byte[] {1, 2, 3};
int res = Helper.CompareMemCmp(left, right);
res will be 0 while I expected it to be +1 !
Regards,
|
|
|
|

|
Interesting... the function used is p-invoking the windows api.
I will run some tests on it and try to get a valid response from it.
Thanks!
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Excellent project. But I have one question. What is the easiest way to get maximum key from RaptorDB?
|
|
|
|

|
Interesting question...
There is no method to do this efficiently at the moment I will try to put it in.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Btw. Is raptorDB manage database file space effectively? I ask because I want use raptorDB to implement simple embedded persistent queue. Do you have in plan implement shrink-like or compact-like methods to prevent grow up database file infinitely - is this methods will be necessary?
|
|
|
|

|
I will probably add a "compacting" feature in the future.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
I want to use RaptorDB with MONO on Linux. It works prefect with only minimal changes.
The only thing is to replace the hard-coded path-seperator "\\" with the .NET path field
"Path.DirectorySeparatorChar" in the following files.
BitmapIndex.cs
MGIndex.cs
KeyStore.cs
mylogger.cs
So in a few minutes the RaptorDB is cross-platform ready with MONO. Maybe you can change this in the next version of RaptorDB.
br,
Alex
|
|
|
|

|
Yes, that is about it although in the Doc version I had to change codedom code to Reflection.Emit also (I was really chuffed when it worked on my Asus TF700).
I will update the KV version soon as there a couple of enhancements and fixes for it.
Thanks Alex!
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
I have a scenario where I just need to test for the existence of a key in the index. Here is an addition to the KeyStore.cs file to just return if a key exists.
public bool Exists( T key ) {
lock ( _lock ) {
int off;
return _index.Get( key, out off );
}
}
Thoughts?
|
|
|
|

|
Absolutely spot on! I will add this in the next release. Its the man, not the machine - Chuck Yeager If at first you don't succeed... get a better publicist If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Can more processes (on the same host) open and read/write the same database?
Thanks.
|
|
|
|

|
No, the database files can only be opened by one process. You can however have a service like host which you can connect to via TCP and have multiple processes work with (this is implemented in the document version but not here).
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Why max cpu usage is 25% even on read and write as exe.
I tested on SSD, Raid5 and RamDisk, all benchmarks have similar time.
10 millions : ~25 sec set, ~45 sec get
Isn't it supposed to use max cpu and why there is no difference on ssd, raid5 and ramdisk?
Cpu is I5 2500, Quad core 3.3 Ghz
Raptor 2.5 version
Still amater
|
|
|
|

|
RaptorDB has been designed to be sensitive to your CPU and mostly your RAM speed not the storage speed.
You will get better performance mostly if you upgrade your memory say from DDR2 to DDR3 etc.
The storage speed only comes into play when the engine is storing to disk and this is mainly done in the background so you wouldn't notice (it will become markedly apparent when you shutdown).
This would also be dependent on the amount of data you are storing (in the main storage file) so in the test program we are storing small ~30 bytes per record so the OS and harddisk caches also smooth this out.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
I made simple test vs MongoDB, the performance difference is very huge. On 1 million Guid test, time is like 10x faster on write and 12x faster on read.
I made the test not with normal collection, but with capped collection as in memory fastest MongoDB collection. From my experience,
What are your future plans about Raptor KV DB?
Still amater
|
|
|
|

|
Which was faster?
The KV's big brother is "RaptorDB the Document Store" version, so most of my efforts are going there.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
RaptorDb was faster.
I`m interested for RaptorDB as output caching provider. The only big problem i see here is that RaptorDB dont have LRU algorithm. With LRU algorithm we go step forward of thinking about consistent hashing client and distributed output caching provider.
My question about scalability was more like this one.
Still amater
|
|
|
|

|
Wow! I never tested MongoDb like this!
LRU is on my todo list mostly for memory usage limiting, currently I have no design (minimalist way to do it) for this so I can't say when it will be implemented.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi, It's great fast database. We want to use your db on medium loaded service (5000 requests per minute)
We've configured to save index database every 30 seconds. After simulated incorrect shutdown
we noticed that indexes are being rebuilded from the begining and it tooks a lot of time.
1. May be there is opportunity to rebuild for only new data?
2. Sometimes system hangs on rebuilding indexes on start for long time without any text in log. With last record
2012-10-03 03:22:26|DEBUG|32|RaptorDB.KeyStore`1|| Checking Index state...
2012-10-03 03:22:26|DEBUG|32|RaptorDB.KeyStore`1|| Rebuilding index...
2012-10-03 03:22:26|DEBUG|32|RaptorDB.KeyStore`1|| last index count = 0
2012-10-03 03:22:26|DEBUG|32|RaptorDB.KeyStore`1|| data items count = 2510698
2012-10-03 03:22:26|DEBUG|32|RaptorDB.KeyStore`1|| 100,000 items re-indexed
Can we do something with that problems?
|
|
|
|

|
Currently there is no way of doing this as you can't tell where to start from and the index does not keep a previous state and the pages could be corrupted in any order.
Hopefully non-clean shutdowns should not happen that often.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Am I doing something wrong? It crashes on EnumerateStorageFile
RaptorDB<int> db1 = RaptorDB<int>.Open("c:\\raptordbtest\\t1", false);
RaptorDB<int> db2 = RaptorDB<int>.Open("c:\\raptordbtest\\t2", true);
db1.Set(1, "s1");
db1.Set(2, "s2");
db1.Set(3, "s3");
db2.Set(2, "log2lab2: str1");
db2.Set(2, "log2lab2: str2");
db2.Set(3, "log3lab3: str1");
db2.Set(3, "log3lab3: str2");
db2.Set(1, "log1lab1: str1");
db2.Set(1, "log1lab1: str2");
foreach (var pair in db2.EnumerateStorageFile())
{
listBox1.Items.Add(pair.Key.ToString());
}
db1.Shutdown();
db2.Shutdown();
|
|
|
|

|
What is the error message?
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
RaptorDB 2.5
file: SafeDictionary.cs
Line: 160
fixed (byte* numRef = &(value[startIndex]))
Message: Index was outside the bounds of the array.
By the way...
If I call method Shutdown() and then reopen database, everything works fine
|
|
|
|

|
Hi, sorry for my bad english.
First, thank you for this work.
The function FetchRecordString and RemoveKey are not thread safe. If I add a lock, the problem is resolve.
An another scenario seem to be problematic:
I add 100 item, iterate with a for, call FetchRecordString, remove the key. After the iteration, I save the index and I ask for the Count() method and I receive a count of 200 ! How it's possible ? I remove all so the count suppose to be 0.
|
|
|
|

|
Thanks!
I will add the locks that are missing.
Count() is using the storage file (100 recs + 100 delete recs), it should be using the index file for counting items.
I will change this in the next release.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|
|

|
Thanks Zab!
1) - find the page in the page list to insert to by comparing the key and the pages first key
- add the key and value to the dictionary of the found page
2) - find the page in the page list for the search key
- get the value from the dictionary in the page found
3) The only limitation at the moment is the amount of memory you have (I had 12gb at the time of testing), it may be possible to go higher on limited ram with a more intelligent caching scheme that flushes out least recently used pages in ram, but it is probably cheaper to get more ram instead.
4)
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
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)
| Type | Article |
| Licence | CPOL |
| First Posted | 18 Jan 2012 |
| Views | 134,043 |
| Downloads | 3,768 |
| Bookmarked | 125 times |
|
|