/// <summary> /// Create map put operation. /// Server writes key/value 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 Put(MapPolicy policy, string binName, Value key, Value value) { Packer packer = new Packer(); if (policy.flags != 0) { packer.PackRawShort(PUT); packer.PackArrayBegin(4); key.Pack(packer); value.Pack(packer); packer.PackNumber(policy.attributes); packer.PackNumber(policy.flags); } else { packer.PackRawShort(policy.itemCommand); if (policy.itemCommand == REPLACE) { // Replace doesn't allow map attributes because it does not create on non-existing key. packer.PackArrayBegin(2); key.Pack(packer); value.Pack(packer); } else { packer.PackArrayBegin(3); key.Pack(packer); value.Pack(packer); packer.PackNumber(policy.attributes); } } return(new Operation(Operation.Type.MAP_MODIFY, binName, Value.Get(packer.ToByteArray()))); }
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()))); }
/// <summary> /// Create map put operation. /// Server writes key/value 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 Put(MapPolicy policy, string binName, Value key, Value value, params CTX[] ctx) { Packer packer = new Packer(); if (policy.flags != 0) { CDT.Init(packer, ctx, PUT, 4); key.Pack(packer); value.Pack(packer); packer.PackNumber(policy.attributes); packer.PackNumber(policy.flags); } else { if (policy.itemCommand == REPLACE) { // Replace doesn't allow map attributes because it does not create on non-existing key. CDT.Init(packer, ctx, policy.itemCommand, 2); key.Pack(packer); value.Pack(packer); } else { CDT.Init(packer, ctx, policy.itemCommand, 3); key.Pack(packer); value.Pack(packer); packer.PackNumber(policy.attributes); } } return(new Operation(Operation.Type.MAP_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, 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()))); }
/// <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()))); }
/// <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)); }
protected internal static Operation CreateOperation(int command, Operation.Type type, string binName, CTX[] ctx, int v1, Value v2) { Packer packer = new Packer(); CDT.Init(packer, ctx, command, 2); packer.PackNumber(v1); v2.Pack(packer); return(new Operation(type, binName, Value.Get(packer.ToByteArray()))); }
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())); }
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()))); }
public static byte[] Pack(int command, Value value, params CTX[] ctx) { Packer packer = new Packer(); Init(packer, ctx); packer.PackArrayBegin(2); packer.PackNumber(command); value.Pack(packer); return(packer.ToByteArray()); }
/// <summary> /// Create list append operation with policy. /// Server appends value to list bin. /// Server returns list size. /// </summary> public static Operation Append(ListPolicy policy, string binName, Value value, params CTX[] ctx) { Packer packer = new Packer(); CDT.Init(packer, ctx, APPEND, 3); value.Pack(packer); packer.PackNumber(policy.attributes); packer.PackNumber(policy.flags); return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray()))); }
/// <summary> /// Create list append operation with policy. /// Server appends value to list bin. /// Server returns list size. /// </summary> public static Operation Append(ListPolicy policy, string binName, Value value) { Packer packer = new Packer(); packer.PackRawShort(APPEND); packer.PackArrayBegin(3); value.Pack(packer); packer.PackNumber(policy.attributes); packer.PackNumber(policy.flags); return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(packer.ToByteArray()))); }
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 increment operation. /// Server increments list[index] by value. /// Value should be integer(IntegerValue, LongValue) or double(DoubleValue, FloatValue). /// Server returns list[index] after incrementing. /// </summary> public static Operation Increment(string binName, int index, Value value) { Packer packer = new Packer(); packer.PackRawShort(INCREMENT); packer.PackArrayBegin(2); packer.PackNumber(index); value.Pack(packer); byte[] bytes = packer.ToByteArray(); return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes))); }
public static byte[] Pack(int command, Value v1, Value v2, int v3, params CTX[] ctx) { Packer packer = new Packer(); Init(packer, ctx); packer.PackArrayBegin(4); packer.PackNumber(command); v1.Pack(packer); v2.Pack(packer); packer.PackNumber(v3); return(packer.ToByteArray()); }
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()))); }
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()); }
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())); }
private void PackObject(object obj) { if (obj == null) { PackNil(); return; } if (obj is Value) { Value value = (Value)obj; value.Pack(this); return; } if (obj is byte[]) { PackBytes((byte[])obj); return; } if (obj is string) { PackString((string)obj); return; } if (obj is int) { PackNumber((int)obj); return; } if (obj is long) { PackNumber((long)obj); return; } if (obj is double) { PackDouble((double)obj); return; } if (obj is float) { PackFloat((float)obj); return; } if (obj is IList) { PackList((IList)obj); return; } if (obj is IDictionary) { PackMap((IDictionary)obj); return; } PackBlob(obj); }
private void PackObject(object obj) { if (obj == null) { PackNil(); return; } if (obj is byte[]) { PackParticleBytes((byte[])obj); return; } if (obj is Value) { Value value = (Value)obj; value.Pack(this); return; } if (obj is IList) { PackList((IList)obj); return; } if (obj is IDictionary) { PackMap((IDictionary)obj); return; } TypeCode code = System.Type.GetTypeCode(obj.GetType()); switch (code) { case TypeCode.Empty: PackNil(); break; case TypeCode.String: PackParticleString((string)obj); break; case TypeCode.Double: PackDouble((double)obj); break; case TypeCode.Single: PackFloat((float)obj); break; case TypeCode.Int64: PackNumber((long)obj); break; case TypeCode.Int32: PackNumber((int)obj); break; case TypeCode.Int16: PackNumber((short)obj); break; case TypeCode.UInt64: PackNumber((ulong)obj); break; case TypeCode.UInt32: PackNumber((uint)obj); break; case TypeCode.UInt16: PackNumber((ushort)obj); break; case TypeCode.Boolean: PackBoolean((bool)obj); break; case TypeCode.Byte: PackNumber((byte)obj); break; case TypeCode.SByte: PackNumber((sbyte)obj); break; case TypeCode.Char: case TypeCode.DateTime: case TypeCode.Decimal: case TypeCode.Object: default: PackBlob(obj); break; } }
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())); }
/// <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)); }
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())); }