public void AssertBatchGetRowResponse(
            BatchGetRowResponse expect, BatchGetRowResponse actual)
        {
            Assert.AreEqual(expect.RowDataGroupByTable.Keys, actual.RowDataGroupByTable.Keys);

            foreach (var table in expect.RowDataGroupByTable)
            {
                Assert.IsTrue(actual.RowDataGroupByTable.ContainsKey(table.Key));
                var tableExpect = table.Value;
                var tableActual = actual.RowDataGroupByTable[table.Key];
                Assert.AreEqual(tableExpect.Count, tableActual.Count);
                for (int i = 0; i < tableExpect.Count; i++)
                {
                    var expectItem = tableExpect[i];
                    var actualItem = tableActual[i];

                    Assert.AreEqual(expectItem.IsOK, actualItem.IsOK);
                    Assert.AreEqual(expectItem.ErrorCode, actualItem.ErrorCode);
                    Assert.AreEqual(expectItem.ErrorMessage, actualItem.ErrorMessage);
                    AssertCapacityUnit(expectItem.Consumed, expectItem.Consumed);

                    AssertColumns(
                        (Dictionary <string, ColumnValue>)expectItem.PrimaryKey,
                        (Dictionary <string, ColumnValue>)actualItem.PrimaryKey);
                    AssertColumns(
                        (Dictionary <string, ColumnValue>)expectItem.Attribute,
                        (Dictionary <string, ColumnValue>)actualItem.Attribute);
                }
            }
        }
        public static void BatchGetRowWithFilter()
        {
            Console.WriteLine("Start batch get row with filter ...");
            PrepareTable();
            PrepareData();
            OTSClient otsClient = Config.GetClient();

            // 批量一次读10行
            BatchGetRowRequest request     = new BatchGetRowRequest();
            List <PrimaryKey>  primaryKeys = new List <PrimaryKey>();

            for (int i = 0; i < 10; i++)
            {
                PrimaryKey primaryKey = new PrimaryKey
                {
                    { "pk0", new ColumnValue(i) },
                    { "pk1", new ColumnValue("abc") }
                };
                primaryKeys.Add(primaryKey);
            }

            var condition = new RelationalCondition("col2",
                                                    CompareOperator.EQUAL,
                                                    new ColumnValue(false));

            request.Add(TableName, primaryKeys, null, condition);

            BatchGetRowResponse response = otsClient.BatchGetRow(request);
            var tableRows = response.RowDataGroupByTable;
            var rows      = tableRows[TableName];

            foreach (var row in rows)
            {
                // 注意:batch操作可能部分成功部分失败,需要为每行检查状态
                if (row.IsOK)
                {
                    Console.WriteLine("-----------------");
                    foreach (KeyValuePair <string, ColumnValue> entry in row.PrimaryKey)
                    {
                        Console.WriteLine(entry.Key + ":" + PrintColumnValue(entry.Value));
                    }
                    foreach (KeyValuePair <string, ColumnValue> entry in row.Attribute)
                    {
                        Console.WriteLine(entry.Key + ":" + PrintColumnValue(entry.Value));
                    }
                    Console.WriteLine("-----------------");
                }
                else
                {
                    Console.WriteLine("Read row with filter failed: " + row.ErrorMessage);
                }
            }

            Console.WriteLine("RowsCount with filter");
        }
        public static void BatchGetRow()
        {
            Console.WriteLine("Start batch get row...");
            PrepareTable();
            PrepareData();
            OTSClient otsClient = Config.GetClient();

            // 批量一次读10行
            BatchGetRowRequest request     = new BatchGetRowRequest();
            List <PrimaryKey>  primaryKeys = new List <PrimaryKey>();

            for (int i = 0; i < 10; i++)
            {
                PrimaryKey primaryKey = new PrimaryKey();
                primaryKey.Add("pk0", new ColumnValue(i));
                primaryKey.Add("pk1", new ColumnValue("abc"));
                primaryKeys.Add(primaryKey);
            }

            request.Add(TableName, primaryKeys);

            BatchGetRowResponse response = otsClient.BatchGetRow(request);
            var tableRows = response.RowDataGroupByTable;
            var rows      = tableRows[TableName];

            foreach (var row in rows)
            {
                // 注意:batch操作可能部分成功部分失败,需要为每行检查状态
                if (row.IsOK)
                {
                    Console.WriteLine("-----------------");
                    foreach (KeyValuePair <string, ColumnValue> entry in row.PrimaryKey)
                    {
                        Console.WriteLine(entry.Key + ":" + PrintColumnValue(entry.Value));
                    }
                    foreach (KeyValuePair <string, ColumnValue> entry in row.Attribute)
                    {
                        Console.WriteLine(entry.Key + ":" + PrintColumnValue(entry.Value));
                    }
                    Console.WriteLine("-----------------");
                }
                else
                {
                    Console.WriteLine("Read row failed: " + row.ErrorMessage);
                }
            }

            Console.WriteLine("RowsCount: " + rows.Count);
        }