GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pulsar/pip/pip-177.md at master · apache/pulsar

Expand file tree

/

pip-177.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
55 lines (38 loc) · 1.63 KB
/

pip-177.md

Copy path

File metadata and controls

55 lines (38 loc) · 1.63 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

PIP-177: Add the classLoader field for SchemaDefinition

Mailing list thread: https://lists.apache.org/thread/ydslz3h8ymjjwm5ng02kwszmc5j5hy30

Motivation

Now, don‘t register logical type conversions when use SchemaDefinition.<T>builder().withJsonDef() to create the schema, beacase it without classLoader param. (e.g: #15899)

See:

pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/AvroReader.java

Lines 58 to 68 in 04aa9e8

public AvroReader(Schema writerSchema, Schema readerSchema, ClassLoader classLoader,
boolean jsr310ConversionEnabled) {
this.schema = readerSchema;
if (classLoader != null) {
ReflectData reflectData = new ReflectData(classLoader);
AvroSchema.addLogicalTypeConversions(reflectData, jsr310ConversionEnabled);
this.reader = new ReflectDatumReader<>(writerSchema, readerSchema, reflectData);
} else {
this.reader = new ReflectDatumReader<>(writerSchema, readerSchema);
}
}

We can add the classLoader field for SchemaDefinition, user can manually pass a classLoader to register logical type conversions

Goal

This proposes to add the classLoader field for SchemaDefinition. When using SchemaDefinition.<T>builder().withJsonDef() to create the schema it must manually specify a classLoader otherwise, the converter will not work.

The priority of the classLoader field will be higher than by the pojoClass.getClassLoader().

API Changes

public class SchemaDefinitionBuilder {
    //....

    /**
     * Set schema of pojo classLoader.
     *
     * @param classLoader pojo classLoader
     *
     * @return schema definition builder
     */
    SchemaDefinitionBuilder<T> withClassLoader(ClassLoader classLoader);
}
public class SchemaDefinition {
    //....

    /**
     * Get pojo classLoader.
     *
     * @return pojo schema
     */
    ClassLoader getClassLoader();
}

Implementation

Add the classloader field for SchemaDefinition.

Links

  • Mailing List voting thread: https://lists.apache.org/thread/ydslz3h8ymjjwm5ng02kwszmc5j5hy30
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.