Skip to content

Commit

Permalink
[hotfix] Improve performance of GenericArraySerializer.copy()
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRRichter committed Jan 7, 2019
1 parent c0a37f8 commit 28e0b83
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.io.IOException;
import java.lang.reflect.Array;
import java.util.Arrays;

import static org.apache.flink.util.Preconditions.checkNotNull;

Expand Down Expand Up @@ -86,16 +87,21 @@ public C[] createInstance() {

@Override
public C[] copy(C[] from) {
C[] copy = create(from.length);

for (int i = 0; i < copy.length; i++) {
C val = from[i];
if (val != null) {
copy[i] = this.componentSerializer.copy(val);
final TypeSerializer<C> serializer = this.componentSerializer;

if (serializer.isImmutableType()) {
return Arrays.copyOf(from, from.length);
} else {
C[] copy = create(from.length);
for (int i = 0; i < copy.length; i++) {
C val = from[i];
if (val != null) {
copy[i] = serializer.copy(val);
}
}
return copy;
}

return copy;
}

@Override
Expand Down

0 comments on commit 28e0b83

Please sign in to comment.