Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 6f18b38fa -> 0606475db
PHOENIX-3898 Empty result set after split with local index on multi-tenant table(Rajeshbabu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/0606475d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/0606475d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/0606475d Branch: refs/heads/4.x-HBase-0.98 Commit: 0606475dbc209973fba87bb32a9060f4d22ee72f Parents: 6f18b38 Author: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Authored: Fri Jun 9 14:33:34 2017 -0700 Committer: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Committed: Fri Jun 9 14:33:34 2017 -0700 ---------------------------------------------------------------------- .../index/MutableIndexSplitForwardScanIT.java | 4 +-- .../end2end/index/MutableIndexSplitIT.java | 10 ++++--- .../index/MutableIndexSplitReverseScanIT.java | 4 +-- .../apache/phoenix/index/IndexMaintainer.java | 31 ++++---------------- 4 files changed, 15 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/0606475d/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitForwardScanIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitForwardScanIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitForwardScanIT.java index 4ce2b4c..75e2ae2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitForwardScanIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitForwardScanIT.java @@ -21,8 +21,8 @@ import org.junit.Test; public class MutableIndexSplitForwardScanIT extends MutableIndexSplitIT { - public MutableIndexSplitForwardScanIT(boolean localIndex) { - super(localIndex); + public MutableIndexSplitForwardScanIT(boolean localIndex, boolean multiTenant) { + super(localIndex, multiTenant); } @Test http://git-wip-us.apache.org/repos/asf/phoenix/blob/0606475d/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitIT.java index 43fb567..85e78e8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitIT.java @@ -52,9 +52,11 @@ import org.junit.runners.Parameterized.Parameters; public abstract class MutableIndexSplitIT extends ParallelStatsDisabledIT { protected final boolean localIndex; + protected final boolean multiTenant; - public MutableIndexSplitIT(boolean localIndex) { + public MutableIndexSplitIT(boolean localIndex,boolean multiTenant) { this.localIndex = localIndex; + this.multiTenant = multiTenant; } private static Connection getConnection(Properties props) throws SQLException { @@ -63,10 +65,10 @@ public abstract class MutableIndexSplitIT extends ParallelStatsDisabledIT { return conn; } - @Parameters(name="MutableIndexSplitIT_localIndex={0}") // name is used by failsafe as file name in reports + @Parameters(name="MutableIndexSplitIT_localIndex={0},multiTenant={1}") // name is used by failsafe as file name in reports public static Collection<Boolean[]> data() { return Arrays.asList(new Boolean[][] { - { false }, { true } }); + { false, false },{ false, true },{true, false}, { true, true } }); } protected void testSplitDuringIndexScan(boolean isReverse) throws Exception { @@ -172,7 +174,7 @@ public abstract class MutableIndexSplitIT extends ParallelStatsDisabledIT { "k2 INTEGER NOT NULL,\n" + "k3 INTEGER,\n" + "v1 VARCHAR,\n" + - "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2))\n" + "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2))" + (multiTenant ? " MULTI_TENANT=true ":"") +"\n" + (splits != null ? (" split on " + splits) : ""); conn.createStatement().execute(ddl); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/0606475d/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitReverseScanIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitReverseScanIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitReverseScanIT.java index dc9a3fa..d7afb31 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitReverseScanIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexSplitReverseScanIT.java @@ -21,8 +21,8 @@ import org.junit.Test; public class MutableIndexSplitReverseScanIT extends MutableIndexSplitIT { - public MutableIndexSplitReverseScanIT(boolean localIndex) { - super(localIndex); + public MutableIndexSplitReverseScanIT(boolean localIndex, boolean multiTenant) { + super(localIndex, multiTenant); } @Test http://git-wip-us.apache.org/repos/asf/phoenix/blob/0606475d/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java index dd46345..be22334 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java @@ -781,32 +781,11 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> { * return the view index id from the index row key */ public byte[] getViewIndexIdFromIndexRowKey(ImmutableBytesWritable indexRowKeyPtr) { - assert(isLocalIndex); - RowKeySchema indexRowKeySchema = getIndexRowKeySchema(); - // TODO add logic to skip region start key as well because we cannot find the region startkey in indexhalfstorefilereader. - ImmutableBytesWritable ptr = new ImmutableBytesWritable(); - TrustedByteArrayOutputStream stream = - new TrustedByteArrayOutputStream(estimatedIndexRowKeyBytes); - DataOutput output = new DataOutputStream(stream); - try { - int indexPosOffset = (!isLocalIndex && nIndexSaltBuckets > 0 ? 1 : 0) + (isMultiTenant ? 1 : 0) + (viewIndexId == null ? 0 : 1); - Boolean hasValue = - indexRowKeySchema.iterator(indexRowKeyPtr, ptr, indexPosOffset); - if (Boolean.TRUE.equals(hasValue)) { - output.write(ptr.get(), ptr.getOffset(), ptr.getLength()); - } - int length = stream.size(); - byte[] dataRowKey = stream.getBuffer(); - return dataRowKey.length == length ? dataRowKey : Arrays.copyOf(dataRowKey, length); - } catch (IOException e) { - throw new RuntimeException(e); // Impossible - } finally { - try { - stream.close(); - } catch (IOException e) { - throw new RuntimeException(e); // Impossible - } - } + assert (isLocalIndex); + ImmutableBytesPtr ptr = + new ImmutableBytesPtr(indexRowKeyPtr.get(),( indexRowKeyPtr.getOffset() + + (nIndexSaltBuckets > 0 ? 1 : 0)), viewIndexId.length); + return ptr.copyBytesIfNecessary(); } private volatile RowKeySchema indexRowKeySchema;