/// <summary>
        /// Create HLL describe operation.
        /// Server returns indexBitCount and minHashBitCount used to create HLL bin in a list of longs.
        /// The list size is 2.
        /// </summary>
        /// <param name="binName">name of bin</param>
        public static Operation Describe(string binName)
        {
            Packer packer = new Packer();

            Init(packer, DESCRIBE, 0);
            return(new Operation(Operation.Type.HLL_READ, binName, Value.Get(packer.ToByteArray())));
        }
Пример #2
0
        internal Expression(Exp exp)
        {
            Packer packer = new Packer();

            exp.Pack(packer);
            bytes = packer.ToByteArray();
        }
Пример #3
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())));
        }
Пример #4
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 HLL refresh operation.
        /// Server updates the cached count (if stale) and returns the count.
        /// </summary>
        /// <param name="binName">name of bin</param>
        public static Operation RefreshCount(string binName)
        {
            Packer packer = new Packer();

            Init(packer, SET_COUNT, 0);
            return(new Operation(Operation.Type.HLL_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
        /// <summary>
        /// Create HLL getCount operation.
        /// Server returns estimated number of elements in the HLL bin.
        /// </summary>
        /// <param name="binName">name of bin</param>
        public static Operation GetCount(string binName)
        {
            Packer packer = new Packer();

            Init(packer, COUNT, 0);
            return(new Operation(Operation.Type.HLL_READ, binName, Value.Get(packer.ToByteArray())));
        }
Пример #7
0
        public static byte[] Pack(IList val)
        {
            Packer packer = new Packer();

            packer.PackList(val);
            return(packer.ToByteArray());
        }
Пример #8
0
        public static byte[] Pack(IDictionary val)
        {
            Packer packer = new Packer();

            packer.PackMap(val);
            return(packer.ToByteArray());
        }
Пример #9
0
        protected internal static Operation CreateRangeOperation(int command, Operation.Type type, string binName, Value begin, Value end, int returnType)
        {
            Packer packer = new Packer();

            packer.PackRawShort(command);

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

            if (end == null)
            {
                packer.PackArrayBegin(2);
                packer.PackNumber(returnType);
                begin.Pack(packer);
            }
            else
            {
                packer.PackArrayBegin(3);
                packer.PackNumber(returnType);
                begin.Pack(packer);
                end.Pack(packer);
            }
            return(new Operation(type, binName, Value.Get(packer.ToByteArray())));
        }
Пример #10
0
        protected internal static Operation CreateOperation(int command, Operation.Type type, string binName)
        {
            Packer packer = new Packer();

            packer.PackRawShort(command);
            return(new Operation(type, binName, Value.Get(packer.ToByteArray())));
        }
Пример #11
0
        public static byte[] Pack(Value[] val)
        {
            Packer packer = new Packer();

            packer.PackValueArray(val);
            return(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())));
        }
        /// <summary>
        /// Create HLL getSimilarity operation.
        /// Server returns estimated similarity of these HLL objects. Return type is a double.
        /// </summary>
        /// <param name="binName">name of bin</param>
        /// <param name="list">list of HLL objects</param>
        public static Operation GetSimilarity(string binName, IList <Value.HLLValue> list)
        {
            Packer packer = new Packer();

            Init(packer, SIMILARITY, 1);
            packer.PackList((IList)list);
            return(new Operation(Operation.Type.HLL_READ, binName, Value.Get(packer.ToByteArray())));
        }
        /// <summary>
        /// Create HLL getIntersectCount operation.
        /// Server returns estimated number of elements that would be contained by the intersection of
        /// these HLL objects.
        /// </summary>
        /// <param name="binName">name of bin</param>
        /// <param name="list">list of HLL objects</param>
        public static Operation GetIntersectCount(string binName, IList <Value.HLLValue> list)
        {
            Packer packer = new Packer();

            Init(packer, INTERSECT_COUNT, 1);
            packer.PackList((IList)list);
            return(new Operation(Operation.Type.HLL_READ, binName, Value.Get(packer.ToByteArray())));
        }
        /// <summary>
        /// Create HLL fold operation.
        /// Servers folds indexBitCount to the specified value.
        /// This can only be applied when minHashBitCount on the HLL bin is 0.
        /// Server does not return a value.
        /// </summary>
        /// <param name="binName">name of bin</param>
        /// <param name="indexBitCount">number of index bits. Must be between 4 and 16 inclusive.</param>
        public static Operation Fold(string binName, int indexBitCount)
        {
            Packer packer = new Packer();

            Init(packer, FOLD, 1);
            packer.PackNumber(indexBitCount);
            return(new Operation(Operation.Type.HLL_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
Пример #16
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())));
        }
Пример #17
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())));
        }
