閱讀323 返回首頁    go 汽車大全


BatchGetRow__API 概覽_API 參考_表格存儲-阿裏雲

行為:

批量讀取一個或多個表中的若幹行數據。

BatchGetRow 操作可視為多個 GetRow 操作的集合,各個操作獨立執行,獨立返回結果,獨立計算服務能力單元。

與執行大量的 GetRow 操作相比,使用 BatchGetRow 操作可以有效減少請求的響應時間,提高數據的讀取速率。

請求結構:

  1. message BatchGetRowRequest {
  2. repeated TableInBatchGetRowRequest tables = 1;
  3. }

tables:

  • 類型:repeated TableInBatchGetRowRequest

  • 是否必要參數:是。

  • 指定了需要要讀取的行信息。

  • 若 tables 中出現了下述情況,則操作整體失敗,返回錯誤。

    • tables 中任一表不存在。

    • tables 中任一表名不符合表名命名規範

    • tables 中任一行未指定主鍵、主鍵名稱不符合規範或者主鍵類型不正確。

    • tables 中任一表的 columns_to_get 內的列名不符合列名命名規範

    • tables 中包含同名的表。

    • tables 中任一表內包含主鍵完全相同的行。

    • 所有 tables 中 RowInBatchGetRowRequest 的總個數超過 100 個。

    • tables 中任一表內不包含任何 RowInBatchGetRowRequest。

    • tables 中任一表的 columns_to_get 超過 128 列。

響應消息結構:

  1. message BatchGetRowResponse {
  2. repeated TableInBatchGetRowResponse tables = 1;
  3. }

tables:

  • 類型:repeated TableInBatchGetRowResponse

  • 對應了每個 table 下讀取到的數據。

  • 響應消息中 TableInBatchGetRowResponse 對象的順序與 BatchGetRowRequest 中的 TableInBatchGetRowRequest 對象的順序相同;每個 TableInBatchGetRowResponse 下麵的 RowInBatchGetRowResponse 對象的順序與 TableInBatchGetRowRequest 下麵的 RowInBatchGetRowRequest 相同。

  • 如果某行不存在或者某行在指定的 columns_to_get 下沒有數據,仍然會在 TableInBatchGetRowResponse 中有一條對應的 RowInBatchGetRowResponse,但其 row 下麵的 primary_key_columns 和 attribute_columns 將為空。

  • 若某行讀取失敗,該行所對應的 RowInBatchGetRowResponse 中 is_ok 將為 false,此時 row 將為空。

注意:BatchGetRow 操作可能會在行級別部分失敗,此時返回的 HTTP 狀態碼仍為 200。應用程序必須對 RowInBatchGetRowResponse 中的 error 進行檢查確認每一行的執行結果,並進行相應的處理。

服務能力單元消耗:

  • 如果本次操作整體失敗,不消耗任何服務能力單元。

  • 如果請求超時,結果未定義,服務能力單元有可能被消耗,也可能未被消耗。

  • 其他情況將每個 RowInBatchGetRowRequest 視為一個 GetRow 操作獨立計算寫服務能力單元,GetRow服務能力單元消耗

請求示例:

  1. BatchGetRowRequest {
  2. tables {
  3. table_name: "consume_history"
  4. rows {
  5. primary_key {
  6. name: "CardID"
  7. value {
  8. type: STRING
  9. v_string: "2007035023"
  10. }
  11. }
  12. primary_key {
  13. name: "SellerID"
  14. value {
  15. type: STRING
  16. v_string: "00022"
  17. }
  18. }
  19. primary_key {
  20. name: "DeviceID"
  21. value {
  22. type: STRING
  23. v_string: "061104"
  24. }
  25. }
  26. primary_key {
  27. name: "OrderNumber"
  28. value {
  29. type: INTEGER
  30. v_int: 142857
  31. }
  32. }
  33. }
  34. rows {
  35. primary_key {
  36. name: "CardID"
  37. value {
  38. type: STRING
  39. v_string: "2007035023"
  40. }
  41. }
  42. primary_key {
  43. name: "SellerID"
  44. value {
  45. type: STRING
  46. v_string: "00026"
  47. }
  48. }
  49. primary_key {
  50. name: "DeviceID"
  51. value {
  52. type: STRING
  53. v_string: "065499"
  54. }
  55. }
  56. primary_key {
  57. name: "OrderNumber"
  58. value {
  59. type: INTEGER
  60. v_int: 153846
  61. }
  62. }
  63. }
  64. columns_to_get: "CardID"
  65. columns_to_get: "SellerID"
  66. columns_to_get: "DeviceID"
  67. columns_to_get: "OrderNumber"
  68. columns_to_get: "Amount"
  69. columns_to_get: "Remarks"
  70. }
  71. }

響應示例:

  1. BatchGetRowResponse {
  2. tables {
  3. table_name: "consume_history"
  4. rows {
  5. is_ok: true
  6. consumed {
  7. capacity_unit {
  8. read: 1
  9. }
  10. }
  11. row {
  12. primary_key_columns {
  13. name: "CardID"
  14. value {
  15. type: STRING
  16. v_string: "2007035023"
  17. }
  18. }
  19. primary_key_columns {
  20. name: "SellerID"
  21. value {
  22. type: STRING
  23. v_string: "00022"
  24. }
  25. }
  26. primary_key_columns {
  27. name: "DeviceID"
  28. value {
  29. type: STRING
  30. v_string: "061104"
  31. }
  32. }
  33. primary_key_columns {
  34. name: "OrderNumber"
  35. value {
  36. type: INTEGER
  37. v_int: 142857
  38. }
  39. }
  40. attribute_columns {
  41. name: "Amount"
  42. value {
  43. type: DOUBLE
  44. v_double: 2.5
  45. }
  46. }
  47. attribute_columns {
  48. name: "Remarks"
  49. value {
  50. type: STRING
  51. v_string: "ice cream"
  52. }
  53. }
  54. }
  55. }
  56. rows {
  57. is_ok: true
  58. consumed {
  59. capacity_unit {
  60. read: 1
  61. }
  62. }
  63. row {
  64. primary_key_columns {
  65. name: "CardID"
  66. value {
  67. type: STRING
  68. v_string: "2007035023"
  69. }
  70. }
  71. primary_key_columns {
  72. name: "SellerID"
  73. value {
  74. type: STRING
  75. v_string: "00026"
  76. }
  77. }
  78. primary_key_columns {
  79. name: "DeviceID"
  80. value {
  81. type: STRING
  82. v_string: "065499"
  83. }
  84. }
  85. primary_key_columns {
  86. name: "OrderNumber"
  87. value {
  88. type: INTEGER
  89. v_int: 153846
  90. }
  91. }
  92. attribute_columns {
  93. name: "Amount"
  94. value {
  95. type: DOUBLE
  96. v_double: 0.5
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }

最後更新:2016-11-23 16:03:56

  上一篇:go GetRange__API 概覽_API 參考_表格存儲-阿裏雲
  下一篇:go BatchWriteRow__API 概覽_API 參考_表格存儲-阿裏雲