singhpk234 commented on code in PR #4807: URL: https://github.com/apache/iceberg/pull/4807#discussion_r882526953
########## core/src/main/java/org/apache/iceberg/RefsTable.java: ########## @@ -0,0 +1,105 @@ +/* + * 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; + +import java.util.Collection; +import java.util.Map; +import java.util.function.Function; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.apache.iceberg.types.Types; + +/** + * A {@link Table} implementation that exposes a table's known snapshot references as rows. + */ +public class RefsTable extends BaseMetadataTable { + private static final Schema SNAPSHOT_SCHEMA = new Schema( + Types.NestedField.required(1, "ref", Types.StringType.get()), Review Comment: [minor] should we call this column, ref_name ? ########## core/src/main/java/org/apache/iceberg/RefsTable.java: ########## @@ -0,0 +1,105 @@ +/* + * 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; + +import java.util.Collection; +import java.util.Map; +import java.util.function.Function; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.apache.iceberg.types.Types; + +/** + * A {@link Table} implementation that exposes a table's known snapshot references as rows. + */ +public class RefsTable extends BaseMetadataTable { + private static final Schema SNAPSHOT_SCHEMA = new Schema( Review Comment: [minor] should we call this `SNAPSHOT_REF_SCHEMA` ? Your thoughts ########## core/src/main/java/org/apache/iceberg/RefsTable.java: ########## @@ -0,0 +1,105 @@ +/* + * 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; + +import java.util.Collection; +import java.util.Map; +import java.util.function.Function; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.apache.iceberg.types.Types; + +/** + * A {@link Table} implementation that exposes a table's known snapshot references as rows. + */ +public class RefsTable extends BaseMetadataTable { + private static final Schema SNAPSHOT_SCHEMA = new Schema( + Types.NestedField.required(1, "ref", Types.StringType.get()), + Types.NestedField.required(2, "type", Types.StringType.get()), + Types.NestedField.required(3, "snapshot_id", Types.LongType.get()), + Types.NestedField.optional(4, "max_reference_age_in_ms", Types.LongType.get()), + Types.NestedField.optional(5, "min_snapshots_to_keep", Types.IntegerType.get()), + Types.NestedField.optional(6, "max_snapshot_age_in_ms", Types.LongType.get()) + ); + + RefsTable(TableOperations ops, Table table) { + this(ops, table, table.name() + ".refs"); + } + + RefsTable(TableOperations ops, Table table, String name) { + super(ops, table, name); + } + + @Override + public TableScan newScan() { + return new RefsTableScan(operations(), table()); + } + + @Override + public Schema schema() { + return SNAPSHOT_SCHEMA; + } + + private DataTask task(BaseTableScan scan) { + TableOperations ops = operations(); + Collection<String> refNames = Sets.newHashSet(); + refNames.addAll(ops.current().refs().keySet()); Review Comment: nit : Can skip 2 step assignment ```suggestion Collection<String> refNames = ops.current().refs().keySet(); ``` -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
