[ 
https://issues.apache.org/jira/browse/PHOENIX-5592?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17236532#comment-17236532
 ] 

ASF GitHub Bot commented on PHOENIX-5592:
-----------------------------------------

yanxinyi commented on a change in pull request #975:
URL: https://github.com/apache/phoenix/pull/975#discussion_r528032496



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/DefaultPhoenixMultiViewListProvider.java
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.phoenix.mapreduce.util;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.ViewUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.charset.StandardCharsets;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class DefaultPhoenixMultiViewListProvider implements 
PhoenixMultiViewListProvider {
+    private static final Logger LOGGER =
+            LoggerFactory.getLogger(DefaultPhoenixMultiViewListProvider.class);
+
+    public List<ViewInfoWritable> getPhoenixMultiViewList(Configuration 
configuration) {
+        List<ViewInfoWritable> viewInfoWritables = new ArrayList<>();
+
+        String query = PhoenixMultiInputUtil.getFetchViewQuery(configuration);
+        boolean isQueryMore = configuration.get(
+                
PhoenixConfigurationUtil.MAPREDUCE_PHOENIX_TTL_DELETE_JOB_ALL_VIEWS) != null;
+        int limit = 
PhoenixConfigurationUtil.getMultiViewQueryMoreSplitSize(configuration);
+        try (PhoenixConnection connection = (PhoenixConnection)
+                ConnectionUtil.getInputConnection(configuration)){
+            try (Statement stmt = connection.createStatement()) {
+                do {
+                    ResultSet viewRs = stmt.executeQuery(query);
+                    String schema = null;
+                    String tableName = null;
+                    String tenantId = null;
+                    String fullTableName = null;
+
+                    while (viewRs.next()) {
+                        schema = viewRs.getString(2);
+                        tableName = viewRs.getString(3);
+                        tenantId = viewRs.getString(1);
+                        fullTableName = tableName;
+                        Long viewTtlValue = viewRs.getLong(4);
+
+                        if (schema != null && schema.length() > 0) {
+                            fullTableName = SchemaUtil.getTableName(schema, 
tableName);
+                        }
+
+                        boolean skip = false;
+                        PTable pTable = null;
+                        try {
+                            pTable = PhoenixRuntime.getTable(connection, 
tenantId, fullTableName);
+                            // we currently only support up to three levels

Review comment:
       actually, we do support multi-levels other than 3, let me remove this.




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

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


> MapReduce job to asynchronously delete rows where the VIEW_TTL has expired.
> ---------------------------------------------------------------------------
>
>                 Key: PHOENIX-5592
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5592
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Xinyi Yan
>            Assignee: Xinyi Yan
>            Priority: Major
>             Fix For: 4.16.0
>
>          Time Spent: 7h
>  Remaining Estimate: 0h
>
> Find the entities from the system catalog which views have TTLs defined on 
> them. Spawn an MR job, whose splitter will create a map task. The mapper 
> issues “select count(1) from the entity and Inject TTL attributes and Delete 
> Hint during Map task. Since the current Phoniex MR framework doesn't support 
> this feature, PhoenixMultiViewReader, PhoenixMultiViewInputSplit, 
> PhoenixMultiViewInputFormat, and a few MR related util classes need to 
> implement.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to