szetszwo commented on code in PR #8073:
URL: https://github.com/apache/ozone/pull/8073#discussion_r1995636553


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableNoCache.java:
##########
@@ -26,21 +26,22 @@
 import java.util.Set;
 import org.apache.hadoop.hdds.annotation.InterfaceAudience.Private;
 import org.apache.hadoop.hdds.annotation.InterfaceStability.Evolving;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
- * Cache implementation for the table. Partial Table cache, where the DB state
- * and cache state will not be same. Partial table cache holds entries until
- * flush to DB happens.
+ * Dummy cache implementation for the table, means key/value are not cached. 
  * @param <KEY>
  * @param <VALUE>
  */
 @Private
 @Evolving
 public class TableNoCache<KEY, VALUE> implements TableCache<KEY, VALUE> {
-  public static final Logger LOG = LoggerFactory.getLogger(TableNoCache.class);
   public static final CacheStats EMPTY_STAT = new CacheStats(0, 0, 0);
+  private static final CacheResult<?> MAY_EXIST = new 
CacheResult<>(CacheResult.CacheStatus.MAY_EXIST, null);

Review Comment:
   Move it to the `TableCache` interface and use it in `FullTableCache` and 
`PartialTableCache`.



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java:
##########
@@ -94,25 +95,33 @@ public TypedTable(RDBTable rawTable,
       CodecRegistry codecRegistry, Class<KEY> keyType,
       Class<VALUE> valueType,
       CacheType cacheType, String threadNamePrefix) throws IOException {
-    this.rawTable = Objects.requireNonNull(rawTable, "rawTable==null");
-    Objects.requireNonNull(codecRegistry, "codecRegistry == null");
-
-    this.keyType = Objects.requireNonNull(keyType, "keyType == null");
-    this.keyCodec = codecRegistry.getCodecFromClass(keyType);
-    Objects.requireNonNull(keyCodec, "keyCodec == null");
-
-    this.valueType = Objects.requireNonNull(valueType, "valueType == null");
-    this.valueCodec = codecRegistry.getCodecFromClass(valueType);
-    Objects.requireNonNull(valueCodec, "valueCodec == null");
-
-    this.supportCodecBuffer = keyCodec.supportCodecBuffer()

Review Comment:
   Or , move the check to `CodecRegistry`.
   ```java
   @ -61,6 +62,7 @@ private CodecMap(Map<Class<?>, Codec<?>> map) {
        }
    
        <T> Codec<T> get(Class<T> clazz) {
   +      Objects.requireNonNull("clazz == null");
          final Codec<?> codec = map.get(clazz);
          return (Codec<T>) codec;
        }
   ```



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableNoCache.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.hdds.utils.db.cache;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.Set;
+import org.apache.hadoop.hdds.annotation.InterfaceAudience.Private;
+import org.apache.hadoop.hdds.annotation.InterfaceStability.Evolving;
+
+/**
+ * Dummy cache implementation for the table, means key/value are not cached. 
+ * @param <KEY>
+ * @param <VALUE>
+ */
+@Private
+@Evolving
+public class TableNoCache<KEY, VALUE> implements TableCache<KEY, VALUE> {
+  public static final CacheStats EMPTY_STAT = new CacheStats(0, 0, 0);
+  private static final CacheResult<?> MAY_EXIST = new 
CacheResult<>(CacheResult.CacheStatus.MAY_EXIST, null);
+
+  private static final TableCache<?, ?> NO_CACHE_INSTANCE = new 
TableNoCache<>();
+  public static <K, V> TableCache<K, V> instance() {
+    return (TableCache<K, V>) NO_CACHE_INSTANCE;
+  }
+

Review Comment:
   Add a private constructor.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to