[ https://issues.apache.org/jira/browse/HIVE-27019?focusedWorklogId=848842&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-848842 ]
ASF GitHub Bot logged work on HIVE-27019: ----------------------------------------- Author: ASF GitHub Bot Created on: 03/Mar/23 07:27 Start Date: 03/Mar/23 07:27 Worklog Time Spent: 10m Work Description: SourabhBadhya commented on code in PR #4032: URL: https://github.com/apache/hive/pull/4032#discussion_r1122980967 ########## ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/MetadataCache.java: ########## @@ -0,0 +1,53 @@ +/* + * 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.hive.ql.txn.compactor; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import org.apache.thrift.TBase; + +import java.util.Optional; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; + +public class MetadataCache { + + private Optional<Cache<String, TBase>> metaCache = Optional.empty(); + + public <T extends TBase<T,?>> T computeIfAbsent(String key, Callable<T> callable) throws Exception { + if (metaCache.isPresent()) { + try { + return (T) metaCache.get().get(key, callable); + } catch (ExecutionException e) { + throw (Exception) e.getCause(); + } + } + return callable.call(); + } + + public Optional<Cache<String, TBase>> initializeCache(boolean tableCacheOn) { Review Comment: Cache is initialized based on a config - In the current master this is code - https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Cleaner.java#L114-L116 I think accepting a boolean in constructor and initializing might also make sense. Return type is also not used anywhere. ########## ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/MetadataCache.java: ########## @@ -0,0 +1,53 @@ +/* + * 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.hive.ql.txn.compactor; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import org.apache.thrift.TBase; + +import java.util.Optional; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; + +public class MetadataCache { + + private Optional<Cache<String, TBase>> metaCache = Optional.empty(); + + public <T extends TBase<T,?>> T computeIfAbsent(String key, Callable<T> callable) throws Exception { + if (metaCache.isPresent()) { + try { + return (T) metaCache.get().get(key, callable); + } catch (ExecutionException e) { + throw (Exception) e.getCause(); + } + } + return callable.call(); + } + + public Optional<Cache<String, TBase>> initializeCache(boolean tableCacheOn) { Review Comment: Done Issue Time Tracking ------------------- Worklog Id: (was: 848842) Time Spent: 17h 10m (was: 17h) > Split Cleaner into separate manageable modular entities > ------------------------------------------------------- > > Key: HIVE-27019 > URL: https://issues.apache.org/jira/browse/HIVE-27019 > Project: Hive > Issue Type: Sub-task > Reporter: Sourabh Badhya > Assignee: Sourabh Badhya > Priority: Major > Labels: pull-request-available > Time Spent: 17h 10m > Remaining Estimate: 0h > > As described by the parent task - > Cleaner can be divided into separate entities like - > *1) Handler* - This entity fetches the data from the metastore DB from > relevant tables and converts it into a request entity called CleaningRequest. > It would also do SQL operations post cleanup (postprocess). Every type of > cleaning request is provided by a separate handler. > *2) Filesystem remover* - This entity fetches the cleaning requests from > various handlers and deletes them according to the cleaning request. -- This message was sent by Atlassian Jira (v8.20.10#820010)