amogh-jahagirdar commented on code in PR #10118:
URL: https://github.com/apache/iceberg/pull/10118#discussion_r1563195336


##########
core/src/main/java/org/apache/iceberg/io/DefaultContentCache.java:
##########
@@ -0,0 +1,295 @@
+/*
+ * 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.iceberg.io;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.Weigher;
+import com.github.benmanes.caffeine.cache.stats.CacheStats;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.ByteBuffer;
+import java.time.Duration;
+import java.util.List;
+import java.util.function.Function;
+import org.apache.iceberg.exceptions.NotFoundException;
+import org.apache.iceberg.exceptions.ValidationException;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class that provides file-content caching during reading.
+ *
+ * <p>The file-content caching is initiated by calling {@link 
DefaultContentCache#tryCache(InputFile)}.
+ * Given a FileIO, a file location string, and file length that is within 
allowed limit,
+ * DefaultContentCache will return a {@link CachingInputFile} that is backed 
by the cache. Calling {@link
+ * CachingInputFile#newStream()} will return a {@link ByteBufferInputStream} 
backed by list of
+ * {@link ByteBuffer} from the cache if such file-content exist in the cache. 
If the file-content
+ * does not exist in the cache yet, a regular InputFile will be instantiated, 
read-ahead, and loaded
+ * into the cache before returning ByteBufferInputStream. The regular 
InputFile is also used as a
+ * fallback if cache loading fail.
+ */
+public class DefaultContentCache implements ContentCache {

Review Comment:
   `InMemoryContentCache`? I understand it's the default impl but feels a bit 
more clear to have InMemory be in the class name since it indicates the 
behavior.



##########
core/src/main/java/org/apache/iceberg/io/ContentCache.java:
##########
@@ -18,274 +18,35 @@
  */
 package org.apache.iceberg.io;
 
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-import com.github.benmanes.caffeine.cache.Weigher;
-import com.github.benmanes.caffeine.cache.stats.CacheStats;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.ByteBuffer;
-import java.time.Duration;
-import java.util.List;
-import java.util.function.Function;
-import org.apache.iceberg.exceptions.NotFoundException;
-import org.apache.iceberg.exceptions.ValidationException;
-import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
-import org.apache.iceberg.relocated.com.google.common.collect.Lists;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * Class that provides file-content caching during reading.
  *
  * <p>The file-content caching is initiated by calling {@link 
ContentCache#tryCache(InputFile)}.
  * Given a FileIO, a file location string, and file length that is within 
allowed limit,
- * ContentCache will return a {@link CachingInputFile} that is backed by the 
cache. Calling {@link
- * CachingInputFile#newStream()} will return a {@link ByteBufferInputStream} 
backed by list of
- * {@link ByteBuffer} from the cache if such file-content exist in the cache. 
If the file-content
- * does not exist in the cache yet, a regular InputFile will be instantiated, 
read-ahead, and loaded
- * into the cache before returning ByteBufferInputStream. The regular 
InputFile is also used as a
- * fallback if cache loading fail.
+ * ContentCache will return an implementation of a {@link InputFile} that may 
be cached.
  */
-public class ContentCache {

Review Comment:
   If we go with such an approach we'll need to be mindful of backwards 
compatibility since this is public; even though this is now an interface others 
can currently be doing a new ContentCache(....) and so a direct removal would 
break those.
   We'd need to put this on a deprecation path



##########
core/src/main/java/org/apache/iceberg/io/ContentCacheManager.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.iceberg.io;
+
+/**
+ * Manages content caches for FileIO implementations, capable of creating or 
retrieving
+ * a {@link ContentCache} given a {@link FileIO}, or dropping a cache for a 
{@link FileIO}.
+ */

Review Comment:
   Sorry not sure if I completely follow, why is `ContentCacheManager` 
required? Couldn't we achieve the desired goals with just having a pluggable 
`ContentCache`?



-- 
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...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to