-
Notifications
You must be signed in to change notification settings - Fork 14.8k
KAFKA-19822: Remove all unused static classes in Field #20799
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,9 +23,6 @@ | |
| import java.util.Arrays; | ||
| import java.util.Objects; | ||
|
|
||
| import static org.apache.kafka.common.protocol.MessageUtil.UNSIGNED_INT_MAX; | ||
| import static org.apache.kafka.common.protocol.MessageUtil.UNSIGNED_SHORT_MAX; | ||
|
|
||
| /** | ||
| * A record that can be serialized and deserialized according to a pre-defined schema | ||
| */ | ||
|
|
@@ -80,124 +77,6 @@ public Object get(BoundField field) { | |
| return getFieldOrDefault(field); | ||
| } | ||
|
|
||
| public Byte get(Field.Int8 field) { | ||
| return getByte(field.name); | ||
| } | ||
|
|
||
| public Integer get(Field.Int32 field) { | ||
| return getInt(field.name); | ||
| } | ||
|
|
||
| public Long get(Field.Int64 field) { | ||
| return getLong(field.name); | ||
| } | ||
|
|
||
| public Uuid get(Field.UUID field) { | ||
| return getUuid(field.name); | ||
| } | ||
|
|
||
| public Integer get(Field.Uint16 field) { | ||
| return getInt(field.name); | ||
| } | ||
|
|
||
| public Long get(Field.Uint32 field) { | ||
| return getLong(field.name); | ||
| } | ||
|
|
||
| public Short get(Field.Int16 field) { | ||
| return getShort(field.name); | ||
| } | ||
|
|
||
| public Double get(Field.Float64 field) { | ||
| return getDouble(field.name); | ||
| } | ||
|
|
||
| public String get(Field.Str field) { | ||
| return getString(field.name); | ||
| } | ||
|
|
||
| public String get(Field.NullableStr field) { | ||
| return getString(field.name); | ||
| } | ||
|
|
||
| public Boolean get(Field.Bool field) { | ||
| return getBoolean(field.name); | ||
| } | ||
|
|
||
| public Object[] get(Field.Array field) { | ||
| return getArray(field.name); | ||
| } | ||
|
|
||
| public Object[] get(Field.ComplexArray field) { | ||
| return getArray(field.name); | ||
| } | ||
|
|
||
| public Long getOrElse(Field.Int64 field, long alternative) { | ||
| if (hasField(field.name)) | ||
| return getLong(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public Uuid getOrElse(Field.UUID field, Uuid alternative) { | ||
| if (hasField(field.name)) | ||
| return getUuid(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public Short getOrElse(Field.Int16 field, short alternative) { | ||
| if (hasField(field.name)) | ||
| return getShort(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public Byte getOrElse(Field.Int8 field, byte alternative) { | ||
| if (hasField(field.name)) | ||
| return getByte(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public Integer getOrElse(Field.Int32 field, int alternative) { | ||
| if (hasField(field.name)) | ||
| return getInt(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public Double getOrElse(Field.Float64 field, double alternative) { | ||
| if (hasField(field.name)) | ||
| return getDouble(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public String getOrElse(Field.NullableStr field, String alternative) { | ||
| if (hasField(field.name)) | ||
| return getString(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public String getOrElse(Field.Str field, String alternative) { | ||
| if (hasField(field.name)) | ||
| return getString(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public boolean getOrElse(Field.Bool field, boolean alternative) { | ||
| if (hasField(field.name)) | ||
| return getBoolean(field.name); | ||
| return alternative; | ||
| } | ||
|
|
||
| public Object[] getOrEmpty(Field.Array field) { | ||
| if (hasField(field.name)) | ||
| return getArray(field.name); | ||
| return new Object[0]; | ||
| } | ||
|
|
||
| public Object[] getOrEmpty(Field.ComplexArray field) { | ||
| if (hasField(field.name)) | ||
| return getArray(field.name); | ||
| return new Object[0]; | ||
| } | ||
|
|
||
| /** | ||
| * Get the record value for the field with the given name by doing a hash table lookup (slower!) | ||
| * | ||
|
|
@@ -225,10 +104,6 @@ public boolean hasField(Field def) { | |
| return schema.get(def.name) != null; | ||
| } | ||
|
|
||
| public boolean hasField(Field.ComplexArray def) { | ||
| return schema.get(def.name) != null; | ||
| } | ||
|
|
||
| public Struct getStruct(BoundField field) { | ||
| return (Struct) get(field); | ||
| } | ||
|
|
@@ -382,79 +257,6 @@ public Struct set(String name, Object value) { | |
| return this; | ||
| } | ||
|
|
||
| public Struct set(Field.Str def, String value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.NullableStr def, String value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Int8 def, byte value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Int32 def, int value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Int64 def, long value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.UUID def, Uuid value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Int16 def, short value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Uint16 def, int value) { | ||
| if (value < 0 || value > UNSIGNED_SHORT_MAX) { | ||
| throw new RuntimeException("Invalid value for unsigned short for " + | ||
| def.name + ": " + value); | ||
| } | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Uint32 def, long value) { | ||
| if (value < 0 || value > UNSIGNED_INT_MAX) { | ||
| throw new RuntimeException("Invalid value for unsigned int for " + | ||
| def.name + ": " + value); | ||
| } | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Float64 def, double value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Bool def, boolean value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.Array def, Object[] value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct set(Field.ComplexArray def, Object[] value) { | ||
| return set(def.name, value); | ||
| } | ||
|
|
||
| public Struct setByteArray(String name, byte[] value) { | ||
| ByteBuffer buf = value == null ? null : ByteBuffer.wrap(value); | ||
| return set(name, buf); | ||
| } | ||
|
|
||
| public Struct setIfExists(Field.Array def, Object[] value) { | ||
| return setIfExists(def.name, value); | ||
| } | ||
|
|
||
| public Struct setIfExists(Field.ComplexArray def, Object[] value) { | ||
| return setIfExists(def.name, value); | ||
| } | ||
|
|
||
| public Struct setIfExists(Field def, Object value) { | ||
|
||
| return setIfExists(def.name, value); | ||
| } | ||
|
|
@@ -501,10 +303,6 @@ public Struct instance(Field field) { | |
| return instance(schema.get(field.name)); | ||
| } | ||
|
|
||
| public Struct instance(Field.ComplexArray field) { | ||
| return instance(schema.get(field.name)); | ||
| } | ||
|
|
||
| /** | ||
| * Empty all the values from this record | ||
| */ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you cleanup the setters as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.