Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-50780][SQL] Use overrideStdFeatures instead of setFeatureMask in JacksonParser #49434

Closed
wants to merge 2 commits into from

Conversation

LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Jan 10, 2025

What changes were proposed in this pull request?

In #49018, the restoration logic for feature flags was fixed using the setFeatureMask method. However, the setFeatureMask method has been deprecated since Jackson 2.7, so this pr reimplements the relevant logic using overrideStdFeatures.

Why are the changes needed?

Clean up the use of deprecated APIs.

https://github.com/FasterXML/jackson-core/blob/0d2b0f39200d466f49f1abb06d9027053d41483d/src/main/java/com/fasterxml/jackson/core/JsonParser.java#L999-L1035

    /**
     * Bulk set method for (re)setting states of all standard {@link Feature}s
     *
     * @param mask Bit mask that defines set of features to enable
     *
     * @return This parser, to allow call chaining
     *
     * @since 2.3
     * @deprecated Since 2.7, use {@link #overrideStdFeatures(int, int)} instead
     */
    @Deprecated
    public JsonParser setFeatureMask(int mask) {
        _features = mask;
        return this;
    }

    /**
     * Bulk set method for (re)setting states of features specified by <code>mask</code>.
     * Functionally equivalent to
     *<code>
     *    int oldState = getFeatureMask();
     *    int newState = (oldState &amp; ~mask) | (values &amp; mask);
     *    setFeatureMask(newState);
     *</code>
     * but preferred as this lets caller more efficiently specify actual changes made.
     *
     * @param values Bit mask of set/clear state for features to change
     * @param mask Bit mask of features to change
     *
     * @return This parser, to allow call chaining
     *
     * @since 2.6
     */
    public JsonParser overrideStdFeatures(int values, int mask) {
        int newState = (_features & ~mask) | (values & mask);
        return setFeatureMask(newState);
    }

Does this PR introduce any user-facing change?

No

How was this patch tested?

Was this patch authored or co-authored using generative AI tooling?

No

@LuciferYang LuciferYang marked this pull request as draft January 10, 2025 05:33
@github-actions github-actions bot added the SQL label Jan 10, 2025
@LuciferYang LuciferYang changed the title Use overrideStdFeatures instead of setFeatureMask [SPARK-50780][SQL] Use overrideStdFeatures instead of setFeatureMask Jan 10, 2025
// which is a bitmask with all bits set, effectively allowing all features
// to be reset. This ensures that every feature is restored to its previous
// state as defined by `oldFeature`.
parser.overrideStdFeatures(oldFeature, ~0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also use a seat mask of -1 to restore the state, as long as all the bits are set to 1.

@LuciferYang LuciferYang changed the title [SPARK-50780][SQL] Use overrideStdFeatures instead of setFeatureMask [SPARK-50780][SQL] Use overrideStdFeatures instead of setFeatureMask for JsonParser Jan 10, 2025
@LuciferYang LuciferYang changed the title [SPARK-50780][SQL] Use overrideStdFeatures instead of setFeatureMask for JsonParser [SPARK-50780][SQL] Use overrideStdFeatures instead of setFeatureMask in JacksonParser Jan 10, 2025
@LuciferYang LuciferYang marked this pull request as ready for review January 10, 2025 08:49
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Thank you, @LuciferYang .

@dongjoon-hyun
Copy link
Member

Merged to master for Apache Spark 4.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants