[ 
https://issues.apache.org/jira/browse/GEODE-3385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16146039#comment-16146039
 ] 

ASF GitHub Bot commented on GEODE-3385:
---------------------------------------

Github user kohlmu-pivotal commented on a diff in the pull request:

    https://github.com/apache/geode/pull/739#discussion_r135899858
  
    --- 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 --
    
    I agree with you that getAll should be used, but if the API does not 
provide the functionality that this interface is to expose, then get is a 
viable option until the API issues are addressed


> Change GetAllRequest to return list of errors
> ---------------------------------------------
>
>                 Key: GEODE-3385
>                 URL: https://issues.apache.org/jira/browse/GEODE-3385
>             Project: Geode
>          Issue Type: Sub-task
>          Components: client/server
>            Reporter: Galen O'Sullivan
>            Assignee: Galen O'Sullivan
>
> GetAllRequest currently returns a list of successful keys or an error (if 
> getting any key threw an exception). We should instead return a list of 
> errors, similar to PutAllRequest.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to