petersomogyi commented on code in PR #8184: URL: https://github.com/apache/hbase/pull/8184#discussion_r3187118457
########## hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/RepresentationDecision.java: ########## @@ -0,0 +1,63 @@ +/* + * 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.hadoop.hbase.io.hfile.cache; + +import org.apache.yetus.audience.InterfaceAudience; + +/** + * Decision describing the cached representation for an admitted block. + */ [email protected] +public final class RepresentationDecision { + + private static final RepresentationDecision CURRENT_HBASE_DEFAULT = + new RepresentationDecision(RepresentationKind.CURRENT_HBASE_DEFAULT); + + private final RepresentationKind kind; + + private RepresentationDecision(RepresentationKind kind) { + this.kind = kind; + } + + /** + * Preserves the representation currently produced by existing HBase code paths. + * @return current HBase default representation decision + */ + public static RepresentationDecision currentHBaseDefault() { + return CURRENT_HBASE_DEFAULT; + } + + /** + * Returns a representation decision for the supplied representation kind. + * @param kind representation kind + * @return representation decision + */ + public static RepresentationDecision of(RepresentationKind kind) { + return kind == RepresentationKind.CURRENT_HBASE_DEFAULT + ? CURRENT_HBASE_DEFAULT + : new RepresentationDecision(kind); + } Review Comment: I'm not sure if this will be on a hot path but if so then you can cache all 4 RepresentationKind instances since the enum is small and fixed. ########## hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/AdmissionDecision.java: ########## @@ -0,0 +1,89 @@ +/* + * 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.hadoop.hbase.io.hfile.cache; + +import org.apache.yetus.audience.InterfaceAudience; + +/** + * Result of cache admission evaluation. + */ [email protected] +public final class AdmissionDecision { + + private static final AdmissionDecision ADMIT = new AdmissionDecision(true, "ADMIT"); + + private static final AdmissionDecision REJECT = new AdmissionDecision(false, "REJECT"); + + private final boolean admit; + private final String reason; + + private AdmissionDecision(boolean admit, String reason) { + this.admit = admit; + this.reason = reason; + } + + /** + * Returns a normal-priority admission decision. + * @return admit decision + */ + public static AdmissionDecision admit() { + return ADMIT; + } + + /** + * Returns an admission decision with a reason. + * @param reason reason text + * @return admit decision + */ + public static AdmissionDecision admit(String reason) { + return new AdmissionDecision(true, reason); + } + + /** + * Returns a rejection decision. * @return reject decision Review Comment: ```suggestion * Returns a rejection decision. * @return reject decision ``` -- 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]
