|
|
Comments and Discussions
|
|
 |

|
I am creating a multi threaded application that need some temprorary data store. I tried sqllite and failed. thinking to try Raptor. Is there is any example for multithread application
Thanks
Albert
Have a date for free
|
|
|
|

|
There is a sample code in the testing project which (commented at the moment) tests the engine to the max with parameters for number of threads and number of documents to insert.
The engine is multi-threaded and there is also a server which you can connect to from multiple clients at the same time.
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.
|
|
|
|

|
Hello,
First let me say thank you for creating this tool, it is truly great. I have a view with a boolean field that I would like to filter on. However attempting to query for all records where this field is "true" returns 0 rows, querying for value "false" returns all of the records. If this feature is not yet implemented that's fine, however if it should work please let me know and I'll post more code.
Here is my Query:
var q = rap.Query(typeof(ImageFile), (ImageFile i) => i.FileUpdated == false);
Thanks!
|
|
|
|

|
This should work.
Post your view definition so I can see how you are using the view.
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.
|
|
|
|

|
namespace ViewDefs
{
#region [ class definitions ]
public class ImageFile
{
public ImageFile()
{
ID = Guid.NewGuid();
OrigFileID = Guid.NewGuid();
}
public Guid ID { get; set; }
public string FilePath { get; set; }
public long OldFileSize { get; set; }
public long NewFileSize { get; set; }
public long DiskSpaceSaved { get; set; }
public DateTime DateTimeFileUpdate { get; set; }
public Boolean FileUpdated { get; set; }
public Guid OrigFileID { get; set; }
}
#endregion
#region [ views ]
[RegisterView]
public class ImageFileView : View<ImageFile>
{
public class RowSchema : RDBSchema
{
public Guid ID;
[FullText]
public string FilePath;
public long OldFileSize;
public long NewFileSize;
public long DiskSpaceSaved;
public DateTime DateTimeFileUpdate;
public Boolean FileUpdated;
public Guid OrigFileID;
}
public ImageFileView()
{
this.Name = "ImageFile";
this.Description = "A primary view for Image Files";
this.isPrimaryList = true;
this.isActive = true;
this.BackgroundIndexing = true;
this.Schema = typeof(ImageFileView.RowSchema);
this.AddFireOnTypes(typeof(ImageFile));
this.Mapper = (api, docid, doc) =>
{
api.EmitObject(docid, doc);
};
}
}
#endregion
}
|
|
|
|

|
Everything seems fine, try setting BackgroundIndexing = false.
You can try deleting the view folder and restarting so the engine rebuilds the view again.
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: Everything seems fine, try setting BackgroundIndexing = false.
This had no effect.
Mehdi Gholam wrote: You can try deleting the view folder and restarting so the engine rebuilds the view again.
This worked. Any ideas on how/why this happens? Some sort of corruption I imagine...
|
|
|
|

|
You have to allow the engine to Shutdown() cleanly and not stop mid-debug for example, since the indexes are flushed to disk on shutdown (or on the timer timeout mid execution ~60 secs).
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 did do that a few times before I discovered the ShutDown() method. Thanks again!
|
|
|
|

|
hi,
you provide to download raptor db doc version 1.8.3 but source code version is 1.0. so where is the raptor db source code version 1.8.3. provide link to download raptor db source code version 1.8.3 if possible.
tbhattacharjee
|
|
|
|

