This is an automated email from the ASF dual-hosted git repository.

skadam pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x by this push:
     new 1c3724a  PHOENIX-5840: IndexTool inline verification should not fail 
with -v ONLY option (#760)
1c3724a is described below

commit 1c3724a2d835e8a77f10f7f817203a51304046eb
Author: Swaroopa Kadam <swaroopa.kada...@gmail.com>
AuthorDate: Wed Apr 15 15:34:38 2020 -0700

    PHOENIX-5840: IndexTool inline verification should not fail with -v ONLY 
option (#760)
    
    Co-authored-by: s.kadam <s.ka...@apache.org>
---
 .../it/java/org/apache/phoenix/end2end/IndexToolIT.java |  4 ++--
 .../coprocessor/IndexToolVerificationResult.java        | 17 ++++-------------
 .../index/PhoenixIndexImportDirectReducer.java          |  2 +-
 .../phoenix/parse/PhoenixRowTimestampFunctionTest.java  | 17 +++++++++++++++++
 4 files changed, 24 insertions(+), 16 deletions(-)

diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
index 4840047..02b253f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
@@ -648,7 +648,7 @@ public class IndexToolIT extends 
BaseUniqueNamesOwnClusterIT {
             // IndexTool will go through each data table row and record the 
mismatches in the output table
             // called PHOENIX_INDEX_TOOL
             runIndexTool(directApi, useSnapshot, schemaName, dataTableName, 
indexTableName,
-                    null, -1, IndexTool.IndexVerifyType.ONLY);
+                    null, 0, IndexTool.IndexVerifyType.ONLY);
             Cell cell = getErrorMessageFromIndexToolOutputTable(conn, 
dataTableFullName, indexTableFullName);
             try {
                 String expectedErrorMsg = 
IndexRebuildRegionScanner.ERROR_MESSAGE_MISSING_INDEX_ROW_BEYOND_MAX_LOOKBACK;
@@ -690,7 +690,7 @@ public class IndexToolIT extends 
BaseUniqueNamesOwnClusterIT {
             conn.createStatement()
                     .execute(String.format("CREATE INDEX %s ON %s (NAME) 
INCLUDE (CODE) ASYNC",
                         indexTableName, dataTableFullName));
-            runIndexTool(directApi, useSnapshot, schemaName, dataTableName, 
indexTableName, null, -1,
+            runIndexTool(directApi, useSnapshot, schemaName, dataTableName, 
indexTableName, null, 0,
                 IndexTool.IndexVerifyType.ONLY);
             Cell cell =
                     getErrorMessageFromIndexToolOutputTable(conn, 
dataTableFullName,
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexToolVerificationResult.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexToolVerificationResult.java
index 989e03f..3299ed6 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexToolVerificationResult.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexToolVerificationResult.java
@@ -412,19 +412,10 @@ public class IndexToolVerificationResult {
         }
     }
 
-    public boolean isVerificationFailed(IndexTool.IndexVerifyType verifyType) {
-        if (verifyType == IndexTool.IndexVerifyType.BEFORE || verifyType == 
IndexTool.IndexVerifyType.NONE) {
-            return false;
-        } else if (verifyType == IndexTool.IndexVerifyType.ONLY) {
-            if (getBefore().getInvalidIndexRowCount() + 
getBefore().getMissingIndexRowCount() +
-                before.getBeyondMaxLookBackInvalidIndexRowCount() + 
before.getBeyondMaxLookBackMissingIndexRowCount() > 0) {
-                return true;
-            }
-        } else if (verifyType == IndexTool.IndexVerifyType.BOTH || verifyType 
== IndexTool.IndexVerifyType.AFTER) {
-            if (getAfter().getInvalidIndexRowCount() + 
getAfter().getMissingIndexRowCount() +
-                after.getBeyondMaxLookBackInvalidIndexRowCount() + 
after.getBeyondMaxLookBackMissingIndexRowCount() > 0) {
-                return true;
-            }
+    public boolean isVerificationFailed() {
+        if (getAfter().getInvalidIndexRowCount() + 
getAfter().getMissingIndexRowCount() +
+                getAfter().getBeyondMaxLookBackInvalidIndexRowCount() + 
getAfter().getBeyondMaxLookBackMissingIndexRowCount() > 0) {
+            return true;
         }
         return false;
     }
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectReducer.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectReducer.java
index 4cd2603..4bbd7c8 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectReducer.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectReducer.java
@@ -96,7 +96,7 @@ public class PhoenixIndexImportDirectReducer extends
                 
context.getCounter(PhoenixIndexToolJobCounters.AFTER_REBUILD_BEYOND_MAXLOOKBACK_INVALID_INDEX_ROW_COUNT).
                         
setValue(verificationResult.getAfterRebuildBeyondMaxLookBackInvalidIndexRowCount());
             }
-            if (verificationResult.isVerificationFailed(verifyType)) {
+            if (verificationResult.isVerificationFailed()) {
                 throw new IOException("Index verification failed! " + 
verificationResult);
             }
         } catch (Exception e) {
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/parse/PhoenixRowTimestampFunctionTest.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/parse/PhoenixRowTimestampFunctionTest.java
index 6e1e901..aa9531e 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/parse/PhoenixRowTimestampFunctionTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/parse/PhoenixRowTimestampFunctionTest.java
@@ -1,3 +1,20 @@
+/*
+ * 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.parse;
 
 import org.junit.Test;

Reply via email to