thecoop commented on code in PR #14482: URL: https://github.com/apache/lucene/pull/14482#discussion_r2066552180
########## lucene/core/src/java/org/apache/lucene/store/DefaultIOContext.java: ########## @@ -0,0 +1,88 @@ +/* + * 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.lucene.store; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +record DefaultIOContext(Optional<ReadAdvice> readAdvice, Set<FileOpenHint> hints) + implements IOContext { + + public DefaultIOContext { + Objects.requireNonNull(readAdvice); + Objects.requireNonNull(hints); + if (readAdvice.isPresent() && !hints.isEmpty()) + throw new IllegalArgumentException("Either ReadAdvice or hints can be specified, not both"); + + assert assertHintTypes(hints); Review Comment: The reason for using assert was that the hints used here would be specified in code, not dynamic - so if the code is validated by the tests (both unit and integration, in and outside lucene) using asserts, then we don't need production checks at all. But I can change it to a production check if the extra safety is worth it? -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org