public void BulkStoreManyWithClient() { using (var svc = new ObjectService(ObjectTestHelper.GetConfig())) { var ns = ObjectTestHelper.NameSpace1; var obj = ObjectTestHelper.ObjectName1; svc.CreateNameSpace(new ObjectNameSpaceConfig(ns, "ZeroG Test", "Unit Test", DateTime.Now)); // stores the object's metadata and builds the database tables svc.ProvisionObjectStore( new ObjectMetadata(ns, obj, new ObjectIndexMetadata[] { new ObjectIndexMetadata("IntIndex1", ObjectIndexType.Integer), new ObjectIndexMetadata("StrIndex1", ObjectIndexType.String, 15) })); var client = new LocalObjectServiceClient(svc, ns, obj); var objCount = 50000; var random = new Random(); var buf = new byte[100]; BulkStore bulk = client.BeginBulkStore(); // generate a list of objects to store for (int i = 0; objCount > i; i++) { random.NextBytes(buf); bulk.Add(buf, new ObjectIndex[] { ObjectIndex.Create("IntIndex1", i + 100), ObjectIndex.Create("StrIndex1", "idx_" + i) }); } // Complete the operation and store and index the objects var ids = bulk.Complete(); Assert.AreEqual(objCount, ids.Count()); // query 100 objects from the index var vals = client.Find(@"{""IntIndex1"":10000, ""Op"": "">"", ""And"" : {""IntIndex1"":10101, ""Op"": ""<""}}"); Assert.AreEqual(100, vals.Count()); } }
public void BulkStoreWithClient() { using (var svc = new ObjectService(ObjectTestHelper.GetConfig())) { var ns = ObjectTestHelper.NameSpace1; var obj = ObjectTestHelper.ObjectName1; svc.CreateNameSpace(new ObjectNameSpaceConfig(ns, "ZeroG Test", "Unit Test", DateTime.Now)); svc.ProvisionObjectStore(new ObjectMetadata(ns, obj)); var client = new LocalObjectServiceClient(svc, ns, obj); var val1 = new Guid("{D22640F0-7D87-4F1C-8817-119FC036FAC1}"); var val2 = new Guid("{72FC1391-EC51-4826-890B-D02071A9A2DE}"); var val3 = new Guid("{72FC1391-EC51-4826-890B-D02071A9A2DE}"); var val2SecondaryKey = Encoding.UTF8.GetBytes("val2key"); BulkStore bulk = client.BeginBulkStore(); bulk.Add(12, val1.ToByteArray()); bulk.Add(val2SecondaryKey, val2.ToByteArray(), null); bulk.Add(500, val3.ToByteArray()); var ids = bulk.Complete().ToArray(); Assert.AreEqual(3, ids.Length); Assert.AreEqual(12, ids[0].ID); Assert.IsFalse(ids[0].HasSecondaryKey()); Assert.AreEqual(1, ids[1].ID); Assert.IsTrue(ids[1].HasSecondaryKey()); Assert.AreEqual(val2SecondaryKey, ids[1].SecondaryKey); Assert.AreEqual(500, ids[2].ID); Assert.IsFalse(ids[2].HasSecondaryKey()); Assert.AreEqual(val1, new Guid(client.Get(12))); Assert.AreEqual(val2, new Guid(client.Get(1))); Assert.AreEqual(val3, new Guid(client.Get(500))); Assert.AreEqual(val2, new Guid(client.GetBySecondaryKey(val2SecondaryKey))); Assert.AreEqual(3, client.Count()); } }