|
|
Comments and Discussions
|
|
 |
|
|

|
query for bool was not working in server mode using a LINQ query (string query worked), found bug on line 148 of LINQString.cs:
changed:
sb.Append(((bool)c.Value) ? 1 : 0);
to
sb.Append(((bool)c.Value) ? "True" : "False");
|
|
|
|

|
Thanks nice catch!
I will be releasing a major update soon and will put this in also.
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 Cooper!
If you are not using full text hoot indexes for strings then you must search for strings exactly (or CaseInsensitive if used).
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,
I've been wanting to ask you this for a while now...
How would you implement a Parent/Child structure in Raptor DB. For example, let's say we have a document type 'pcDocument' that can have "children" or "parents" of the same type. I tried creating a List of pcDocument in the object definition, but that doesn't work...so after a little trial and error I figured out a way to get I what I want, it's not a very efficient way of doing it (due to multiple queries required to extract structure) but it's does work.
So we set up our document class with an ID, and whatever fields we want to store (name,description, whatever) and a List of childDocuments, childDocument stores the ID of the "child document":
#region [ class definitions ]
public class pcDocument
{
public pcDocument()
{
ID = Guid.NewGuid();
}
public Guid ID { get; set; }
public string documentName { get; set; }
public List<childDocument> Children { get; set; }
}
public class childDocument
{
public Guid pcDocumentID { get; set; }
}
#endregion
Then I can use something like this to get a List of children:
public static Result<pcDocumentView.RowSchema> getChildDocuments(Guid parentDocumentID)
{
Result<pcDocumentView.RowSchema> retval = new Result<pcDocumentView.RowSchema>();
System.Text.StringBuilder linqQuery = new System.Text.StringBuilder();
var q = rap.Query<childDocumentView.RowSchema>(c => c.docid == parentDocumentID);
foreach (childDocumentView.RowSchema child in q.Rows)
{
linqQuery.AppendLine("docid = \"" + child.pcDocumentID.ToString() + "\"");
linqQuery.AppendLine("OR");
}
if (linqQuery.ToString().Length>0)
{
string slinqQuery = linqQuery.ToString().Substring(0, linqQuery.ToString().Length - 6);
retval = Program._rap.Query<pcDocumentView.RowSchema>(slinqQuery);
}
return retval;
}
I can use something similar to get a list of Parents for a given childDocumentID.
It's a bit stupid and real ugly...but it's the best I could come up with. Do you have any suggestions for a better method?
Thanks
*edit: corrections
modified 15 Mar '13 - 15:30.
|
|
|
|

|
I you need to query the children then just create a view for it (parentguid, childguid,...)
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 not sure I understand...how does this differ from what I'm doing?
|
|
|
|

|
Create another specific view for this case.
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 was trying to get NotEqual (!=) working in a Raptor query, and when it didn't work I looked into the code and found that in LINQQuery.cs VisitBinary method ExpressionType.NotEqual is tested for but not handled in the else if, and in LINQString.cs VisitBinary ExpressionType.NotEqual is commented out. Is NotEqual not implemented?
Thanks
|
|
|
|

|
Thanks!
I probably missed that in the linq (although the execution part works).
I will fix 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.
|
|
|
|
|

|
Fixed now in v1.9.2
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.
|
|
|
|

|
When querying for string values, it appears that the query engine is case sensitive. So, if a record exists with the fileName 12345678 and fileExtension .txt and I perform the following test:
string fname="12345678";
string fext = ".TXT";
var q = rap.Query<ssDocumentView.RowSchema>(f=> f.fileName==fname && f.fileExtension==fext);
MessageBox.Show(q.Count.ToString());
It returns 0 rows, if I change fext to ".txt" it returns 1 row (the correct value).
Is this by design? If so, is there any way to do a case-insensitive query?
|
|
|
|

