Ejemplo n.º 1
0
        /// <summary>
        /// 通过多个参数构造一个新的<see cref="GetRangeRequest"/>
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="direction">前向还是后向</param>
        /// <param name="inclusiveStartPrimaryKey">区间开始位置,包含</param>
        /// <param name="exclusiveEndPrimaryKey">区间结束位置,不包含</param>
        /// <param name="columnsToGet">返回的列名称的列表</param>
        /// <param name="limit">最大返回数</param>
        public GetRangeRequest(string tableName,
                               GetRangeDirection direction,
                               PrimaryKey inclusiveStartPrimaryKey,
                               PrimaryKey exclusiveEndPrimaryKey,
                               HashSet <string> columnsToGet = null,
                               int?limit = null,
                               IColumnCondition condition = null)
        {
            QueryCriteria = new RangeRowQueryCriteria(tableName)
            {
                Direction = direction,
                Limit     = limit,
                InclusiveStartPrimaryKey = inclusiveStartPrimaryKey,
                ExclusiveEndPrimaryKey   = exclusiveEndPrimaryKey
            };

            if (columnsToGet != null)
            {
                QueryCriteria.SetColumnsToGet(columnsToGet);
            }

            if (condition != null)
            {
                QueryCriteria.Filter = condition.ToFilter();
            }
        }
        /// <summary>
        /// 添加一个表的多行读请求。
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="primaryKeys">多行的主键</param>
        /// <param name="columnsToGet">要读取的列</param>
        /// <param name="condition">过滤条件</param>
        public void Add(string tableName,
                        List <PrimaryKey> primaryKeys,
                        HashSet <string> columnsToGet = null,
                        IColumnCondition condition    = null)
        {
            var rowQueryCriteria = new MultiRowQueryCriteria(tableName);

            rowQueryCriteria.SetRowKeys(primaryKeys);

            if (columnsToGet != null)
            {
                rowQueryCriteria.SetColumnsToGet(columnsToGet);
            }

            if (condition != null)
            {
                rowQueryCriteria.Filter = condition.ToFilter();
            }

            rowQueryCriteriaDict[tableName] = rowQueryCriteria;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 构造一个新的<see cref="GetRowRequest" />实例。
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="primaryKey">主键</param>
        /// <param name="columnsToGet">获取的列名称列表,如果为空,则获取所有列</param>
        /// <param name="condition">过滤条件</param>
        public GetRowRequest(string tableName,
                             PrimaryKey primaryKey,
                             HashSet <string> columnsToGet = null,
                             IColumnCondition condition    = null,
                             TimeRange timeRange           = null,
                             int?maxVersion     = null,
                             bool?cacheBlocks   = null,
                             string startColumn = null,
                             string endColumn   = null,
                             byte[] token       = null
                             )
        {
            QueryCriteria = new SingleRowQueryCriteria(tableName)
            {
                RowPrimaryKey = primaryKey
            };

            if (columnsToGet != null)
            {
                QueryCriteria.SetColumnsToGet(columnsToGet);
            }

            if (condition != null)
            {
                QueryCriteria.Filter = condition.ToFilter();
            }

            if (timeRange != null)
            {
                QueryCriteria.TimeRange = timeRange;
            }

            QueryCriteria.MaxVersions = maxVersion;
            QueryCriteria.CacheBlocks = cacheBlocks;
            QueryCriteria.StartColumn = startColumn;
            QueryCriteria.EndColumn   = endColumn;
            QueryCriteria.Token       = token;
        }