コード例 #1
0
        protected internal static Operation CreateOperation(int command, Operation.Type type, string binName, CTX[] ctx)
        {
            Packer packer = new Packer();

            CDT.Init(packer, ctx, command, 0);
            return(new Operation(type, 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, 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())));
        }
コード例 #3
0
        /// <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)
        {
            Packer packer = new Packer();

            CDT.Init(packer, ctx, APPEND_ITEMS, 1);
            packer.PackList(list);
            return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #4
0
        /// <summary>
        /// Create default list append operation.
        /// Server appends value to end of list bin.
        /// Server returns list size.
        /// </summary>
        public static Operation Append(string binName, Value value, params CTX[] ctx)
        {
            Packer packer = new Packer();

            CDT.Init(packer, ctx, APPEND, 1);
            value.Pack(packer);
            return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #5
0
        /// <summary>
        /// Create default list insert items operation.
        /// Server inserts each input list item starting at specified index of list bin.
        /// Server returns list size.
        /// </summary>
        public static Operation InsertItems(string binName, int index, IList list, params CTX[] ctx)
        {
            Packer packer = new Packer();

            CDT.Init(packer, ctx, INSERT_ITEMS, 2);
            packer.PackNumber(index);
            packer.PackList(list);
            return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #6
0
        protected internal static Operation CreateOperation(int command, Operation.Type type, string binName, CTX[] ctx, int v1, IList v2)
        {
            Packer packer = new Packer();

            CDT.Init(packer, ctx, command, 2);
            packer.PackNumber(v1);
            packer.PackList(v2);
            return(new Operation(type, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #7
0
        /// <summary>
        /// Create list append items operation with policy.
        /// Server appends each input list item to list bin.
        /// Server returns list size.
        /// </summary>
        public static Operation AppendItems(ListPolicy policy, string binName, IList list, params CTX[] ctx)
        {
            Packer packer = new Packer();

            CDT.Init(packer, ctx, APPEND_ITEMS, 3);
            packer.PackList(list);
            packer.PackNumber(policy.attributes);
            packer.PackNumber(policy.flags);
            return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #8
0
        protected internal static Operation CreateOperation(int command, Operation.Type type, string binName, CTX[] ctx, Value v1, Value v2, int v3)
        {
            Packer packer = new Packer();

            CDT.Init(packer, ctx, command, 3);
            v1.Pack(packer);
            v2.Pack(packer);
            packer.PackNumber(v3);
            return(new Operation(type, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #9
0
        /// <summary>
        /// Create map create operation.
        /// Server creates map at given context level.
        /// </summary>
        public static Operation Create(string binName, MapOrder order, params CTX[] ctx)
        {
            // If context not defined, the set order for top-level bin map.
            if (ctx == null || ctx.Length == 0)
            {
                return(SetMapPolicy(new MapPolicy(order, MapWriteMode.UPDATE), binName));
            }

            Packer packer = new Packer();

            CDT.Init(packer, ctx, SET_TYPE, 1, CTX.GetFlag(order));
            packer.PackNumber((int)order);
            return(new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #10
0
        /// <summary>
        /// Create list create operation.
        /// Server creates list at given context level. The context is allowed to be beyond list
        /// boundaries only if pad is set to true.  In that case, nil list entries will be inserted to
        /// satisfy the context position.
        /// </summary>
        public static Operation Create(string binName, ListOrder order, bool pad, params CTX[] ctx)
        {
            // If context not defined, the set order for top-level bin list.
            if (ctx == null || ctx.Length == 0)
            {
                return(SetOrder(binName, order));
            }

            Packer packer = new Packer();

            CDT.Init(packer, ctx, SET_TYPE, 1, CTX.GetFlag(order, pad));
            packer.PackNumber((int)order);
            return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
コード例 #11
0
        protected internal static Operation CreateRangeOperation(int command, Operation.Type type, string binName, CTX[] ctx, Value begin, Value end, int returnType)
        {
            Packer packer = new Packer();

            if (begin == null)
            {
                begin = Value.AsNull;
            }

            if (end == null)
            {
                CDT.Init(packer, ctx, command, 2);
                packer.PackNumber(returnType);
                begin.Pack(packer);
            }
            else
            {
                CDT.Init(packer, ctx, command, 3);
                packer.PackNumber(returnType);
                begin.Pack(packer);
                end.Pack(packer);
            }
            return(new Operation(type, binName, Value.Get(packer.ToByteArray())));
        }