phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pbo...@apache.org
Subject [2/7] phoenix git commit: PHOENIX-4762 Performance regression with transactional immutable indexes
Date Sat, 02 Jun 2018 08:12:08 GMT
http://git-wip-us.apache.org/repos/asf/phoenix/blob/edb6dcf5/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java
b/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java
index f3ad42f..751945a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java
@@ -108,6 +108,11 @@ public interface PhoenixTransactionContext {
         public HTableInterface getTransactionalTable(HTableInterface htable, boolean isImmutable)
{
             return null;
         }
+
+        @Override
+        public HTableInterface getTransactionalTableWriter(HTableInterface htable, PTable
table) {
+            return null;
+        }
     };
     /**
      * 
@@ -225,4 +230,5 @@ public interface PhoenixTransactionContext {
     public PhoenixTransactionContext newTransactionContext(PhoenixTransactionContext contex,
boolean subTask);
 
     public HTableInterface getTransactionalTable(HTableInterface htable, boolean isImmutable);
+    public HTableInterface getTransactionalTableWriter(HTableInterface htable, PTable table);
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/edb6dcf5/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java
b/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java
index 9c6af63..94d6765 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java
@@ -469,5 +469,21 @@ public class TephraTransactionContext implements PhoenixTransactionContext
{
         this.addTransactionAware(transactionAwareHTable);
         return transactionAwareHTable;
     }
+
+    @Override
+    public HTableInterface getTransactionalTableWriter(HTableInterface htable, PTable table)
{
+        boolean isIndex = table.getType() == PTableType.INDEX;
+        TransactionAwareHTableDelegate transactionAwareHTable = new TransactionAwareHTableDelegate(htable,
table.isImmutableRows() || isIndex ? TxConstants.ConflictDetection.NONE : TxConstants.ConflictDetection.ROW);
+        // Don't add immutable indexes (those are the only ones that would participate
+        // during a commit), as we don't need conflict detection for these.
+        if (isIndex) {
+            transactionAwareHTable.startTx(getTransaction());
+        } else {
+            // Even for immutable, we need to do this so that an abort has the state
+            // necessary to generate the rows to delete.
+            this.addTransactionAware(transactionAwareHTable);
+        }
+        return transactionAwareHTable;
+    }
     
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/edb6dcf5/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
index 7e280f4..78a68d2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
@@ -42,7 +42,6 @@ import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Durability;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTableInterface;
@@ -116,7 +115,6 @@ import org.apache.phoenix.schema.types.PDecimal;
 import org.apache.phoenix.schema.types.PLong;
 import org.apache.phoenix.schema.types.PVarbinary;
 import org.apache.phoenix.schema.types.PVarchar;
-import org.apache.phoenix.transaction.PhoenixTransactionContext;
 
 import com.google.common.collect.Lists;
 
@@ -269,32 +267,6 @@ public class IndexUtil {
                             .getLength()) == 0);
     }
 
-    public static List<Delete> generateDeleteIndexData(final PTable table, PTable index,
-            List<Delete> dataMutations, ImmutableBytesWritable ptr, final KeyValueBuilder
kvBuilder, PhoenixConnection connection)
-            throws SQLException {
-        try {
-            IndexMaintainer maintainer = index.getIndexMaintainer(table, connection);
-            List<Delete> indexMutations = Lists.newArrayListWithExpectedSize(dataMutations.size());
-            for (final Mutation dataMutation : dataMutations) {
-                long ts = MetaDataUtil.getClientTimeStamp(dataMutation);
-                ptr.set(dataMutation.getRow());
-                byte[] regionStartKey = null;
-                byte[] regionEndkey = null;
-                if(maintainer.isLocalIndex()) {
-                    HRegionLocation tableRegionLocation = connection.getQueryServices().getTableRegionLocation(table.getPhysicalName().getBytes(),
dataMutation.getRow());
-                    regionStartKey = tableRegionLocation.getRegionInfo().getStartKey();
-                    regionEndkey = tableRegionLocation.getRegionInfo().getEndKey();
-                }
-                Delete delete = maintainer.buildDeleteMutation(kvBuilder, null, ptr, Collections.<KeyValue>emptyList(),
ts, regionStartKey, regionEndkey);
-                delete.setAttribute(PhoenixTransactionContext.TX_ROLLBACK_ATTRIBUTE_KEY,
dataMutation.getAttribute(PhoenixTransactionContext.TX_ROLLBACK_ATTRIBUTE_KEY));
-                indexMutations.add(delete);
-            }
-            return indexMutations;
-        } catch (IOException e) {
-            throw new SQLException(e);
-        }
-    }
-    
     public static List<Mutation> generateIndexData(final PTable table, PTable index,
             final MultiRowMutationState multiRowMutationState, List<Mutation> dataMutations,
final KeyValueBuilder kvBuilder, PhoenixConnection connection)
             throws SQLException {


Mime
View raw message