示例#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())));
        }
        /// <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
        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())));
        }
示例#6
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())));
        }
示例#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())));
        }
        /// <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())));
        }
 /// <summary>
 /// Create map size operation.
 /// Server returns size of map.
 /// </summary>
 public static Operation Size(string binName, params CTX[] ctx)
 {
     return(CDT.CreateOperation(SIZE, Operation.Type.MAP_READ, binName, ctx));
 }
 /// <summary>
 /// Create map remove operation.
 /// Server removes "count" map items starting at specified rank and returns removed data specified by returnType.
 /// </summary>
 public static Operation RemoveByRankRange(string binName, int rank, int count, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(REMOVE_BY_RANK_RANGE, Operation.Type.MAP_MODIFY, binName, ctx, (int)returnType, rank, count));
 }
 /// <summary>
 /// Create map remove operation.
 /// Server removes map items starting at specified index to the end of map and returns removed
 /// data specified by returnType.
 /// </summary>
 public static Operation RemoveByIndexRange(string binName, int index, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(REMOVE_BY_INDEX_RANGE, Operation.Type.MAP_MODIFY, binName, ctx, (int)returnType, index));
 }
 /// <summary>
 /// Create map remove operation.
 /// Server removes map items identified by value range (valueBegin inclusive, valueEnd exclusive).
 /// If valueBegin is null, the range is less than valueEnd.
 /// If valueEnd is null, the range is greater than equal to valueBegin.
 /// <para>
 /// Server returns removed data specified by returnType.
 /// </para>
 /// </summary>
 public static Operation RemoveByValueRange(string binName, Value valueBegin, Value valueEnd, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateRangeOperation(REMOVE_BY_VALUE_INTERVAL, Operation.Type.MAP_MODIFY, binName, ctx, valueBegin, valueEnd, (int)returnType));
 }
 /// <summary>
 /// Create map get by index range operation.
 /// Server selects "count" map items starting at specified index and returns selected data specified by returnType.
 /// </summary>
 public static Operation GetByIndexRange(string binName, int index, int count, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(GET_BY_INDEX_RANGE, Operation.Type.MAP_READ, binName, ctx, (int)returnType, index, count));
 }
 /// <summary>
 /// Create map get by value list operation.
 /// Server selects map items identified by values and returns selected data specified by returnType.
 /// </summary>
 public static Operation GetByValueList(string binName, IList values, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(GET_BY_VALUE_LIST, Operation.Type.MAP_READ, binName, ctx, (int)returnType, values));
 }
 /// <summary>
 /// Create map get by value operation.
 /// Server selects map items identified by value and returns selected data specified by returnType.
 /// </summary>
 public static Operation GetByValue(string binName, Value value, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(GET_BY_VALUE, Operation.Type.MAP_READ, binName, ctx, (int)returnType, value));
 }
 /// <summary>
 /// Create map get by key list operation.
 /// Server selects map items identified by keys and returns selected data specified by returnType.
 /// </summary>
 public static Operation GetByKeyList(string binName, IList keys, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(GET_BY_KEY_LIST, Operation.Type.MAP_READ, binName, ctx, (int)returnType, keys));
 }
 /// <summary>
 /// Create map get by key operation.
 /// Server selects map item identified by key and returns selected data specified by returnType.
 /// </summary>
 public static Operation GetByKey(string binName, Value key, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(GET_BY_KEY, Operation.Type.MAP_READ, binName, ctx, (int)returnType, key));
 }
 /// <summary>
 /// Create map get by key range operation.
 /// Server selects map items identified by key range (keyBegin inclusive, keyEnd exclusive).
 /// If keyBegin is null, the range is less than keyEnd.
 /// If keyEnd is null, the range is greater than equal to keyBegin.
 /// <para>
 /// Server returns selected data specified by returnType.
 /// </para>
 /// </summary>
 public static Operation GetByKeyRange(string binName, Value keyBegin, Value keyEnd, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateRangeOperation(GET_BY_KEY_INTERVAL, Operation.Type.MAP_READ, binName, ctx, keyBegin, keyEnd, (int)returnType));
 }
 /// <summary>
 /// Create map remove operation.
 /// Server removes map item identified by key and returns removed data specified by returnType.
 /// </summary>
 public static Operation RemoveByKey(string binName, Value key, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(REMOVE_BY_KEY, Operation.Type.MAP_MODIFY, binName, ctx, (int)returnType, key));
 }
 /// <summary>
 /// Create map get by key relative to index range operation.
 /// Server selects map items nearest to key and greater by index.
 /// Server returns selected data specified by returnType.
 /// <para>
 /// Examples for ordered map [{0=17},{4=2},{5=15},{9=10}]:
 /// <ul>
 /// <li>(value,index) = [selected items]</li>
 /// <li>(5,0) = [{5=15},{9=10}]</li>
 /// <li>(5,1) = [{9=10}]</li>
 /// <li>(5,-1) = [{4=2},{5=15},{9=10}]</li>
 /// <li>(3,2) = [{9=10}]</li>
 /// <li>(3,-2) = [{0=17},{4=2},{5=15},{9=10}]</li>
 /// </ul>
 /// </para>
 /// </summary>
 public static Operation GetByKeyRelativeIndexRange(string binName, Value key, int index, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(GET_BY_KEY_REL_INDEX_RANGE, Operation.Type.MAP_READ, binName, ctx, (int)returnType, key, index));
 }
 /// <summary>
 /// Create map remove operation.
 /// Server removes map items identified by keys and returns removed data specified by returnType.
 /// </summary>
 public static Operation RemoveByKeyList(string binName, IList keys, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(REMOVE_BY_KEY_LIST, Operation.Type.MAP_MODIFY, binName, ctx, (int)returnType, keys));
 }
 /// <summary>
 /// Create map get by value range operation.
 /// Server selects map items identified by value range (valueBegin inclusive, valueEnd exclusive)
 /// If valueBegin is null, the range is less than valueEnd.
 /// If valueEnd is null, the range is greater than equal to valueBegin.
 /// <para>
 /// Server returns selected data specified by returnType.
 /// </para>
 /// </summary>
 public static Operation GetByValueRange(string binName, Value valueBegin, Value valueEnd, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateRangeOperation(GET_BY_VALUE_INTERVAL, Operation.Type.MAP_READ, binName, ctx, valueBegin, valueEnd, (int)returnType));
 }
 /// <summary>
 /// Create map remove by key relative to index range operation.
 /// Server removes map items nearest to key and greater by index with a count limit.
 /// Server returns removed data specified by returnType.
 /// <para>
 /// Examples for map [{0=17},{4=2},{5=15},{9=10}]:
 /// <ul>
 /// <li>(value,index,count) = [removed items]</li>
 /// <li>(5,0,1) = [{5=15}]</li>
 /// <li>(5,1,2) = [{9=10}]</li>
 /// <li>(5,-1,1) = [{4=2}]</li>
 /// <li>(3,2,1) = [{9=10}]</li>
 /// <li>(3,-2,2) = [{0=17}]</li>
 /// </ul>
 /// </para>
 /// </summary>
 public static Operation RemoveByKeyRelativeIndexRange(string binName, Value key, int index, int count, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(REMOVE_BY_KEY_REL_INDEX_RANGE, Operation.Type.MAP_MODIFY, binName, ctx, (int)returnType, key, index, count));
 }
 /// <summary>
 /// Create map get by value relative to rank range operation.
 /// Server selects map items nearest to value and greater by relative rank.
 /// Server returns selected data specified by returnType.
 /// <para>
 /// Examples for map [{4=2},{9=10},{5=15},{0=17}]:
 /// <ul>
 /// <li>(value,rank) = [selected items]</li>
 /// <li>(11,1) = [{0=17}]</li>
 /// <li>(11,-1) = [{9=10},{5=15},{0=17}]</li>
 /// </ul>
 /// </para>
 /// </summary>
 public static Operation GetByValueRelativeRankRange(string binName, Value value, int rank, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(GET_BY_VALUE_REL_RANK_RANGE, Operation.Type.MAP_READ, binName, ctx, (int)returnType, value, rank));
 }
 /// <summary>
 /// Create map remove operation.
 /// Server removes map items identified by value and returns removed data specified by returnType.
 /// </summary>
 public static Operation RemoveByValue(string binName, Value value, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(REMOVE_BY_VALUE, Operation.Type.MAP_MODIFY, binName, ctx, (int)returnType, value));
 }
 /// <summary>
 /// Create map get by rank range operation.
 /// Server selects "count" map items starting at specified rank and returns selected data specified by returnType.
 /// </summary>
 public static Operation GetByRankRange(string binName, int rank, int count, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(GET_BY_RANK_RANGE, Operation.Type.MAP_READ, binName, ctx, (int)returnType, rank, count));
 }
 /// <summary>
 /// Create map remove operation.
 /// Server removes map items identified by values and returns removed data specified by returnType.
 /// </summary>
 public static Operation RemoveByValueList(string binName, IList values, MapReturnType returnType, params CTX[] ctx)
 {
     return(CDT.CreateOperation(REMOVE_BY_VALUE_LIST, Operation.Type.MAP_MODIFY, binName, ctx, (int)returnType, values));
 }