foreverneverer commented on code in PR #1104:
URL: https://github.com/apache/incubator-pegasus/pull/1104#discussion_r939787887


##########
java-client/src/main/java/org/apache/pegasus/client/PegasusTable.java:
##########
@@ -2109,40 +2177,69 @@ private void handleWriteLimiterException(DefaultPromise 
promise, String message)
   }
 
   static class Request {
-    byte[] hashKey = null;
-    byte[] sortKey = null;
-    int sortKeyCount = 0;
+    byte[] hashKey = "".getBytes();
+    byte[] sortKey = "".getBytes();
+    int sortKeyCount = 1;
+

Review Comment:
   delete space



##########
java-client/src/main/java/org/apache/pegasus/client/PegasusTable.java:
##########
@@ -2109,40 +2177,69 @@ private void handleWriteLimiterException(DefaultPromise 
promise, String message)
   }
 
   static class Request {
-    byte[] hashKey = null;
-    byte[] sortKey = null;
-    int sortKeyCount = 0;
+    byte[] hashKey = "".getBytes();
+    byte[] sortKey = "".getBytes();
+    int sortKeyCount = 1;
+
+    int valueLength = -1;
 
     Request(byte[] hashKey) {
       this.hashKey = hashKey;
     }
 
     Request(byte[] hashKey, byte[] sortKey) {
       this.hashKey = hashKey;
-      this.sortKey = sortKey;
+      this.sortKey = sortKey == null ? "".getBytes() : sortKey;
     }
 
-    Request(byte[] hashKey, int sortKeyCount) {
+    Request(byte[] hashKey, byte[] sortKey, int sortKeyCount, int valueLength) 
{
       this.hashKey = hashKey;
+      this.sortKey = sortKey == null ? "".getBytes() : sortKey;
       this.sortKeyCount = sortKeyCount;
+      this.valueLength = valueLength;
     }
 
     private String getSubstring(byte[] key) {
       String keyStr = key == null ? "" : new String(key);
       return keyStr.length() < 32 ? keyStr : keyStr.substring(0, 32);
     }
 
+    public static int getValueLength(List<Pair<byte[], byte[]>> values) {
+      if (values == null) {
+        return 0;
+      }
+      int valuesLength = 0;
+      for (Pair<byte[], byte[]> pair : values) {
+        byte[] multiValue = pair.getRight() == null ? "".getBytes() : 
pair.getRight();
+        valuesLength += multiValue.length;
+      }
+      return valuesLength;
+    }
+
+    public static int getValueLength(Mutations mutations) {
+      if (mutations == null) {
+        return 0;
+      }
+      int valuesLength = 0;
+      for (mutate mu : mutations.getMutations()) {
+        byte[] MutateValue = mu.value == null ? "".getBytes() : mu.value.data;
+        valuesLength += MutateValue.length;
+      }
+      return valuesLength;
+    }
+
     @Override
     public String toString() {
       if (sortKey != null) {
         return String.format(
-            "[hashKey[:32]=\"%s\",sortKey[:32]=\"%s\"]",
-            getSubstring(hashKey), getSubstring(sortKey));
+            
"[hashKey[:32]=\"%s\",sortKey[:32]=\"%s\",sortKeyCount=%d,valueLength=%d]",
+            getSubstring(hashKey), getSubstring(sortKey), sortKeyCount, 
valueLength);
       }
 
       if (sortKeyCount > 0) {
         return String.format(
-            "[hashKey[:32]=\"%s\",sortKeyCount=%d]", getSubstring(hashKey), 
sortKeyCount);
+            "[hashKey[:32]=\"%s\",sortKeyCount=%d,valueLength = %d]",
+            getSubstring(hashKey), sortKeyCount);

Review Comment:
   These code won't run for your default(sortKey, sortKeyCount ) value



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to