phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-4278) Implement pure client side transactional index maintenance
Date Thu, 08 Feb 2018 11:40:00 GMT

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

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

Github user ohadshacham commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/291#discussion_r166908718
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/execute/PhoenixTxnIndexMutationGenerator.java
---
    @@ -0,0 +1,505 @@
    +/*
    + * 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.execute;
    +
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.google.common.collect.Sets;
    +import com.google.common.primitives.Longs;
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.hadoop.hbase.*;
    +import org.apache.hadoop.hbase.client.*;
    +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
    +import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
    +import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.hadoop.hbase.util.Pair;
    +import org.apache.phoenix.compile.ScanRanges;
    +import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
    +import org.apache.phoenix.filter.SkipScanFilter;
    +import org.apache.phoenix.hbase.index.MultiMutation;
    +import org.apache.phoenix.hbase.index.ValueGetter;
    +import org.apache.phoenix.hbase.index.covered.IndexMetaData;
    +import org.apache.phoenix.hbase.index.covered.IndexUpdate;
    +import org.apache.phoenix.hbase.index.covered.TableState;
    +import org.apache.phoenix.hbase.index.covered.update.ColumnReference;
    +import org.apache.phoenix.hbase.index.covered.update.ColumnTracker;
    +import org.apache.phoenix.hbase.index.covered.update.IndexedColumnGroup;
    +import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
    +import org.apache.phoenix.index.IndexMaintainer;
    +import org.apache.phoenix.index.PhoenixIndexCodec;
    +import org.apache.phoenix.jdbc.PhoenixConnection;
    +import org.apache.phoenix.query.KeyRange;
    +import org.apache.phoenix.schema.PTable;
    +import org.apache.phoenix.schema.types.PVarbinary;
    +import org.apache.phoenix.transaction.PhoenixTransactionContext;
    +import org.apache.phoenix.transaction.PhoenixTransactionContext.PhoenixVisibilityLevel;
    +import org.apache.phoenix.util.ScanUtil;
    +import org.apache.phoenix.util.SchemaUtil;
    +
    +import java.io.IOException;
    +import java.sql.SQLException;
    +import java.util.*;
    +
    +
    +public class PhoenixTxnIndexMutationGenerator {
    +
    +    private static final Log LOG = LogFactory.getLog(PhoenixTxnIndexMutationGenerator.class);
    +
    +    private final PhoenixConnection connection;
    +    private final PhoenixTransactionContext phoenixTransactionContext;
    +
    +    PhoenixTxnIndexMutationGenerator(PhoenixConnection connection, PhoenixTransactionContext
phoenixTransactionContext) {
    +        this.phoenixTransactionContext = phoenixTransactionContext;
    +        this.connection = connection;
    +    }
    +
    +    private static void addMutation(Map<ImmutableBytesPtr, MultiMutation> mutations,
ImmutableBytesPtr row, Mutation m) {
    +        MultiMutation stored = mutations.get(row);
    +        // we haven't seen this row before, so add it
    +        if (stored == null) {
    +            stored = new MultiMutation(row);
    +            mutations.put(row, stored);
    +        }
    +        stored.addAll(m);
    +    }
    +
    +    public List<Mutation> getIndexUpdates(final PTable table, PTable index, List<Mutation>
dataMutations) throws IOException, SQLException {
    +
    +        if (dataMutations.isEmpty()) {
    +            return new ArrayList<Mutation>();
    +        }
    +
    +        Map<String,byte[]> updateAttributes = dataMutations.get(0).getAttributesMap();
    +        boolean replyWrite = (BaseScannerRegionObserver.ReplayWrite.fromBytes(updateAttributes.get(BaseScannerRegionObserver.REPLAY_WRITES))
!= null);
    +        byte[] txRollbackAttribute = updateAttributes.get(PhoenixTransactionContext.TX_ROLLBACK_ATTRIBUTE_KEY);
    +
    +        IndexMaintainer maintainer = index.getIndexMaintainer(table, connection);
    +
    +        boolean isRollback = txRollbackAttribute!=null;
    +        boolean isImmutable = maintainer.isImmutableRows();
    --- End diff --
    
    Done


> Implement pure client side transactional index maintenance
> ----------------------------------------------------------
>
>                 Key: PHOENIX-4278
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4278
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: James Taylor
>            Assignee: Ohad Shacham
>            Priority: Major
>
> The index maintenance for transactions follows the same model as non transactional tables
- coprocessor based on data table updates that looks up previous row value to perform maintenance.
This is necessary for non transactional tables to ensure the rows are locked so that a consistent
view may be obtained. However, for transactional tables, the time stamp oracle ensures uniqueness
of time stamps (via transaction IDs) and the filtering handles a scan seeing the "true" last
committed value for a row. Thus, there's no hard dependency to perform this on the server
side.
> Moving the index maintenance to the client side would prevent any RS->RS RPC calls
(which have proved to be troublesome for HBase). It would require returning more data to the
client (i.e. the prior row value), but this seems like a reasonable tradeoff.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message