Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ class JacksonParser(
case _: StringType => (parser: JsonParser) => {
// This must be enabled if we will retrieve the bytes directly from the raw content:
val oldFeature = parser.getFeatureMask
parser.setFeatureMask(oldFeature | JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION.getMask)
val featureToAdd = JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION.getMask
parser.overrideStdFeatures(oldFeature | featureToAdd, featureToAdd)
val result = parseJsonToken[UTF8String](parser, dataType) {
case VALUE_STRING =>
UTF8String.fromString(parser.getText)
Expand Down Expand Up @@ -338,8 +339,11 @@ class JacksonParser(
UTF8String.fromBytes(writer.toByteArray)
}
}
// Reset back to the original configuration:
parser.setFeatureMask(oldFeature)
// Reset back to the original configuration using `~0` as the mask,
// 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.

result
}

Expand Down
Loading