|
|
Comments and Discussions
|
|
 |

|
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.
|
|
|
|
 |
|
|
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 | 157,178 |
| Downloads | 5,215 |
| Bookmarked | 225 times |
|
|