http://git-wip-us.apache.org/repos/asf/phoenix/blob/eeea6c60/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 158f1e8..28dc87a 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 @@ -398,5 +398,21 @@ public class TephraTransactionContext implements PhoenixTransactionContext { this.addTransactionAware(transactionAwareHTable); return transactionAwareHTable; } + + @Override + public Table getTransactionalTableWriter(Table htable, PTable table) { + boolean isIndex = table.getType() == PTableType.INDEX; + TransactionAwareHTable transactionAwareHTable = new TransactionAwareHTable(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/eeea6c60/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 c6cbe3e..3d4c3ca 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 @@ -41,7 +41,6 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionLocation; 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.Mutation; @@ -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.getRegion().getStartKey(); - regionEndkey = tableRegionLocation.getRegion().getEndKey(); - } - Delete delete = maintainer.buildDeleteMutation(kvBuilder, null, ptr, Collections.<Cell>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 {