Skip to content

Commit

Permalink
[FLINK-19981][core][table] Add name-based field mode for Row
Browse files Browse the repository at this point in the history
This adds a name-based field mode to the Row class. A row can
 operate in 3 different modes: name-based, position-based, or
a hybrid of both when leaving the Flink runtime. It simplifies
the handling of large rows (possibly with hundreds of fields)
and will make it easier to switch between DataStream API and
Table API.

See the documentation of the Row class for more information.

This closes apache#14420.
  • Loading branch information
twalthr committed Jan 4, 2021
1 parent 86a9af3 commit 603e28e
Show file tree
Hide file tree
Showing 12 changed files with 1,131 additions and 193 deletions.
Expand Up @@ -32,6 +32,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -253,7 +254,11 @@ public TypeSerializer<Row> createSerializer(ExecutionConfig config) {
for (int i = 0; i < len; i++) {
fieldSerializers[i] = types[i].createSerializer(config);
}
return new RowSerializer(fieldSerializers);
final LinkedHashMap<String, Integer> positionByName = new LinkedHashMap<>();
for (int i = 0; i < fieldNames.length; i++) {
positionByName.put(fieldNames[i], i);
}
return new RowSerializer(fieldSerializers, positionByName);
}

@Override
Expand Down Expand Up @@ -308,7 +313,7 @@ public TypeSerializer<Row> createLegacySerializer(ExecutionConfig config) {
for (int i = 0; i < len; i++) {
fieldSerializers[i] = types[i].createSerializer(config);
}
return new RowSerializer(fieldSerializers, true);
return new RowSerializer(fieldSerializers, null, true);
}

/** Tests whether an other object describes the same, schema-equivalent row information. */
Expand Down

0 comments on commit 603e28e

Please sign in to comment.