Vikas~

I suspect your best bet is:

```
Schema<?> s = ....
Object o = s.newInstance();
if (o instanceof MessageOrBuilder) {
    return ((MessageOrBuilder)o).getDescriptorForType();
}
return nullptr;
```

If you are using the JavaLite runtime, you may not have descriptor
information available, so this can produce nullptr.

Matt

On Sat, Aug 6, 2022 at 4:13 PM Vikas Dahiya <[email protected]> wrote:

> Matt,
>
> Kafka APIs really don't have to do anything here. Think of it as a
> problem: I got a schema from any random place (in this case it's a schema
> registry), and now I need to use this schema to create an Object to use in
> my system. I don't have generated java classes at my disposal. So I am
> looking to get the descriptor to create an Object out of this schema. Hope
> that helps to understand the problem.
>
> Thanks,
> Vikas
> On Saturday, August 6, 2022 at 1:05:00 PM UTC-7 [email protected] wrote:
>
>> Vikas~
>>
>> I don't really know the Kafka APIs, but it might be better to ask on one
>> of their lists or maybe stack overflow.
>>
>> Matt
>>
>> On Sat, Aug 6, 2022 at 3:57 PM Vikas Dahiya <[email protected]> wrote:
>>
>>> Matt, I am using kafka, I don’t have a code snippet as I am just getting
>>> the schema from confulant schema registry and need a descriptor to create
>>> the object. I can share the schema snippet if that can help.
>>>
>>> Vikas
>>>
>>> On Sat, Aug 6, 2022 at 12:30 PM Matthew Fowles Kulukundis <
>>> [email protected]> wrote:
>>>
>>>> Vikas~
>>>>
>>>> Do you have links to your code or snippets you can share?  Are you
>>>> using kafka or AWS schema registry or something?
>>>>
>>>> Matt
>>>>
>>>> On Sat, Aug 6, 2022 at 3:23 PM Vikas Dahiya <[email protected]>
>>>> wrote:
>>>>
>>>>> Matt, I am using Java.
>>>>>
>>>>> Thanks!
>>>>> Vikas
>>>>>
>>>>> On Saturday, August 6, 2022 at 11:57:25 AM UTC-7 [email protected]
>>>>> wrote:
>>>>>
>>>>>> Vikas~
>>>>>>
>>>>>> What language are you using (C++, Java, Python, etc)?
>>>>>>
>>>>>> Matt
>>>>>>
>>>>>> On Fri, Aug 5, 2022 at 5:14 PM Vikas Dahiya <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> I have an in memory proto schema which I am reading from the schema
>>>>>>> registry. I am looking for a way or the best way if there are more than
>>>>>>> one, to get the descriptor for this schema. How can I do that? I am new 
>>>>>>> to
>>>>>>> protobuf and pardon me if the provided information is not sufficient, 
>>>>>>> but I
>>>>>>> can provide any required additional details.
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Protocol Buffers" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/protobuf/3b2a5728-549b-4c19-a1b2-4811b0124f8cn%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/protobuf/3b2a5728-549b-4c19-a1b2-4811b0124f8cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Protocol Buffers" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>
>>>>
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/protobuf/b87d55ad-1bfe-4378-9355-e43a55f47003n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/protobuf/b87d55ad-1bfe-4378-9355-e43a55f47003n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/1f6e5388-75ed-4a06-944e-0efce86dfc03n%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/1f6e5388-75ed-4a06-944e-0efce86dfc03n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CAMiELU0fzxLbQmjp%2BCPBaNafor9%2Bk1ESDaBm0LqZAHaLjHo1qA%40mail.gmail.com.

Reply via email to