dimas-b commented on code in PR #3256: URL: https://github.com/apache/polaris/pull/3256#discussion_r2760203117
########## storage/files/api/src/main/java/org/apache/polaris/storage/files/api/FileSpec.java: ########## @@ -0,0 +1,101 @@ +/* + * 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.storage.files.api; + +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import java.util.Optional; +import java.util.OptionalLong; +import org.apache.polaris.immutables.PolarisImmutable; + +/** + * Describes a single file/object in an object storage. + * + * <p>Not all attributes are populated by every {@link FileOperations} function. + */ +@PolarisImmutable +public interface FileSpec { + + /** The full object storage URI. */ + String location(); + + /** + * The type of the file, if known, as a convenience hint. + * + * <p>The type might have been guessed from the file name, in which case the returned value is not + * guaranteed to be accurate. + * + * @see #guessTypeFromName() + */ + Optional<FileType> fileType(); + + /** The size of the file in bytes, if available. */ + OptionalLong size(); + + /** The creation timestamp in milliseconds since the epoch, if available. */ + OptionalLong createdAtMillis(); + + static Builder builder() { + return ImmutableFileSpec.builder(); + } + + static Builder fromLocation(String location) { + return builder().location(location); + } + + static Builder fromLocationAndSize(String location, long size) { + var b = fromLocation(location); + if (size > 0L) { + b.size(size); + } + return b; + } + + /** Guesses the given file's type from its name, not guaranteed to be accurate. */ + default FileType guessTypeFromName() { Review Comment: AFAIK this method has been moved to test code. -- 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]
