public void TestInvalidPKInSchema() { // TODO Error Injection to test DescribeTable var primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add("PK0", ColumnValueType.Double); primaryKeySchema.Add("PK1", ColumnValueType.Double); SetTestConext(pkSchema: primaryKeySchema, allFailedMessage: "DOUBLE is an invalid type for the primary key."); TestSingleAPI("CreateTable"); primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add("PK0", ColumnValueType.Boolean); primaryKeySchema.Add("PK1", ColumnValueType.Boolean); SetTestConext(pkSchema: primaryKeySchema, allFailedMessage: "BOOLEAN is an invalid type for the primary key."); TestSingleAPI("CreateTable"); //primaryKeySchema = new PrimaryKeySchema(); //primaryKeySchema.Add("PK0", ColumnValueType.Binary); //primaryKeySchema.Add("PK1", ColumnValueType.Binary); //SetTestConext(pkSchema:primaryKeySchema, allFailedMessage:"BINARY is an invalid type for the primary key."); //TestSingleAPI("CreateTable"); // INF_MIN INF_MAX 类型的 ColumnValueType 在C# SDK里没有 }
public void CreateTestTableWith2PK() { var schema = new PrimaryKeySchema(); schema.Add("PK0", ColumnValueType.String); schema.Add("PK1", ColumnValueType.Integer); CreateTestTable(TestTableName, schema, new CapacityUnit(0, 0)); }
public void TestStringPKInSchema() { var primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add("PK0", ColumnValueType.String); primaryKeySchema.Add("PK1", ColumnValueType.String); SetTestConext(pkSchema: primaryKeySchema); TestSingleAPI("CreateTable"); TestSingleAPI("DescribeTable"); }
public static void TableOperations() { // 创建表 OTSClient otsClient = Config.GetClient(); { Console.WriteLine("Start create table..."); PrimaryKeySchema primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add("pk0", ColumnValueType.Integer); primaryKeySchema.Add("pk1", ColumnValueType.String); TableMeta tableMeta = new TableMeta(TableName, primaryKeySchema); CapacityUnit reservedThroughput = new CapacityUnit(1, 1); CreateTableRequest request = new CreateTableRequest(tableMeta, reservedThroughput); otsClient.CreateTable(request); Console.WriteLine("Table is created: " + TableName); } // 更新表 { Thread.Sleep(60 * 1000); // 每次更新表需要至少间隔1分钟 Console.WriteLine("Start update table..."); CapacityUnit reservedThroughput = new CapacityUnit(0, 0); // 将预留CU调整为0,0 UpdateTableRequest request = new UpdateTableRequest(TableName, reservedThroughput); UpdateTableResponse response = otsClient.UpdateTable(request); Console.WriteLine("LastIncreaseTime: " + response.ReservedThroughputDetails.LastIncreaseTime); Console.WriteLine("LastDecreaseTime: " + response.ReservedThroughputDetails.LastDecreaseTime); Console.WriteLine("NumberOfDecreaseToday: " + response.ReservedThroughputDetails.LastIncreaseTime); Console.WriteLine("ReadCapacity: " + response.ReservedThroughputDetails.CapacityUnit.Read); Console.WriteLine("WriteCapacity: " + response.ReservedThroughputDetails.CapacityUnit.Write); } // 描述表 { Console.WriteLine("Start describe table..."); DescribeTableRequest request = new DescribeTableRequest(TableName); DescribeTableResponse response = otsClient.DescribeTable(request); Console.WriteLine("LastIncreaseTime: " + response.ReservedThroughputDetails.LastIncreaseTime); Console.WriteLine("LastDecreaseTime: " + response.ReservedThroughputDetails.LastDecreaseTime); Console.WriteLine("NumberOfDecreaseToday: " + response.ReservedThroughputDetails.LastIncreaseTime); Console.WriteLine("ReadCapacity: " + response.ReservedThroughputDetails.CapacityUnit.Read); Console.WriteLine("WriteCapacity: " + response.ReservedThroughputDetails.CapacityUnit.Write); } // 删除表 //{ //Console.WriteLine("Start delete table..."); //DeleteTableRequest request = new DeleteTableRequest(TableName); //otsClient.DeleteTable(request); //Console.WriteLine("Table is deleted."); //} }
public void CreateTestTable() { var primaryKeys = new PrimaryKeySchema(); primaryKeys.Add("PK0", ColumnValueType.String); primaryKeys.Add("PK1", ColumnValueType.Integer); var tableMeta = new TableMeta("SampleTableName", primaryKeys); var reservedThroughput = new CapacityUnit(0, 0); var request = new CreateTableRequest(tableMeta, reservedThroughput); OTSClient.CreateTable(request); WaitForTableReady(); }
private void CreateTable() { var otsClient = OTSClient; var primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add("PK0", ColumnValueType.String); primaryKeySchema.Add("PK1", ColumnValueType.Integer); var tableMeta = new TableMeta("SampleTable", primaryKeySchema); var reservedThroughput = new CapacityUnit(0, 0); var request = new CreateTableRequest(tableMeta, reservedThroughput); var response = otsClient.CreateTable(request); WaitForTableReady(); }
public void TestOneColumnInPK() { var primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add("PK0", ColumnValueType.Integer); var primaryKey = new PrimaryKey(); primaryKey.Add("PK0", new ColumnValue(123)); var startPrimaryKey = new PrimaryKey(); startPrimaryKey.Add("PK0", ColumnValue.INF_MIN); var endPrimaryKey = new PrimaryKey(); endPrimaryKey.Add("PK0", ColumnValue.INF_MAX); SetTestConext(pkSchema: primaryKeySchema, primaryKey: primaryKey, startPrimaryKey: startPrimaryKey, endPrimaryKey: endPrimaryKey); TestSingleAPI("CreateTable"); TestSingleAPI("DescribeTable"); WaitForTableReady(); TestAllDataAPI(createTable: false); }
public void TestForError() { var schema = new PrimaryKeySchema(); schema.Add("pk1", ColumnValueType.String); CreateTestTable(TestTableName, schema, new CapacityUnit(0, 0)); var attr1 = new AttributeColumns(); attr1.Add("attr", new ColumnValue("attr_value1")); var attr2 = new AttributeColumns(); attr2.Add("attr", new ColumnValue("attr_value2")); var attr3 = new AttributeColumns(); attr3.Add("attr", new ColumnValue("attr_value3")); { var pk1 = new PrimaryKey(); pk1.Add("pk1", new ColumnValue("1")); pk1.Add("pk2", new ColumnValue("1")); var pk2 = new PrimaryKey(); pk2.Add("pk1", new ColumnValue("2")); pk2.Add("pk2", new ColumnValue("2")); var pk3 = new PrimaryKey(); pk3.Add("pk1", new ColumnValue("3")); pk3.Add("pk2", new ColumnValue("3")); { var request = new BatchWriteRowRequest(); var change = new RowChanges(); change.AddPut(new Condition(RowExistenceExpectation.IGNORE), pk1, attr1); change.AddPut(new Condition(RowExistenceExpectation.IGNORE), pk2, attr2); change.AddPut(new Condition(RowExistenceExpectation.IGNORE), pk3, attr3); request.Add(TestTableName, change); var response = OTSClient.BatchWriteRow(request); var tables = response.TableRespones; Assert.AreEqual(1, tables.Count); var rows = tables[TestTableName]; Assert.AreEqual(3, rows.PutResponses.Count); Assert.AreEqual("OTSInvalidPK", rows.PutResponses[0].ErrorCode); Assert.AreEqual("OTSInvalidPK", rows.PutResponses[1].ErrorCode); Assert.AreEqual("OTSInvalidPK", rows.PutResponses[2].ErrorCode); Assert.AreEqual("Validate PK size fail. Input: 2, Meta: 1.", rows.PutResponses[0].ErrorMessage); Assert.AreEqual("Validate PK size fail. Input: 2, Meta: 1.", rows.PutResponses[1].ErrorMessage); Assert.AreEqual("Validate PK size fail. Input: 2, Meta: 1.", rows.PutResponses[2].ErrorMessage); } } }
private void CreateTable(OTSClient client, String tableName) { foreach (var tableItem in client.ListTable(new ListTableRequest()).TableNames) { client.DeleteTable(new DeleteTableRequest(tableItem)); } var primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add(COLUMN_GID_NAME, ColumnValueType.Integer); primaryKeySchema.Add(COLUMN_UID_NAME, ColumnValueType.Integer); var tableMeta = new TableMeta(tableName, primaryKeySchema); var reservedThroughput = new CapacityUnit(0, 0); var request = new CreateTableRequest(tableMeta, reservedThroughput); var response = OTSClient.CreateTable(request); // 创建表只是提交请求,OTS创建表需要一段时间,这里是简单的sleep,请根据实际逻辑修改 WaitForTableReady(); }
public void CreateTableAndDelete() { var primaryKeys = new PrimaryKeySchema(); primaryKeys.Add("PK0", ColumnValueType.String); primaryKeys.Add("PK1", ColumnValueType.Integer); var tableMeta = new TableMeta("SampleTableName", primaryKeys); var reservedThroughput = new CapacityUnit(0, 0); var request1 = new CreateTableRequest(tableMeta, reservedThroughput); var response1 = OTSClient.CreateTable(request1); var request2 = new ListTableRequest(); var response2 = OTSClient.ListTable(request2); Assert.AreEqual(new List <string>() { "SampleTableName" }, response2.TableNames); Thread.Sleep(1000); var request3 = new DescribeTableRequest("SampleTableName"); var response3 = OTSClient.DescribeTable(request3); Assert.AreEqual("SampleTableName", response3.TableMeta.TableName); Assert.AreEqual(primaryKeys, response3.TableMeta.PrimaryKeySchema); Assert.AreEqual(reservedThroughput.Read, response3.ReservedThroughputDetails.CapacityUnit.Read); Assert.AreEqual(reservedThroughput.Write, response3.ReservedThroughputDetails.CapacityUnit.Write); OTSClient.DeleteTable(new DeleteTableRequest("SampleTableName")); var request4 = new ListTableRequest(); var response4 = OTSClient.ListTable(request4); Assert.AreEqual(new List <string>() { }, response4.TableNames); }
private static void PrepareTable() { // 创建表 OTSClient otsClient = Config.GetClient(); IList <string> tables = otsClient.ListTable(new ListTableRequest()).TableNames; if (tables.Contains(tableName)) { return; } PrimaryKeySchema primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add("pk0", ColumnValueType.Integer); primaryKeySchema.Add("pk1", ColumnValueType.String); TableMeta tableMeta = new TableMeta(tableName, primaryKeySchema); CapacityUnit reservedThroughput = new CapacityUnit(0, 0); CreateTableRequest request = new CreateTableRequest(tableMeta, reservedThroughput); otsClient.CreateTable(request); }
public void CreateTestTableWith4PK(CapacityUnit reservedThroughput = null, string tableName = null) { if (reservedThroughput == null) { reservedThroughput = new CapacityUnit(0, 0); } var schema = new PrimaryKeySchema(); schema.Add("PK0", ColumnValueType.String); schema.Add("PK1", ColumnValueType.String); schema.Add("PK2", ColumnValueType.Integer); schema.Add("PK3", ColumnValueType.Integer); if (string.IsNullOrEmpty(tableName)) { CreateTestTable(TestTableName, schema, reservedThroughput); } else { CreateTestTable(tableName, schema, reservedThroughput); } }
public void TestRetryWithOTSNotEnoughCapacityUnit() { var schema = new PrimaryKeySchema(); schema.Add("PK0", ColumnValueType.String); schema.Add("PK1", ColumnValueType.Integer); CreateTestTable(TestTableName, schema, new CapacityUnit(0, 0)); var primaryKey = new PrimaryKey(); primaryKey.Add("PK0", new ColumnValue("ABC")); primaryKey.Add("PK1", new ColumnValue(123)); var attribute = new AttributeColumns(); attribute.Add("Col0", new ColumnValue("ABC")); PutSingleRow(TestTableName, primaryKey, attribute); for (int i = 0; i < 20; i++) { CheckSingleRow(TestTableName, primaryKey, attribute, new CapacityUnit(1, 0)); } }
public void UpdateTableAndThenDescribe() { var primaryKeys = new PrimaryKeySchema(); primaryKeys.Add("PK0", ColumnValueType.String); primaryKeys.Add("PK1", ColumnValueType.Integer); var tableMeta = new TableMeta("update_table_and_then_describe", primaryKeys); var reservedThroughput = new CapacityUnit(0, 0); var request1 = new CreateTableRequest(tableMeta, reservedThroughput); var response1 = OTSClient.CreateTable(request1); WaitBeforeUpdateTable(); var request2 = new UpdateTableRequest( "update_table_and_then_describe", new CapacityUnit(1, 1) ); var response2 = OTSClient.UpdateTable(request2); Assert.AreEqual(0, response2.ReservedThroughputDetails.NumberOfDecreasesToday); Assert.AreEqual(100, response2.ReservedThroughputDetails.CapacityUnit.Read); Assert.AreEqual(100, response2.ReservedThroughputDetails.CapacityUnit.Write); }
private void CreateTable(String tableName) { foreach (var tableItem in OTSClient.ListTable(new ListTableRequest()).TableNames) { OTSClient.DeleteTable(new DeleteTableRequest(tableItem)); } var primaryKeySchema = new PrimaryKeySchema(); primaryKeySchema.Add("PK0", ColumnValueType.Integer); var tableMeta = new TableMeta(tableName, primaryKeySchema); var reservedThroughput = new CapacityUnit(0, 0); var request = new CreateTableRequest(tableMeta, reservedThroughput); var response = OTSClient.CreateTable(request); WaitForTableReady(); }
public void TestForError() { var schema = new PrimaryKeySchema(); schema.Add("pk1", ColumnValueType.String); CreateTestTable(TestTableName, schema, new CapacityUnit(0, 0)); { var request = new BatchGetRowRequest(); List <PrimaryKey> primaryKeys = new List <PrimaryKey>(); var pk1 = new PrimaryKey(); pk1.Add("pk1", new ColumnValue("1")); pk1.Add("pk2", new ColumnValue("1")); var pk2 = new PrimaryKey(); pk2.Add("pk1", new ColumnValue("2")); pk2.Add("pk2", new ColumnValue("2")); var pk3 = new PrimaryKey(); pk3.Add("pk1", new ColumnValue("3")); pk3.Add("pk2", new ColumnValue("3")); primaryKeys.Add(pk1); primaryKeys.Add(pk2); primaryKeys.Add(pk3); request.Add(TestTableName, primaryKeys); var response = OTSClient.BatchGetRow(request); var tables = response.RowDataGroupByTable; Assert.AreEqual(1, tables.Count); var rows = tables[TestTableName]; Assert.AreEqual(3, rows.Count); Assert.AreEqual("OTSInvalidPK", rows[0].ErrorCode); Assert.AreEqual("OTSInvalidPK", rows[1].ErrorCode); Assert.AreEqual("OTSInvalidPK", rows[2].ErrorCode); Assert.AreEqual("Validate PK size fail. Input: 2, Meta: 1.", rows[0].ErrorMessage); Assert.AreEqual("Validate PK size fail. Input: 2, Meta: 1.", rows[1].ErrorMessage); Assert.AreEqual("Validate PK size fail. Input: 2, Meta: 1.", rows[2].ErrorMessage); } }
public void TestTooMuchColumnInPK() { var primaryKeySchema = new PrimaryKeySchema(); var primaryKey = new PrimaryKey(); for (int i = 0; i < 1000; i++) { primaryKeySchema.Add("PK" + i, ColumnValueType.Integer); primaryKey.Add("PK" + i, new ColumnValue(123)); } SetTestConext(pkSchema: primaryKeySchema, primaryKey: primaryKey, endPrimaryKey: primaryKey, allFailedMessage: "The number of primary key columns must be in range: [1, 4]."); TestSingleAPI("CreateTable"); CreateTestTableWith4PK(); TestAllDataAPI(createTable: false); }
void testBadColumnName(string badColumnName) { var badPrimaryKeySchema = new PrimaryKeySchema(); badPrimaryKeySchema.Add(badColumnName, ColumnValueType.String); var badPrimaryKey = new PrimaryKey(); badPrimaryKey.Add(badColumnName, new ColumnValue(3.14)); var badColumnsToGet = new HashSet <string>(); badColumnsToGet.Add(badColumnName); var errorMessage = String.Format("Invalid column name: '{0}'.", badColumnName); var badAttribute = new AttributeColumns(); badAttribute.Add(badColumnName, new ColumnValue(3.14)); SetTestConext( pkSchema: badPrimaryKeySchema, primaryKey: badPrimaryKey, startPrimaryKey: badPrimaryKey, allFailedMessage: errorMessage); TestAllDataAPI(deleteTable: false); SetTestConext( attribute: badAttribute, allFailedMessage: errorMessage); TestAllDataAPIWithAttribute(false); SetTestConext( columnsToGet: badColumnsToGet, allFailedMessage: errorMessage); TestAllDataAPIWithColumnsToGet(); }
public void SetTestConext(string tableName = null, PrimaryKeySchema pkSchema = null, CapacityUnit reservedThroughput = null, PrimaryKey primaryKey = null, AttributeColumns attribute = null, UpdateOfAttribute updateOfAttributeForPut = null, UpdateOfAttribute updateOfAttributeForDelete = null, Condition condition = null, GetRangeDirection direction = GetRangeDirection.Forward, PrimaryKey startPrimaryKey = null, PrimaryKey endPrimaryKey = null, HashSet <string> columnsToGet = null, int?limit = null, CapacityUnit putRowConsumed = null, CapacityUnit getRowConsumed = null, CapacityUnit updateRowConsumed = null, CapacityUnit deleteRowConsumed = null, CapacityUnit getRangeConsumed = null, Dictionary <string, string> expectedFailure = null, string allFailedMessage = null) { var DefaultPrimaryKeySchema = new PrimaryKeySchema(); DefaultPrimaryKeySchema.Add("PK0", ColumnValueType.String); DefaultPrimaryKeySchema.Add("PK1", ColumnValueType.String); DefaultPrimaryKeySchema.Add("PK2", ColumnValueType.Integer); DefaultPrimaryKeySchema.Add("PK3", ColumnValueType.Integer); var DefaultReservedThroughput = new CapacityUnit(0, 0); TestContext = new APITestContext(); TestContext.expectedFailure = expectedFailure; TestContext.allFailedMessage = allFailedMessage; TestContext.tableName = tableName ?? OTSUnitTestBase.TestTableName; TestContext.pkSchema = pkSchema ?? DefaultPrimaryKeySchema; TestContext.reservedThroughput = reservedThroughput ?? DefaultReservedThroughput; TestContext.primaryKey = primaryKey ?? PrimaryKeyWith4Columns; TestContext.attribute = attribute ?? AttributeWith5Columns; TestContext.condition = condition ?? new Condition(RowExistenceExpectation.IGNORE); TestContext.startPrimaryKey = startPrimaryKey ?? MinPrimaryKeyWith4Columns; TestContext.endPrimaryKey = endPrimaryKey ?? MaxPrimaryKeyWith4Columns; TestContext.putRowConsumed = putRowConsumed ?? new CapacityUnit(0, 1); TestContext.getRowConsumed = getRowConsumed ?? new CapacityUnit(1, 0); TestContext.updateRowConsumed = updateRowConsumed ?? new CapacityUnit(0, 1); TestContext.deleteRowConsumed = deleteRowConsumed ?? new CapacityUnit(0, 1); TestContext.getRangeConsumed = getRangeConsumed ?? new CapacityUnit(1, 0); TestContext.columnsToGet = columnsToGet; TestContext.limit = limit; TestContext.direction = direction; if (updateOfAttributeForPut == null) { updateOfAttributeForPut = new UpdateOfAttribute(); foreach (var item in TestContext.attribute) { updateOfAttributeForPut.AddAttributeColumnToPut(item.Key, item.Value); } } if (updateOfAttributeForDelete == null) { updateOfAttributeForDelete = new UpdateOfAttribute(); foreach (var item in TestContext.attribute) { updateOfAttributeForDelete.AddAttributeColumnToDelete(item.Key); } } TestContext.updateOfAttributeForPut = updateOfAttributeForPut; TestContext.updateOfAttributeForDelete = updateOfAttributeForDelete; }
/// <summary> /// /// </summary> /// <param name="type"></param> protected static string SetTable(Type type) { #region 初始化缓存 if (!tableNames.ContainsKey(type)) { foreach (var attr in type.CustomAttributes) { if (attr.AttributeType == typeof(System.ComponentModel.DataAnnotations.Schema.TableAttribute)) { tableNames.TryAdd(type, attr.ConstructorArguments[0].Value.ToString()); break; } } } #endregion var name = tableNames.ContainsKey(type) ? tableNames[type] : type.Name.ToLower(); #region 分析表结构 var pkSchema = new PrimaryKeySchema(); foreach (PropertyInfo info in rft.GetPropertyList(type)) { if (info.GetCustomAttribute(typeof(System.ComponentModel.DataAnnotations.KeyAttribute)) == null) { continue; } else if (info.PropertyType == typeof(int)) { pkSchema.Add(info.Name, ColumnValueType.Integer); } else if (info.PropertyType == typeof(string)) { pkSchema.Add(info.Name, ColumnValueType.String); } else if (info.PropertyType == typeof(byte[])) { pkSchema.Add(info.Name, ColumnValueType.Binary); } else { throw new Exception("不支持当前类型的主键"); } } ; #endregion #region 生成表结构 if (tableKey.ContainsKey(name)) { #region 对比已有结构 tableKey[name].ForEach(key => { pkSchema.ForEach(tmp => { if (key.Item1 == tmp.Item1 && (key.Item2 != tmp.Item2 || key.Item3 != tmp.Item3)) { log.Fatal("Table structure is inconsistent, table name:" + name); return; } }); }); #endregion } else { #region 创建新表 //通过表名和主键列的schema创建一个tableMeta var client = new OTSClient(OtsConfig); var tableMeta = new TableMeta(name, pkSchema); // 设定预留读吞吐量为0,预留写吞吐量为0 var reservedThroughput = new CapacityUnit(0, 0); try { // 构造CreateTableRequest对象 var reqCreateTable = new CreateTableRequest(tableMeta, reservedThroughput); // 调用client的CreateTable接口,如果没有抛出异常,则说明成功,否则失败 client.CreateTable(reqCreateTable); // 生成查询索引 var reqCreateSearchIndex = new CreateSearchIndexRequest(name, name); var fieldSchemas = new List <FieldSchema>(); foreach (PropertyInfo info in rft.GetPropertyList(type)) { if (info.GetCustomAttribute(typeof(System.ComponentModel.DataAnnotations.CompareAttribute)) == null) { continue; } else if (info.PropertyType == typeof(int) || info.PropertyType == typeof(long)) { fieldSchemas.Add(new FieldSchema(info.Name, FieldType.LONG) { index = true }); } else if (info.PropertyType == typeof(string)) { fieldSchemas.Add(new FieldSchema(info.Name, FieldType.TEXT) { index = true }); } else if (info.PropertyType == typeof(double)) { fieldSchemas.Add(new FieldSchema(info.Name, FieldType.DOUBLE) { index = true }); } else if (info.PropertyType == typeof(bool)) { fieldSchemas.Add(new FieldSchema(info.Name, FieldType.BOOLEAN) { index = true }); } } ; if (fieldSchemas.Count > 0) { reqCreateSearchIndex.IndexSchame = new IndexSchema() { FieldSchemas = fieldSchemas }; client.CreateSearchIndex(reqCreateSearchIndex); log.Info("Create table succeeded, table name:" + name); } } // 处理异常 catch (Exception ex) { Console.WriteLine("Create table failed, exception:{0}", ex.Message); } #endregion } #endregion return(name); }
public void TestForNormal() { var schema = new PrimaryKeySchema(); schema.Add("pk1", ColumnValueType.String); CreateTestTable(TestTableName, schema, new CapacityUnit(0, 0)); var attr1 = new AttributeColumns(); attr1.Add("attr", new ColumnValue("attr_value1")); var attr2 = new AttributeColumns(); attr2.Add("attr", new ColumnValue("attr_value2")); var attr3 = new AttributeColumns(); attr3.Add("attr", new ColumnValue("attr_value3")); { List <PrimaryKey> primaryKeys = new List <PrimaryKey>(); var pk1 = new PrimaryKey(); pk1.Add("pk1", new ColumnValue("1")); var pk2 = new PrimaryKey(); pk2.Add("pk1", new ColumnValue("2")); var pk3 = new PrimaryKey(); pk3.Add("pk1", new ColumnValue("3")); primaryKeys.Add(pk1); primaryKeys.Add(pk2); primaryKeys.Add(pk3); { var request = new BatchWriteRowRequest(); var change = new RowChanges(); change.AddPut(new Condition(RowExistenceExpectation.IGNORE), pk1, attr1); change.AddPut(new Condition(RowExistenceExpectation.IGNORE), pk2, attr2); change.AddPut(new Condition(RowExistenceExpectation.IGNORE), pk3, attr3); request.Add(TestTableName, change); var response = OTSClient.BatchWriteRow(request); } { var request = new BatchGetRowRequest(); request.Add(TestTableName, primaryKeys); var response = OTSClient.BatchGetRow(request); var tables = response.RowDataGroupByTable; Assert.AreEqual(1, tables.Count); var rows = tables[TestTableName]; Assert.AreEqual(3, rows.Count); AssertPrimaryKey(pk1, rows[0].PrimaryKey); AssertPrimaryKey(pk2, rows[1].PrimaryKey); AssertPrimaryKey(pk3, rows[2].PrimaryKey); AssertAttribute(attr1, rows[0].Attribute); AssertAttribute(attr2, rows[1].Attribute); AssertAttribute(attr3, rows[2].Attribute); } } }