public void OperateMapClear() { // Test clear. if (!args.ValidateMap()) { return; } Key key = new Key(args.ns, args.set, "opmkey9"); client.Delete(null, key); Dictionary <Value, Value> inputMap = new Dictionary <Value, Value>(); inputMap[Value.Get("Charlie")] = Value.Get(55); inputMap[Value.Get("Jim")] = Value.Get(98); Record record = client.Operate(null, key, MapOperation.PutItems(MapPolicy.Default, binName, inputMap)); AssertRecordFound(key, record); long size = record.GetLong(binName); Assert.AreEqual(2, size); record = client.Operate(null, key, MapOperation.Clear(binName), MapOperation.Size(binName) ); IList results = record.GetList(binName); size = (long)results[1]; Assert.AreEqual(0, size); }
public void OperateMapRemove() { // Test remove. Key key = new Key(args.ns, args.set, "opmkey7"); client.Delete(null, key); Dictionary <Value, Value> inputMap = new Dictionary <Value, Value>(); inputMap[Value.Get("Charlie")] = Value.Get(55); inputMap[Value.Get("Jim")] = Value.Get(98); inputMap[Value.Get("John")] = Value.Get(76); inputMap[Value.Get("Harry")] = Value.Get(82); inputMap[Value.Get("Sally")] = Value.Get(79); inputMap[Value.Get("Lenny")] = Value.Get(84); inputMap[Value.Get("Abe")] = Value.Get(88); List <Value> removeItems = new List <Value>(); removeItems.Add(Value.Get("Sally")); removeItems.Add(Value.Get("UNKNOWN")); removeItems.Add(Value.Get("Lenny")); Record record = client.Operate(null, key, MapOperation.PutItems(MapPolicy.Default, binName, inputMap), MapOperation.RemoveByKey(binName, Value.Get("NOTFOUND"), MapReturnType.VALUE), MapOperation.RemoveByKey(binName, Value.Get("Jim"), MapReturnType.VALUE), MapOperation.RemoveByKeyList(binName, removeItems, MapReturnType.COUNT), MapOperation.RemoveByValue(binName, Value.Get(55), MapReturnType.KEY), MapOperation.Size(binName)); AssertRecordFound(key, record); IList results = record.GetList(binName); int i = 0; long val = (long)results[i++]; Assert.AreEqual(7, val); object obj = results[i++]; Assert.IsNull(obj); val = (long)results[i++]; Assert.AreEqual(98, val); val = (long)results[i++]; Assert.AreEqual(2, val); IList list = (IList)results[i++]; Assert.AreEqual(1, list.Count); Assert.AreEqual("Charlie", (string)list[0]); val = (long)results[i++]; Assert.AreEqual(3, val); }
private void RunSimpleExample(AerospikeClient client, Arguments args) { Key key = new Key(args.ns, args.set, "mapkey"); string binName = args.GetBinName("mapbin"); // Delete record if it already exists. client.Delete(args.writePolicy, key); IDictionary inputMap = new Dictionary <Value, Value>(); inputMap[Value.Get(1)] = Value.Get(55); inputMap[Value.Get(2)] = Value.Get(33); // Write values to empty map. Record record = client.Operate(args.writePolicy, key, MapOperation.PutItems(MapPolicy.Default, binName, inputMap)); console.Info("Record: " + record); // Pop value from map and also return new size of map. record = client.Operate(args.writePolicy, key, MapOperation.RemoveByKey(binName, Value.Get(1), MapReturnType.VALUE), MapOperation.Size(binName)); console.Info("Record: " + record); // There should be one result for each map operation on the same map bin. // In this case, there are two map operations (pop and size), so there // should be two results. IList results = record.GetList(binName); foreach (object value in results) { console.Info("Received: " + value); } }