ChristofferEmilKristensen commented on code in PR #656:
URL: https://github.com/apache/wayang/pull/656#discussion_r2691613516


##########
wayang-commons/wayang-basic/src/main/java/org/apache/wayang/basic/operators/ApacheIcebergSource.java:
##########
@@ -0,0 +1,337 @@
+/*
+ * 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.wayang.basic.operators;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import org.apache.wayang.basic.data.Record;
+import org.apache.wayang.basic.types.RecordType;
+import 
org.apache.wayang.commons.util.profiledb.model.measurement.TimeMeasurement;
+import org.apache.wayang.core.api.Configuration;
+import org.apache.wayang.core.optimizer.OptimizationContext;
+import org.apache.wayang.core.optimizer.cardinality.CardinalityEstimate;
+import org.apache.wayang.core.plan.wayangplan.UnarySource;
+import org.apache.wayang.core.types.DataSetType;
+
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.data.IcebergGenerics;
+import org.apache.iceberg.data.IcebergGenerics.ScanBuilder;
+import org.apache.iceberg.expressions.Expression;
+import org.apache.iceberg.io.CloseableIterable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.OptionalLong;
+
+import org.apache.commons.lang3.Validate;
+import org.apache.iceberg.FileScanTask;
+import org.apache.iceberg.Table;
+
+/**
+ * This source reads an Iceberg Table and outputs the lines as
+ * {@link org.apache.wayang.basic.data.Record}
+ * units.
+ */
+public class ApacheIcebergSource extends UnarySource<Record> {
+
+    private final Logger logger = LogManager.getLogger(this.getClass());
+
+    private final Catalog catalog;
+
+    private final TableIdentifier tableIdentifier;
+
+    private Collection<Expression> whereExpressions;
+    private Collection<String> columns;
+
+    private org.apache.iceberg.Table cachedTable = null;
+
+    private static final Double defaultSelectivityValue = 0.10;
+
+    /**
+     * Creates a new Iceberg source instance.
+     *
+     * @param catalog          Iceberg catalog used to load the table
+     * @param tableIdentifier  identifier of the target table
+     * @param whereExpressions list of
+     *                         {@link 
org.apache.iceberg.expressions.Expression}
+     *                         filters; empty list for none
+     * @param columns          collection of column names to project; empty 
list for
+     *                         all columns
+     * @return a new {@link ApacheIcebergSource} instance
+     */
+    public static ApacheIcebergSource create(Catalog catalog, TableIdentifier 
tableIdentifier,
+            org.apache.iceberg.expressions.Expression[] whereExpressions,
+            String[] columns) {
+
+            List<org.apache.iceberg.expressions.Expression> whereList =
+            (whereExpressions == null) ? Collections.emptyList() : 
Arrays.asList(whereExpressions);
+
+            List<String> columnList =
+                 (columns == null) ? Collections.emptyList() : 
Arrays.asList(columns);
+
+        return new ApacheIcebergSource(catalog, tableIdentifier, whereList, 
columnList);
+    }
+
+    public ApacheIcebergSource(Catalog catalog, TableIdentifier 
tableIdentifier,
+            Collection<Expression> whereExpressions, Collection<String> 
columns) {
+        
+        
+        super(createOutputDataSetType(columns));
+        this.catalog = catalog;
+        this.tableIdentifier = tableIdentifier;
+
+        this.whereExpressions = whereExpressions;
+        this.columns = columns;
+    }
+
+    /**
+     * Copies an instance (exclusive of broadcasts).
+     *
+     * @param that that should be copied
+     */
+    public ApacheIcebergSource(ApacheIcebergSource that) {
+        super(that);
+        this.catalog = that.getCatalog();
+        this.columns = that.getColumns();
+        this.tableIdentifier = that.getTableIdentifier();
+        this.whereExpressions = that.getWhereExpressions();
+    }
+
+    @Override
+    public 
Optional<org.apache.wayang.core.optimizer.cardinality.CardinalityEstimator> 
createCardinalityEstimator(

Review Comment:
   Has been updates now.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to