flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggevay <...@git.apache.org>
Subject [GitHub] flink pull request #2211: [WIP][FLINK-3599] Code generation for PojoSerializ...
Date Thu, 08 Sep 2016 11:42:24 GMT
Github user ggevay commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2211#discussion_r77990200
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenTypeSerializerProxy.java
---
    @@ -0,0 +1,148 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.api.java.typeutils.runtime;
    +
    +import org.apache.flink.api.common.ExecutionConfig;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.core.memory.DataInputView;
    +import org.apache.flink.core.memory.DataOutputView;
    +import org.apache.flink.util.InstantiationUtil;
    +
    +import java.io.IOException;
    +import java.io.ObjectInputStream;
    +import java.lang.reflect.Constructor;
    +
    +public class GenTypeSerializerProxy<T> extends TypeSerializer<T> {
    +	private final String code;
    +	private final String name;
    +	private final Class<T> clazz;
    +	private final TypeSerializer<?>[] fieldSerializers;
    +	private final ExecutionConfig config;
    +
    +	transient private TypeSerializer<T> impl = null;
    +
    +	private void compile() {
    +		try {
    +			assert impl == null;
    +			Class<?> serializerClazz = InstantiationUtil.compile(clazz.getClassLoader(),
name, code);
    +			Constructor<?>[] ctors = serializerClazz.getConstructors();
    +			assert ctors.length == 1;
    +			impl = (TypeSerializer<T>) ctors[0].newInstance(new Object[]{clazz, fieldSerializers,
config});
    --- End diff --
    
    varargs, no need to create an array


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message