private static Exp.Type GetValueType(ListReturnType returnType) { int t = (int)returnType & ~(int)ListReturnType.INVERTED; if (t == (int)ListReturnType.VALUE) { return(Exp.Type.LIST); } else { return(Exp.Type.INT); } }
/// <summary> /// Create list remove by value relative to rank range operation. /// Server removes list items nearest to value and greater by relative rank with a count limit. /// Server returns removed data specified by returnType. /// <para> /// Examples for ordered list [0,4,5,9,11,15]: /// <ul> /// <li>(value,rank,count) = [removed items]</li> /// <li>(5,0,2) = [5,9]</li> /// <li>(5,1,1) = [9]</li> /// <li>(5,-1,2) = [4,5]</li> /// <li>(3,0,1) = [4]</li> /// <li>(3,3,7) = [11,15]</li> /// <li>(3,-3,2) = []</li> /// </ul> /// </para> /// </summary> public static Operation RemoveByValueRelativeRankRange(string binName, Value value, int rank, int count, ListReturnType returnType) { return(CDT.CreateOperation(REMOVE_BY_VALUE_REL_RANK_RANGE, Operation.Type.CDT_MODIFY, binName, (int)returnType, value, rank, count)); }
/// <summary> /// Create expression that selects "count" list items starting at specified rank and returns /// selected data specified by returnType. /// </summary> public static Exp GetByRankRange(ListReturnType returnType, Exp rank, Exp count, Exp bin, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_RANK_RANGE, (int)returnType, rank, count, ctx); return(AddRead(bin, bytes, GetValueType(returnType))); }
/// <summary> /// Create expression that selects list items starting at specified index to the end of list /// and returns selected data specified by returnType. /// </summary> public static Exp GetByIndexRange(ListReturnType returnType, Exp index, Exp bin, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_INDEX_RANGE, (int)returnType, index, ctx); return(AddRead(bin, bytes, GetValueType(returnType))); }
/// <summary> /// Create expression that selects list items identified by value range and returns selected data /// specified by returnType. /// </summary> /// <example> /// <code> /// // List bin "a" items >= 10 && items < 20 /// ListExp.GetByValueRange(ListReturnType.VALUE, Exp.Val(10), Exp.Val(20), Exp.ListBin("a")) /// </code> /// </example> /// <param name="returnType">metadata attributes to return. See <see cref="ListReturnType"/></param> /// <param name="valueBegin">begin expression inclusive. If null, range is less than valueEnd.</param> /// <param name="valueEnd">end expression exclusive. If null, range is greater than equal to valueBegin.</param> /// <param name="bin">bin or list value expression</param> /// <param name="ctx">optional context path for nested CDT</param> public static Exp GetByValueRange(ListReturnType returnType, Exp valueBegin, Exp valueEnd, Exp bin, params CTX[] ctx) { byte[] bytes = ListExp.PackRangeOperation(ListOperation.GET_BY_VALUE_INTERVAL, (int)returnType, valueBegin, valueEnd, ctx); return(AddRead(bin, bytes, GetValueType(returnType))); }
/// <summary> /// Create list get by index range operation. /// Server selects "count" list items starting at specified index and returns selected data specified /// by returnType. /// </summary> public static Operation GetByIndexRange(string binName, int index, int count, ListReturnType returnType, params CTX[] ctx) { return(CDT.CreateOperation(GET_BY_INDEX_RANGE, Operation.Type.CDT_READ, binName, ctx, (int)returnType, index, count)); }
/// <summary> /// Create list get by value list operation. /// Server selects list items identified by values and returns selected data specified by returnType. /// </summary> public static Operation GetByValueList(string binName, IList values, ListReturnType returnType, params CTX[] ctx) { return(CDT.CreateOperation(GET_BY_VALUE_LIST, Operation.Type.CDT_READ, binName, ctx, (int)returnType, values)); }
/// <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, params CTX[] ctx) { return(CDT.CreateOperation(GET_BY_VALUE, Operation.Type.CDT_READ, binName, ctx, (int)returnType, value)); }
/// <summary> /// Create list remove operation. /// Server removes "count" list items starting at specified index and returns removed data specified by returnType. /// </summary> public static Operation RemoveByIndexRange(string binName, int index, int count, ListReturnType returnType, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.REMOVE_BY_INDEX_RANGE, (int)returnType, index, count, ctx); return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes))); }
/// <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, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.REMOVE_BY_VALUE, (int)returnType, value, ctx); return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes))); }
/// <summary> /// Create list get by rank range operation. /// Server selects list items starting at specified rank to the last ranked item and returns selected /// data specified by returnType. /// </summary> public static Operation GetByRankRange(string binName, int rank, ListReturnType returnType) { return(CDT.CreateOperation(GET_BY_RANK_RANGE, Operation.Type.CDT_READ, binName, (int)returnType, rank)); }
/// <summary> /// Create list get by index range operation. /// Server selects list items starting at specified index to the end of list and returns selected /// data specified by returnType. /// </summary> public static Operation GetByIndexRange(string binName, int index, ListReturnType returnType) { return(CDT.CreateOperation(GET_BY_INDEX_RANGE, Operation.Type.CDT_READ, binName, (int)returnType, index)); }
/// <summary> /// Create list remove operation. /// Server removes list items starting at specified rank to the last ranked item and returns removed /// data specified by returnType. /// </summary> public static Operation RemoveByRankRange(string binName, int rank, ListReturnType returnType) { return(CDT.CreateOperation(REMOVE_BY_RANK_RANGE, Operation.Type.CDT_MODIFY, binName, (int)returnType, rank)); }
/// <summary> /// Create list remove operation. /// Server removes "count" list items starting at specified index and returns removed data specified by returnType. /// </summary> public static Operation RemoveByIndexRange(string binName, int index, int count, ListReturnType returnType) { return(CDT.CreateOperation(REMOVE_BY_INDEX_RANGE, Operation.Type.CDT_MODIFY, binName, (int)returnType, index, count)); }
/// <summary> /// Create list remove operation. /// Server removes list item identified by index and returns removed data specified by returnType. /// </summary> public static Operation RemoveByIndex(string binName, int index, ListReturnType returnType) { return(CDT.CreateOperation(REMOVE_BY_INDEX, Operation.Type.CDT_MODIFY, binName, (int)returnType, index)); }
/// <summary> /// Create list remove operation. /// Server removes list items starting at specified index to the end of list and returns removed /// data specified by returnType. /// </summary> public static Operation RemoveByIndexRange(string binName, int index, ListReturnType returnType, params CTX[] ctx) { return(CDT.CreateOperation(REMOVE_BY_INDEX_RANGE, Operation.Type.CDT_MODIFY, binName, ctx, (int)returnType, index)); }
/// <summary> /// Create list remove operation. /// Server removes "count" list items starting at specified rank and returns removed data specified by returnType. /// </summary> public static Operation RemoveByRankRange(string binName, int rank, int count, ListReturnType returnType, params CTX[] ctx) { return(CDT.CreateOperation(REMOVE_BY_RANK_RANGE, Operation.Type.CDT_MODIFY, binName, ctx, (int)returnType, rank, count)); }
/// <summary> /// Create list remove operation. /// Server removes list items starting at specified rank to the last ranked item and returns removed /// data specified by returnType. /// </summary> public static Operation RemoveByRankRange(string binName, int rank, ListReturnType returnType, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.REMOVE_BY_RANK_RANGE, (int)returnType, rank, ctx); return(new Operation(Operation.Type.CDT_MODIFY, binName, Value.Get(bytes))); }
/// <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, params CTX[] ctx) { return(CDT.CreateRangeOperation(GET_BY_VALUE_INTERVAL, Operation.Type.CDT_READ, binName, ctx, valueBegin, valueEnd, (int)returnType)); }
/// <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, params CTX[] ctx) { byte[] bytes = CDT.PackRangeOperation(ListOperation.GET_BY_VALUE_INTERVAL, (int)returnType, valueBegin, valueEnd, ctx); return(new Operation(Operation.Type.CDT_READ, binName, Value.Get(bytes))); }
/// <summary> /// Create list get by value relative to rank range operation. /// Server selects list items nearest to value and greater by relative rank. /// Server returns selected data specified by returnType. /// <para> /// Examples for ordered list [0,4,5,9,11,15]: /// <ul> /// <li>(value,rank) = [selected items]</li> /// <li>(5,0) = [5,9,11,15]</li> /// <li>(5,1) = [9,11,15]</li> /// <li>(5,-1) = [4,5,9,11,15]</li> /// <li>(3,0) = [4,5,9,11,15]</li> /// <li>(3,3) = [11,15]</li> /// <li>(3,-3) = [0,4,5,9,11,15]</li> /// </ul> /// </para> /// </summary> public static Operation GetByValueRelativeRankRange(string binName, Value value, int rank, ListReturnType returnType, params CTX[] ctx) { return(CDT.CreateOperation(GET_BY_VALUE_REL_RANK_RANGE, Operation.Type.CDT_READ, binName, ctx, (int)returnType, value, rank)); }
/// <summary> /// Create list get by value list operation. /// Server selects list items identified by values and returns selected data specified by returnType. /// </summary> public static Operation GetByValueList(string binName, IList values, ListReturnType returnType, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_VALUE_LIST, (int)returnType, values, ctx); return(new Operation(Operation.Type.CDT_READ, binName, Value.Get(bytes))); }
/// <summary> /// Create list get by rank range operation. /// Server selects "count" list items starting at specified rank and returns selected data specified by returnType. /// </summary> public static Operation GetByRankRange(string binName, int rank, int count, ListReturnType returnType, params CTX[] ctx) { return(CDT.CreateOperation(GET_BY_RANK_RANGE, Operation.Type.CDT_READ, binName, ctx, (int)returnType, rank, count)); }
/// <summary> /// Create list get by index range operation. /// Server selects list items starting at specified index to the end of list and returns selected /// data specified by returnType. /// </summary> public static Operation GetByIndexRange(string binName, int index, ListReturnType returnType, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_INDEX_RANGE, (int)returnType, index, ctx); return(new Operation(Operation.Type.CDT_READ, binName, Value.Get(bytes))); }
/// <summary> /// Create expression that selects list items identified by values and returns selected data /// specified by returnType. /// </summary> public static Exp GetByValueList(ListReturnType returnType, Exp values, Exp bin, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_VALUE_LIST, (int)returnType, values, ctx); return(AddRead(bin, bytes, GetValueType(returnType))); }
/// <summary> /// Create list get by rank range operation. /// Server selects "count" list items starting at specified rank and returns selected data specified by returnType. /// </summary> public static Operation GetByRankRange(string binName, int rank, int count, ListReturnType returnType, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_RANK_RANGE, (int)returnType, rank, count, ctx); return(new Operation(Operation.Type.CDT_READ, binName, Value.Get(bytes))); }
/// <summary> /// Create expression that selects list item identified by rank and returns selected /// data specified by returnType. /// </summary> /// <example> /// <code> /// // Player with lowest score. /// ListExp.GetByRank(ListReturnType.VALUE, Type.STRING, Exp.Val(0), Exp.ListBin("a")) /// </code> /// </example> /// <param name="returnType">metadata attributes to return. See <see cref="ListReturnType"/></param> /// <param name="valueType">expected type of return value</param> /// <param name="rank">rank expression</param> /// <param name="bin">list bin or list value expression</param> /// <param name="ctx">optional context path for nested CDT</param> public static Exp GetByRank(ListReturnType returnType, Exp.Type valueType, Exp rank, Exp bin, params CTX[] ctx) { byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_RANK, (int)returnType, rank, ctx); return(AddRead(bin, bytes, valueType)); }
/// <summary> /// Create list remove operation. /// Server removes list items identified by values and returns removed data specified by returnType. /// </summary> public static Operation RemoveByValueList(string binName, IList values, ListReturnType returnType, params CTX[] ctx) { return(CDT.CreateOperation(REMOVE_BY_VALUE_LIST, Operation.Type.CDT_MODIFY, binName, ctx, (int)returnType, values)); }
/// <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, params CTX[] ctx) { return(CDT.CreateRangeOperation(REMOVE_BY_VALUE_INTERVAL, Operation.Type.CDT_MODIFY, binName, ctx, valueBegin, valueEnd, (int)returnType)); }
/// <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)); }