public static void Enumerate() { var db = new RaptorDB <Guid>("c:\\RaptorDbTest\\enumerate", true); Guid sk = Guid.NewGuid(); db.Set(sk, "find key"); for (int i = 0; i < 100000; i++) { db.Set(Guid.NewGuid(), "" + i); } int found = 0; foreach (var enu in db.Enumerate(sk)) { if (found == 0) { string str = db.FetchRecordString(enu.Value); if (str != "find key") { Console.WriteLine(str); Assert.Fail(); } } found++; } Console.WriteLine("Enumerate from key count = " + found); db.RemoveKey(sk); db.Shutdown(); }
private static void readthread(RaptorDB <Guid> rap, List <Guid> guids, int count, char c) { Thread.Sleep(5000); int notfound = 0; for (int i = 0; i < count; i++) { string bb = ""; if (rap.Get(guids[i], out bb)) { if (bb != "" + i) { notfound++; } } else { notfound++; } if (i % 100000 == 0) { Console.Write(c); } } if (notfound > 0) { Console.WriteLine("not found = " + notfound); Assert.Fail(); } Console.WriteLine("read done"); }
private void init() { #if USENOSQL string playerdbfile = Path.Combine(STOREPATH, PLAYER_DB); string campaigndbfile = Path.Combine(STOREPATH, CAMPAIGN_DB); m_playerDb = RaptorDB<string>.Open(playerdbfile, false); m_campaignDb = RaptorDB<string>.Open(campaigndbfile, true); if (m_campaignDb.Count() > 0) { for (int i = 0; i < m_campaignDb.Count(); i++) { string campaignStr = m_campaignDb.FetchRecordString(i); string campaignKey = campaignStr.Split('#')[0]; string dbfilepath = campaignStr.Split('#')[1]; CampaignDatabaseRaptorDb db = new CampaignDatabaseRaptorDb(); db.CampaignKey = campaignKey; db.StorePath = dbfilepath; db.init(); m_dictRunningCampaigns.Add(campaignKey, (ICampaignDatabase)db); } } #endif }
public void Init() { var storePath = _parameters.Keys.Contains("file") ? Convert.ToString(_parameters.GetValuesForKey("file").First()):DefaultFileName; if (!Path.IsPathRooted(storePath)) storePath = DataPath.Combine(storePath); _storeFile = new FileInfo(storePath); _logger.NoticeFormat("Opening [{0}] Store...", _storeFile); _db = RaptorDB<string>.Open(_storeFile.FullName, false); }
/// <summary> /// Create a new instance of Raptor3D that is intended to be stored and used throughout the life of the program. /// When running on iOS, this constructor must be called from the main thread. /// </summary> /// <param name="name">The name of the storage directory, the default 'raptor' is recommended unless creating multiple document stores.</param> public Raptor3D(string name = "raptor") { if (!ValidCrossPlatformName(name)) { throw new ArgumentException($"In order to enable the best cross platform ability, names are limited to {validNamePattern}", nameof(name)); } indexDirectory = new DirectoryInfo(Path.Combine(Application.persistentDataPath, name, "raptor")); datastore = new RaptorDB <string>(indexDirectory.FullName, 64, false); }
public static void StringKeyTest() { var db = RaptorDB <string> .Open("c:\\raptordbtest\\strings", 255, true); for (int i = 0; i < 100000; i++) { db.Set("asdfasd" + i, "" + i); } db.Shutdown(); }
public void Init() { var storePath = _parameters.Keys.Contains("file") ? Convert.ToString(_parameters.GetValuesForKey("file").First()):DefaultFileName; if (!Path.IsPathRooted(storePath)) { storePath = DataPath.Combine(storePath); } _storeFile = new FileInfo(storePath); _logger.NoticeFormat("Opening [{0}] Store...", _storeFile); _db = RaptorDB <string> .Open(_storeFile.FullName, false); }
private static void insertthread(RaptorDB <Guid> rap, List <Guid> guids, int start, int count, char c) { for (int i = 0; i < count; i++) { rap.Set(guids[i + start], "" + (i + start)); if (i % 100000 == 0) { Console.Write(c); } } }
private static void testnoget() { int count = 100 * 1000000; string dbpath = "c:\\RaptorDbTest\\test1"; var rap = RaptorDB <Guid> .Open(dbpath, true); Console.WriteLine("---------------"); Console.WriteLine("Writing " + count.ToString("#,#")); //List<Guid> guid = new List<Guid>(); //for (int i = 0; i < count; i++) // guid.Add(Guid.NewGuid()); DateTime dt = DateTime.Now; for (int i = 0; i < count; i++) { Guid g = Guid.NewGuid(); rap.Set(g, "" + g); if (i % 100000 == 0) { Console.Write("."); } } Console.WriteLine("set done"); double st = DateTime.Now.Subtract(dt).TotalSeconds; //rap.Shutdown(); //rap = RaptorDB<Guid>.Open(dbpath, true); //dt = DateTime.Now; //int failed = 0; //for (int i = 0; i < count; i++) //{ // if (i % 100000 == 0) // Console.Write("."); // string str = ""; // if (rap.Get(guid[i], out str) == false) // failed++; // else // { // if (str != "" + guid[i]) // failed++; // } //} //Console.WriteLine("get done"); //if (failed > 0) // Console.WriteLine("failed count = " + failed); //Console.WriteLine(rap.GetStatistics()); Console.WriteLine("set time = " + st); //Console.WriteLine("get time = " + DateTime.Now.Subtract(dt).TotalSeconds); rap.Shutdown(); Console.ReadKey(); }
public RaptorDBServer(int port, string DataPath) { _path = Directory.GetCurrentDirectory(); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); _server = new NetworkServer(); _raptor = RaptorDB.Open(DataPath); register = _raptor.GetType().GetMethod("RegisterView", BindingFlags.Instance | BindingFlags.Public); save = _raptor.GetType().GetMethod("Save", BindingFlags.Instance | BindingFlags.Public); Initialize(); _server.Start(port, processpayload); }
public static List<object> Sum_Products_based_on_filter(RaptorDB.Common.IRaptorDB rap, string filter) { var q = rap.Query<RaptorDBTest1Views.SalesItemRowsView.RowSchema>(filter); var res = from x in q.Rows group x by x.Product into g select new SumType //avoid annonymous types { Product = g.Key, TotalPrice = g.Sum(p => p.Price), TotalQTY = g.Sum(p => p.QTY) }; return res.ToList<object>(); }
public static void Duplicates_Set_and_Get() { var db = new RaptorDB <Guid>("c:\\RaptorDbTest\\duptestfetch", true); int guidcount = 1000; int dupcount = 100; var guids = new List <Guid>(); for (int i = 0; i < guidcount; i++) { guids.Add(Guid.NewGuid()); } foreach (Guid g in guids) { for (int i = 0; i < dupcount; i++) { string s = "" + g + " " + i; db.Set(g, Encoding.Unicode.GetBytes(s)); } } db.SaveIndex(); foreach (Guid g in guids) { int j = 0; foreach (int i in db.GetDuplicates(g)) { string s = db.FetchRecordString(i); if (s.StartsWith(g.ToString()) == false) { Console.WriteLine("guid not correct = " + g + " returned = " + s); } else { j++; } } if (j < dupcount - 1) { Console.WriteLine("" + g + " count = " + j); Assert.Fail(); } //else // Console.WriteLine("" + g + " = OK"); } Console.WriteLine("ALL OK"); db.Shutdown(); }
public RaptorDBServer(int port, string DataPath) { _path = Directory.GetCurrentDirectory(); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); _server = new NetworkServer(); if (_S == "/")// unix system _datapath = DataPath.Replace("\\", "/"); else _datapath = DataPath; if (_datapath.EndsWith(_S) == false) _datapath += _S; _raptor = RaptorDB.Open(DataPath); register = _raptor.GetType().GetMethod("RegisterView", BindingFlags.Instance | BindingFlags.Public); save = _raptor.GetType().GetMethod("Save", BindingFlags.Instance | BindingFlags.Public); Initialize(); _server.Start(port, processpayload); }
private static void threadtest(RaptorDB <Guid> rap) { int count = 1000000; List <Guid> guids = new List <Guid>(); Console.WriteLine("building list..."); for (int i = 0; i < 2 * count; i++) { guids.Add(Guid.NewGuid()); } Console.WriteLine("starting..."); Thread t1 = new Thread(() => insertthread(rap, guids, 0, count, '.')); Thread t2 = new Thread(() => insertthread(rap, guids, count, count, '-')); Thread t3 = new Thread(() => readthread(rap, guids, count, 'R')); t3.Start(); t2.Start(); t1.Start(); t3.Join(); t2.Join(); t1.Join(); }
public AIEngine(GameMaster master) { Master = master; DB = RaptorDB<string>.Open (System.IO.Path.GetFullPath (DB_PATH), false); }
public void init() { string dbFilePath = Path.Combine(m_strDbStorePath, m_strCampaignKey); m_db = new RaptorDB<string>(dbFilePath, false); }
public TitanicRaptorDBMap(ITitanicMapConfig <K, V> config) { this.config = config; rdb = RaptorDB <K> .Open(config.BackingStoreFileName, false); }
public TitanicRaptorDBArray(ITitanicArrayConfig <T> config) { this.config = config; TSize = GetSizeInBytes(config.DataSerializer); rdb = RaptorDB <long> .Open(config.BackingStoreFileName, false); }