Ramin Gharib created FLINK-41338:
------------------------------------
Summary: Add an edit API to VariantBuilder
Key: FLINK-41338
URL: https://issues.apache.org/jira/browse/FLINK-41338
Project: Flink
Issue Type: Sub-task
Components: API / Core
Reporter: Ramin Gharib
Adds the Java API that the FLIP-618 modification functions build on. A builder
holds one value, records edits through handles, and writes the result once in
build(). The source value never changes.
{code:java}
Variant out = event.toBuilder().getField("user").removeField("email").build();
Variant user = Variant.newBuilder().setField("name", "Ada").setField("qty",
2).build();
// {"name":"Ada","qty":2}
{code}
Scope:
* Variant: static of(..) for each supported Java type, ofNull(), newBuilder(),
newBuilder(Variant) and the default method toBuilder().
* VariantBuilder: navigation handles getField and getElement, then setField,
removeField, keepFields, setArrayElement, insertArrayElement,
appendArrayElement, removeArrayElement, stripNulls and build.
* BinaryVariantBuilder records edits as a tree of places and writes once in
build(). Parts that no edit touches are copied as raw bytes, and the source
metadata is kept.
* The FLIP's error table: NullPointerException for a null field name,
IllegalArgumentException for a negative index, VariantTypeException in build()
for a place of the wrong kind or a result over 16 MiB, IllegalStateException
for any call after build().
* Methods that take a Variant accept any implementation, not only BinaryVariant.
* Deprecate VariantBuilder#of, ofNull, object and array, and the nested
VariantObjectBuilder and VariantArrayBuilder. They keep working.
* Unit tests for the new methods and the deprecated ones.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)