static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (Scheduler = new TaskScheduler(JobQueue.WindowsMessageBased)) using (ErrorList = new ErrorListDialog()) { Scheduler.ErrorHandler = OnTaskError; Preferences = new Tangle <object>( Scheduler, CreatePreferencesStorage() ); using (var f = Scheduler.Start(MainTask(), TaskExecutionPolicy.RunAsBackgroundTask)) { f.RegisterOnComplete((_) => { if (_.Failed) { Application.Exit(); } }); Application.Run(); } } }
public void TestSimpleJoin() { for (int i = 0; i < 8; i++) { Scheduler.WaitFor(Tangle.Set(i, i * 2)); } using (var otherTangle = new Tangle <int>(Scheduler, new SubStreamSource(Storage, "2_", false))) { var keys = new List <string>(); for (int i = 0; i < 8; i++) { var key = new String((char)('a' + i), 1); keys.Add(key); Scheduler.WaitFor(otherTangle.Set(key, i)); } var joinResult = Scheduler.WaitFor( otherTangle.Join( Tangle, keys, (leftValue) => leftValue ) ); for (int i = 0; i < 8; i++) { var item = joinResult[i]; Assert.AreEqual(i, item.Key); Assert.AreEqual(i * 2, item.Value); } } }
public override void SetUp() { base.SetUp(); Tangle = new Tangle <SpecialType>( Scheduler, Storage, ownsStorage: true ); }
protected IEnumerator <object> CheckLotsOfValues(Tangle <int> tangle, int numIterations) { for (int i = 0; i < numIterations; i++) { var f = tangle.Get(i); yield return(f); Assert.AreEqual(i, f.Result); } }
public override void SetUp() { base.SetUp(); Tangle = new Tangle <int>( Scheduler, Storage, serializer: BlittableSerializer <int> .Serialize, deserializer: BlittableSerializer <int> .Deserialize, ownsStorage: true ); }
public void TestKnotTangleIsContiguousFalse() { Knot knot = new Knot(new List <int>() { -1, 2, -3, 1, -2, 3, -4, 5, -6, 7, 8, 4, -5, 6, -7, -8 }); PrivateObject obj = new PrivateObject(knot); Tangle t = new Tangle(new int[] { 5, 6, 7 }); bool test = (bool)obj.Invoke("IsContiguousTangle", t); Assert.AreEqual(false, test); }
public void TestIsValidTangleFalse4() { Knot knot = new Knot(new List <int>() { 1, -2, 3, -1, 2, -3, 4, -4 }); Tangle tangle = new Tangle(new int[] { 3, 1 }); PrivateObject obj = new PrivateObject(knot); bool isValid = (bool)obj.Invoke("IsValidTangle", tangle); Assert.AreEqual(false, isValid); }
public void TestKnotEndsContiguousTangle() { Knot knot = new Knot(new List <int>() { -1, 2, -3, 1, -2, 3, -4, 5, -6, 7, 8, 4, -5, 6, -7, -8 }); PrivateObject obj = new PrivateObject(knot); Tangle t = new Tangle(new int[] { 1, 2, 3 }); int[] test = (int[])obj.Invoke("GetTangleEnds", t); Assert.AreEqual(2, test.Length); Assert.AreEqual(15, test[0]); Assert.AreEqual(6, test[1]); }
protected IEnumerator <object> WriteLotsOfValuesInBatch(Tangle <int> tangle, int numIterations, int direction) { int batchSize = 256; Batch <int> batch = null; if (direction > 0) { for (int i = 0; i < numIterations; i++) { if (batch == null) { batch = Tangle.CreateBatch(batchSize); } batch.Add(i, i); if (batch.Count == batchSize) { yield return(batch.Execute()); batch = null; } } } else { for (int i = numIterations - 1; i >= 0; i--) { if (batch == null) { batch = Tangle.CreateBatch(batchSize); } batch.Add(i, i); if (batch.Count == batchSize) { yield return(batch.Execute()); batch = null; } } } if (batch != null) { yield return(batch.Execute()); } }
public unsafe override void SetUp() { base.SetUp(); var serializer = new Squared.Data.Mangler.Serialization.StringSerializer( Encoding.UTF8 ); Tangle = new Tangle <string>( Scheduler, Storage, serializer: serializer.Serialize, deserializer: serializer.Deserialize, ownsStorage: true ); }
public void TestTangleHashOK() { Tangle t1 = new Tangle(new int[] { 2, -1, 3 }); Tangle t2 = new Tangle(new int[] { 1, -2, -3 }); Tangle t3 = new Tangle(new int[] { -1, 3, 2 }); Tangle t4 = new Tangle(new int[] { -1, -4, 3, 2, 4 }); int h1 = t1.Hash(); int h2 = t2.Hash(); int h3 = t3.Hash(); int h4 = t4.Hash(); Assert.AreEqual(h1, h2); Assert.AreEqual(h2, h3); Assert.AreEqual(h3, h4); }
public void TestCascadingSelect() { using (var otherTangle1 = new Tangle <int>(Scheduler, new SubStreamSource(Storage, "2_", false))) using (var otherTangle2 = new Tangle <int>(Scheduler, new SubStreamSource(Storage, "3_", false))) { Scheduler.WaitFor(Tangle.Set(1, 1)); Scheduler.WaitFor(otherTangle1.Set(2, 3)); Scheduler.WaitFor(otherTangle2.Set(2, 5)); Scheduler.WaitFor(otherTangle2.Set(3, 4)); var result = Scheduler.WaitFor(Tangle.CascadingSelect( new [] { otherTangle1, otherTangle2 }, new [] { 1, 2, 3, 4 } )); Assert.AreEqual(new [] { 1, 3, 4, default(int) }, result); } }
protected IEnumerator <object> WriteLotsOfValues(Tangle <int> tangle, int numIterations, int direction) { if (direction > 0) { for (int i = 0; i < numIterations; i++) { yield return(tangle.Set(i, i)); } } else { for (int i = numIterations - 1; i >= 0; i--) { yield return(tangle.Set(i, i)); } } }
public override void SetUp() { base.SetUp(); Tangle = new Tangle<object>(Scheduler, Storage); Serializer = new TanglePropertySerializer(Tangle); }
public override void SetUp() { base.SetUp(); Tangle = new Tangle<SpecialType>( Scheduler, Storage, ownsStorage: true ); }
public unsafe override void SetUp() { base.SetUp(); var serializer = new Squared.Data.Mangler.Serialization.StringSerializer( Encoding.UTF8 ); Tangle = new Tangle<string>( Scheduler, Storage, serializer: serializer.Serialize, deserializer: serializer.Deserialize, ownsStorage: true ); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (Scheduler = new TaskScheduler(JobQueue.WindowsMessageBased)) using (ErrorList = new ErrorListDialog()) { Scheduler.ErrorHandler = OnTaskError; Preferences = new Tangle<object>( Scheduler, CreatePreferencesStorage() ); using (var f = Scheduler.Start(MainTask(), TaskExecutionPolicy.RunAsBackgroundTask)) { f.RegisterOnComplete((_) => { if (_.Failed) Application.Exit(); }); Application.Run(); } } }
public void TestCascadingSelect() { using (var otherTangle1 = new Tangle<int>(Scheduler, new SubStreamSource(Storage, "2_", false))) using (var otherTangle2 = new Tangle<int>(Scheduler, new SubStreamSource(Storage, "3_", false))) { Scheduler.WaitFor(Tangle.Set(1, 1)); Scheduler.WaitFor(otherTangle1.Set(2, 3)); Scheduler.WaitFor(otherTangle2.Set(2, 5)); Scheduler.WaitFor(otherTangle2.Set(3, 4)); var result = Scheduler.WaitFor(Tangle.CascadingSelect( new [] { otherTangle1, otherTangle2 }, new [] { 1, 2, 3, 4 } )); Assert.AreEqual(new [] { 1, 3, 4, default(int) }, result); } }
public void TestSimpleJoin() { for (int i = 0; i < 8; i++) Scheduler.WaitFor(Tangle.Set(i, i * 2)); using (var otherTangle = new Tangle<int>(Scheduler, new SubStreamSource(Storage, "2_", false))) { var keys = new List<string>(); for (int i = 0; i < 8; i++) { var key = new String((char)('a' + i), 1); keys.Add(key); Scheduler.WaitFor(otherTangle.Set(key, i)); } var joinResult = Scheduler.WaitFor( otherTangle.Join( Tangle, keys, (leftValue) => leftValue ) ); for (int i = 0; i < 8; i++) { var item = joinResult[i]; Assert.AreEqual(i, item.Key); Assert.AreEqual(i * 2, item.Value); } } }
public override void SetUp() { base.SetUp(); Tangle = new Tangle <object>(Scheduler, Storage); Serializer = new TanglePropertySerializer(Tangle); }
protected IEnumerator<object> CheckLotsOfValues(Tangle<int> tangle, int numIterations) { for (int i = 0; i < numIterations; i++) { var f = tangle.Get(i); yield return f; Assert.AreEqual(i, f.Result); } }
protected IEnumerator<object> WriteLotsOfValues(Tangle<int> tangle, int numIterations, int direction) { if (direction > 0) for (int i = 0; i < numIterations; i++) { yield return tangle.Set(i, i); } else for (int i = numIterations - 1; i >= 0; i--) { yield return tangle.Set(i, i); } }
protected IEnumerator<object> WriteLotsOfValuesInBatch(Tangle<int> tangle, int numIterations, int direction) { int batchSize = 256; Batch<int> batch = null; if (direction > 0) for (int i = 0; i < numIterations; i++) { if (batch == null) batch = Tangle.CreateBatch(batchSize); batch.Add(i, i); if (batch.Count == batchSize) { yield return batch.Execute(); batch = null; } } else for (int i = numIterations - 1; i >= 0; i--) { if (batch == null) batch = Tangle.CreateBatch(batchSize); batch.Add(i, i); if (batch.Count == batchSize) { yield return batch.Execute(); batch = null; } } if (batch != null) yield return batch.Execute(); }
public override void SetUp() { base.SetUp(); Tangle = new Tangle<int>( Scheduler, Storage, serializer: BlittableSerializer<int>.Serialize, deserializer: BlittableSerializer<int>.Deserialize, ownsStorage: true ); }