eric-maynard commented on code in PR #402: URL: https://github.com/apache/polaris/pull/402#discussion_r1814022037
########## polaris-service/src/test/java/org/apache/polaris/service/catalog/io/TestFileIO.java: ########## @@ -0,0 +1,142 @@ +/* + * 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.polaris.service.catalog.io; + +import java.util.Map; +import java.util.function.Supplier; +import org.apache.iceberg.DataFile; +import org.apache.iceberg.DeleteFile; +import org.apache.iceberg.ManifestFile; +import org.apache.iceberg.io.FileIO; +import org.apache.iceberg.io.InputFile; +import org.apache.iceberg.io.OutputFile; + +/** + * File IO wrapper used for tests. It measures the number of bytes read, files written, and files + * deleted. It can inject exceptions during InputFile and OutputFile creation. + */ +public class TestFileIO implements FileIO { + private final FileIO io; + private final Supplier<RuntimeException> newInputFileExceptionSupplier; + private final Supplier<RuntimeException> newOutputFileExceptionSupplier; + + private long inputBytes; + private int numOutputFiles; + private int numDeletedFiles; + + public TestFileIO( + FileIO io, + Supplier<RuntimeException> newInputFileExceptionSupplier, + Supplier<RuntimeException> newOutputFileExceptionSupplier) { + this.io = io; + this.newInputFileExceptionSupplier = newInputFileExceptionSupplier; + this.newOutputFileExceptionSupplier = newOutputFileExceptionSupplier; + } + + public long getInputBytes() { + return inputBytes; + } + + public int getNumOuptutFiles() { + return numOutputFiles; + } + + public int getNumDeletedFiles() { + return numDeletedFiles; + } + + private InputFile wrapInputFile(InputFile inner) { + RuntimeException e = newInputFileExceptionSupplier.get(); Review Comment: Same as above, it might make sense for these to be optional. Alternatively if the intent is to always throw an exception maybe this should be something like `FailingFileIO` -- 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]
