You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Robert Yokota (Jira)" <ji...@apache.org> on 2020/04/29 01:35:00 UTC

[jira] [Updated] (AVRO-2822) Need a method to reconstruct the original schema string before referenced schemas were resolved and inlined by the Parser

     [ https://issues.apache.org/jira/browse/AVRO-2822?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Yokota updated AVRO-2822:
--------------------------------
    Description: 
I need a method to reconstruct the original schema string before referenced schemas were resolved and inlined by the Parser.

There is already logic to do this for a schema in the context of a protocol, but not when a schema (and its referenced schemas) are submitted to the parser() method of Schema.Parser.

The method would essentially look like
{code:java}
public String toString(Collection<Schema> referencedSchemas, boolean pretty) {
  try {
    StringWriter writer = new StringWriter();
    JsonGenerator gen = FACTORY.createGenerator(writer);
    if (pretty) {
      gen.useDefaultPrettyPrinter();
    }
    Schema.Names names = new Schema.Names();
    if (referencedSchemas != null) {
      for (Schema s : referencedSchemas) {
        names.add(s);
      }
    }
    toJson(names, gen);
    gen.flush();
    return writer.toString();
  } catch (IOException e) {
    throw new AvroRuntimeException(e);
  }
}{code}
 

 

  was:
I need a method to reconstruct the original schema string before referenced schemas were resolved and inlined by the Parser.

There is already logic to do this for a schema in the context of a protocol, but not when a schema (and its referenced schemas) are submitted to the parser() method of Schema.Parser.

The method would essentially look like
```

public String toString(Collection<Schema> referencedSchemas, boolean pretty) {
 try {
 StringWriter writer = new StringWriter();
 JsonGenerator gen = FACTORY.createGenerator(writer);
 if (pretty) {
 gen.useDefaultPrettyPrinter();
 }
 Schema.Names names = new Schema.Names();
 if (referencedSchemas != null) {
 for (Schema s : referencedSchemas) {
 names.add(s);
 }
 }
 toJson(names, gen);
 gen.flush();
 return writer.toString();
 } catch (IOException e) {
 throw new AvroRuntimeException(e);
 }
}

```


> Need a method to reconstruct the original schema string before referenced schemas were resolved and inlined by the Parser
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-2822
>                 URL: https://issues.apache.org/jira/browse/AVRO-2822
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.9.2
>            Reporter: Robert Yokota
>            Priority: Minor
>             Fix For: 1.10.0
>
>
> I need a method to reconstruct the original schema string before referenced schemas were resolved and inlined by the Parser.
> There is already logic to do this for a schema in the context of a protocol, but not when a schema (and its referenced schemas) are submitted to the parser() method of Schema.Parser.
> The method would essentially look like
> {code:java}
> public String toString(Collection<Schema> referencedSchemas, boolean pretty) {
>   try {
>     StringWriter writer = new StringWriter();
>     JsonGenerator gen = FACTORY.createGenerator(writer);
>     if (pretty) {
>       gen.useDefaultPrettyPrinter();
>     }
>     Schema.Names names = new Schema.Names();
>     if (referencedSchemas != null) {
>       for (Schema s : referencedSchemas) {
>         names.add(s);
>       }
>     }
>     toJson(names, gen);
>     gen.flush();
>     return writer.toString();
>   } catch (IOException e) {
>     throw new AvroRuntimeException(e);
>   }
> }{code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)