From d3f0d4393ae12fcd95036b4d37ae00b39a724961 Mon Sep 17 00:00:00 2001 From: olivertang Date: Sat, 12 Feb 2022 21:08:40 +0800 Subject: [PATCH] fix byte[] can not be the hashkey --- .../xiaomi/infra/pegasus/client/PegasusTable.java | 12 ++++++++---- .../infra/pegasus/client/PegasusTableInterface.java | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/xiaomi/infra/pegasus/client/PegasusTable.java b/src/main/java/com/xiaomi/infra/pegasus/client/PegasusTable.java index d21c7aba..cefc33f0 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/client/PegasusTable.java +++ b/src/main/java/com/xiaomi/infra/pegasus/client/PegasusTable.java @@ -438,7 +438,8 @@ public void onCompletion(client_operator clientOP) { result.valueMap = new HashMap<>(); for (full_data oneData : gop.get_response().data) { result.valueMap.put( - Pair.of(oneData.hash_key.data, oneData.sort_key.data), oneData.value.data); + Pair.of(new String(oneData.hash_key.data), new String(oneData.sort_key.data)), + oneData.value.data); } promise.setSuccess(result); @@ -1086,10 +1087,10 @@ public int batchGet3( futures.add(asyncBatchGet(request, timeout)); } - List, byte[]>> resultMapList = new ArrayList<>(); + List, byte[]>> resultMapList = new ArrayList<>(); for (int i = 0; i < this.table.getPartitionCount(); i++) { if (emptyResults.get(i)) { - Map, byte[]> emptyMap = new HashMap<>(); + Map, byte[]> emptyMap = new HashMap<>(); resultMapList.add(emptyMap); continue; } @@ -1112,7 +1113,10 @@ public int batchGet3( continue; } - byte[] value = resultMapList.get(index).get(keys.get(i)); + byte[] value = + resultMapList + .get(index) + .get(Pair.of(new String(keys.get(i).getLeft()), new String(keys.get(i).getRight()))); results.add(Pair.of(null, value)); count++; diff --git a/src/main/java/com/xiaomi/infra/pegasus/client/PegasusTableInterface.java b/src/main/java/com/xiaomi/infra/pegasus/client/PegasusTableInterface.java index ae776754..cef03fe2 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/client/PegasusTableInterface.java +++ b/src/main/java/com/xiaomi/infra/pegasus/client/PegasusTableInterface.java @@ -181,7 +181,7 @@ public static class BatchGetResult { */ public boolean allFetched; - public Map, byte[]> valueMap; + public Map, byte[]> valueMap; } public static interface MultiGetListener extends GenericFutureListener> {