/// <summary> /// Create map put items operation /// Server writes each map item to map bin and returns map size. /// <para> /// The required map policy dictates the type of map to create when it does not exist. /// The map policy also specifies the flags used when writing items to the map. /// See policy <see cref="Aerospike.Client.MapPolicy"/>. /// </para> /// </summary> public static Operation PutItems(MapPolicy policy, string binName, IDictionary map, params CTX[] ctx) { Packer packer = new Packer(); if (policy.flags != 0) { PackUtil.Init(packer, ctx); packer.PackArrayBegin(4); packer.PackNumber(MapOperation.PUT_ITEMS); packer.PackMap(map); packer.PackNumber(policy.attributes); packer.PackNumber(policy.flags); } else { if (policy.itemsCommand == REPLACE_ITEMS) { // Replace doesn't allow map attributes because it does not create on non-existing key. PackUtil.Init(packer, ctx); packer.PackArrayBegin(2); packer.PackNumber(policy.itemsCommand); packer.PackMap(map); } else { PackUtil.Init(packer, ctx); packer.PackArrayBegin(3); packer.PackNumber(policy.itemsCommand); packer.PackMap(map); packer.PackNumber(policy.attributes); } } byte[] bytes = packer.ToByteArray(); return(new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(bytes))); }
/// <summary> /// Create default list append items operation. /// Server appends each input list item to end of list bin. /// Server returns list size. /// </summary> public static Operation AppendItems(string binName, IList list, params CTX[] ctx) { // Compiler bug prevents calling of this method. // byte[] bytes = PackUtil.Pack(ListOperation.APPEND_ITEMS, list, ctx); // Duplicate method instead. Packer packer = new Packer(); PackUtil.Init(packer, ctx); packer.PackArrayBegin(2); packer.PackNumber(ListOperation.APPEND_ITEMS); packer.PackList(list); byte[] bytes = packer.ToByteArray(); return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes))); }
internal static byte[] PackRangeOperation(int command, int returnType, Value begin, Value end, CTX[] ctx) { Packer packer = new Packer(); PackUtil.Init(packer, ctx); packer.PackArrayBegin((end != null) ? 4 : 3); packer.PackNumber(command); packer.PackNumber(returnType); if (begin != null) { begin.Pack(packer); } else { packer.PackNil(); } if (end != null) { end.Pack(packer); } return(packer.ToByteArray()); }