You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "doki23 (via GitHub)" <gi...@apache.org> on 2023/03/18 06:09:54 UTC

[GitHub] [iceberg] doki23 commented on a diff in pull request #7109: Flink: Apply row level filtering

doki23 commented on code in PR #7109:
URL: https://github.com/apache/iceberg/pull/7109#discussion_r1140949052


##########
flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/FlinkSourceFilter.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.iceberg.flink;
+
+import org.apache.flink.api.common.functions.FilterFunction;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.expressions.Evaluator;
+import org.apache.iceberg.expressions.Expression;
+import org.apache.iceberg.types.Types;
+
+public class FlinkSourceFilter implements FilterFunction<RowData> {
+
+  private final Schema schema;
+  private final Expression expr;
+  private final boolean caseSensitive;
+
+  private volatile RowDataWrapper wrapper;
+  private volatile Evaluator evaluator;
+
+  public FlinkSourceFilter(Schema schema, Expression expr, boolean caseSensitive) {
+    this.schema = schema;
+    this.expr = expr;
+    this.caseSensitive = caseSensitive;
+  }
+
+  @Override
+  public boolean filter(RowData value) throws Exception {
+    if (this.wrapper == null) {
+      RowType rowType = FlinkSchemaUtil.convert(schema);
+      Types.StructType struct = schema.asStruct();
+      this.wrapper = new RowDataWrapper(rowType, struct);

Review Comment:
   Is it possible to make the wrapper serializable?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org