コード例 #1
0
        /// <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 <seealso 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)
            {
                CDT.Init(packer, ctx, PUT_ITEMS, 3);
                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.
                    CDT.Init(packer, ctx, policy.itemsCommand, 1);
                    packer.PackMap(map);
                }
                else
                {
                    CDT.Init(packer, ctx, policy.itemsCommand, 2);
                    packer.PackMap(map);
                    packer.PackNumber(policy.attributes);
                }
            }
            return(new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #2
0
        /// <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 <seealso cref="Aerospike.Client.MapPolicy"/>.
        /// </para>
        /// </summary>
        public static Operation PutItems(MapPolicy policy, string binName, IDictionary map)
        {
            Packer packer = new Packer();

            if (policy.flags != 0)
            {
                packer.PackRawShort(PUT_ITEMS);
                packer.PackArrayBegin(3);
                packer.PackMap(map);
                packer.PackNumber(policy.attributes);
                packer.PackNumber(policy.flags);
            }
            else
            {
                packer.PackRawShort(policy.itemsCommand);

                if (policy.itemsCommand == REPLACE_ITEMS)
                {
                    // Replace doesn't allow map attributes because it does not create on non-existing key.
                    packer.PackArrayBegin(1);
                    packer.PackMap(map);
                }
                else
                {
                    packer.PackArrayBegin(2);
                    packer.PackMap(map);
                    packer.PackNumber(policy.attributes);
                }
            }
            return(new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #3
0
        public static byte[] Pack(IDictionary val)
        {
            Packer packer = new Packer();

            packer.PackMap(val);
            return(packer.ToByteArray());
        }
コード例 #4
0
 public static byte[] Pack(IDictionary val)
 {
     Packer packer = new Packer();
     packer.PackMap(val);
     return packer.ToByteArray();
 }
コード例 #5
0
        /// <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 mode used when writing items to the map.
        /// See policy <seealso cref="Aerospike.Client.MapPolicy"/> and write mode 
        /// <seealso cref="Aerospike.Client.MapWriteMode"/>.
        /// </para>
        /// </summary>
        public static Operation PutItems(MapPolicy policy, string binName, IDictionary map)
        {
            Packer packer = new Packer();
            packer.PackRawShort(policy.itemsCommand);

            if (policy.itemsCommand == MapBase.REPLACE_ITEMS)
            {
                // Replace doesn't allow map attributes because it does not create on non-existing key.
                packer.PackArrayBegin(1);
                packer.PackMap(map);
            }
            else
            {
                packer.PackArrayBegin(2);
                packer.PackMap(map);
                packer.PackNumber(policy.attributes);
            }
            return new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray()));
        }
コード例 #6
0
 public override void Pack(Packer packer)
 {
     packer.PackMap(map);
 }
コード例 #7
0
 public override void Pack(Packer packer)
 {
     packer.PackMap(map);
 }