Пример #18
0
        public static byte[] Pack(int command, Exp v1)
        {
            Packer packer = new Packer();

            packer.PackArrayBegin(2);
            packer.PackNumber(command);
            v1.Pack(packer);
            return(packer.ToByteArray());
        }
 /// <summary>
 /// Create list append operation.
 /// Server appends value to end of list bin.
 /// Server returns list size.
 /// </summary>
 public static Operation Append(string binName, Value value)
 {
     Packer packer = new Packer();
     packer.PackRawShort(APPEND);
     packer.PackArrayBegin(1);
     value.Pack(packer);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_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)
        {
            Packer packer = new Packer();

            packer.PackRawShort(APPEND_ITEMS);
            packer.PackArrayBegin(1);
            packer.PackList(list);
            return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
        /// <summary>
        /// Create HLL set union operation.
        /// Server sets union of specified HLL objects with HLL bin.
        /// Server does not return a value.
        /// </summary>
        /// <param name="policy">write policy, use <seealso cref="HLLPolicy.Default"/> for default</param>
        /// <param name="binName">name of bin</param>
        /// <param name="list">list of HLL objects</param>
        public static Operation SetUnion(HLLPolicy policy, string binName, IList <Value.HLLValue> list)
        {
            Packer packer = new Packer();

            Init(packer, SET_UNION, 2);
            packer.PackList((IList)list);
            packer.PackNumber(policy.flags);
            return(new Operation(Operation.Type.HLL_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
Пример #22
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())));
        }
        /// <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)
        {
            Packer packer = new Packer();

            packer.PackRawShort(APPEND);
            packer.PackArrayBegin(1);
            value.Pack(packer);
            return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
Пример #24
0
        public static byte[] Pack(int command, params CTX[] ctx)
        {
            Packer packer = new Packer();

            Init(packer, ctx);
            packer.PackArrayBegin(1);
            packer.PackNumber(command);
            return(packer.ToByteArray());
        }
Пример #25
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())));
        }
Пример #26
0
        /// <summary>
        /// Create list clear operation.
        /// Server removes all items in list bin.
        /// Server does not return a result by default.
        /// </summary>
        public static Operation Clear(string binName)
        {
            Packer packer = new Packer();

            packer.PackRawShort(CLEAR);
            //packer.PackArrayBegin(0);
            byte[] bytes = packer.ToByteArray();
            return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes)));
        }
Пример #27
0
        protected internal static Operation SetMapPolicy(string binName, int attributes)
        {
            Packer packer = new Packer();

            packer.PackRawShort(SET_TYPE);
            packer.PackArrayBegin(1);
            packer.PackNumber(attributes);
            return(new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray())));
        }
Пример #28
0
        /// <summary>
        /// Create list size operation.
        /// Server returns size of list.
        /// </summary>
        public static Operation Size(string binName)
        {
            Packer packer = new Packer();

            packer.PackRawShort(SIZE);
            //packer.PackArrayBegin(0);
            byte[] bytes = packer.ToByteArray();
            return(new Operation(Operation.Type.CDT_READ, binName, Value.Get(bytes)));
        }
Пример #29
0
        /// <summary>
        /// Create list get range operation.
        /// Server returns items starting at index to the end of list.
        /// </summary>
        public static Operation GetRange(string binName, int index)
        {
            Packer packer = new Packer();

            packer.PackRawShort(GET_RANGE);
            packer.PackArrayBegin(1);
            packer.PackNumber(index);
            byte[] bytes = packer.ToByteArray();
            return(new Operation(Operation.Type.CDT_READ, binName, Value.Get(bytes)));
        }
Пример #30
0
        protected internal static Operation CreateOperation(int command, Operation.Type type, string binName, int index, MapReturnType returnType)
        {
            Packer packer = new Packer();

            packer.PackRawShort(command);
            packer.PackArrayBegin(2);
            packer.PackNumber((int)returnType);
            packer.PackNumber(index);
            return(new Operation(type, binName, Value.Get(packer.ToByteArray())));
        }
Пример #31
0
        protected internal static Operation CreateOperation(int command, Operation.Type type, string binName, int v1, Value v2)
        {
            Packer packer = new Packer();

            packer.PackRawShort(command);
            packer.PackArrayBegin(2);
            packer.PackNumber(v1);
            v2.Pack(packer);
            return(new Operation(type, binName, Value.Get(packer.ToByteArray())));
        }
