This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/phoenix-adapters.git
The following commit(s) were added to refs/heads/main by this push:
new 4f929d7 Return mock consumed capacity for all APIs
4f929d7 is described below
commit 4f929d7e8511ba164045e689933792d9e638a125
Author: Palash Chauhan <[email protected]>
AuthorDate: Thu Jan 8 11:20:12 2026 -0800
Return mock consumed capacity for all APIs
---
.../main/java/org/apache/phoenix/ddb/service/DeleteItemService.java | 2 ++
.../src/main/java/org/apache/phoenix/ddb/service/GetItemService.java | 2 ++
.../src/main/java/org/apache/phoenix/ddb/service/PutItemService.java | 4 +++-
.../main/java/org/apache/phoenix/ddb/service/UpdateItemService.java | 5 ++++-
.../src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java | 5 ++---
5 files changed, 13 insertions(+), 5 deletions(-)
diff --git
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/DeleteItemService.java
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/DeleteItemService.java
index e761d82..8892ffc 100644
---
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/DeleteItemService.java
+++
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/DeleteItemService.java
@@ -55,6 +55,8 @@ public class DeleteItemService {
} catch (SQLException e) {
throw new PhoenixServiceException(e);
}
+ result.put(ApiMetadata.CONSUMED_CAPACITY,
+
CommonServiceUtils.getConsumedCapacity((String)request.get(ApiMetadata.TABLE_NAME)));
return result;
}
diff --git
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/GetItemService.java
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/GetItemService.java
index 63167ee..a1b0c08 100644
---
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/GetItemService.java
+++
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/GetItemService.java
@@ -119,6 +119,8 @@ public class GetItemService {
getProjectionAttributes(request));
finalResult.put("Item", item);
}
+ finalResult.put(ApiMetadata.CONSUMED_CAPACITY,
+
CommonServiceUtils.getConsumedCapacity((String)request.get(ApiMetadata.TABLE_NAME)));
return finalResult;
}
diff --git
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/PutItemService.java
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/PutItemService.java
index 432c2e3..97751d7 100644
---
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/PutItemService.java
+++
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/PutItemService.java
@@ -57,13 +57,15 @@ public class PutItemService {
private static final RawBsonDocument EMPTY_RAW_BSON_DOC =
RawBsonDocument.parse("{}");
public static Map<String, Object> putItem(Map<String, Object> request,
String connectionUrl) {
- Map<String, Object> result;
+ Map<String, Object> result = new HashMap<>();
try (Connection connection =
ConnectionUtil.getConnection(connectionUrl)) {
connection.setAutoCommit(true);
result = putItemWithConn(connection, request);
} catch (SQLException e) {
throw new PhoenixServiceException(e);
}
+ result.put(ApiMetadata.CONSUMED_CAPACITY,
+
CommonServiceUtils.getConsumedCapacity((String)request.get(ApiMetadata.TABLE_NAME)));
return result;
}
diff --git
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/UpdateItemService.java
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/UpdateItemService.java
index ea1beb9..5c3a412 100644
---
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/UpdateItemService.java
+++
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/UpdateItemService.java
@@ -86,10 +86,13 @@ public class UpdateItemService {
boolean hasCondExp =
(request.get(ApiMetadata.CONDITION_EXPRESSION) != null) || (
request.get(ApiMetadata.EXPECTED) != null);
- return DMLUtils.executeUpdate(statementInfo.stmt,
+ Map<String, Object> res =
DMLUtils.executeUpdate(statementInfo.stmt,
(String) request.get(ApiMetadata.RETURN_VALUES),
(String)
request.get(ApiMetadata.RETURN_VALUES_ON_CONDITION_CHECK_FAILURE),
hasCondExp, pkCols, ApiOperation.UPDATE_ITEM);
+ res.put(ApiMetadata.CONSUMED_CAPACITY,
+
CommonServiceUtils.getConsumedCapacity((String)request.get(ApiMetadata.TABLE_NAME)));
+ return res;
} catch (SQLException e) {
throw new PhoenixServiceException(e);
}
diff --git
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java
index 8d1b37f..c778c3d 100644
---
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java
+++
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java
@@ -4,7 +4,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Base64;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -67,13 +66,13 @@ public class DMLUtils {
String returnValuesOnConditionCheckFailure, boolean hasCondExp,
List<PColumn> pkCols,
ApiOperation apiOperation) throws SQLException,
ConditionCheckFailedException {
try {
- Map<String, Object> returnAttrs = Collections.emptyMap();
+ Map<String, Object> returnAttrs = new HashMap<>();
if (!needReturnRow(returnValue,
returnValuesOnConditionCheckFailure)) {
int returnStatus = stmt.executeUpdate();
if (returnStatus == 0 && hasCondExp) {
throw new ConditionCheckFailedException();
}
- return Collections.emptyMap();
+ return new HashMap<>();
}
Pair<Integer, ResultSet> resultPair;
if (ApiMetadata.ALL_OLD.equals(returnValue)