Skip to content

Commit

Permalink
Legacy schema writer option (#489)
Browse files Browse the repository at this point in the history
* Legacy schema writer option
  • Loading branch information
li-ukumar authored May 11, 2023
1 parent 8db108f commit 71a06ac
Show file tree
Hide file tree
Showing 24 changed files with 521 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ public class AvscGenerationConfig {
*/
public static final AvscGenerationConfig CANONICAL_ONELINE = new AvscGenerationConfig(
false, false, false, Optional.of(Boolean.FALSE), false, false,
false, false, false, false, true, false);
false, false, false, false, true, false, false);

/**
* Broad Canonical form of avro, includes defaults and field / schema aliases
* Apache Avro.
*/
public static final AvscGenerationConfig CANONICAL_BROAD_ONELINE = new AvscGenerationConfig(
false, false, false, Optional.of(Boolean.FALSE), false, true,
false, true, false, true, true, false);
false, true, false, true, true, false, false);

/**
* if this value is set to true, and the rest of the values on this config object
Expand Down Expand Up @@ -162,6 +162,10 @@ public class AvscGenerationConfig {
* true to write namespace relative to parent namespace. False writes full namespace.
*/
public final boolean writeRelativeNamespace;
/**
* true to write using legacy AvscWriter, order of fields may be non-deterministic
*/
public final boolean isLegacy;


public AvscGenerationConfig(
Expand All @@ -188,6 +192,7 @@ public AvscGenerationConfig(
this.retainSchemaAliases = true;
this.writeNamespaceExplicitly = false;
this.writeRelativeNamespace = true;
this.isLegacy = true;
}

public AvscGenerationConfig(
Expand Down Expand Up @@ -221,6 +226,42 @@ public AvscGenerationConfig(
this.retainSchemaAliases = retainSchemaAliases;
this.writeNamespaceExplicitly = writeNamespaceExplicitly;
this.writeRelativeNamespace = writeRelativeNamespace;
this.isLegacy = true;
}

public AvscGenerationConfig(
boolean preferUseOfRuntimeAvro,
boolean forceUseOfRuntimeAvro,
boolean prettyPrint,
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
Optional<Boolean> retainPreAvro702Logic,
boolean addAvro702Aliases,
boolean retainDefaults,
boolean retainDocs,
boolean retainFieldAliases,
boolean retainNonClaimedProps,
boolean retainSchemaAliases,
boolean writeNamespaceExplicitly,
boolean writeRelativeNamespace,
boolean isLegacy
) {
//noinspection OptionalAssignedToNull
if (retainPreAvro702Logic == null) {
throw new IllegalArgumentException("retainPreAvro702Logic cannot be null");
}
this.preferUseOfRuntimeAvro = preferUseOfRuntimeAvro;
this.forceUseOfRuntimeAvro = forceUseOfRuntimeAvro;
this.prettyPrint = prettyPrint;
this.retainPreAvro702Logic = retainPreAvro702Logic;
this.addAvro702Aliases = addAvro702Aliases;
this.retainDefaults = retainDefaults;
this.retainDocs = retainDocs;
this.retainFieldAliases = retainFieldAliases;
this.retainNonClaimedProps = retainNonClaimedProps;
this.retainSchemaAliases = retainSchemaAliases;
this.writeNamespaceExplicitly = writeNamespaceExplicitly;
this.writeRelativeNamespace = writeRelativeNamespace;
this.isLegacy = isLegacy;
}

public boolean isPreferUseOfRuntimeAvro() {
Expand Down
Loading

0 comments on commit 71a06ac

Please sign in to comment.