phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [phoenix] gjacoby126 commented on a change in pull request #469: PHOENIX-5156 Consistent Global Indexes for Non-Transactional Tables
Date Mon, 18 Mar 2019 21:40:52 GMT
gjacoby126 commented on a change in pull request #469: PHOENIX-5156 Consistent Global Indexes
for Non-Transactional Tables
URL: https://github.com/apache/phoenix/pull/469#discussion_r266636715
 
 

 ##########
 File path: phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexRowVerifier.java
 ##########
 @@ -0,0 +1,208 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.CHECK_VERIFY_COLUMN;
+import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.EMPTY_COLUMN_FAMILY_NAME;
+import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.PHYSICAL_DATA_TABLE_NAME;
+import static org.apache.phoenix.query.QueryConstants.GLOBAL_INDEX_VERIFIED_COLUMN_NAME_BYTES;
+import static org.apache.phoenix.schema.types.PDataType.FALSE_BYTES;
+import static org.apache.phoenix.schema.types.PDataType.TRUE_BYTES;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.hadoop.hbase.regionserver.Region;
+import org.apache.hadoop.hbase.regionserver.RegionScanner;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.apache.phoenix.util.IndexUtil;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.ServerUtil;
+
+/**
+ * 
+ * Class that verifies a given row of a non-transactional global index.
+ * An instance of this class is created by a scan region observer
+ * and called to verify individual rows of a non-transactional global index
+ *
+ */
+public class GlobalIndexRowVerifier {
+    private final long AGE_THRESHOLD_TO_DELETE_MS = 3600*1000; /* One hour */
+    private boolean verify;
+    private Scan scan;
+    private Scan indexScan;
+    private Scan buildIndexScan = null;
+    private Table dataHTable;
+    private byte[] emptyCF;
+    private IndexMaintainer indexMaintainer = null;
+    private byte[][] viewConstants = null;
+    private RegionCoprocessorEnvironment env;
+    private Region region = null;
+
+    public GlobalIndexRowVerifier(RegionCoprocessorEnvironment env, Scan scan) {
+        verify = scan.getAttribute(CHECK_VERIFY_COLUMN) != null;
+        if (verify) {
+            this.env = env;
+            this.scan = scan;
+            emptyCF = scan.getAttribute(EMPTY_COLUMN_FAMILY_NAME);
+        }
+    }
+
+    public GlobalIndexRowVerifier(RegionCoprocessorEnvironment env, Scan scan,
+                                  IndexMaintainer indexMaintainer, byte[][] viewConstants)
{
+        this(env, scan);
+        if (verify) {
+            this.indexMaintainer = indexMaintainer;
+            this.viewConstants = viewConstants;
+        }
+    }
+
+    private List<Cell> rebuildSingleIndexRow(byte[] indexRowKey, long ts) throws IOException
{
+        // Build the data table row key from the index table row key
+        if (buildIndexScan == null) {
+            region = env.getRegion();
+            buildIndexScan = new Scan();
+            indexScan = new Scan(scan);
+            byte[] dataTableName = scan.getAttribute(PHYSICAL_DATA_TABLE_NAME);
+            byte[] indexTableName = region.getRegionInfo().getTable().getName();
+            dataHTable = ServerUtil.getHTableForCoprocessorScan(env,
+                    SchemaUtil.getPhysicalTableName(dataTableName, env.getConfiguration()));
+            if (indexMaintainer == null) {
+                byte[] md = scan.getAttribute(PhoenixIndexCodec.INDEX_PROTO_MD);
+                List<IndexMaintainer> maintainers = IndexMaintainer.deserialize(md,
true);
+                Iterator<IndexMaintainer> maintainerIterator = maintainers.iterator();
 
 Review comment:
   Here again you're getting the index maintainer for a particular index -- seems like this
can be a shared utility method somewhere. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message