|
Normal string "columns" are case sensitive at the moment (full text search isn't).
I will make this more "SQL" like and be case insensitive in the next release.
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.
|
|
|
|

|
Mehdi Gholam wrote: I will make this more "SQL" like and be case insensitive in the next release.
That would be great!
Thanks
|
|
|
|

|
Fixed now in v1.9.2
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.
|
|
|
|

|
When i query on the document type i get this exception
System.InvalidCastException : Unable to cast object of type 'RowSchema' to type 'SampleViews.SalesInvoice'
var qq = rap.Query(typeof(SalesInvoice));
foreach (SalesInvoice item in qq.Rows)
According to the article i can query on view type or document type. I can query on the view but not on the document type. I also tried the new query syntax for the document type as well, but got System.InvalidOperationException : Stack empty.
rap.Query<SalesInvoice>(x => true);
There are no concrete examples of querying the document type to prove this is possible.
|
|
|
|

|
I'm not the article author but I can try to help you out. You can Query by document type, but the .Rows list will be a list of RowSchema. In my experience with Raptor you query a document's view.RowSchema and, if necessary (for example, you want to update data in the document) you can Fetch the actual document by calling rap.Fetch with the RowSchema.docid property. Fetching a document is relatively expensive, so you should only do it when you really need to.
|
|
|
|

|
I know object updates are appended to the database (not overwritten) but what about files?
If if save a file using rap.SaveBytes(g,b[]) is the previous version of this file retained? If so, do you plan to offer a method to retrieve these previous versions?
|
|
|
|

|
Yes, SaveBytes() follows the same methodology as documents and updates are appended (your storage will grow).
I will add a get previous method for the older version which is lacking at the moment, soon.
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.
|
|
|
|

|
That's great! I'm actually glad that RaptorDB is append only because then I don't have to track revisions separately
|
|
|
|

|
Great for diverting blame from your department
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.
|
|
|
|

|
exactly
|
|
|
|

|
Hey,
So I was noticing that the size of my storage file was increasing a lot more than I would have expected it to. When you do the following:
Sample temp = DB.Fetch(DocID);
temp.Values.Add("new value");
DB.Save(temp, temp.ID);
Is the old instance of temp with the ID DocID in the storage file overwritten, or is the old instance kept and the updated object just appended to the storage file? I read on codeplex your justification of the delete behavior and in it you mentioned that the storage files were implemented to be append only which might be why I'm having issues.
What I'm seeing is that I have an object that contains a list which I append to every few minutes and I then write back this object to the DB. After about 250 iterations of adding to this list I'm serializing this object to a JSON string and writing this to a text file, which ends up being about 10MB in size. This size is reasonable for this object which stores a large amount of data but what I notice is that the size of the data.mgdat file has increased to about 1.5GB. Does this sound like the correct behavior?
|
|
|
|

|
The storage file are append only, so deletes and changes are appended and the original data is kept.
So if you have a doc with ID=1 and save it 100 times you will have 100 copies in the storage file with ID=1 but if you Fetch that ID you will get the last one (I will add a method to get the list of the previous changes for that ID which is lacking at the moment).
For an object of ~10mb and you are saving it 250 times then the size of the mgdat file seems reasonable.
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.
|
|
|
|
|

|
Are Save/Fetch Bytes supported in Server Mode? When I savebytes the return value is true, but attempting to fetchbytes returns null. Are there any other feature differences between embedded and server modes that I should be aware of?
Thanks
|
|
|
|

|
They should be the same, I will look into it.
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.
|
|
|
|

|
Oops!
Add the following in RaptorDBClient.cs line 104 :
...
case "savebytes":
ret.OK = _raptor.SaveBytes(p.Docid, (byte[])p.Data); break;
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.
|
|
|
|

|
That did it!
One note, that code needs to be to RaptorDBServer.cs line 104.
Thanks!
|
|
|
|

|
Sorry, yes my mistake.
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.
|
|
|
|

|
Hey,
I'm seeing an issue if I start up RaptorDB in server mode, then write to the database from the same process that started the DB in server mode. I'm able to write to the DB running in server mode from a separate process/exe with no problems.
Some sample code below.
Console.WriteLine("Starting DB in server mode");
RaptorDBServer server = new RaptorDBServer(90, "_data");
Console.WriteLine("Connecting to DB in server mode");
IRaptorDB DB = new RaptorDBClient("localhost", 90, "admin", "admin");
Sample obj = new Sample(){
Name = "Object",
OtherValue = "Other value for object 1"
};
DB.Save(obj.ID, obj);
DB.Shutdown();
server.Shutdown();
The exception is in the DB log which I've included below.
2012-12-17 11:39:09|DEBUG|1|RaptorDB.RaptorDB|| RaptorDB starting...
2012-12-17 11:39:09|DEBUG|1|RaptorDB.RaptorDB|| RaptorDB data folder = C:\testRaptorDB\bin\Debug\_data\
2012-12-17 11:39:09|DEBUG|1|RaptorDB.KeyStore`1|| Current Count = 0
2012-12-17 11:39:09|DEBUG|1|RaptorDB.KeyStore`1|| Checking Index state...
2012-12-17 11:39:09|DEBUG|1|RaptorDB.KeyStore`1|| Starting save timer
2012-12-17 11:39:09|DEBUG|1|RaptorDB.KeyStore`1|| Current Count = 0
2012-12-17 11:39:09|DEBUG|1|RaptorDB.KeyStore`1|| Checking Index state...
2012-12-17 11:39:09|DEBUG|1|RaptorDB.KeyStore`1|| Starting save timer
2012-12-17 11:39:10|DEBUG|1|RaptorDB.Views.TaskQueue|| TaskQueue starting
2012-12-17 11:39:10|DEBUG|1|RaptorDB.Hoot|| Starting hOOt....
2012-12-17 11:39:10|DEBUG|1|RaptorDB.Hoot|| Storage Folder = C:\testRaptorDB\bin\Debug\_data\Data\Fulltext\
2012-12-17 11:39:10|DEBUG|1|RaptorDB.RaptorDBServer|| loading dll for views : C:\testRaptorDB\bin\Debug\Extensions\testLib.dll
2012-12-17 11:39:11|DEBUG|1|RaptorDB.Views.ViewHandler|| Rebuilding view from scratch...
2012-12-17 11:39:11|DEBUG|1|RaptorDB.Views.ViewHandler|| View = SampleView
2012-12-17 11:39:11|DEBUG|1|RaptorDB.Views.ViewHandler|| rebuild done (s) = 0
2012-12-17 11:39:16|ERROR|7|RaptorDB.RaptorDBServer|| System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Unable to cast object of type 'testLib.SampleView' to type 'RaptorDB.View`1[testLib.Sample]'.
at RaptorDB.Views.ViewHandler.Insert[T](Guid guid, T doc) in c:\RaptorDB\v1.9.0\RaptorDB\Views\ViewHandler.cs:line 132
at RaptorDB.Views.ViewManager.Insert[T](String viewname, Guid docid, T data) in c:\v1.9.0\RaptorDB\Views\ViewManager.cs:line 191
at RaptorDB.RaptorDB.SaveInPrimaryView[T](String viewname, Guid docid, T data) in c:\RaptorDB\v1.9.0\RaptorDB\RaptorDB.cs:line 508
at RaptorDB.RaptorDB.Save[T](Guid docid, T data) in c:\RaptorDB\v1.9.0\RaptorDB\RaptorDB.cs:line 128
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at RaptorDB.RaptorDBServer.processpayload(Object data) in c:\RaptorDB\v1.9.0\RaptorDB\RaptorDBServer.cs:line 102
2012-12-17 11:39:17|DEBUG|4|RaptorDB.Common.NetworkServer|| tcp connects/sec = 1
2012-12-17 11:39:17|DEBUG|1|RaptorDB.Hoot|| saving index...
2012-12-17 11:39:17|DEBUG|1|RaptorDB.Hoot|| save time (ms) = 3.9208
2012-12-17 11:39:17|DEBUG|1|RaptorDB.RaptorDB|| last full text record = -1
2012-12-17 11:39:17|DEBUG|1|RaptorDB.RaptorDB|| last record = -1
2012-12-17 11:39:17|DEBUG|1|RaptorDB.RaptorDB|| last backup record = -1
2012-12-17 11:39:17|DEBUG|1|RaptorDB.RaptorDB|| Shutting down
2012-12-17 11:39:17|DEBUG|1|RaptorDB.Views.ViewManager|| View Manager shutdown
2012-12-17 11:39:17|DEBUG|1|RaptorDB.Views.TaskQueue|| TaskQueue shutdown
2012-12-17 11:39:17|DEBUG|1|RaptorDB.Views.ViewManager|| shutting down view : SampleView
2012-12-17 11:39:17|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down Viewhandler
2012-12-17 11:39:17|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down view index : docid
2012-12-17 11:39:17|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-17 11:39:17|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-17 11:39:17|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-17 11:39:17|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-17 11:39:17|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down view index : Name
2012-12-17 11:39:17|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-17 11:39:17|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-17 11:39:17|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-17 11:39:17|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-17 11:39:17|DEBUG|1|RaptorDB.KeyStore`1|| Shutting down
2012-12-17 11:39:17|DEBUG|1|RaptorDB.KeyStore`1|| saving to disk
2012-12-17 11:39:17|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-17 11:39:17|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-17 11:39:17|DEBUG|1|RaptorDB.KeyStore`1|| index saved
2012-12-17 11:39:17|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-17 11:39:17|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-17 11:39:18|DEBUG|1|RaptorDB.KeyStore`1|| Shutting down log
|
|
|
|

|
Are you sure the types are the same?
Quote: 'testLib.SampleView' to type 'RaptorDB.View`1[testLib.Sample]
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.
|
|
|
|

|
Sorry, I meant to add the Sample object definition as well. I've included it below.
As far as I can tell they are the same and when I set a break point at line 132 in ViewHandler.cs I can see
- The parameter doc, which is passed to the method, is of type testLib.Sample
- _view is of type testLib.SampleView
This looks like it should work to me.
If I change to using the DB as an embedded DB it works fine, it's only when I have it in server mode.
public class Sample
{
public Guid ID;
public string Name;
public string OtherValue;
public Sample()
{
}
}
[RegisterView]
public class SampleView : View<Sample>
{
public class RowSchema : RDBSchema
{
public string Name;
}
public SampleView()
{
this.Name = "SampleView";
this.Description = "A primary view for sample objects";
this.isPrimaryList = true;
this.isActive = true;
this.BackgroundIndexing = false;
this.Schema = typeof(SampleView.RowSchema);
this.AddFireOnTypes(typeof(Sample));
this.Mapper = (api, docid, doc) =>
{
api.EmitObject(docid, doc);
};
}
}
|
|
|
|

|
One thing I have noticed is that the DLL files can be loaded from different locations and you will get errors like this, one workaround is to make sure you are referencing and loading the same dll files, or you could use the GAC and strong name your assemblies.
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.
|
|
|
|

|
Ok from what you said it gave me a better idea of what to look at to solve the issue and I've found a fix although it's not ideal. I've included the code changes below.
The directory structure of my compiled project is this
_data
Backup
Data
Logs
Restore
Temp
Views
Extensions
testLib.dll
users.config
testRaptorDB.exe
testLib.dll
RaptorDB.dll
RaptorDB.Common.dll
- I can connect and insert records to the "_data" db fine in embedded mode
- In server mode I get a System.InvalidCastException when I try to insert records.
You mentioned that you have seen this issue when DLL files are loaded from different locations. The only different location that is used in server mode compared to embedded mode is "testLib.dll" under "Extensions".
So I modified line 255 in RaptorDBServer.cs so that we don't load views from "Extensions" but instead from the DLL's in local path.
string path = _path;
foreach (var f in Directory.GetFiles(path, "*.dll"))
{
When I do this then I can insert in server mode without any exceptions and everything works as I would expect it to. So it looks like there's issues with loading views from DLL's in the "Extensions" directory in Server mode if you also want to insert into the DB from that same executable. This is because to insert you also need to include the same DLL from the "Extensions" directory in your local directory which cause a conflict of some sort on insertion.
This fix isn't ideal because the server now has to read all DLL's in our local directory but a solution for this may be to add a Extensions file that specifies which DLL's to read as opposed to the current method of loading all the DLL's from the Extensions directory.
modified 19 Dec '12 - 8:18.
|
|
|
|

|
Does this look like a reasonable solution, can you think of any knock on effects this might have?
It's been working fine for me so far. I'll let you know if I have any issues.
|
|
|
|

|
The only problem is that you have to make sure the dll's are the same when you update your code and make sure you copy them to both places.
A much cleaner approach is to put the dll's in GAC.
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.
|
|
|
|

|
The application I've been using RaptorDB for is a ClickOnce app so I can't install DLL's to the GAC. I did test with installing to the GAC and this stops the issue I'm seeing occuring but as I said this solution doesn't work for my particular situation.
If it's not a priority for you to develop functionality to support this, then would you be interested in adding this functionality if I implemented it? One way to implement server mode view registration could be:
- the server checks for an Extensions directory get the list of DLL's in this directory
- the server then checks for a Extensions.regview file
- this file would contain the paths to any other DLL's that the user wants to register views from
- register views from the two lists of DLL's
Does that sound ok to you?
Thanks again for the help, RaptorDB seems to be great and I'm slowly getting to grips with it's inner workings. I hope I'll be able to contribute back to the codebase soon as well.
|
|
|
|

|
I trying this against v1.9.0
I'm unable to retrieve all results for a certain type in Server mode but it does work in embedded mode fine.
My object and view definition are here:
public class Sample
{
public Guid ID;
public string Name;
public string OtherValue;
public Sample()
{
}
}
[RegisterView]
public class SampleView : View<Sample>
{
public class RowSchema : RDBSchema
{
public string Name;
}
public SampleView()
{
this.Name = "SampleView";
this.Description = "A primary view for sample objects";
this.isPrimaryList = true;
this.isActive = true;
this.BackgroundIndexing = false;
this.Schema = typeof(SampleView.RowSchema);
this.AddFireOnTypes(typeof(Sample));
this.Mapper = (api, docid, doc) =>
{
api.EmitObject(docid, doc);
};
}
}
I've tried a number of different query formats and they're all working against the DB running in Embedded mode but not when I access it in Server mode. I've included a test case and all the query formats I've tried below. The query formats I've tried are:
DB.Query("SampleView"); DB.Query(typeof(Sample)); DB.Query(typeof(SampleView)); DB.Query(typeof(SampleView.RowSchema));
DB.Query("SampleView", (SampleView.RowSchema v) => v.Name == "Object"); DB.Query(typeof(Sample), (SampleView.RowSchema v) => v.Name == "Object"); DB.Query(typeof(SampleView), (SampleView.RowSchema v) => v.Name == "Object"); DB.Query(typeof(SampleView.RowSchema), (SampleView.RowSchema v) => v.Name == "Object"); DB.Query<SampleView.RowSchema>(v => v.Name == "Object"); DB.Query<SampleView.RowSchema>("Name = \"Object\"");
I'm getting 3 different behaviors for the query formats when run against the DB in Server mode, these are
- I get back a Result<object> list with a size of 0
- I get back a null result
- I get the following exception
System.ArgumentNullException: Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.Cast[TResult](IEnumerable source)
at RaptorDB.RaptorDBClient.GenericResult[T](Result`1 res) in c:\RaptorDB\v1.9.0\RaptorDB.Common\RaptorDBClient.cs:line 475
at RaptorDB.RaptorDBClient.Query[T](Expression`1 filter, Int32 start, Int32 c
ount) in c:\RaptorDB\v1.9.0\RaptorDB.Common\RaptorDBClient.cs:line 469
at RaptorDB.RaptorDBClient.Query[T](Expression`1 filter) in c:\RaptorDB\v1.9.0\RaptorDB.Common\RaptorDBClient.cs:line 455
at testRaptorDB.Program.ReadAllObjects() in c:\testRaptorDB\testRaptorDB\Program.cs:line 104
I've written a test case to demonstrate my issue below. I compiled it, copied the dll with the Sample object and SampleView definitions into the "Extensions" directory and then ran the test case with the various query formats I specified above (which are available but commented out in the test case). Am I do anything obviously wrong? I'm just looking for any way of fetching all objects of a particular type from the database while running in Server mode.
using System;
using System.Linq;
using System.IO;
using RaptorDB;
using RaptorDB.Common;
class Program
{
static int waitTime = 5;
static string dataPath = "_data";
static IRaptorDB DB = null;
static Sample[] SampleArray =
{
new Sample
{
ID = Guid.NewGuid(),
Name = "Object",
OtherValue = "other value for object 1"
},
new Sample
{
ID = Guid.NewGuid(),
Name = "Object",
OtherValue = "other value for object 2"
}
};
public static void Main(string[] args)
{
Console.WriteLine("Delete database directory if it already exists");
Directory.Delete(dataPath, true);
Console.WriteLine("Connecting to DB in embedded mode");
DBInit();
WriteSampleData();
Wait();
ReadAllObjects();
Console.WriteLine("Closing DB in embedded mode");
DB.Shutdown();
Console.WriteLine("Starting DB in server mode");
RaptorDBServer server = new RaptorDBServer(90, dataPath);
Console.WriteLine("Connecting to DB in server mode");
DB = new RaptorDBClient("localhost", 90, "admin", "admin");
ReadAllObjects();
DB.Shutdown();
server.Shutdown();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
static void DBInit()
{
Console.WriteLine("Initialise database");
RaptorDB.RaptorDB rapDB = RaptorDB.RaptorDB.Open(dataPath);
rapDB.RegisterView( new SampleView());
DB = rapDB;
}
static void WriteSampleData()
{
foreach(Sample obj in SampleArray)
{
Console.WriteLine("{0} : {1} : {2}", obj.ID.ToString(), obj.Name, obj.OtherValue);
DB.Save(obj.ID, obj);
}
}
static void ReadAllObjects()
{
Console.WriteLine("Read back all data from DB\n");
try
{
var list = DB.Query("SampleView");
if(list.Count > 0)
{
Console.WriteLine("-- {0} SampleView retrieved", list.Count);
foreach(SampleView.RowSchema row in list.Rows)
{
Console.WriteLine("-- ViewRow {0}: {1}", row.docid.ToString(), row.Name);
Console.WriteLine("");
}
}
else
Console.WriteLine("-- 0 SampleView retrieved");
}
catch(Exception e)
{
Console.WriteLine("Error: {0}", e.ToString());
}
}
static void Wait()
{
Console.Write("\nWait a few seconds to make sure records are written");
for(int i =0; i< waitTime; i++)
{
Console.Write(".");
System.Threading.Thread.Sleep(1000);
}
Console.WriteLine("\n");
}
}
Command Line Output
Delete database directory if it already exists
Connecting to DB in embedded mode
Initialise database
3ae79e98-b64e-4a64-99bc-98d697105630 : Object : other value for object 1
978e9367-2299-4a9c-9c45-536957840fc5 : Object : other value for object 2
Wait a few seconds to make sure records are written.....
Read back all data from DB
-- 2 SampleView retrieved
-- ViewRow 3ae79e98-b64e-4a64-99bc-98d697105630: Object
-- ViewRow 978e9367-2299-4a9c-9c45-536957840fc5: Object
Closing DB in embedded mode
Starting DB in server mode
Connecting to DB in server mode
Read back all data from DB
Error: System.NullReferenceException: Object reference not set to an instance of an object.
at testRaptorDB.Program.ReadAllObjects() in c:\testRaptorDB\testRaptorDB\Program.cs
Log file from DB directory
2012-12-10 05:49:11|DEBUG|1|RaptorDB.RaptorDB|| RaptorDB starting...
2012-12-10 05:49:11|DEBUG|1|RaptorDB.RaptorDB|| RaptorDB data folder = C:\testRaptorDB\testRaptorDB\bin\Debug\_data\
2012-12-10 05:49:12|DEBUG|1|RaptorDB.KeyStore`1|| Current Count = 0
2012-12-10 05:49:12|DEBUG|1|RaptorDB.KeyStore`1|| Checking Index state...
2012-12-10 05:49:12|DEBUG|1|RaptorDB.KeyStore`1|| Starting save timer
2012-12-10 05:49:12|DEBUG|1|RaptorDB.KeyStore`1|| Current Count = 0
2012-12-10 05:49:12|DEBUG|1|RaptorDB.KeyStore`1|| Checking Index state...
2012-12-10 05:49:12|DEBUG|1|RaptorDB.KeyStore`1|| Starting save timer
2012-12-10 05:49:12|DEBUG|1|RaptorDB.Views.TaskQueue|| TaskQueue starting
2012-12-10 05:49:12|DEBUG|1|RaptorDB.Hoot|| Starting hOOt....
2012-12-10 05:49:12|DEBUG|1|RaptorDB.Hoot|| Storage Folder = C:\testRaptorDB\testRaptorDB\bin\Debug\_data\Data\Fulltext\
2012-12-10 05:49:12|DEBUG|1|RaptorDB.Views.ViewHandler|| Rebuilding view from scratch...
2012-12-10 05:49:12|DEBUG|1|RaptorDB.Views.ViewHandler|| View = SampleView
2012-12-10 05:49:12|DEBUG|1|RaptorDB.Views.ViewHandler|| rebuild done (s) = 0
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Views.ViewHandler|| query : SampleView
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Views.ViewHandler|| query rows fetched (ms) : 10.7833
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Views.ViewHandler|| query rows count : 2
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Hoot|| saving index...
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Hoot|| save time (ms) = 2.9409
2012-12-10 05:49:17|DEBUG|1|RaptorDB.RaptorDB|| last full text record = -1
2012-12-10 05:49:17|DEBUG|1|RaptorDB.RaptorDB|| last record = 1
2012-12-10 05:49:17|DEBUG|1|RaptorDB.RaptorDB|| last backup record = -1
2012-12-10 05:49:17|DEBUG|1|RaptorDB.RaptorDB|| Shutting down
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Views.ViewManager|| View Manager shutdown
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Views.TaskQueue|| TaskQueue shutdown
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Views.ViewManager|| shutting down view : SampleView
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down Viewhandler
2012-12-10 05:49:17|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down view index : docid
2012-12-10 05:49:17|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-10 05:49:17|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-10 05:49:18|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-10 05:49:18|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-10 05:49:18|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down view index : Name
2012-12-10 05:49:18|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-10 05:49:18|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-10 05:49:18|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-10 05:49:18|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-10 05:49:19|DEBUG|1|RaptorDB.KeyStore`1|| Shutting down
2012-12-10 05:49:19|DEBUG|1|RaptorDB.KeyStore`1|| saving to disk
2012-12-10 05:49:19|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-10 05:49:19|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-10 05:49:19|DEBUG|1|RaptorDB.KeyStore`1|| index saved
2012-12-10 05:49:19|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-10 05:49:19|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-10 05:49:19|DEBUG|1|RaptorDB.KeyStore`1|| Shutting down log
2012-12-10 05:49:20|DEBUG|1|RaptorDB.RaptorDB|| RaptorDB starting...
2012-12-10 05:49:20|DEBUG|1|RaptorDB.RaptorDB|| RaptorDB data folder = C:\testRaptorDB\testRaptorDB\bin\Debug\_data\
2012-12-10 05:49:20|DEBUG|1|RaptorDB.KeyStore`1|| Current Count = 2
2012-12-10 05:49:20|DEBUG|1|RaptorDB.KeyStore`1|| Checking Index state...
2012-12-10 05:49:20|DEBUG|1|RaptorDB.KeyStore`1|| Starting save timer
2012-12-10 05:49:20|DEBUG|1|RaptorDB.KeyStore`1|| Current Count = 0
2012-12-10 05:49:20|DEBUG|1|RaptorDB.KeyStore`1|| Checking Index state...
2012-12-10 05:49:20|DEBUG|1|RaptorDB.KeyStore`1|| Starting save timer
2012-12-10 05:49:20|DEBUG|1|RaptorDB.Views.TaskQueue|| TaskQueue starting
2012-12-10 05:49:20|DEBUG|1|RaptorDB.Hoot|| Starting hOOt....
2012-12-10 05:49:20|DEBUG|1|RaptorDB.Hoot|| Storage Folder = C:\testRaptorDB\testRaptorDB\bin\Debug\_data\Data\Fulltext\
2012-12-10 05:49:20|DEBUG|1|RaptorDB.RaptorDBServer|| loading dll for views : C:\testRaptorDB\testRaptorDB\bin\Debug\Extensions\testLib.dll
2012-12-10 05:49:21|DEBUG|5|RaptorDB.RaptorDB|| byte[] is null
2012-12-10 05:49:21|DEBUG|5|RaptorDB.RaptorDB|| curr rec = 2
2012-12-10 05:49:21|DEBUG|5|RaptorDB.RaptorDB|| last rec = 2
2012-12-10 05:49:21|DEBUG|6|RaptorDB.Views.ViewHandler|| query : SampleView
2012-12-10 05:49:21|DEBUG|6|RaptorDB.Views.ViewHandler|| query :
2012-12-10 05:49:21|ERROR|6|RaptorDB.RaptorDBServer|| Expression expected (at index 0)
2012-12-10 05:49:22|DEBUG|1|RaptorDB.Hoot|| saving index...
2012-12-10 05:49:22|DEBUG|1|RaptorDB.Hoot|| save time (ms) = 0
2012-12-10 05:49:22|DEBUG|1|RaptorDB.RaptorDB|| last full text record = -1
2012-12-10 05:49:22|DEBUG|1|RaptorDB.RaptorDB|| last record = 2
2012-12-10 05:49:22|DEBUG|1|RaptorDB.RaptorDB|| last backup record = -1
2012-12-10 05:49:22|DEBUG|1|RaptorDB.RaptorDB|| Shutting down
2012-12-10 05:49:22|DEBUG|1|RaptorDB.Views.ViewManager|| View Manager shutdown
2012-12-10 05:49:22|DEBUG|1|RaptorDB.Views.TaskQueue|| TaskQueue shutdown
2012-12-10 05:49:22|DEBUG|1|RaptorDB.Views.ViewManager|| shutting down view : SampleView
2012-12-10 05:49:22|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down Viewhandler
2012-12-10 05:49:22|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down view index : docid
2012-12-10 05:49:22|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-10 05:49:22|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-10 05:49:22|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-10 05:49:22|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-10 05:49:22|DEBUG|1|RaptorDB.Views.ViewHandler|| Shutting down view index : Name
2012-12-10 05:49:22|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-10 05:49:22|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-10 05:49:22|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-10 05:49:22|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-10 05:49:22|DEBUG|1|RaptorDB.KeyStore`1|| Shutting down
2012-12-10 05:49:22|DEBUG|1|RaptorDB.KeyStore`1|| saving to disk
2012-12-10 05:49:22|DEBUG|1|RaptorDB.MGIndex`1|| Total split time (s) = 0
2012-12-10 05:49:22|DEBUG|1|RaptorDB.MGIndex`1|| Total pages = 1
2012-12-10 05:49:22|DEBUG|1|RaptorDB.KeyStore`1|| index saved
2012-12-10 05:49:22|DEBUG|1|RaptorDB.IndexFile`1|| Shutdown IndexFile
2012-12-10 05:49:22|DEBUG|1|RaptorDB.BitmapIndex|| Shutdown BitmapIndex
2012-12-10 05:49:22|DEBUG|1|RaptorDB.KeyStore`1|| Shutting down log
|
|
|
|

|
Thanks!
I have found a bug in the bitmap index (probably not related), I will post that update soon.
I will look into this issue also, (the voting is off on the forums at the moment )
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, let me know if there's anything else I can help with
|
|
|
|

|
Fixed the issues, I will post an update soon.
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.
|
|
|
|

|
Cheers, I just tested that there and it's working fine.
So from the different examples I gave in my test case:
- the first 4 are fixed by this
- next 2 already worked and continue to work
- the following 2 were actually as a result of this other issue that I proposed a fix for here and here
DB.Query("SampleView"); DB.Query(typeof(Sample)); DB.Query(typeof(SampleView)); DB.Query(typeof(SampleView.RowSchema));
DB.Query("SampleView", (SampleView.RowSchema v) => v.Name == "Object"); DB.Query(typeof(Sample), (SampleView.RowSchema v) => v.Name == "Object"); DB.Query(typeof(SampleView), (SampleView.RowSchema v) => v.Name == "Object"); DB.Query(typeof(SampleView.RowSchema), (SampleView.RowSchema v) => v.Name == "Object");
|
|
|
|

|
I am very impressed with the DB and I notice in your article that you have a Silverlight 5 demo screenshot but when looking at the source code you don't include support for compiling Silverlight 5 projects.
Does RaptorDB in fact work with Silverlight 5 and do you have a version of the source code that supports it?
Graeme
|
|
|
|

|
Thanks Graeme!
Microsoft nicely removed the Reflection.Emit functionality used by the fastJSON serializers in RaptorDB in Silverlight v5 (they were in v4), so RaptorDB will not compile or work with Silverlight5.
Creating a workaround is not on my todo list and frankly I feel Silverlight is a sinking ship, I would much rather switch to Android and MonoDroid which works right now.
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
|
NoSql, JSON based, Document store database with compiled .net map functions and automatic hybrid bitmap indexing and LINQ query filters (now with standalone Server mode, Backup and Active Restore, Transactions, Server side queries, MonoDroid support)
| Type | Article |
| Licence | CPOL |
| First Posted | 29 Apr 2012 |
| Views | 158,843 |
| Downloads | 5,256 |
| Bookmarked | 230 times |
|
|