|
If you have downloaded the v1.8.3 zip file then that is the current version.
If you are referring to the AssemblyVersion of the code then yes they are 1.0 and I am not updating them.
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 added an Enum to my entity and the related views and i now get an exception registering the views. Raptor.Entities.Languages is the Enum. i will post classes below the exception
System.ArgumentException was unhandled by user code
HResult=-2147024809
Message=GenericArguments[0], 'Raptor.Entities.Languages', on 'RaptorDB.TypeIndexes`1[T]' violates the constraint of type 'T'.
Source=mscorlib
StackTrace:
at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
at RaptorDB.Views.ViewHandler.CreateIndex(String name, Type type) in D:\AnimeManager\Libs\RaptorDB\RaptorDB doc v1.8.3\RaptorDB\Views\ViewHandler.cs:line 591
at RaptorDB.Views.ViewHandler.CreateLoadIndexes(ViewRowDefinition viewRowDefinition) in D:\AnimeManager\Libs\RaptorDB\RaptorDB doc v1.8.3\RaptorDB\Views\ViewHandler.cs:line 486
at RaptorDB.Views.ViewHandler.SetView[T](View`1 view, KeyStoreGuid docs) in D:\AnimeManager\Libs\RaptorDB\RaptorDB doc v1.8.3\RaptorDB\Views\ViewHandler.cs:line 91
at RaptorDB.Views.ViewManager.RegisterView[T](View`1 view) in D:\AnimeManager\Libs\RaptorDB\RaptorDB doc v1.8.3\RaptorDB\Views\ViewManager.cs:line 246
at RaptorDB.RaptorDB.RegisterView[T](View`1 view) in D:\AnimeManager\Libs\RaptorDB\RaptorDB doc v1.8.3\RaptorDB\RaptorDB.cs:line 245
at Raptor.Data.OpenDB() in d:\AnimeManager\AnimeManager\DataLayer\Raptor\Data.cs:line 45
at UnitTests.DataLayerRaptorTests.TestInitialize() in d:\AnimeManager\AnimeManager\UnitTests\DataLayerRaptorTests.cs:line 30
InnerException: System.TypeLoadException
HResult=-2146233054
Message=GenericArguments[0], 'Raptor.Entities.Languages', on 'RaptorDB.MGIndex`1[T]' violates the constraint of type parameter 'T'.
Source=mscorlib
TypeName=""
StackTrace:
at System.RuntimeTypeHandle.Instantiate(RuntimeTypeHandle handle, IntPtr* pInst, Int32 numGenericArgs, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.Instantiate(Type[] inst)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
InnerException:
public class NameList : EntityBase
{
public List<Name> Names { get; set; }
public List<DataSourceDetail> DataSourceDetails { get; set; }
public NameList()
: base()
{
Names = new List<Name>();
DataSourceDetails = new List<DataSourceDetail>();
}
}
[RegisterView]
public class NameListView : View<NameList>
{
public class RowSchema : RowSchemaBase {
public Guid UnquieID;
public Languages Language;
public NameTypes NameType;
[FullText]
public string Name;
public override Type GetViewType()
{
return typeof(NameListView);
}
}
public NameListView()
{
this.Name = "NameList";
this.Description = "A primary view for NameList";
this.isPrimaryList = true;
this.isActive = true;
this.BackgroundIndexing = false;
this.Version = 1;
this.Schema = typeof(NameListView.RowSchema);
this.AddFireOnTypes(typeof(NameList));
this.Mapper = (api, docid, doc) =>
{
foreach (var name in doc.Names)
{
api.Emit(docid, doc.UniqueID, name.Language, name.NameType, name.Value);
}
};
}
}
|
|
|
|

|
Yes, unfortunately currently RaptorDB only supports simple types when serializing row data (byte, int, string, float, decimal etc.).
Enum's are supported by the doc serializer without problem, a workaround is to emit the byte value in the mapper for rows.
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 done some debugging and a little playing around and got almost no where. First i tried to convert the enum to int in the api.Emit method call in the view thinking that was what you meant by mapper. That failed. I then debugged and found the issue where the index constructor did not support enum so i did a check on the type and if it was an enum i created the index as an int index. The next issue i then hit was CreateResultRowFiller() in ViewHandler that just errors due to missing types etc.
Is it possible to keep the enum data type on the view or are you saying the enum on the rowshema has to be changed to an int and that i need to cast my linq queries as well? Another option i am thinking of is using is converting enums to strings then parse them out but even if i did that instead of ints i would still have an issue at that codegen class at least. I was really hoping to find a way to get enums working but maybe it just is not possible for the views.
|
|
|
|

|
it also seems like there is a same or similar issue with nullable datetime but i suspect with nullable types in general
|
|
|
|

|
Yes nulls and nullable types are on my todo list, (nulls have a design but need to be coded and tested).
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 will put a revamped row serializer to my todo list for more type support in views.
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.
|
|
|
|

|
So I'm deleting objects from the database using
DB.Delete(docid);
Then if for some reason I have to force the views to rebuild by deleting the "Views" folder under that RaptorDB data folder the deleted entries reappear in my view again.
Now we get strange behaviour
DB.Delete(docid);
returns false but still removes the entry from the view. But a call to
DB.Fetch(docid);
returns null, so although we can see the deleted entries in the view we can't actually retrieve the object they represent.
You mention in the documentation that the objects are never actually deleted, they are just flagged as deleted but it looks to me that there is a bug with this here when views are being rebuilt.
I've tried to have a look at the code around this but haven't quite been able to figure out how this flagging is being done yet.
Thanks in advance for the help.
|
|
|
|

|
Thanks!
The problem is probably in the RebuildFromScratch method, the storage file has an entry for a deleted guid and this method should handle that correctly.
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, I'd found that part of the code since I posted. Stepping through the code it appears that the RebuildFromScratch() is incorrectly identifying these objects as not having been deleted.
private bool isDeleted(byte[] hdr)
{
return (hdr[(int)HDR_POS.Flags] & (byte)1) > 0;
}
Is returning false, for entities that have been deleted. The value of hdr is {77, 71, 82, 4, 0, 0, 0, 0, 0, 0, 0, 0, 19, 160, 1, 0, 0, 0} So the 16th value(which stores the flag) is 0, which means it's not deleted
Also while rebuilding the view there are a number of entities with an all zero GUID which isDeleted is returning true for.
I'm able to reproduce this even after deleting the database and starting again by just creating 1 or 2 objects in the database, deleting them, then removing the "Views" folder and re-starting my app.
Any ideas?
|
|
|
|

|
Can you please debug the StorageFile.WriteData method and see if it is setting the flag to 1 :
if (deleted)
hdr[(int)HDR_POS.Flags] = (byte)1;
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.
|
|
|
|

|
Yeah, the flag is being set to 1 initially in StorageFile.WriteData so it looks like it's an issue with rebuilding the views.
The only objects that are being read back from the database which are marked as deleted are the objects I mentioned before where the docid is all zeros.
|
|
|
|

|
The code seems logically ok, the only thing that I can think of is when deleting, the index for the guid is not up to date so it can't find the the guid to mark them as deleted in :
private void DeleteRowsWith(Guid guid)
{
WAHBitArray gc = QueryColumnExpression(_docid, RDBExpression.Equal, guid);
_deletedRows.InPlaceOR(gc);
}
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 just trying to create a demo of this bug. At the moment it's wrapped up application code so I'm just seeing if I can separate it out into a simple test case. I'll get back to you later on it.
Thanks for the help.
|
|
|
|

|
So I've created a simple test case for the bug I'm seeing.
- I create a new DB
- populate it
- delete 1 object
- close the connection to the DB so I can remove the "Views" folder
- reconnect
- display all objects in the database
When I run this, even though I delete "Object 1", after re-connecting to the database it re-appears. Also as the code also shows it only re-appears in the view as a call to DB.Fetch(docid) is unable to retrieve the object.
I added artificial waits throughout the code to make sure that the data has been written,s o it shouldn't just be a simple race condition.
Does this help?
using System;
using System.Linq;
using System.IO;
using RaptorDB;
namespace testRaptorDB
{
class Program
{
static int waitTime = 5;
static string dataPath = "_data";
static RaptorDB.RaptorDB DB = null;
static Sample[] SampleArray =
{
new Sample
{
ID = Guid.NewGuid(),
Name = "Object 1",
OtherValue = "other value for object 1"
},
new Sample
{
ID = Guid.NewGuid(),
Name = "Object 2",
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);
DBInit();
WriteSampleData();
Wait();
ReadAllObjects();
if(DB.Delete(SampleArray[0].ID))
Console.WriteLine("Deleted {0}", SampleArray[0].Name);
else
{
Console.WriteLine("Unable to delete object");
return;
}
Wait();
ReadAllObjects();
RemoveViewFolder();
Wait();
ReadAllObjects();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
static void DBInit()
{
Console.WriteLine("Initialise database");
DB = RaptorDB.RaptorDB.Open(dataPath);
DB.RegisterView( new SampleView());
}
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");
var list = DB.Query("SampleView");
foreach(SampleView.RowSchema row in list.Rows)
{
Console.WriteLine("ViewRow {0}: {1}", row.docid.ToString(), row.Name);
Sample obj = (Sample)DB.Fetch(row.docid);
if(obj != null)
Console.WriteLine("Object {0} : {1} : {2}", obj.ID.ToString(), obj.Name, obj.OtherValue);
else
Console.WriteLine("Can't retrieve original Object");
Console.WriteLine("");
}
}
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");
}
static void RemoveViewFolder()
{
Console.WriteLine("Close connection to DB");
DB.Shutdown();
DB = null;
Console.WriteLine("Remove 'Views' folder from DB folder to force the views to be re-populated");
Directory.Delete(dataPath + @"\Views", true);
Console.WriteLine("Re-connect to database");
DBInit();
}
}
public class Sample
{
public Guid ID;
public string Name;
public string OtherValue;
public Sample()
{
}
}
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 = true;
this.Schema = typeof(SampleView.RowSchema);
this.AddFireOnTypes(typeof(Sample));
this.Mapper = (api, docid, doc) =>
{
api.EmitObject(docid, doc);
};
}
}
}
|
|
|
|
 |
|
|
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 | 159,430 |
| Downloads | 5,277 |
| Bookmarked | 230 times |
|
|