public void CompareInt16() { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); AllSupported obj = new AllSupported(1); CompareByField <AllSupported> compareByField = new CompareByField <AllSupported>("int16", session); BTreeSet <AllSupported> sortedSet = new BTreeSet <AllSupported>(compareByField, session, 1000, sizeof(Int16), true); for (int i = 0; i < 100000; i++) { obj = new AllSupported(1); obj.int16 = (Int16)randGen.Next(Int16.MinValue, Int16.MaxValue); sortedSet.Add(obj); } int ct = 0; AllSupported prior = null; foreach (AllSupported currentObj in (IEnumerable <AllSupported>)sortedSet) { if (prior != null) { Assert.Less(prior.int16, currentObj.int16); } prior = currentObj; ct++; } session.Commit(); } }
public void CompareInt64() { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); AllSupported obj = new AllSupported(2, session); CompareByField <AllSupported> compareByField = new CompareByField <AllSupported>("int64", session); BTreeSet <AllSupported> sortedSet = new BTreeSet <AllSupported>(compareByField, session, 1000, sizeof(Int64), true); for (int i = 0; i < 100000; i++) { obj = new AllSupported(1, session); obj.int64 = randGen.Next(Int32.MinValue, Int32.MaxValue) * randGen.Next(); sortedSet.Add(obj); } int ct = 0; //foreach (AllSupported currentObj in (IEnumerable<AllSupported>)sortedSet) // { // Console.WriteLine(currentObj.int32); // ct++; // } AllSupported prior = null; ct = 0; foreach (AllSupported currentObj in (IEnumerable <AllSupported>)sortedSet) { if (prior != null) { Assert.Less(prior.int64, currentObj.int64); } prior = currentObj; ct++; } session.Commit(); } }
public void CompareDateTime() { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); AllSupported obj; CompareByField <AllSupported> compareByField = new CompareByField <AllSupported>("dateTime", session); BTreeSet <AllSupported> sortedSet = new BTreeSet <AllSupported>(compareByField, session, 1000, sizeof(long), true); for (int i = 0; i < 20000; i++) { obj = new AllSupported(1); obj.dateTime = DateTime.FromBinary(randGen.Next(Int32.MinValue, Int32.MaxValue) * randGen.Next()); sortedSet.Add(obj); } int ct = 0; AllSupported prior = null; foreach (AllSupported currentObj in (IEnumerable <AllSupported>)sortedSet) { if (prior != null) { Assert.Less(prior.dateTime, currentObj.dateTime); } prior = currentObj; ct++; } session.Commit(); } }
public void CompareInt32DescendingComparisonArray() { #if DEBUG Assert.Throws <NotImplementedException>(() => { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); AllSupported obj = new AllSupported(2); CompareByField <AllSupported> compareByField = new CompareByField <AllSupported>("int32", session, false, false, false); BTreeSet <AllSupported> sortedSet = new BTreeSet <AllSupported>(compareByField, session, 1000, sizeof(Int32), true); for (int i = 0; i < 100000; i++) { obj = new AllSupported(1); obj.int32 = randGen.Next(Int32.MinValue, Int32.MaxValue); sortedSet.Add(obj); } int ct = 0; AllSupported prior = null; foreach (AllSupported currentObj in (IEnumerable <AllSupported>)sortedSet) { if (prior != null) { Assert.Greater(prior.int32, currentObj.int32); } prior = currentObj; ct++; } session.Commit(); } }); #endif }
public void CompareInt32Descending() { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); AllSupported obj = new AllSupported(2, session); CompareByField <AllSupported> compareByField = new CompareByField <AllSupported>("int32", session, false, false, false); BTreeSet <AllSupported> sortedSet = new BTreeSet <AllSupported>(compareByField, session, 1000); for (int i = 0; i < 100000; i++) { obj = new AllSupported(1, session); obj.int32 = randGen.Next(Int32.MinValue, Int32.MaxValue); sortedSet.Add(obj); } int ct = 0; AllSupported prior = null; foreach (AllSupported currentObj in (IEnumerable <AllSupported>)sortedSet) { if (prior != null) { Assert.Greater(prior.int32, currentObj.int32); } prior = currentObj; ct++; } session.Commit(); } }
static int Main(string[] args) { UInt64 id; AllSupported allSupported, allSupported2; AllSuportedSub4 sub4; try { using (SessionNoServer session = new SessionNoServer(s_systemDir)) { Console.WriteLine("Running with databases in directory: " + session.SystemDirectory); session.BeginUpdate(); File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"), true); sub4 = new AllSuportedSub4(); session.Persist(sub4); id = sub4.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(s_systemDir)) { session.BeginRead(); sub4 = (AllSuportedSub4)session.Open(id); session.Commit(); } using (SessionNoServer session = new SessionNoServer(s_systemDir)) { session.BeginUpdate(); allSupported = new AllSupported(3); session.Persist(allSupported); id = allSupported.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(s_systemDir)) { session.BeginRead(); allSupported2 = (AllSupported)session.Open(id); session.Commit(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(1); } return(0); }
public void CompareString(int compArraySize) { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); AllSupported obj = new AllSupported(1, session); CompareByField <AllSupported> compareByField = new CompareByField <AllSupported>("aString", session); BTreeSet <AllSupported> sortedSet = new BTreeSet <AllSupported>(compareByField, session, 1000, (ushort)compArraySize); session.Persist(sortedSet); for (int i = 0; i < 11000; i++) { obj = new AllSupported(1, session); obj.aString = RandomString(10); sortedSet.AddFast(obj); } obj = new AllSupported(1, session); obj.aString = null; session.Persist(obj); sortedSet.Add(obj); int ct = 0; AllSupported prior = null; foreach (AllSupported currentObj in (IEnumerable <AllSupported>)sortedSet) { if (prior != null) { if (prior.aString != null) { if (currentObj.aString == null) { Assert.Fail("Null is < than a non NULL"); } else { Assert.Less(prior.aString, currentObj.aString); } } } prior = currentObj; ct++; } session.Commit(); } }
public void CompareDouble(bool completeKey) { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); AllSupported obj = new AllSupported(1); CompareByField <AllSupported> compareByField = new CompareByField <AllSupported>("aDouble", session); BTreeSet <AllSupported> sortedSet = new BTreeSet <AllSupported>(compareByField, session, 1000, sizeof(double), completeKey); List <AllSupported> toRemove = new List <AllSupported>(); for (int i = 0; i < 100000; i++) { obj = new AllSupported(1); obj.aDouble = (randGen.NextDouble() - randGen.NextDouble()) * randGen.Next(UInt16.MinValue, UInt16.MaxValue); if (i % 3500 == 0) { toRemove.Add(obj); } sortedSet.Add(obj); } session.Commit(); session.BeginUpdate(); foreach (AllSupported r in toRemove) { sortedSet.Remove(r); } int ct = 0; AllSupported prior = null; foreach (AllSupported currentObj in (IEnumerable <AllSupported>)sortedSet) { if (prior != null) { Assert.Less(prior.aDouble, currentObj.aDouble); } prior = currentObj; ct++; } session.Commit(); } }
// [Test] public void Azure() { UInt64 id = 42949738497; AllSupported allSuported, allSupported2; string connectionString = null; using (StreamReader sr = new StreamReader("c:/AzureConnectionString.txt")) { connectionString = sr.ReadToEnd(); } // A better way of using Azure files is to mount cloud directory as a local drive. // Such as: net use f: \\veleocitydb.file.core.windows.net\azure /u:veleocitydb [access key] // Add access key and update for your case. // Then you can use the mounted Azure directory just like you use any local drive! /*using (SessionBase session = new SessionNoServer("v:/azure", 99999, false)) * { * session.BeginUpdate(); * allSuported = new AllSupported(3); * allSuported.Persist(session, allSuported); * id = allSuported.Id; * session.Commit(); * } * * using (SessionNoServer session = new SessionNoServer("v:/azure", 99999, false)) * { * session.BeginRead(); * allSupported2 = (AllSupported)session.Open(id); * session.Commit(); * }*/ using (SessionBase session = new AzureSession(connectionString, "azure", "azure", 99999, false)) { session.BeginUpdate(); allSuported = new AllSupported(3, session); session.Persist(allSuported); id = allSuported.Id; session.Commit(); } using (SessionNoServer session = new AzureSession(connectionString, "azure", "azure", 99999, false)) { session.BeginRead(); allSupported2 = (AllSupported)session.Open(id); Assert.NotNull(allSupported2); session.Commit(); } /* Not yet working. Challenge is that an Azure Stream can only be Read only or Update only - not both. Another challenge is required calls to Flush() and resizing of files have to be explicit. * * using (SessionBase session = new AzureSession(connectionString, "azure", "azure", 99999, true)) * { * session.BeginUpdate(); * foreach (Database db in session.OpenAllDatabases(true)) * if (db.DatabaseNumber >= 10 || db.DatabaseNumber == SessionBase.IndexDescriptorDatabaseNumber) * session.DeleteDatabase(db); * session.Commit(); * session.BeginUpdate(); * DatabaseLocation defaultLocation = session.DatabaseLocations.Default(); * List<Database> dbList = session.OpenLocationDatabases(defaultLocation, true); * foreach (Database db in dbList) * if (db.DatabaseNumber > Database.InitialReservedDatabaseNumbers) * session.DeleteDatabase(db); * session.DeleteLocation(defaultLocation); * session.Commit(); * }*/ }
public void AllSupported() { UInt64 id; AllSupported allSuported, allSupported2; AllSuportedSub1 allSuportedSub1, allSuportedSub2; AllSuportedSub2 allSuportedSub2_1, allSuportedSub2_2; AllSuportedSub3 allSuportedSub3_1, allSuportedSub3_2; AllSuportedSub4 allSuportedSub4; AllSupported[,] a1 = new AllSupported[10, 5]; AllSupported[,,] a2 = new AllSupported[8, 4, 3]; AllSupported[,,,] a3 = new AllSupported[7, 6, 2, 1]; Dictionary <int, string>[,,] a4 = new Dictionary <int, string> [2, 4, 33]; string s1str = DataMember.TypeToString(a1.GetType()); string s2str = DataMember.TypeToString(a2.GetType()); string s3str = DataMember.TypeToString(a3.GetType()); string s4str = DataMember.TypeToString(a4.GetType()); bool typeUpdated; using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); Type t1 = DataMember.StringToType(s1str, session, out typeUpdated); Type t2 = DataMember.StringToType(s2str, session, out typeUpdated); Type t3 = DataMember.StringToType(s3str, session, out typeUpdated); Type t4 = DataMember.StringToType(s4str, session, out typeUpdated); Assert.AreEqual(t1, a1.GetType()); Assert.AreEqual(t2, a2.GetType()); Assert.AreEqual(t3, a3.GetType()); Assert.AreEqual(t4, a4.GetType()); allSuportedSub4 = new AllSuportedSub4(); session.Persist(allSuportedSub4); id = allSuportedSub4.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub4 = (AllSuportedSub4)session.Open(id); Assert.NotNull(allSuportedSub4); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub1 = new AllSuportedSub1(3); allSuportedSub1.Persist(session, allSuportedSub1); foreach (var o in allSuportedSub1.PetListOidShort) { session.Persist(o, allSuportedSub1); } id = allSuportedSub1.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub2 = (AllSuportedSub1)session.Open(id); Assert.NotNull(allSuportedSub2); Assert.AreEqual(allSuportedSub2.m_type[0], typeof(Pet)); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub2_1 = new AllSuportedSub2(3); allSuportedSub2_1.Persist(session, allSuportedSub2_1); id = allSuportedSub2_1.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub2_2 = (AllSuportedSub2)session.Open(id); Assert.NotNull(allSuportedSub2_2); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub3_1 = new AllSuportedSub3(3); allSuportedSub3_1.Persist(session, allSuportedSub3_1); id = allSuportedSub3_1.Id; session.Commit(); } using (var session = new SessionNoServerShared(systemDir)) { session.BeginRead(); allSuportedSub3_2 = (AllSuportedSub3)session.Open(id); Assert.NotNull(allSuportedSub3_2); session.Commit(); } using (var session = new SessionNoServer(systemDir)) { session.BeginUpdate(); var x = new AllSuportedSub5(); session.Persist(x); id = x.Id; session.Commit(); } using (var session = new SessionNoServer(systemDir)) { session.BeginUpdate(); var x = (AllSuportedSub5)session.Open(id); x.Update(); x.nullableaDouble = 0.5; session.Commit(); } using (var session = new SessionNoServer(systemDir)) { session.BeginUpdate(); var x = new AllSuportedSub6(); session.Persist(x); id = x.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); var x = (AllSuportedSub6)session.Open(id); x.Update(); session.Commit(); } using (var session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuported = new AllSupported(3, session); allSuported.Persist(session, allSuported); allSuported.m_weakRefArray[0] = new WeakIOptimizedPersistableReference <IOptimizedPersistable>(allSuported); allSuported.m_objectArray[0] = new WeakIOptimizedPersistableReference <IOptimizedPersistable>(allSuported); id = allSuported.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSupported2 = (AllSupported)session.Open(id); allSupported2.Update(); allSupported2.nullableaDouble = 0.5; allSupported2.NullableDateTime = DateTime.MaxValue; allSupported2 = null; session.Commit(); } using (var session = new SessionNoServer(systemDir)) { session.BeginRead(); allSupported2 = (AllSupported)session.Open(id); Assert.NotNull(allSupported2); Assert.AreEqual(allSupported2.nullableaDouble, 0.5); Assert.AreEqual(allSupported2.NullableDateTime, DateTime.MaxValue); session.Commit(); session.BeginUpdate(); allSupported2.NullableDateTime = DateTime.UtcNow; session.Commit(); session.BeginRead(); allSupported2 = (AllSupported)session.Open(id); Assert.AreEqual(DateTimeKind.Utc, allSupported2.NullableDateTime.Value.Kind); session.Commit(); } }
public void AllSupported() { UInt64 id; AllSupported allSuported, allSupported2; AllSuportedSub1 allSuportedSub1, allSuportedSub2; AllSuportedSub2 allSuportedSub2_1, allSuportedSub2_2; AllSuportedSub3 allSuportedSub3_1, allSuportedSub3_2; using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub1 = new AllSuportedSub1(3); allSuportedSub1.Persist(session, allSuportedSub1); id = allSuportedSub1.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub2 = (AllSuportedSub1)session.Open(id); Assert.NotNull(allSuportedSub2); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub2_1 = new AllSuportedSub2(3); allSuportedSub2_1.Persist(session, allSuportedSub2_1); id = allSuportedSub2_1.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub2_2 = (AllSuportedSub2)session.Open(id); Assert.NotNull(allSuportedSub2_2); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub3_1 = new AllSuportedSub3(3); allSuportedSub3_1.Persist(session, allSuportedSub3_1); id = allSuportedSub3_1.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub3_2 = (AllSuportedSub3)session.Open(id); Assert.NotNull(allSuportedSub3_2); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); var x = new AllSuportedSub5(); session.Persist(x); id = x.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); var x = (AllSuportedSub5)session.Open(id); x.Update(); x.nullableaDouble = 0.5; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); var x = (AllSuportedSub5)session.Open(id); Assert.NotNull(x); Assert.AreEqual(x.nullableaDouble, 0.5); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuported = new AllSupported(3); allSuported.Persist(session, allSuported); id = allSuported.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSupported2 = (AllSupported)session.Open(id); allSupported2.Update(); allSupported2.nullableaDouble = 0.5; allSupported2.nullabledateTime = DateTime.MaxValue; allSupported2 = null; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSupported2 = (AllSupported)session.Open(id); Assert.NotNull(allSupported2); Assert.AreEqual(allSupported2.nullableaDouble, 0.5); Assert.AreEqual(allSupported2.nullabledateTime, DateTime.MaxValue); session.Commit(); } }
public void AllSupported() { UInt64 id; AllSupported allSuported, allSupported2; AllSuportedSub1 allSuportedSub1, allSuportedSub2; AllSuportedSub2 allSuportedSub2_1, allSuportedSub2_2; AllSuportedSub3 allSuportedSub3_1, allSuportedSub3_2; using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub1 = new AllSuportedSub1(3); allSuportedSub1.Persist(session, allSuportedSub1); id = allSuportedSub1.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub2 = (AllSuportedSub1)session.Open(id); Assert.NotNull(allSuportedSub2); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub2_1 = new AllSuportedSub2(3); allSuportedSub2_1.Persist(session, allSuportedSub2_1); id = allSuportedSub2_1.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub2_2 = (AllSuportedSub2)session.Open(id); Assert.NotNull(allSuportedSub2_2); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuportedSub3_1 = new AllSuportedSub3(3); allSuportedSub3_1.Persist(session, allSuportedSub3_1); id = allSuportedSub3_1.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSuportedSub3_2 = (AllSuportedSub3)session.Open(id); Assert.NotNull(allSuportedSub3_2); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); var x = new AllSuportedSub5(); session.Persist(x); id = x.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); var x = (AllSuportedSub5)session.Open(id); x.Update(); x.nullableaDouble = 0.5; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); var x = (AllSuportedSub5)session.Open(id); Assert.NotNull(x); Assert.AreEqual(x.nullableaDouble, 0.5); session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSuported = new AllSupported(3); allSuported.Persist(session, allSuported); allSuported.m_weakRefArray[0] = new WeakIOptimizedPersistableReference <IOptimizedPersistable>(allSuported); allSuported.m_objectArray[0] = new WeakIOptimizedPersistableReference <IOptimizedPersistable>(allSuported); id = allSuported.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); allSupported2 = (AllSupported)session.Open(id); allSupported2.Update(); allSupported2.nullableaDouble = 0.5; allSupported2.NullableDateTime = DateTime.MaxValue; allSupported2 = null; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginRead(); allSupported2 = (AllSupported)session.Open(id); Assert.NotNull(allSupported2); Assert.AreEqual(allSupported2.nullableaDouble, 0.5); Assert.AreEqual(allSupported2.NullableDateTime, DateTime.MaxValue); session.Commit(); session.BeginUpdate(); allSupported2.NullableDateTime = DateTime.UtcNow; session.Commit(); session.BeginRead(); allSupported2 = (AllSupported)session.Open(id); Assert.AreEqual(DateTimeKind.Utc, allSupported2.NullableDateTime.Value.Kind); session.Commit(); } }