aturoczy commented on code in PR #5606:
URL: https://github.com/apache/hive/pull/5606#discussion_r1950024471


##########
standalone-metastore/metastore-catalog/src/main/java/org/apache/iceberg/HiveCachingCatalog.java:
##########
@@ -0,0 +1,331 @@
+/*
+ * 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;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.RemovalCause;
+import com.github.benmanes.caffeine.cache.RemovalListener;
+import com.github.benmanes.caffeine.cache.Ticker;
+import java.time.Duration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.catalog.SupportsNamespaces;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.exceptions.AlreadyExistsException;
+import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
+import org.apache.iceberg.exceptions.NoSuchNamespaceException;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * Class that wraps an Iceberg Catalog to cache tables.
+ * Initial code in:
+ * 
https://github.com/apache/iceberg/blob/1.3.x/core/src/main/java/org/apache/iceberg/CachingCatalog.java
+ * Main difference is the SupportsNamespace and the fact that loadTable 
performs a metadata refresh.
+ *
+ * <p>See {@link CatalogProperties#CACHE_EXPIRATION_INTERVAL_MS} for more 
details regarding special
+ * values for {@code expirationIntervalMillis}.
+ */
+public class HiveCachingCatalog<CATALOG extends Catalog & SupportsNamespaces> 
implements Catalog, SupportsNamespaces {
+  private static final Logger LOG = 
LoggerFactory.getLogger(HiveCachingCatalog.class);
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected final long expirationIntervalMillis;
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected final Cache<TableIdentifier, Table> tableCache;
+  private final CATALOG catalog;
+  private final boolean caseSensitive;
+
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected HiveCachingCatalog(CATALOG catalog, long expirationIntervalMillis) 
{

Review Comment:
   Just naming, but I think **expiration** is more expressive. IntervalMills 
just add more unnatured linguistic element. The documentation or the 
intelligence should describe the intervals. It is just minor thing. 



##########
standalone-metastore/metastore-catalog/src/main/java/org/apache/iceberg/HiveCachingCatalog.java:
##########
@@ -0,0 +1,331 @@
+/*
+ * 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;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.RemovalCause;
+import com.github.benmanes.caffeine.cache.RemovalListener;
+import com.github.benmanes.caffeine.cache.Ticker;
+import java.time.Duration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.catalog.SupportsNamespaces;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.exceptions.AlreadyExistsException;
+import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
+import org.apache.iceberg.exceptions.NoSuchNamespaceException;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * Class that wraps an Iceberg Catalog to cache tables.
+ * Initial code in:
+ * 
https://github.com/apache/iceberg/blob/1.3.x/core/src/main/java/org/apache/iceberg/CachingCatalog.java
+ * Main difference is the SupportsNamespace and the fact that loadTable 
performs a metadata refresh.
+ *
+ * <p>See {@link CatalogProperties#CACHE_EXPIRATION_INTERVAL_MS} for more 
details regarding special
+ * values for {@code expirationIntervalMillis}.
+ */
+public class HiveCachingCatalog<CATALOG extends Catalog & SupportsNamespaces> 
implements Catalog, SupportsNamespaces {
+  private static final Logger LOG = 
LoggerFactory.getLogger(HiveCachingCatalog.class);
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected final long expirationIntervalMillis;
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected final Cache<TableIdentifier, Table> tableCache;
+  private final CATALOG catalog;
+  private final boolean caseSensitive;
+
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected HiveCachingCatalog(CATALOG catalog, long expirationIntervalMillis) 
{
+    Preconditions.checkArgument(
+        expirationIntervalMillis != 0,

Review Comment:
   Also I would suggest to add a realistic value. For example everything that 
is less then a minute does not need for cache. So maybe <60000 is expressive.  
But it can be arguable.  If it 0 then disabled. 



##########
standalone-metastore/metastore-catalog/src/main/java/org/apache/iceberg/HiveCachingCatalog.java:
##########
@@ -0,0 +1,331 @@
+/*
+ * 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;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.RemovalCause;
+import com.github.benmanes.caffeine.cache.RemovalListener;
+import com.github.benmanes.caffeine.cache.Ticker;
+import java.time.Duration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.catalog.SupportsNamespaces;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.exceptions.AlreadyExistsException;
+import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
+import org.apache.iceberg.exceptions.NoSuchNamespaceException;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * Class that wraps an Iceberg Catalog to cache tables.
+ * Initial code in:
+ * 
https://github.com/apache/iceberg/blob/1.3.x/core/src/main/java/org/apache/iceberg/CachingCatalog.java
+ * Main difference is the SupportsNamespace and the fact that loadTable 
performs a metadata refresh.
+ *
+ * <p>See {@link CatalogProperties#CACHE_EXPIRATION_INTERVAL_MS} for more 
details regarding special
+ * values for {@code expirationIntervalMillis}.
+ */
+public class HiveCachingCatalog<CATALOG extends Catalog & SupportsNamespaces> 
implements Catalog, SupportsNamespaces {
+  private static final Logger LOG = 
LoggerFactory.getLogger(HiveCachingCatalog.class);
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected final long expirationIntervalMillis;
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected final Cache<TableIdentifier, Table> tableCache;
+  private final CATALOG catalog;
+  private final boolean caseSensitive;
+
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected HiveCachingCatalog(CATALOG catalog, long expirationIntervalMillis) 
{
+    Preconditions.checkArgument(
+        expirationIntervalMillis != 0,
+        "When %s is set to 0, the catalog cache should be disabled. This 
indicates a bug.",
+        CatalogProperties.CACHE_EXPIRATION_INTERVAL_MS);
+    this.catalog = catalog;
+    this.caseSensitive = true;

Review Comment:
   It is always true as I see. Do you need this? Or where it can be false?



##########
standalone-metastore/metastore-catalog/data/conf/README.txt:
##########
@@ -0,0 +1 @@
+Need to force creation of a directory.

Review Comment:
   yes, please remove it, if it does not contains anything. If later needs, you 
can put back anytime



##########
standalone-metastore/metastore-catalog/src/main/java/org/apache/iceberg/HiveCachingCatalog.java:
##########
@@ -0,0 +1,331 @@
+/*
+ * 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;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.RemovalCause;
+import com.github.benmanes.caffeine.cache.RemovalListener;
+import com.github.benmanes.caffeine.cache.Ticker;
+import java.time.Duration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.catalog.SupportsNamespaces;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.exceptions.AlreadyExistsException;
+import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
+import org.apache.iceberg.exceptions.NoSuchNamespaceException;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * Class that wraps an Iceberg Catalog to cache tables.
+ * Initial code in:
+ * 
https://github.com/apache/iceberg/blob/1.3.x/core/src/main/java/org/apache/iceberg/CachingCatalog.java
+ * Main difference is the SupportsNamespace and the fact that loadTable 
performs a metadata refresh.
+ *
+ * <p>See {@link CatalogProperties#CACHE_EXPIRATION_INTERVAL_MS} for more 
details regarding special
+ * values for {@code expirationIntervalMillis}.
+ */
+public class HiveCachingCatalog<CATALOG extends Catalog & SupportsNamespaces> 
implements Catalog, SupportsNamespaces {
+  private static final Logger LOG = 
LoggerFactory.getLogger(HiveCachingCatalog.class);
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected final long expirationIntervalMillis;
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected final Cache<TableIdentifier, Table> tableCache;
+  private final CATALOG catalog;
+  private final boolean caseSensitive;
+
+  @SuppressWarnings("checkstyle:VisibilityModifier")
+  protected HiveCachingCatalog(CATALOG catalog, long expirationIntervalMillis) 
{
+    Preconditions.checkArgument(
+        expirationIntervalMillis != 0,
+        "When %s is set to 0, the catalog cache should be disabled. This 
indicates a bug.",

Review Comment:
   "This indicates a bug."
   
   In my mind it indicates a wrong config value. It is technically not a bug.



-- 
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: gitbox-unsubscr...@hive.apache.org

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


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

Reply via email to