GetRow

Last Updated: Oct 11, 2016

GetRow

Action:

Reads a single data row based on a given primary key.

Request Structure:

  1. message GetRowRequest {
  2. required string table_name = 1;
  3. repeated Column primary_key = 2;
  4. repeated string columns_to_get = 3;
  5. }

table_name:

  • Type: string
  • Required Parameter: Yes
  • The name of the table holding the data to be read.

primary_key:

  • Required Parameter: Yes
  • All primary key columns of this row.

columns_to_get:

  • Type: repeated string
  • Required Parameter: No
  • The names of all columns to be returned. If null, all columns of this row will be returned.
  • If the specified column does not exist, data will not be returned for this column.
  • If a duplicate column name is given, the return results will only include this column once.
  • In columns_to_get, the number of strings should not exceed 128.

Response Message Structure:

  1. message GetRowResponse {
  2. required ConsumedCapacity consumed = 1;
  3. required Row row = 2;
  4. }

consumed:

  • The capacity units consumed by this operation.

row:

  • The collection of column data to be returned for this row. Here, primary_key_columns and attribute_columns respectively store primary key columns and attribute columns that are read. Their order may not be consistent with that of columns_to_get in GetRowRequest.
  • If this row does not exist, primary_key_columns and attribute_columns will be null.

Capacity Unit Consumption:

  • If the requested row does not exist, 1 read capacity unit is consumed.
  • If the requested row exists, the number of consumed read capacity units is the size of all data from this row divided by 1KB and rounded up. For information on data size calculation, please refer to Billing Explanation.
  • If request timeout occurs and the results are undefined, a capacity unit may or may not be consumed.
  • If an internal error code is returned (HTTP status code: 5XX), this operation will not consume capacity units. If other errors are returned, it will consume 1 read capacity unit.

Request Example:

  1. GetRowRequest {
  2. table_name: "consume_history"
  3. primary_key {
  4. name: "CardID"
  5. value {
  6. type: STRING
  7. v_string: "2007035023"
  8. }
  9. }
  10. primary_key {
  11. name: "SellerID"
  12. value {
  13. type: STRING
  14. v_string: "00022"
  15. }
  16. }
  17. primary_key {
  18. name: "DeviceID"
  19. value {
  20. type: STRING
  21. v_string: "061104"
  22. }
  23. }
  24. primary_key {
  25. name: "OrderNumber"
  26. value {
  27. type: INTEGER
  28. v_int: 142857
  29. }
  30. }
  31. columns_to_get: "CardID"
  32. columns_to_get: "SellerID"
  33. columns_to_get: "DeviceID"
  34. columns_to_get: "OrderNumber"
  35. columns_to_get: "Amount"
  36. columns_to_get: "Remarks"
  37. }

Response Example:

  1. GetRowResponse {
  2. consumed {
  3. capacity_unit {
  4. read: 1
  5. }
  6. }
  7. row {
  8. primary_key_columns {
  9. name: "CardID"
  10. value {
  11. type: STRING
  12. v_string: "2007035023"
  13. }
  14. }
  15. primary_key_columns {
  16. name: "SellerID"
  17. value {
  18. type: STRING
  19. v_string: "00022"
  20. }
  21. }
  22. primary_key_columns {
  23. name: "DeviceID"
  24. value {
  25. type: STRING
  26. v_string: "061104"
  27. }
  28. }
  29. primary_key_columns {
  30. name: "OrderNumber"
  31. value {
  32. type: INTEGER
  33. v_int: 142857
  34. }
  35. }
  36. attribute_columns {
  37. name: "Amount"
  38. value {
  39. type: DOUBLE
  40. v_double: 2.5
  41. }
  42. }
  43. attribute_columns {
  44. name: "Remarks"
  45. value {
  46. type: STRING
  47. v_string: "ice cream"
  48. }
  49. }
  50. }
  51. }
Thank you! We've received your feedback.