Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interfaces for Action CheckSnapshotIntegrity #10642

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add interfaces for CheckSnapshotIntegrity
Co-authored-by: Yufei Gu <yufei@apache.org>
  • Loading branch information
huaxingao and flyrain committed Jul 5, 2024
commit 1f2123f814826c5ab6e32de0c05f4bdc89b5acf8
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ default RewritePositionDeleteFiles rewritePositionDeletes(Table table) {
throw new UnsupportedOperationException(
this.getClass().getName() + " does not implement rewritePositionDeletes");
}
/** Instantiates an action to check snapshot integrity. */
default CheckSnapshotIntegrity checkSnapshotIntegrity(Table table) {
throw new UnsupportedOperationException(
this.getClass().getName() + " does not implement checkSnapshotIntegrity");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.actions;

import java.util.concurrent.ExecutorService;

public interface CheckSnapshotIntegrity
extends Action<CheckSnapshotIntegrity, CheckSnapshotIntegrity.Result> {

/**
* Passes an alternative executor service that will be used for snapshot integrity checking. If
* this method is not called, snapshot integrity checker will still be running by a single
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2nd part can be rewritten as a single threaded executor service is used by default

* threaded executor service.
*
* @param executorService an executor service to parallelize tasks to check snapshot integrity
* @return this for method chaining
*/
CheckSnapshotIntegrity executeWith(ExecutorService executorService);

/**
* Pass the target version to check. The action checks the snapshots in the target version, not in
* the current version of the table.
*
* @param targetVersion the target version file to be checked. Either a file name or a file path
* is acceptable. For example, it could be either
* "00001-8893aa9e-f92e-4443-80e7-cfa42238a654.metadata.json" or
* "/path/to/00001-8893aa9e-f92e-4443-80e7-cfa42238a654.metadata.json".
* @return this for method chaining
*/
CheckSnapshotIntegrity targetVersion(String targetVersion);
Copy link
Contributor

@himadripal himadripal Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the param name be changed to targetVersionFilePointer or targetVersionMetadataFile


/** The action result that contains a summary of the execution. */
interface Result {
/** Returns locations of missing metadata/data files. */
Iterable<String> missingFileLocations();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.actions;

public class BaseCheckSnapshotIntegrityResult implements CheckSnapshotIntegrity.Result {
private final Iterable<String> missingFileLocations;

public BaseCheckSnapshotIntegrityResult(Iterable<String> missingFileLocations) {
this.missingFileLocations = missingFileLocations;
}

@Override
public Iterable<String> missingFileLocations() {
return missingFileLocations;
}
}