public Qualifier(String field, FilterOperation operation, Value value1) : this() { internalMap[FIELD] = field; internalMap[OPERATION] = operation; internalMap[VALUE1] = value1; }
/// <summary> /// Initialize large list operator. /// </summary> /// <param name="client">client</param> /// <param name="policy">generic configuration parameters, pass in null for defaults</param> /// <param name="key">unique record identifier</param> /// <param name="binName">bin name</param> public LargeList(AerospikeClient client, WritePolicy policy, Key key, string binName) { this.client = client; this.policy = policy; this.key = key; this.binName = Value.Get(binName); }
public ExecuteCommand(Cluster cluster, WritePolicy writePolicy, Key key, string packageName, string functionName, Value[] args) : base(cluster, writePolicy, key, null) { this.writePolicy = writePolicy; this.packageName = packageName; this.functionName = functionName; this.args = args; }
/// <summary> /// Initialize large set operator. /// </summary> /// <param name="client">client</param> /// <param name="policy">generic configuration parameters, pass in null for defaults</param> /// <param name="key">unique record identifier</param> /// <param name="binName">bin name</param> /// <param name="createModule">Lua function name that initializes list configuration parameters, pass null for default set</param> public LargeSet(AerospikeClient client, WritePolicy policy, Key key, string binName, string createModule) { this.client = client; this.policy = policy; this.key = key; this.binName = Value.Get(binName); this.createModule = Value.Get(createModule); }
public void Add(Value value) { Key subKey = MakeSubKey (value); client.Put (this.policy, subKey, new Bin (ListElementBinName, value)); // add the digest of the subKey to the CDT List in the Customer record client.Operate(this.policy, this.key, ListOperation.Append(this.binNameString, Value.Get(subKey.digest))); }
public AsyncExecute(AsyncCluster cluster, WritePolicy writePolicy, ExecuteListener listener, Key key, string packageName, string functionName, Value[] args) : base(cluster, writePolicy, null, key, null) { this.writePolicy = writePolicy; this.executeListener = listener; this.packageName = packageName; this.functionName = functionName; this.args = args; }
/// <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, 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> /// Initialize key from namespace, optional set name and user key. /// The set name and user defined key are converted to a digest before sending to the server. /// The user key is not used or returned by the server by default. If the user key needs /// to persist on the server, use one of the following methods: /// <list type="bullet"> /// <item>Set "WritePolicy.sendKey" to true. In this case, the key will be sent to the server for storage on writes /// and retrieved on multi-record scans and queries.</item> /// <item>Explicitly store and retrieve the key in a bin.</item> /// </list> /// </summary> /// <param name="ns">namespace</param> /// <param name="setName">optional set name, enter null when set does not exist</param> /// <param name="key">user defined unique identifier within set.</param> /// <exception cref="AerospikeException">if digest computation fails</exception> public Key(string ns, string setName, Value key) { this.ns = ns; this.setName = setName; this.userKey = key; // Some value types can't be used as keys (csblob, list, map, null). Verify key type. key.ValidateKeyType(); digest = ComputeDigest(setName, key); }
private void WriteField(Value value, int type) { int offset = dataOffset + FIELD_HEADER_SIZE; dataBuffer[offset++] = (byte)value.Type; int len = value.Write(dataBuffer, offset) + 1; WriteFieldHeader(len, type); dataOffset += len; }
public void SetUdf(WritePolicy policy, Key key, string packageName, string functionName, Value[] args) { Begin(); int fieldCount = EstimateKeySize(policy, key); byte[] argBytes = Packer.Pack(args); fieldCount += EstimateUdfSize(packageName, functionName, argBytes); SizeBuffer(); WriteHeader(policy, 0, Command.INFO2_WRITE, fieldCount, 0); WriteKey(policy, key); WriteField(packageName, FieldType.UDF_PACKAGE_NAME); WriteField(functionName, FieldType.UDF_FUNCTION); WriteField(argBytes, FieldType.UDF_ARGLIST); End(); }
/// <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(ListPolicy policy, string binName, int index, Value value) { return(CDT.CreateOperation(INCREMENT, Operation.Type.CDT_MODIFY, binName, index, value, policy.attributes, policy.flags)); }
/// <summary> /// Create list get by value range operation. /// Server selects list 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, ListReturnType returnType) { return(CDT.CreateRangeOperation(GET_BY_VALUE_INTERVAL, Operation.Type.CDT_READ, binName, valueBegin, valueEnd, (int)returnType)); }
/// <summary> /// Select range of values from list. /// Supported by server versions >= 3.5.8. /// </summary> /// <param name="begin">low value of the range (inclusive)</param> /// <param name="end">high value of the range (inclusive)</param> /// <param name="count">maximum number of values to return, pass in zero to obtain all values within range</param> public IList Range(Value begin, Value end, int count) { return (IList)client.Execute(policy, key, PackageName, "find_range", binName, begin, end, Value.Get(count)); }
/// <summary> /// Select values from list and apply specified Lua filter. /// </summary> /// <param name="value">value to select</param> /// <param name="filterModule">Lua module name which contains filter function</param> /// <param name="filterName">Lua function name which applies filter to returned list</param> /// <param name="filterArgs">arguments to Lua function name</param> public IList FindThenFilter(Value value, string filterModule, string filterName, params Value[] filterArgs) { return (IList)client.Execute(policy, key, PackageName, "find_then_filter", binName, value, Value.Get(filterModule), Value.Get(filterName), Value.Get(filterArgs)); }
/// <summary> /// Select values from list. /// </summary> /// <param name="value">value to select</param> public IList Find(Value value) { return (IList)client.Execute(policy, key, PackageName, "find", binName, value); }
private Key MakeSubKey(Value value) { Key subKey; String valueString; if (value is Value.MapValue) { IDictionary map = (IDictionary) value.Object; valueString = map ["key"].ToString(); } else { valueString = value.ToString (); } string subKeyString = String.Format ("{0}::{1}", this.key.userKey.ToString (), valueString); subKey = new Key (this.key.ns, this.key.setName, subKeyString); return subKey; }
public void Update(Value value) { if (Size () == 0) { Add (value); } else { Key subKey = MakeSubKey (value); client.Put (this.policy, subKey, new Bin (ListElementBinName, value)); } }
/// <summary> /// Create list remove operation. /// Server removes list items identified by value and returns removed data specified by returnType. /// </summary> public static Operation RemoveByValue(string binName, Value value, ListReturnType returnType) { return(CDT.CreateOperation(REMOVE_BY_VALUE, Operation.Type.CDT_MODIFY, binName, (int)returnType, value)); }
/// <summary> /// Create list remove operation. /// Server removes list 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, ListReturnType returnType) { return(CDT.CreateRangeOperation(REMOVE_BY_VALUE_INTERVAL, Operation.Type.CDT_MODIFY, binName, valueBegin, valueEnd, (int)returnType)); }
public void PackValueArray(Value[] values) { PackArrayBegin(values.Length); foreach (Value value in values) { value.Pack(this); } }
/// <summary> /// Delete values from list between range. Return count of entries removed. /// </summary> /// <param name="begin">low value of the range (inclusive)</param> /// <param name="end">high value of the range (inclusive)</param> public int Remove(Value begin, Value end) { object result = client.Execute(policy, key, PackageName, "remove_range", binName, begin, end); return (result != null) ? (int)(long)result : 0; }
public static byte[] Pack(Value[] val) { Packer packer = new Packer(); packer.PackValueArray(val); return packer.ToByteArray(); }
/// <summary> /// Create list set operation with policy. /// Server sets item value at specified index in list bin. /// Server does not return a result by default. /// </summary> public static Operation Set(ListPolicy policy, string binName, int index, Value value) { return(CDT.CreateOperation(SET, Operation.Type.CDT_MODIFY, binName, index, value, policy.flags)); }
/// <summary> /// Select values from the begin key up to a maximum count. /// Supported by server versions >= 3.5.8. /// </summary> /// <param name="begin">start value (inclusive)</param> /// <param name="count">maximum number of values to return</param> public IList FindFrom(Value begin, int count) { return (IList)client.Execute(policy, key, PackageName, "find_from", binName, begin, Value.Get(count)); }
/// <summary> /// Select value from set. /// </summary> /// <param name="value">value to select</param> public object Get(Value value) { return client.Execute(policy, key, PackageName, "get", binName, value); }
/// <summary> /// Select range of values from list. /// </summary> /// <param name="begin">begin value inclusive</param> /// <param name="end">end value inclusive</param> public IList Range(Value begin, Value end) { return (IList)client.Execute(policy, key, PackageName, "range", binName, begin, end); }
/// <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) { return(CDT.CreateOperation(SET, Operation.Type.CDT_MODIFY, binName, index, value)); }
/// <summary> /// Select range of values from the large list up to a maximum count after applying lua filter. /// Supported by server versions >= 3.5.8. /// </summary> /// <param name="begin">low value of the range (inclusive)</param> /// <param name="end">high value of the range (inclusive)</param> /// <param name="count">maximum number of values to return after applying lua filter. Pass in zero to obtain all values within range.</param> /// <param name="filterModule">Lua module name which contains filter function</param> /// <param name="filterName">Lua function name which applies filter to returned list</param> /// <param name="filterArgs">arguments to Lua function name</param> public IList Range(Value begin, Value end, int count, string filterModule, string filterName, params Value[] filterArgs) { return (IList)client.Execute(policy, key, PackageName, "find_range", binName, begin, end, Value.Get(count), Value.Get(filterModule), Value.Get(filterName), Value.Get(filterArgs)); }
/// <summary> /// Create list get by value operation. /// Server selects list items identified by value and returns selected data specified by returnType. /// </summary> public static Operation GetByValue(string binName, Value value, ListReturnType returnType) { return(CDT.CreateOperation(GET_BY_VALUE, Operation.Type.CDT_READ, binName, (int)returnType, value)); }
/// <summary> /// Update value in list if key exists. Add value to list if key does not exist. /// If value is a map, the key is identified by "key" entry. Otherwise, the value is the key. /// If large list does not exist, create it. /// </summary> /// <param name="value">value to update</param> public void Update(Value value) { client.Execute(policy, key, PackageName, "update", binName, value); }
public bool Exists(Value keyValue) { Key subKey = MakeSubKey (keyValue); return client.Exists (this.policy, subKey); }
/// <summary> /// Check existence of value in the set. /// </summary> /// <param name="value">value to check</param> public bool Exists(Value value) { object result = client.Execute(policy, key, PackageName, "exists", binName, value); return (result != null) ? ((long)result != 0) : false; }
public IList Find(Value value) { Key subKey = MakeSubKey (value); Record record = client.Get (this.policy, subKey, ListElementBinName); if (record != null) { Object result = record.GetValue (ListElementBinName); return new List<Object> (){ result }; } else { return null; } }
/// <summary> /// Delete value from set. /// </summary> /// <param name="value">value to delete</param> public void Remove(Value value) { client.Execute(policy, key, PackageName, "remove", binName, value); }
/// <summary> /// Check existence of value in the set. /// </summary> /// <param name="value">value to check</param> public bool Exists(Value value) { object result = client.Execute(policy, key, PackageName, "exists", binName, value); return Util.ToBool(result); }
/// <summary> /// Add a value to the set. If the set does not exist, create it using specified userModule configuration. /// </summary> /// <param name="value">value to add</param> public void Add(Value value) { client.Execute(policy, key, PackageName, "add", binName, value, createModule); }
/// <summary> /// Create default 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) { return(CDT.CreateOperation(INCREMENT, Operation.Type.CDT_MODIFY, binName, index, value)); }