private byte[] createMarshalledUser(String name, String surname) throws IOException {
    User user = new User();
    user.setId(1);
    user.setName(name);
    user.setSurname(surname);
    user.setGender(User.Gender.MALE);
    user.setAccountIds(Collections.singleton(12));

    Address address = new Address();
    address.setStreet("Dark Alley");
    address.setPostCode("1234");
    user.setAddresses(Collections.singletonList(address));

    return ProtobufUtil.toWrappedByteArray(
        ProtobufMetadataManagerImpl.getSerializationContextInternal(cacheManager), user);
  }
  private QueryResponse executeNonIndexedQuery(
      AdvancedCache<byte[], byte[]> cache, SerializationContext serCtx, QueryRequest request)
      throws IOException {
    boolean compatMode = cache.getCacheConfiguration().compatibility().enabled();
    Class<? extends Matcher> matcherImplClass =
        compatMode ? CompatibilityReflectionMatcher.class : ProtobufMatcher.class;

    EmbeddedQuery eq =
        new EmbeddedQuery(
            cache,
            request.getJpqlString(),
            request.getStartOffset(),
            request.getMaxResults(),
            matcherImplClass);
    List<?> list = eq.list();
    int projSize = 0;
    if (eq.getProjection() != null && eq.getProjection().length > 0) {
      projSize = eq.getProjection().length;
    }
    List<WrappedMessage> results =
        new ArrayList<WrappedMessage>(projSize == 0 ? list.size() : list.size() * projSize);
    for (Object o : list) {
      if (projSize == 0) {
        if (compatMode) {
          // if we are in compat mode then this is the real object so need to marshall it first
          o = ProtobufUtil.toWrappedByteArray(serCtx, o);
        }
        results.add(new WrappedMessage(o));
      } else {
        Object[] row = (Object[]) o;
        for (int j = 0; j < projSize; j++) {
          results.add(new WrappedMessage(row[j]));
        }
      }
    }

    QueryResponse response = new QueryResponse();
    response.setTotalResults(eq.getResultSize());
    response.setNumResults(list.size());
    response.setProjectionSize(projSize);
    response.setResults(results);

    return response;
  }
 @Override
 public byte[] filterAndConvert(
     Object key,
     Object oldValue,
     Metadata oldMetadata,
     Object newValue,
     Metadata newMetadata,
     EventType eventType) {
   ObjectFilter.FilterResult filterResult =
       filterAndConverter.filterAndConvert(key, newValue, newMetadata);
   if (filterResult != null) {
     try {
       return ProtobufUtil.toWrappedByteArray(
           serCtx,
           new FilterResult(
               filterResult.getInstance(),
               filterResult.getProjection(),
               filterResult.getSortProjection()));
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
   }
   return null;
 }