/// <exception cref="System.Exception"></exception> public virtual void Test2() { if (!isLocal) { return; } string baseName = GetBaseName(); NeoDatis.Btree.IBTreePersister persister = GetPersister(baseName); NeoDatis.Btree.IBTree tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple("test2" , 2, persister); for (int i = 0; i < Size; i++) { tree.Insert(i + 1, "value " + (i + 1)); } AssertEquals(Size, tree.GetSize()); System.Collections.IEnumerator iterator = tree.Iterator(NeoDatis.Odb.Core.OrderByConstants .OrderByDesc); int j = 0; while (iterator.MoveNext()) { object o = iterator.Current; // println(o); j++; if (j == Size) { AssertEquals("value " + 1, o); } } persister.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { if (!isLocal) { return; } string baseName = GetBaseName(); NeoDatis.Btree.IBTreePersister persister = GetPersister(baseName); NeoDatis.Btree.IBTree tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple("test1" , 2, persister); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); for (int i = 0; i < Size; i++) { tree.Insert(i + 1, "value " + (i + 1)); } long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); Println(end - start); if (testPerformance) { AssertTrue((end - start) < 0.34 * Size); } // println("insert of "+SIZE+" elements in BTREE = " + // (end-start)+"ms"); // persister.close(); // persister = getPersister(); AssertEquals(Size, tree.GetSize()); System.Collections.IEnumerator iterator = tree.Iterator(NeoDatis.Odb.Core.OrderByConstants .OrderByAsc); int j = 0; while (iterator.MoveNext()) { object o = iterator.Current; AssertEquals("value " + (j + 1), o); j++; if (j % 1000 == 0) { Println(j); } } persister.Close(); DeleteBase(baseName); }
public virtual void Test1() { if (!isLocal) { return; } string baseName = GetBaseName(); NeoDatis.Btree.IBTreePersister persister = GetPersister(baseName); NeoDatis.Btree.IBTree tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple("test1" , 2, persister); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); for (int i = 0; i < Size; i++) { tree.Insert(i + 1, "value " + (i + 1)); } long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); Println(end - start); if (testPerformance) { AssertTrue((end - start) < 0.34 * Size); } // println("insert of "+SIZE+" elements in BTREE = " + // (end-start)+"ms"); // persister.close(); // persister = getPersister(); AssertEquals(Size, tree.GetSize()); System.Collections.IEnumerator iterator = tree.Iterator(NeoDatis.Odb.Core.OrderByConstants .OrderByAsc); int j = 0; while (iterator.MoveNext()) { object o = iterator.Current; AssertEquals("value " + (j + 1), o); j++; if (j % 1000 == 0) { Println(j); } } persister.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { if (!isLocal) { return; } DeleteBase("btree45.neodatis"); NeoDatis.Odb.ODB odb = Open("btree45.neodatis"); NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine storageEngine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(odb); NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister persister = new NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister (storageEngine); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple ("t", 3, persister); tree.Insert(1, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 1")); tree.Insert(20, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 20")); tree.Insert(25, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 25")); tree.Insert(29, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 29")); tree.Insert(21, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 21")); AssertEquals(5, tree.GetRoot().GetNbKeys()); AssertEquals(0, tree.GetRoot().GetNbChildren()); AssertEquals(21, tree.GetRoot().GetMedian().GetKey()); AssertEquals("[Value 21]", tree.GetRoot().GetMedian().GetValue().ToString()); AssertEquals(0, tree.GetRoot().GetNbChildren()); // println(tree.getRoot()); tree.Insert(45, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 45")); AssertEquals(2, tree.GetRoot().GetNbChildren()); AssertEquals(1, tree.GetRoot().GetNbKeys()); AssertEquals(21, tree.GetRoot().GetKeyAt(0)); AssertEquals("[Value 21]", tree.GetRoot().GetValueAsObjectAt(0).ToString()); persister.Close(); odb = Open("btree45.neodatis"); storageEngine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(odb); persister = new NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister(storageEngine); tree = (NeoDatis.Btree.IBTreeMultipleValuesPerKey)persister.LoadBTree(tree.GetId( )); AssertEquals(6, tree.GetSize()); // println(tree.getRoot()); NeoDatis.Odb.Test.Btree.Odb.MyObject o = (NeoDatis.Odb.Test.Btree.Odb.MyObject)tree .Search(20)[0]; AssertEquals("Value 20", o.GetName()); o = (NeoDatis.Odb.Test.Btree.Odb.MyObject)tree.Search(29)[0]; AssertEquals("Value 29", o.GetName()); o = (NeoDatis.Odb.Test.Btree.Odb.MyObject)tree.Search(45)[0]; AssertEquals("Value 45", o.GetName()); odb.Close(); DeleteBase("btree45.neodatis"); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { if (!isLocal) { return; } DeleteBase("btree45.neodatis"); NeoDatis.Odb.ODB odb = Open("btree45.neodatis"); NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine storageEngine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(odb); NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister persister = new NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister (storageEngine); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple ("t", 3, persister); tree.Insert(1, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 1")); tree.Insert(20, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 20")); tree.Insert(25, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 25")); tree.Insert(29, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 29")); tree.Insert(21, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 21")); AssertEquals(5, tree.GetRoot().GetNbKeys()); AssertEquals(0, tree.GetRoot().GetNbChildren()); AssertEquals(21, tree.GetRoot().GetMedian().GetKey()); AssertEquals("[Value 21]", tree.GetRoot().GetMedian().GetValue().ToString()); AssertEquals(0, tree.GetRoot().GetNbChildren()); // println(tree.getRoot()); tree.Insert(45, new NeoDatis.Odb.Test.Btree.Odb.MyObject("Value 45")); AssertEquals(2, tree.GetRoot().GetNbChildren()); AssertEquals(1, tree.GetRoot().GetNbKeys()); AssertEquals(21, tree.GetRoot().GetKeyAt(0)); AssertEquals("[Value 21]", tree.GetRoot().GetValueAsObjectAt(0).ToString()); persister.Close(); odb = Open("btree45.neodatis"); storageEngine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(odb); persister = new NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister(storageEngine); tree = (NeoDatis.Btree.IBTreeMultipleValuesPerKey)persister.LoadBTree(tree.GetId( )); AssertEquals(6, tree.GetSize()); // println(tree.getRoot()); NeoDatis.Odb.Test.Btree.Odb.MyObject o = (NeoDatis.Odb.Test.Btree.Odb.MyObject)tree .Search(20)[0]; AssertEquals("Value 20", o.GetName()); o = (NeoDatis.Odb.Test.Btree.Odb.MyObject)tree.Search(29)[0]; AssertEquals("Value 29", o.GetName()); o = (NeoDatis.Odb.Test.Btree.Odb.MyObject)tree.Search(45)[0]; AssertEquals("Value 45", o.GetName()); odb.Close(); DeleteBase("btree45.neodatis"); }
/// <exception cref="System.Exception"></exception> public virtual void Test1a() { if (!isLocal) { return; } string baseName = GetBaseName(); // Configuration.setInPlaceUpdate(true); NeoDatis.Btree.IBTreePersister persister = GetPersister(baseName); NeoDatis.Btree.IBTree tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple("test1a" , 2, persister); for (int i = 0; i < Size; i++) { tree.Insert(i + 1, "value " + (i + 1)); } // println(new BTreeDisplay().build(tree,true).toString()); persister.Close(); persister = GetPersister(baseName); tree = persister.LoadBTree(tree.GetId()); // println(new BTreeDisplay().build(tree,true).toString()); AssertEquals(Size, tree.GetSize()); System.Collections.IEnumerator iterator = tree.Iterator(NeoDatis.Odb.Core.OrderByConstants .OrderByAsc); int j = 0; while (iterator.MoveNext()) { object o = iterator.Current; AssertEquals("value " + (j + 1), o); j++; if (j == Size) { AssertEquals("value " + Size, o); } } persister.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void Test2a() { if (!isLocal) { return; } string baseName = GetBaseName(); NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); // LogUtil.allOn(true); DeleteBase(baseName); NeoDatis.Btree.IBTreePersister persister = GetPersister(baseName); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple ("test2a", 20, persister); long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); for (int i = 0; i < Size; i++) { tree.Insert(i + 1, "value " + (i + 1)); } // println("Commiting"); persister.Close(); long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // println("insert of "+SIZE+" elements in BTREE = " + // (end0-start0)+"ms"); // println("end Commiting"); // println("updates : IP="+ObjectWriter.getNbInPlaceUpdates()+" , N="+ObjectWriter.getNbNormalUpdates()); // ODB odb = open(baseName); // odb.getObjects(LazyNode.class); // odb.close(); persister = GetPersister(baseName); // println("reloading btree"); tree = (NeoDatis.Btree.IBTreeMultipleValuesPerKey)persister.LoadBTree(tree.GetId( )); // println("end reloading btree , size="+tree.size()); AssertEquals(Size, tree.GetSize()); long totalSearchTime = 0; long oneSearchTime = 0; long minSearchTime = 10000; long maxSearchTime = -1; for (int i = 0; i < Size; i++) { long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); System.Collections.IList o = tree.Search(i + 1); long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); AssertEquals("value " + (i + 1), o[0]); oneSearchTime = (end - start); // println("Search time for "+o+" = "+oneSearchTime); if (oneSearchTime > maxSearchTime) { maxSearchTime = oneSearchTime; } if (oneSearchTime < minSearchTime) { minSearchTime = oneSearchTime; } totalSearchTime += oneSearchTime; } persister.Close(); // println("total search time="+totalSearchTime + // " - mean st="+((double)totalSearchTime/SIZE)); // println("min search time="+minSearchTime + " - max="+maxSearchTime); // Median search time must be smaller than 1ms DeleteBase(baseName); AssertTrue(totalSearchTime < 1 * Size); }
public virtual void Test2() { if (!isLocal) { return; } string baseName = GetBaseName(); NeoDatis.Btree.IBTreePersister persister = GetPersister(baseName); NeoDatis.Btree.IBTree tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple("test2" , 2, persister); for (int i = 0; i < Size; i++) { tree.Insert(i + 1, "value " + (i + 1)); } AssertEquals(Size, tree.GetSize()); System.Collections.IEnumerator iterator = tree.Iterator(NeoDatis.Odb.Core.OrderByConstants .OrderByDesc); int j = 0; while (iterator.MoveNext()) { object o = iterator.Current; // println(o); j++; if (j == Size) { AssertEquals("value " + 1, o); } } persister.Close(); DeleteBase(baseName); }
public virtual void Test2a() { if (!isLocal) { return; } string baseName = GetBaseName(); NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); // LogUtil.allOn(true); DeleteBase(baseName); NeoDatis.Btree.IBTreePersister persister = GetPersister(baseName); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple ("test2a", 20, persister); long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); for (int i = 0; i < Size; i++) { tree.Insert(i + 1, "value " + (i + 1)); } // println("Commiting"); persister.Close(); long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // println("insert of "+SIZE+" elements in BTREE = " + // (end0-start0)+"ms"); // println("end Commiting"); // println("updates : IP="+ObjectWriter.getNbInPlaceUpdates()+" , N="+ObjectWriter.getNbNormalUpdates()); // ODB odb = open(baseName); // odb.getObjects(LazyNode.class); // odb.close(); persister = GetPersister(baseName); // println("reloading btree"); tree = (NeoDatis.Btree.IBTreeMultipleValuesPerKey)persister.LoadBTree(tree.GetId( )); // println("end reloading btree , size="+tree.size()); AssertEquals(Size, tree.GetSize()); long totalSearchTime = 0; long oneSearchTime = 0; long minSearchTime = 10000; long maxSearchTime = -1; for (int i = 0; i < Size; i++) { long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); System.Collections.IList o = tree.Search(i + 1); long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); AssertEquals("value " + (i + 1), o[0]); oneSearchTime = (end - start); // println("Search time for "+o+" = "+oneSearchTime); if (oneSearchTime > maxSearchTime) { maxSearchTime = oneSearchTime; } if (oneSearchTime < minSearchTime) { minSearchTime = oneSearchTime; } totalSearchTime += oneSearchTime; } persister.Close(); // println("total search time="+totalSearchTime + // " - mean st="+((double)totalSearchTime/SIZE)); // println("min search time="+minSearchTime + " - max="+maxSearchTime); // Median search time must be smaller than 1ms DeleteBase(baseName); AssertTrue(totalSearchTime < 1 * Size); }
public virtual void Test1a() { if (!isLocal) { return; } string baseName = GetBaseName(); // Configuration.setInPlaceUpdate(true); NeoDatis.Btree.IBTreePersister persister = GetPersister(baseName); NeoDatis.Btree.IBTree tree = new NeoDatis.Odb.Impl.Core.Btree.ODBBTreeMultiple("test1a" , 2, persister); for (int i = 0; i < Size; i++) { tree.Insert(i + 1, "value " + (i + 1)); } // println(new BTreeDisplay().build(tree,true).toString()); persister.Close(); persister = GetPersister(baseName); tree = persister.LoadBTree(tree.GetId()); // println(new BTreeDisplay().build(tree,true).toString()); AssertEquals(Size, tree.GetSize()); System.Collections.IEnumerator iterator = tree.Iterator(NeoDatis.Odb.Core.OrderByConstants .OrderByAsc); int j = 0; while (iterator.MoveNext()) { object o = iterator.Current; AssertEquals("value " + (j + 1), o); j++; if (j == Size) { AssertEquals("value " + Size, o); } } persister.Close(); DeleteBase(baseName); }