private FieldDescriptor getFieldDescriptor(Descriptor messageDescriptor, String attributePath) { FieldDescriptor fd = null; String[] split = attributePath.split("[.]"); for (int i = 0; i < split.length; i++) { String name = split[i]; fd = messageDescriptor.findFieldByName(name); if (fd == null) { throw log.unknownField(name, messageDescriptor.getFullName()); } IndexingMetadata indexingMetadata = messageDescriptor.getProcessedAnnotation(IndexingMetadata.INDEXED_ANNOTATION); if (indexingMetadata != null && !indexingMetadata.isFieldIndexed(fd.getNumber())) { throw log.fieldIsNotIndexed(name, messageDescriptor.getFullName()); } if (i < split.length - 1) { messageDescriptor = fd.getMessageType(); } } return fd; }
@Override public byte[] query(AdvancedCache<byte[], byte[]> cache, byte[] query) { try { SerializationContext serCtx = ProtobufMetadataManager.getSerializationContextInternal(cache.getCacheManager()); QueryRequest request = ProtobufUtil.fromByteArray(serCtx, query, 0, query.length, QueryRequest.class); QueryResponse response; if (cache.getCacheConfiguration().indexing().index().isEnabled()) { response = executeQuery(cache, serCtx, request); } else { response = executeNonIndexedQuery(cache, serCtx, request); } return ProtobufUtil.toByteArray(serCtx, response); } catch (IOException e) { throw log.errorExecutingQuery(e); } }