public static void test_main_big() { DB.Root("/tmp/"); iBoxDB.DBDebug.DDebug.DeleteDBFiles(1); DB db = new DB(1); String[] ts = new String[] { File.OpenText(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/hero.txt").ReadToEnd() }; Engine engine = new Engine(); engine.Config(db.GetConfig().DBConfig); AutoBox auto = db.Open(); var b = DateTime.Now; for (int i = 0; i < ts.Length; i++) { using (var box = auto.Cube()) { engine.indexText(box, i, ts [i], false); box.Commit().Assert(); } } Console.WriteLine("Index " + (DateTime.Now - b).TotalSeconds); var strkw = "黄蓉"; b = DateTime.Now; int c = 0; for (int i = 0; i < 20; i++) { b = DateTime.Now; c = 0; using (var box = auto.Cube()) { foreach (KeyWord kw in engine.search(box, strkw)) { c++; } } Console.WriteLine(c + " , " + (DateTime.Now - b).TotalSeconds); } b = DateTime.Now; c = 0; int p = ts [0].IndexOf(strkw); while (p > 0) { c++; p = ts [0].IndexOf(strkw, p + 2); } Console.WriteLine(c + " , " + (DateTime.Now - b).TotalSeconds); auto.GetDatabase().Close(); }
/// <summary> /// Inserts data. /// </summary> /// <typeparam name="T">The type definition of data.</typeparam> /// <param name="tableName">Name of the table.</param> /// <param name="values">The list of data.</param> /// <returns><c>true</c> if insert data success, <c>false</c> otherwise.</returns> public bool Insert <T>(string tableName, params T[] values) where T : class { try { if (database != null && values != null) { using (IBox box = database.Cube()) { for (int i = 0, length = values.Length; i < length; ++i) { T data = values[i]; box.Bind(tableName).Insert(data); } CommitResult result = box.Commit(); if (result.Equals(CommitResult.OK)) { return(true); } else { Debug.LogError(result.GetErrorMsg(box)); } } } } catch (Exception exception) { Debug.LogException(exception); } return(false); }
public static void test_order() { DB.Root("/tmp/"); BoxSystem.DBDebug.DeleteDBFiles(3); DB db = new DB(3); Engine engine = new Engine(); engine.Config(db.GetConfig().DBConfig); AutoBox auto = db.Open(); int count = 100; String[] ts = new String[count]; for (int i = 0; i < count; i++) { ts[i] = "test " + i; } for (int i = 0; i < ts.Length; i++) { using (IBox box = auto.Cube()) { engine.indexText(box, i, ts[i], false); box.Commit().Assert(); } } bool doagain = true; long startId = long.MaxValue; long tcount = 0; while (doagain && (startId >= 0)) { doagain = false; using (IBox box = auto.Cube()) { foreach (KeyWord kw in engine.searchDistinct(box, "test", startId, 9)) { Console.WriteLine(engine.getDesc(ts[(int)kw.getID()], kw, 20)); tcount++; doagain = true; startId = kw.getID() - 1; } } Console.WriteLine(); Console.WriteLine(startId); } Console.WriteLine(count + " == " + tcount); auto.GetDatabase().Dispose(); }
public int Count(ValueList Conditions) { AutoBox auto = _db.Open(); StringBuilder ql = new StringBuilder(); ql.Append($"from Block"); List <object> args = new List <object>(); if (Conditions.Count > 0) { ql.Append($" where "); for (var i = 0; i < Conditions.Count; i++) { ql.Append($" {Conditions[i].Name} == ? &"); args.Add(Conditions[i].Value); } } IEnumerable <Block> result = null; using (Box box = auto.Cube()) { try { result = box.Select <Block>(ql.ToString().TrimEnd('&'), args.ToArray()); return(result.Count()); } catch (Exception ex) { //TODO: Log Exeption } } return(0); }
public Block Find(ValueList Conditions) { AutoBox auto = _db.Open(); StringBuilder ql = new StringBuilder(); ql.Append($"from Block"); List <object> args = new List <object>(); if (Conditions.Count > 0) { ql.Append($" where "); for (var i = 0; i < Conditions.Count; i++) { ql.Append($" {Conditions[i].Name} == ? &"); args.Add(Conditions[i].Value); } } IEnumerable <Block> result; using (Box box = auto.Cube()) { try { return(box.Select <Block>(ql.ToString().TrimEnd('&'), args.ToArray()).First()); } catch (Exception ex) { //log exception } } return(null); //TODO: find a better way to handle this }
public bool Add(Block item) { AutoBox auto = _db.Open(); CommitResult cr; using (Box box = auto.Cube()) { box["Block"].Insert <Block>(item, 0); cr = box.Commit(); } return(cr.Assert()); }
/// <summary> /// Deletes data by the given primary key value. /// </summary> /// <param name="tableName">Name of the table.</param> /// <param name="primaryKeyValues">The primary key values.</param> /// <returns><c>true</c> if delete data success, <c>false</c> otherwise.</returns> public bool Delete(string tableName, params object[] primaryKeyValues) { CheckDisposed(); try { if (database != null && primaryKeyValues != null) { using (IBox box = database.Cube()) { for (int i = 0, length = primaryKeyValues.Length; i < length; ++i) { object primaryKeyValue = primaryKeyValues[i]; box.Bind(tableName, primaryKeyValue).Delete(); } CommitResult result = box.Commit(); if (result.Equals(CommitResult.OK)) { return(true); } else { Debug.LogError(result.GetErrorMsg(box)); } } } } catch (Exception exception) { Debug.LogException(exception); } return(false); }
public bool Add(Transaction item) { //TODO: Need to add a Block and it's transactions in a batch (Transaction) to avoid possible data loss if (item.PaymentId == Constants.NULL_HASH) { item.PaymentId = ""; //clear this to save on storage space } AutoBox auto = _db.Open(); CommitResult cr; using (Box box = auto.Cube()) { //set the Tx Id - this is just a random Value for storage purposes item.Id = box.NewId(); box["Transaction"].Insert <Transaction>(item); cr = box.Commit(); } if (cr == CommitResult.OK) { return(true); } return(false); }
public Block FindTopBlock() { AutoBox auto = _db.Open(); StringBuilder ql = new StringBuilder(); ql.Append($"from Block"); List <Block> result; using (Box box = auto.Cube()) { result = box.Select <Block>(ql.ToString()).OrderByDescending(x => x.Height).Take(1).ToList(); //TODO: Test Performance and see if there's a better way to implement this } try { return(result.First()); } catch (Exception ex) { //TODO: Log Exception return(null); //TODO: find a better way to handle this } }
public int Count() { AutoBox auto = _db.Open(); StringBuilder ql = new StringBuilder(); ql.Append($"from Block"); List <object> args = new List <object>(); IEnumerable <Block> result = null; using (Box box = auto.Cube()) { try { result = box.Select <Block>(ql.ToString().TrimEnd('&'), args.ToArray()); return(result.Count()); } catch (Exception ex) { //TODO: Log Exeption } } return(0); }
public long indexTextNoTran(AutoBox auto, int commitCount, long id, String str, bool isRemove) { if (id == -1) { return(-1); } long itCount = 0; char[] cs = sUtil.clear(str); List <KeyWord> map = sUtil.fromString(id, cs, true); IBox box = null; int ccount = 0; foreach (KeyWord kw in map) { if (box == null) { box = auto.Cube(); ccount = commitCount; } insertToBox(box, kw, isRemove); itCount++; if (--ccount < 1) { box.Commit().Assert(); box = null; } } if (box != null) { box.Commit().Assert(); } return(itCount); }
public static void test_main() { DB.Root("/tmp/"); iBoxDB.DBDebug.DDebug.DeleteDBFiles(1); DB db = new DB(1); String[] ts = new String[] { //ID=0 "Setting up Git\n" + "\n" + "Download and install the latest version of GitHub Desktop. " + "This will automatically install Git and keep it up-to-date for you.\n" + "On your computer, open the Git Shell application.\n" + "Tell Git your name so your commits will be properly labeled. Type everything after the $ here:\n" + "\n babies " + "git config --global user.name \"YOUR NAME\"\n" + "Tell Git the email address that will be associated with your Git commits. " + "The email you specify should be the same one found in your email settings. " + "To keep your email address hidden," + " 关于 see \"Keeping your C# Java NoSQL email address [email protected] private\".", //ID=1 "关于版本控制\n" + "什么是“版本控制”?我为什么要关心它呢? 版本控制是一种记录一个或若干文件内容变化,1234567890ABCDEFGH " + "以便将来查阅特定版本修订情况的系统。 在本书所展示的例子中,我们对保存着软件源代码的文件作版本控制," + "但实际上,C lang IT 你可以对任何类型的文件进行版本控制。", //ID=2 "バージョン管理に関して\n" + "\n" + "「バージョン管理」とは何でしょうか。また、なぜそれを気にする必要があるのでしょうか。 " + "バージョン管理とは、一つのファイルやファイルの集合に対して時間とともに加えられていく変更を記録するシステムで、" + "後で特定バージョンを呼び出すことができるようにするためのものです。" + " 本書の例では、バージョン管理されるファイルとしてソフトウェアのソースコードを用いていますが、" + "実際にはコンピューター上のあらゆる種類のファイルをバージョン管理のもとに置くことができます。", //ID=3 "關於版本控制\n" + "什麼是版本控制? 以及為什麼讀者會在意它? " + "版本控制是一個能夠記錄一個或一組檔案在某一段時間的變更," + "使得讀者以後能取回特定版本的系統。 NoSQL" + "在本書的範例中,讀者會學到如何對軟體的原始碼做版本控制。" + " 即使實際上讀者幾乎可以針對電腦上任意型態的檔案做版本控制。", //ID=4 "Git 简史\n" + "同生活中的许多伟大事物一样,Git 诞生于一个极富纷争大举创新的年代。nosql \n" + "\n" + "Linux 内核开源项目有着为数众广的参与者。 绝大多数的 Linux 内核维护工作都花在了提交补丁和保存归档的" + "繁琐事务上(1991-2002年间)。 到 2002 年," + "整个项目组开始启用一个专有的分布式版本控制系统 BitKeeper 来管理和维护代码。\n" + "\n" + "到了 2005 年,开发 BitKeeper 的商业公司同 Linux 内核开源社区的合作关系结束," + "他们收回了 Linux 内核社区免费使用 BitKeeper 的权力。" + " 这就迫使 Linux 开源社区(特别是 Linux 的缔造者 Linux Torvalds)基于使用 BitKcheper 时的" + "经验教训,开发出自己的版本系统。 他们对新的系统制订了若干目标:" }; Engine engine = new Engine(); engine.Config(db.GetConfig().DBConfig); AutoBox auto = db.Open(); for (int i = 0; i < ts.Length; i++) { using (var box = auto.Cube()) { engine.indexText(box, i, ts [i], false); box.Commit().Assert(); } } using (var box = auto.Cube()) { //engine.indexText(box, 4, ts[4], true); box.Commit().Assert(); } using (var box = auto.Cube()) { // searchDistinct() search() foreach (KeyWord kw in engine.search(box, "nosql 经验 git ")) { Console.WriteLine(kw.ToFullString()); Console.WriteLine(engine.getDesc(ts [(int)kw.ID], kw, 20)); } } auto.GetDatabase().Close(); }
private static void test_big(String book, long dbid, bool rebuild, char split, String strkw, int notranCount) { DB.Root("/tmp/"); if (rebuild) { iBoxDB.DBDebug.DDebug.DeleteDBFiles(dbid); } DB db = new DB(dbid); String[] tstmp = File.OpenText(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal) + book).ReadToEnd().Split(split); List <String> list = new List <String> (); for (int i = 0; i < 2; i++) { foreach (String str in tstmp) { list.Add(str); } } String[] ts = list.ToArray(); Engine engine = new Engine(); engine.Config(db.GetConfig().DBConfig); //engine.maxSearchTime = 1000; AutoBox auto = db.Open(); var b = DateTime.Now; if (rebuild) { long rbcount = 0; Parallel.For(0, ts.Length, (i) => { if (notranCount < 1) { using (var box = auto.Cube()) { Interlocked.Add(ref rbcount, engine.indexText(box, i, ts [i], false)); box.Commit().Assert(); } } else { Interlocked.Add(ref rbcount, engine.indexTextNoTran(auto, notranCount, i, ts [i], false)); } }); Console.WriteLine("Index " + (DateTime.Now - b).TotalSeconds + " -" + rbcount); } b = DateTime.Now; int c = 0; for (int i = 0; i < 20; i++) { b = DateTime.Now; c = 0; using (var box = auto.Cube()) { foreach (KeyWord kw in engine.searchDistinct(box, strkw)) { c++; } } Console.WriteLine(c + " , " + (DateTime.Now - b).TotalSeconds); } for (int i = 0; i < ts.Length; i++) { ts [i] = ts [i].ToLower() + " "; } strkw = strkw.ToLower(); String[] kws = strkw.Split(' '); StringUtil sutil = new StringUtil(); b = DateTime.Now; c = 0; int starti = 0; Test: for (int i = starti; i < ts.Length; i++) { for (int j = 0; j < kws.Length; j++) { int p = ts [i].IndexOf(kws [j]); if (p < 0) { starti = i + 1; goto Test; } char pc = ts [i] [p + kws [j].Length]; if (sutil.isWord(pc)) { //System.out.println(pc); starti = i + 1; goto Test; } } c++; } Console.WriteLine(c + " , " + (DateTime.Now - b).TotalSeconds + " -" + ts.Length); auto.GetDatabase().Close(); }
public static void test_main() { DB.Root("/tmp/"); String[] ts = new String[] { //ID=0 "Setting up Git\n" + "\n" + "Download and install the latest version of GitHub Desktop. " + "This will automatically install Git and keep it up-to-date for you.\n" + "On your computer, open the Git Shell application.\n" + "Tell Git your name so your commits will be properly labeled. Type everything after the $ here:\n" + "\n babies " + "git config --global user.name \"YOUR NAME\"\n" + "Tell Git the email address that will be associated with your Git commits. " + "The email you specify should be the same one found in your email settings. " + "To keep your email address hidden," + " 关于 see \"Keeping your C# Java NoSQL email address [email protected] private\".", //ID=1 "关于版本控制\n" + "什么是“版本控制”?我为什么要关心它呢? 版本控制是一种记录一个或若干文件内容变化,1234567890ABCDEFGH " + "以便将来查阅特定版本修订情况的系统。 在本书所展示的例子中,我们对保存着软件源代码的文件作版本控制," + "但实际上,C lang IT 你可以对任何类型的文件进行版本控制。", //ID=2 "バージョン管理に関して\n" + "\n" + "「バージョン管理」とは何でしょうか。また、なぜそれを気にする必要があるのでしょうか。 " + "バージョン管理とは、一つのファイルやファイルの集合に対して時間とともに加えられていく変更を記録するシステムで、" + "後で特定バージョンを呼び出すことができるようにするためのものです。" + " 本書の例では、バージョン管理されるファイルとしてソフトウェアのソースコードを用いていますが、" + "実際にはコンピューター上のあらゆる種類のファイルをバージョン管理のもとに置くことができます。", //ID=3 "關於版本控制\n" + "什麼是版本控制? 以及為什麼讀者會在意它? 美食" + "版本控制是一個能夠記錄一個或一組檔案在某一段時間的變更," + "使得讀者以後能取回特定版本的系統。has NoSQL" + "在本書的範例中,android 讀者會學到如何對軟體的原始碼做版本控制。" + " 即使實際上讀者幾乎可以針對電腦上任意型態的檔案做版本控制。", //ID=4 "Git 简史\n" + "同生活中的许多伟大事物一样,Git 诞生于一个极富纷争大举创新的年代。nosql \n" + "\n" + "Linux 内核开源项目有着为数众广的参与者。 绝大多数的 Linux 内核维护工作都花在了提交补丁和保存归档的" + "繁琐事务上(1991-2002年间)。 到 2002 年," + "整个项目组开始启用一个专有的分布式版本控制系统 BitKeeper 来管理和维护代码。\n" + "\n" + "到了 2005 年,开发 BitKeeper 的商业公司同 Linux 内核开源社区的合作关系结束," + "他们收回了 Linux 内核社区免费使用 BitKeeper 的权力。" + " 这就迫使 Linux 开源社区(特别是 Linux 的缔造者 Linux Torvalds)基于使用 BitKcheper 时的" + "经验教训,开发出自己的版本系统。 他们对新的系统制订了若干目标:", //ID=5 "버전 관리란?\n\n버전 관리는 무엇이고 우리는 왜 이것을 알아야 할까? 버전 관리 시스템은 파일 변화를 시간에 따라 " + "기록했다가 나중에 특정 시점의 버전을 다시 꺼내올 수 있는 시스템이다. 이 책에서는 버전 관리하는 예제로 소프트웨어 " + "소스 코드만 보여주지만, 실제로 거의 모든 컴퓨터 파일의 버전을 관리할 수 있다.\n\n그래픽 디자이너나" + "웹 디자이너도 버전 관리 시스템(VCS - Version Control System)을 사용할 수 있다. VCS로 이미지나 레이아웃의" + "버전(변경 이력 혹은 수정 내용)을 관리하는 것은 매우 현명하다. VCS를 사용하면 각 파일을 이전 상태로 되돌릴 수 있고," + "프로젝트를 통째로 이전 is 상태로 되돌릴 수 있고, 시간에 따라 수정 내용을 비교해 볼 수 있고," + "누가 문제를 일으켰는지도 추적할 수 있고, 누가 언제 만들어낸 이슈인지도 알 수 있다. VCS를 사용하면 파일을 잃어버리거나" + "잘못 고쳤을 때도 쉽게 복구할 수 있다. HAS GIT 이런 모든 장점을 큰 노력 없이 이용할 수 있다." }; for (int tran = 0; tran < 2; tran++) { iBoxDB.DBDebug.DDebug.DeleteDBFiles(3); DB db = new DB(3); Engine engine = new Engine(); engine.Config(db.GetConfig().DBConfig); AutoBox auto = db.Open(); for (int i = 0; i < ts.Length; i++) { if (tran == 0) { using (var box = auto.Cube()) { engine.indexText(box, i, ts [i], false); box.Commit().Assert(); } } else { engine.indexTextNoTran(auto, 3, i, ts [i], false); } } using (var box = auto.Cube()) { //engine.indexText(box, 4, ts[4], true); box.Commit().Assert(); } using (var box = auto.Cube()) { // searchDistinct() search() foreach (KeyWord kw in engine.search(box, "nosql has 電 原始碼 meishi androd")) { Console.WriteLine(kw.ToFullString()); Console.WriteLine(engine.getDesc(ts [(int)kw.ID], kw, 20)); Console.WriteLine(); } foreach (String skw in engine.discover(box, 'n', 's', 2, '\u2E80', '\u9fa5', 2)) { Console.WriteLine(skw); } } auto.GetDatabase().Close(); Console.WriteLine("----------------------------------"); } }
public static Box Cube() => Auto.Cube();
void Start() { if (auto == null) { DB.Root(Application.persistentDataPath); DB db = new DB(5); //load from Resources //db = new DB(((TextAsset)(UnityEngine.Resources.Load("db2"))).bytes); // two tables(Player,Item) and their keys(ID,Name) db.GetConfig().EnsureTable <Player> ("Player", "ID"); // set max-length to 20 , default is 32 db.GetConfig().EnsureTable <Item> ("Item", "Name(20)"); { // [Optional] // if device has small memory & disk db.MinConfig(); // smaller DB file size db.GetConfig().DBConfig.FileIncSize = 1; } auto = db.Open(); } //Transaction using (var box = auto.Cube()) { // set " limit 0,1 " will faster if (box.SelectCount("from Item limit 0,1") == 0) { // insert player's score to database var player = new Player { Name = "Player_" + (int)Time.realtimeSinceStartup, Score = DateTime.Now.Second + (int)Time.realtimeSinceStartup + 1, ID = box.NewId() }; box ["Player"].Insert(player); //dynamic data, each object has different properties var shield = new Item() { Name = "Shield", Position = 1 }; shield ["attributes"] = new string[] { "earth" }; box ["Item"].Insert(shield); var spear = new Item() { Name = "Spear", Position = 2 }; spear ["attributes"] = new string[] { "metal", "fire" }; spear ["attachedSkills"] = new string[] { "dragonFire" }; box ["Item"].Insert(spear); var composedItem = new Item() { Name = "ComposedItem", Position = 3, XP = 0 }; composedItem ["Source1"] = "Shield"; composedItem ["Source2"] = "Spear"; composedItem ["level"] = 0; box ["Item"].Insert(composedItem); } CommitResult cr = box.Commit(); } DrawToString(); }
private static void test_big(String book, long dbid, bool rebuild, char split, String strkw, int notranCount) { DB.Root("/tmp/"); if (rebuild) { BoxSystem.DBDebug.DeleteDBFiles(dbid); } DB db = new DB(dbid); String[] tstmp = File.OpenText(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal) + book).ReadToEnd().Split(split); //three times data List <String> list = new List <String>(); for (int i = 0; i < 3; i++) { foreach (String str in tstmp) { list.Add(str); } } String[] ts = list.ToArray(); Engine engine = new Engine(); engine.Config(db.GetConfig().DBConfig); //engine.maxSearchTime = 1000; AutoBox auto = db.Open(); var b = DateTime.Now; if (rebuild) { long rbcount = 0; Parallel.For(0, ts.Length, (i) => { if (notranCount < 1) { using (var box = auto.Cube()) { Interlocked.Add(ref rbcount, engine.indexText(box, i, ts[i], false)); box.Commit().Assert(); } } else { Interlocked.Add(ref rbcount, engine.indexTextNoTran(auto, notranCount, i, ts[i], false)); } }); Console.WriteLine("Index " + (DateTime.Now - b).TotalSeconds + " -" + rbcount); } b = DateTime.Now; int c = 0; for (int i = 0; i < 20; i++) { b = DateTime.Now; c = 0; using (var box = auto.Cube()) { foreach (KeyWord kw in engine.searchDistinct(box, strkw)) { c++; } } Console.WriteLine("DB: " + c + " , " + (DateTime.Now - b).TotalSeconds + "s"); } StringUtil sutil = new StringUtil(); for (int i = 0; i < ts.Length; i++) { ts[i] = ts[i].ToLower() + " "; ts[i] = " " + new String(sutil.clear(ts[i])) + " "; } strkw = strkw.ToLower(); String[] kws = strkw.Split(new char[] { ' ' }); String tmp_kws = null; for (int i = 0; i < kws.Length; i++) { if (kws[i].length() < 1) { kws[i] = null; continue; } if (tmp_kws == null) { if (kws[i].StartsWith("\"")) { tmp_kws = kws[i]; kws[i] = null; } } else if (tmp_kws != null) { tmp_kws += (" " + kws[i]); if (kws[i].EndsWith("\"")) { kws[i] = tmp_kws.substring(1, tmp_kws.length() - 1); tmp_kws = null; } else { kws[i] = null; } } } b = DateTime.Now; c = 0; int starti = 0; Test: while (starti < ts.Length) { int i = starti++; for (int j = 0; j < kws.Length; j++) { if (kws[j] == null) { continue; } int p = 0; Test_P: while (p >= 0) { p = ts[i].IndexOf(kws[j], p + 1); if (p < 0) { goto Test; } if (onlyPart(ts[i], kws[j], p)) { goto Test_P; } break; } } c++; } Console.WriteLine("MEM: " + c + " , " + (DateTime.Now - b).TotalSeconds + "s -" + ts.Length); auto.GetDatabase().Dispose(); }
public static void test_main() { DB.Root("/tmp/"); BoxSystem.DBDebug.DeleteDBFiles(7); DB db = new DB(7); db.GetConfig().DBConfig.EnsureTable <TextObject>("TextObject", "ID"); Engine engine = new Engine(); engine.Config(db.GetConfig().DBConfig); AutoBox auto = db.Open(); { TextObject to = new TextObject(); to.ID = 1; to.Season = 2018; to.Group = 3; to.Time = new DateTime(2018, 3, 5); to.Keys = new string[] { "COOL", "FAST" }; to.KVDesc = new Dictionary <string, object> { { "Name", "X-MAN" }, { "Speed", 3000 } }; auto.Insert <TextObject>("TextObject", to); engine.indexTextNoTran(auto, int.MaxValue, to.ID, to.ToString(), false); TextObject to2 = new TextObject(); to2.ID = 2; to2.Season = 2018; to2.Group = 4; to2.Time = new DateTime(2018, 3, 6); to2.Keys = new string[] { "Sharp" }; to2.KVDesc = new Dictionary <string, object> { { "Speed", "gt4000" } }; auto.Insert <TextObject>("TextObject", to2); engine.indexTextNoTran(auto, int.MaxValue, to2.ID, to2.ToString(), false); } //SQL and //auto.Select ("from TextObject where Season==?"); //auto.Select ("from TextObject where Group==?"); //auto.Select ("from TextObject where Season==? & Group==?"); //auto.Select ("from TextObject where Time==?"); //auto.Select ("from TextObject where Season==? & Time==?"); //Full text search -and using (var box = auto.Cube()) { Console.WriteLine("Search: Season=2018"); String searchText = "SE-" + 2018; foreach (var kw in engine.searchDistinct(box, searchText, long.MaxValue, 200)) { Console.WriteLine(box["TextObject", kw.getID()].Select <TextObject>()); } Console.WriteLine("\r\nSearch: KVDesc={ \"Name\", \"X-MAN\" } , Keys={COOL}"); searchText = "KV-" + "Name" + "-" + "X-MAN" + " KE-" + "COOL"; foreach (var kw in engine.searchDistinct(box, searchText, long.MaxValue, 200)) { Console.WriteLine(box["TextObject", kw.getID()].Select <TextObject>()); } } Console.WriteLine(""); //Full text search -or using (var box = auto.Cube()) { HashSet <long> ids = new HashSet <long>(); Console.WriteLine("Search: Time=2018-3-6 OR KVDesc={ \"Name\", \"X-MAN\" } , Keys={COOL}"); String searchText = "TI-" + TextObject.DateTimeToStringShort(new DateTime(2018, 3, 6)); foreach (var kw in engine.searchDistinct(box, searchText, long.MaxValue, 200)) { ids.add(kw.getID()); } searchText = "KV-" + "Name" + "-" + "X-MAN" + " KE-" + "COOL"; foreach (var kw in engine.searchDistinct(box, searchText, long.MaxValue, 200)) { ids.add(kw.getID()); } long[] idslong = new long[ids.Count]; ids.CopyTo(idslong); Array.Sort(idslong); for (var i = idslong.Length - 1; i >= 0; i--) { Console.WriteLine(box["TextObject", idslong[i]].Select <TextObject>()); } } auto.GetDatabase().Dispose(); }
public static IBox Cube() { return(Auto.Cube()); }