Пример #32
0
 protected internal static Operation CreateOperation(int command, int attributes, string binName, Value value1, Value value2)
 {
     Packer packer = new Packer();
     packer.PackRawShort(command);
     packer.PackArrayBegin(3);
     value1.Pack(packer);
     value2.Pack(packer);
     packer.PackNumber(attributes);
     return new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray()));
 }
 /// <summary>
 /// Create list set operation.
 /// Server sets item value at specified index in list bin.
 /// Server does not return a result by default.
 /// </summary>
 public static Operation Set(string binName, int index, Value value)
 {
     Packer packer = new Packer();
     packer.PackRawShort(SET);
     packer.PackArrayBegin(2);
     packer.PackNumber(index);
     value.Pack(packer);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes));
 }
 /// <summary>
 /// Create list size operation.
 /// Server returns size of list.
 /// </summary>
 public static Operation Size(string binName)
 {
     Packer packer = new Packer();
     packer.PackRawShort(SIZE);
     //packer.PackArrayBegin(0);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_READ, binName, Value.Get(bytes));
 }
 /// <summary>
 /// Create list trim operation.
 /// Server removes "count" items in list bin that do not fall into range specified
 /// by index and count range.  If the range is out of bounds, then all items will be removed.
 /// Server returns list size after trim.
 /// </summary>
 public static Operation Trim(string binName, int index, int count)
 {
     Packer packer = new Packer();
     packer.PackRawShort(TRIM);
     packer.PackArrayBegin(2);
     packer.PackNumber(index);
     packer.PackNumber(count);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes));
 }
 /// <summary>
 /// Create 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)
 {
     Packer packer = new Packer();
     packer.PackRawShort(APPEND_ITEMS);
     packer.PackArrayBegin(1);
     packer.PackList(list);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes));
 }
 public static byte[] Pack(Value[] val)
 {
     Packer packer = new Packer();
     packer.PackValueArray(val);
     return packer.ToByteArray();
 }
Пример #38
0
        protected internal static Operation CreatePut(int command, int attributes, string binName, Value value1, Value value2)
        {
            Packer packer = new Packer();
            packer.PackRawShort(command);

            if (command == MapBase.REPLACE)
            {
                // Replace doesn't allow map attributes because it does not create on non-existing key.
                packer.PackArrayBegin(2);
                value1.Pack(packer);
                value2.Pack(packer);
            }
            else
            {
                packer.PackArrayBegin(3);
                value1.Pack(packer);
                value2.Pack(packer);
                packer.PackNumber(attributes);
            }
            return new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray()));
        }
 /// <summary>
 /// Create list remove range operation.
 /// Server removes items starting at specified index to the end of list.
 /// Server returns number of items removed.
 /// </summary>
 public static Operation RemoveRange(string binName, int index)
 {
     Packer packer = new Packer();
     packer.PackRawShort(REMOVE_RANGE);
     packer.PackArrayBegin(1);
     packer.PackNumber(index);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes));
 }
Пример #40
0
        protected internal static Operation CreateRangeOperation(int command, Operation.Type type, string binName, Value begin, Value end, MapReturnType returnType)
        {
            Packer packer = new Packer();
            packer.PackRawShort(command);

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

            if (end == null)
            {
                packer.PackArrayBegin(2);
                packer.PackNumber((int)returnType);
                begin.Pack(packer);
            }
            else
            {
                packer.PackArrayBegin(3);
                packer.PackNumber((int)returnType);
                begin.Pack(packer);
                end.Pack(packer);
            }
            return new Operation(type, binName, Value.Get(packer.ToByteArray()));
        }
Пример #41
0
 protected internal static Operation CreateOperation(int command, Operation.Type type, string binName, Value value, MapReturnType returnType)
 {
     Packer packer = new Packer();
     packer.PackRawShort(command);
     packer.PackArrayBegin(2);
     packer.PackNumber((int)returnType);
     value.Pack(packer);
     return new Operation(type, binName, Value.Get(packer.ToByteArray()));
 }
Пример #42
0
 protected internal static Operation CreateOperation(int command, Operation.Type type, string binName)
 {
     Packer packer = new Packer();
     packer.PackRawShort(command);
     return new Operation(type, binName, Value.Get(packer.ToByteArray()));
 }
Пример #43
0
 protected internal static Operation SetMapPolicy(string binName, int attributes)
 {
     Packer packer = new Packer();
     packer.PackRawShort(SET_TYPE);
     packer.PackArrayBegin(1);
     packer.PackNumber(attributes);
     return new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray()));
 }
 /// <summary>
 /// Create list get range operation.
 /// Server returns "count" items starting at specified index in list bin.
 /// </summary>
 public static Operation GetRange(string binName, int index, int count)
 {
     Packer packer = new Packer();
     packer.PackRawShort(GET_RANGE);
     packer.PackArrayBegin(2);
     packer.PackNumber(index);
     packer.PackNumber(count);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_READ, binName, Value.Get(bytes));
 }
 public static byte[] Pack(IDictionary val)
 {
     Packer packer = new Packer();
     packer.PackMap(val);
     return packer.ToByteArray();
 }
 public static byte[] Pack(IList val)
 {
     Packer packer = new Packer();
     packer.PackList(val);
     return packer.ToByteArray();
 }
Пример #47
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()));
        }
 /// <summary>
 /// Create list clear operation.
 /// Server removes all items in list bin.
 /// Server does not return a result by default.
 /// </summary>
 public static Operation Clear(string binName)
 {
     Packer packer = new Packer();
     packer.PackRawShort(CLEAR);
     //packer.PackArrayBegin(0);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes));
 }
 /// <summary>
 /// Create 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)
 {
     Packer packer = new Packer();
     packer.PackRawShort(INSERT_ITEMS);
     packer.PackArrayBegin(2);
     packer.PackNumber(index);
     packer.PackList(list);
     byte[] bytes = packer.ToByteArray();
     return new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes));
 }