Github user hiteshk25 commented on a diff in the pull request:
https://github.com/apache/geode/pull/739#discussion_r135883931
--- Diff:
geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandler.java
---
@@ -50,26 +53,52 @@
.makeErrorResponse(ProtocolErrorCode.REGION_NOT_FOUND.codeValue,
"Region not found"));
}
- try {
- Set<Object> keys = new HashSet<>();
- for (BasicTypes.EncodedValue key : request.getKeyList()) {
- keys.add(ProtobufUtilities.decodeValue(serializationService, key));
- }
- Map<?, ?> results = region.getAll(keys);
- Set<BasicTypes.Entry> entries = new HashSet<>();
- for (Map.Entry entry : results.entrySet()) {
- entries.add(
- ProtobufUtilities.createEntry(serializationService,
entry.getKey(), entry.getValue()));
- }
- return
Success.of(RegionAPI.GetAllResponse.newBuilder().addAllEntries(entries).build());
- } catch (UnsupportedEncodingTypeException ex) {
- return Failure.of(ProtobufResponseUtilities.makeErrorResponse(
- ProtocolErrorCode.VALUE_ENCODING_ERROR.codeValue, "Encoding not
supported."));
- } catch (CodecNotRegisteredForTypeException ex) {
- return Failure.of(ProtobufResponseUtilities.makeErrorResponse(
- ProtocolErrorCode.VALUE_ENCODING_ERROR.codeValue,
- "Codec error in protobuf deserialization."));
+ Map<Boolean, List<Object>> resultsCollection =
request.getKeyList().stream()
+ .map((key) -> processOneMessage(serializationService, region, key))
+ .collect(Collectors.partitioningBy(x -> x instanceof
BasicTypes.Entry));
+ RegionAPI.GetAllResponse.Builder responseBuilder =
RegionAPI.GetAllResponse.newBuilder();
+
+ for (Object entry : resultsCollection.get(true)) {
+ responseBuilder.addEntries((BasicTypes.Entry) entry);
+ }
+
+ for (Object entry : resultsCollection.get(false)) {
+ responseBuilder.addFailures((BasicTypes.KeyedError) entry);
}
+
+ return Success.of(responseBuilder.build());
}
+ private Object processOneMessage(SerializationService
serializationService, Region region,
+ BasicTypes.EncodedValue key) {
+ try {
+ Object decodedKey =
ProtobufUtilities.decodeValue(serializationService, key);
+ Object value = region.get(decodedKey);
--- End diff --
We should not be calling region.get for region.getAll. if there is any
issue with region.getall then file bug to track that issue. but region.get not
acceptable
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---